nbxtensor 0.0.9__tar.gz → 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (375) hide show
  1. nbxtensor-0.1.0/.github/workflows/cla.yml +29 -0
  2. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/CHANGELOG.md +32 -1
  3. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/CONTRIBUTING.md +12 -0
  4. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/NOTICE +1 -0
  5. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/PKG-INFO +5 -4
  6. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/README.md +2 -1
  7. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/pyproject.toml +3 -3
  8. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/__init__.py +1 -1
  9. nbxtensor-0.1.0/src/nbxtensor/memory/host_spill.py +90 -0
  10. nbxtensor-0.1.0/src/nbxtensor/memory/kv_host_pages.py +317 -0
  11. nbxtensor-0.1.0/src/nbxtensor/memory/kv_host_tier.py +222 -0
  12. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/kv_session.py +5 -0
  13. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/paged_kv.py +159 -13
  14. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/attention_wrappers.py +67 -22
  15. nbxtensor-0.1.0/src/nbxtensor/ops/embedding_pool.py +44 -0
  16. nbxtensor-0.1.0/src/nbxtensor/ops/host_decode_partial.py +114 -0
  17. nbxtensor-0.1.0/src/nbxtensor/ops/token_bitmask.py +64 -0
  18. nbxtensor-0.1.0/tests/test_a_kv_page_goes_to_the_host_and_back_bit_exact.py +82 -0
  19. nbxtensor-0.1.0/tests/test_a_sequence_decodes_past_the_card_s_pages.py +122 -0
  20. nbxtensor-0.1.0/tests/test_a_setting_not_served_says_why.py +32 -0
  21. nbxtensor-0.1.0/tests/test_a_small_tensor_never_pins_a_large_block.py +52 -0
  22. nbxtensor-0.1.0/tests/test_a_spilled_sequence_attends_as_one.py +115 -0
  23. nbxtensor-0.1.0/tests/test_a_sweep_refused_everywhere_says_so.py +35 -0
  24. nbxtensor-0.1.0/tests/test_a_table_pin_holder_holds_one_pin_per_set_of_wraps.py +36 -0
  25. nbxtensor-0.1.0/tests/test_a_token_bitmask_leaves_only_the_allowed_logits.py +85 -0
  26. nbxtensor-0.1.0/tests/test_a_triton_kernel_compiles_for_amd_and_launches_through_hip.py +115 -0
  27. nbxtensor-0.1.0/tests/test_allocator_interceptor.py +159 -0
  28. nbxtensor-0.1.0/tests/test_an_attention_returns_its_rows_log_sum_exp.py +91 -0
  29. nbxtensor-0.1.0/tests/test_an_embedding_is_pooled_as_its_model_declares.py +41 -0
  30. nbxtensor-0.1.0/tests/test_array_api_promotion.py +70 -0
  31. nbxtensor-0.1.0/tests/test_blas_on_macos_14_runs_without_thread_control.py +76 -0
  32. nbxtensor-0.1.0/tests/test_cpu_pool.py +85 -0
  33. nbxtensor-0.1.0/tests/test_device_facts.py +55 -0
  34. nbxtensor-0.1.0/tests/test_device_files.py +25 -0
  35. nbxtensor-0.1.0/tests/test_device_memory.py +63 -0
  36. nbxtensor-0.1.0/tests/test_dtype_convert.py +58 -0
  37. nbxtensor-0.1.0/tests/test_dtype_outputs.py +53 -0
  38. nbxtensor-0.1.0/tests/test_dtype_promotion.py +60 -0
  39. nbxtensor-0.1.0/tests/test_gathered_kv_pages_are_the_per_layer_copies_bits.py +118 -0
  40. nbxtensor-0.1.0/tests/test_host.py +50 -0
  41. nbxtensor-0.1.0/tests/test_install_metal_fetches_only_what_it_names.py +186 -0
  42. nbxtensor-0.1.0/tests/test_io_bf16_split.py +20 -0
  43. nbxtensor-0.1.0/tests/test_io_read_rate.py +85 -0
  44. nbxtensor-0.1.0/tests/test_it_installs_on_a_mac.py +23 -0
  45. nbxtensor-0.1.0/tests/test_level_zero_states_an_integrated_gpu.py +126 -0
  46. nbxtensor-0.1.0/tests/test_nbx_dtype.py +37 -0
  47. nbxtensor-0.1.0/tests/test_no_environment_switch_changes_a_kernel.py +24 -0
  48. nbxtensor-0.1.0/tests/test_ops_cost.py +63 -0
  49. nbxtensor-0.1.0/tests/test_policy.py +55 -0
  50. nbxtensor-0.1.0/tests/test_readme.py +39 -0
  51. nbxtensor-0.1.0/tests/test_shape.py +56 -0
  52. nbxtensor-0.1.0/tests/test_the_backend_is_the_card_on_the_machine.py +19 -0
  53. nbxtensor-0.1.0/tests/test_the_compiler_key_is_prewarmed.py +23 -0
  54. nbxtensor-0.1.0/tests/test_the_hip_driver_keeps_the_launch_contract.py +174 -0
  55. nbxtensor-0.1.0/tests/test_the_kv_host_tier_keeps_whole_pages_by_prefix.py +83 -0
  56. nbxtensor-0.1.0/tests/test_the_launcher_refuses_a_backend_it_has_no_driver_for.py +42 -0
  57. nbxtensor-0.1.0/tests/test_the_level_zero_backend_keeps_its_contracts.py +403 -0
  58. nbxtensor-0.1.0/tests/test_the_malloc_trace_names_the_wrapper.py +25 -0
  59. nbxtensor-0.1.0/tests/test_the_metal_dispatch_facts_are_declared_or_refused.py +31 -0
  60. nbxtensor-0.1.0/tests/test_third_party_notices.py +81 -0
  61. nbxtensor-0.1.0/tests/test_version.py +23 -0
  62. nbxtensor-0.0.9/.gitignore +0 -309
  63. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/.github/PULL_REQUEST_TEMPLATE/certificate.md +0 -0
  64. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/LICENSE +0 -0
  65. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/THIRD_PARTY_NOTICES.md +0 -0
  66. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/assets/logo.png +0 -0
  67. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/__main__.py +0 -0
  68. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/__init__.py +0 -0
  69. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/capabilities.py +0 -0
  70. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/cpu/__init__.py +0 -0
  71. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/cpu/blas.py +0 -0
  72. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/cpu/pool.py +0 -0
  73. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/cpu_backend.py +0 -0
  74. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/device_facts.py +0 -0
  75. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/device_files.py +0 -0
  76. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/device_names.py +0 -0
  77. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/amd/cdna.yml +0 -0
  78. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/amd/cdna2.yml +0 -0
  79. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/amd/cdna3.yml +0 -0
  80. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/amd/cdna4.yml +0 -0
  81. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/amd/rdna3.yml +0 -0
  82. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/amd/rdna4.yml +0 -0
  83. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m1.yml +0 -0
  84. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m1_max.yml +0 -0
  85. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m1_pro.yml +0 -0
  86. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m1_ultra.yml +0 -0
  87. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m2.yml +0 -0
  88. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m2_max.yml +0 -0
  89. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m2_pro.yml +0 -0
  90. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m2_ultra.yml +0 -0
  91. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m3.yml +0 -0
  92. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m3_max.yml +0 -0
  93. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m3_pro.yml +0 -0
  94. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m3_ultra.yml +0 -0
  95. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m4.yml +0 -0
  96. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m4_max.yml +0 -0
  97. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m4_pro.yml +0 -0
  98. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m5.yml +0 -0
  99. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m5_max.yml +0 -0
  100. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m5_pro.yml +0 -0
  101. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m5_ultra.yml +0 -0
  102. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_m6.yml +0 -0
  103. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/apple/apple_silicon.yml +0 -0
  104. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/intel/arl_h.yml +0 -0
  105. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/intel/arl_s.yml +0 -0
  106. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/intel/bmg.yml +0 -0
  107. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/intel/dg2.yml +0 -0
  108. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/intel/lnl.yml +0 -0
  109. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/intel/mtl.yml +0 -0
  110. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/intel/ptl_h.yml +0 -0
  111. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/intel/ptl_u.yml +0 -0
  112. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/intel/pvc.yml +0 -0
  113. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/nvidia/ampere.yml +0 -0
  114. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/nvidia/hopper.yml +0 -0
  115. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/devices/nvidia/volta.yml +0 -0
  116. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/faults.py +0 -0
  117. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/host_memory.py +0 -0
  118. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/install_help.py +0 -0
  119. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/install_metal.py +0 -0
  120. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/install_steps.yml +0 -0
  121. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/launcher.py +0 -0
  122. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/launcher_contract.py +0 -0
  123. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/level_zero.py +0 -0
  124. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/level_zero_driver.py +0 -0
  125. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/libnames.py +0 -0
  126. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/metal_backend.py +0 -0
  127. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/metal_device.py +0 -0
  128. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/process_memory.py +0 -0
  129. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/replay_graph.py +0 -0
  130. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/runtime.py +0 -0
  131. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/backend/triton_ext_driver.py +0 -0
  132. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/dtype/__init__.py +0 -0
  133. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/dtype/convert.py +0 -0
  134. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/dtype/dtypes.yml +0 -0
  135. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/dtype/itemsize.py +0 -0
  136. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/dtype/nbx_dtype.py +0 -0
  137. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/dtype/operands.py +0 -0
  138. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/dtype/outputs.py +0 -0
  139. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/dtype/policy.py +0 -0
  140. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/dtype/policy.yml +0 -0
  141. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/dtype/promotion.py +0 -0
  142. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/host.py +0 -0
  143. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/io/__init__.py +0 -0
  144. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/io/read_rate.py +0 -0
  145. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/io/safetensors.py +0 -0
  146. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/__init__.py +0 -0
  147. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/allocator.py +0 -0
  148. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/arena.py +0 -0
  149. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/device_memory.py +0 -0
  150. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/device_transfer.py +0 -0
  151. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/layout.py +0 -0
  152. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/memory_pool.py +0 -0
  153. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/metal.py +0 -0
  154. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/oom_advice.py +0 -0
  155. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/pages.py +0 -0
  156. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/pointer_tables.py +0 -0
  157. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/pool.py +0 -0
  158. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/shadow.py +0 -0
  159. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/slab.py +0 -0
  160. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/trace_replay.py +0 -0
  161. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/traces/sana-video-2b-720p.16g.2026-11-02.tsv +0 -0
  162. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/memory/vmm.py +0 -0
  163. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/__init__.py +0 -0
  164. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/_autotune_policy.py +0 -0
  165. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/_common.py +0 -0
  166. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/_configs.py +0 -0
  167. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/_cost.py +0 -0
  168. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/abs.py +0 -0
  169. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/adaptive_avg_pool2d.py +0 -0
  170. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/add.py +0 -0
  171. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/addcdiv.py +0 -0
  172. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/addcmul.py +0 -0
  173. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/addmv_op.py +0 -0
  174. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/addr.py +0 -0
  175. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/all_reduce.py +0 -0
  176. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/amax.py +0 -0
  177. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/any_reduce.py +0 -0
  178. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/arange_op.py +0 -0
  179. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/argmax.py +0 -0
  180. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/argmin.py +0 -0
  181. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/atan2.py +0 -0
  182. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/autotune_bucket.py +0 -0
  183. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/autotune_cache.py +0 -0
  184. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/autotune_certified.py +0 -0
  185. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/autotune_refusals.py +0 -0
  186. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/autotune_settings.py +0 -0
  187. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/avg_pool2d.py +0 -0
  188. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/baddbmm_op.py +0 -0
  189. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/batch_norm.py +0 -0
  190. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/binary_strided.py +0 -0
  191. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/bitwise_and.py +0 -0
  192. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/bitwise_left_shift.py +0 -0
  193. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/bitwise_not.py +0 -0
  194. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/bitwise_or.py +0 -0
  195. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/bitwise_right_shift.py +0 -0
  196. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/bucketize.py +0 -0
  197. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/cat_op.py +0 -0
  198. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/celu.py +0 -0
  199. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/certified_index.py +0 -0
  200. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/clamp.py +0 -0
  201. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/clamp_min.py +0 -0
  202. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/conv2d.py +0 -0
  203. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/conv2d_m8n8k4.py +0 -0
  204. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/conv_depthwise2d.py +0 -0
  205. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/conv_transpose2d.py +0 -0
  206. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/conv_wrappers.py +0 -0
  207. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/copy.py +0 -0
  208. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/copy_op.py +0 -0
  209. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/cos.py +0 -0
  210. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/count_nonzero.py +0 -0
  211. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/cross_entropy.py +0 -0
  212. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/cummax.py +0 -0
  213. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/cummin.py +0 -0
  214. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/cumsum.py +0 -0
  215. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/decode_attn_vec.py +0 -0
  216. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/depthwise_conv2d.py +0 -0
  217. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/dequant_gemv.py +0 -0
  218. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/dft.py +0 -0
  219. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/dispatch.py +0 -0
  220. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/div.py +0 -0
  221. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/dot_op.py +0 -0
  222. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/dropout.py +0 -0
  223. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/dtype_convert.py +0 -0
  224. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/elementwise_launch.py +0 -0
  225. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/elementwise_wrappers.py +0 -0
  226. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/elu.py +0 -0
  227. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/embedding.py +0 -0
  228. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/eq.py +0 -0
  229. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/erf.py +0 -0
  230. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/exp.py +0 -0
  231. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/exp2.py +0 -0
  232. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/fft_op.py +0 -0
  233. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/fill_op.py +0 -0
  234. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/flash_attention.py +0 -0
  235. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/flash_attention_m8n8k4.py +0 -0
  236. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/flash_decode.py +0 -0
  237. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/flip_op.py +0 -0
  238. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/floor.py +0 -0
  239. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/full_op.py +0 -0
  240. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/fused_moe.py +0 -0
  241. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/fused_moe_m8n8k4.py +0 -0
  242. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/fused_upsample_conv.py +0 -0
  243. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/gather_op.py +0 -0
  244. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/ge.py +0 -0
  245. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/gelu.py +0 -0
  246. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/gemv_vec.py +0 -0
  247. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/glu.py +0 -0
  248. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/grid_sampler.py +0 -0
  249. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/group_norm_tiled.py +0 -0
  250. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/groupnorm.py +0 -0
  251. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/gt.py +0 -0
  252. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/hardsigmoid.py +0 -0
  253. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/hardswish.py +0 -0
  254. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/im2col.py +0 -0
  255. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/index_add.py +0 -0
  256. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/index_put_op.py +0 -0
  257. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/index_select.py +0 -0
  258. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/index_wrappers.py +0 -0
  259. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/isfinite.py +0 -0
  260. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/isinf.py +0 -0
  261. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/isnan.py +0 -0
  262. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/launch_keys.py +0 -0
  263. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/launch_observer.py +0 -0
  264. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/layernorm.py +0 -0
  265. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/le.py +0 -0
  266. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/leaky_relu.py +0 -0
  267. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/lerp.py +0 -0
  268. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/linalg_wrappers.py +0 -0
  269. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/linspace_op.py +0 -0
  270. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/log.py +0 -0
  271. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/log_sigmoid.py +0 -0
  272. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/logical_and.py +0 -0
  273. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/logical_not.py +0 -0
  274. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/logical_or.py +0 -0
  275. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/logical_xor.py +0 -0
  276. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/loss_wrappers.py +0 -0
  277. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/lt.py +0 -0
  278. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/masked_fill.py +0 -0
  279. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/matmul.py +0 -0
  280. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/matmul_m8n8k4.py +0 -0
  281. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/max_pool2d.py +0 -0
  282. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/max_pool3d.py +0 -0
  283. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/max_reduce.py +0 -0
  284. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/maximum.py +0 -0
  285. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/mean.py +0 -0
  286. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/min_reduce.py +0 -0
  287. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/minimum.py +0 -0
  288. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/mish.py +0 -0
  289. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/mma_m8n8k4.py +0 -0
  290. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/moe_align.py +0 -0
  291. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/moe_decode_vec.py +0 -0
  292. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/moe_device_residency.py +0 -0
  293. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/moe_wrappers.py +0 -0
  294. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/mse_loss.py +0 -0
  295. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/mul.py +0 -0
  296. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/nan_to_num.py +0 -0
  297. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/ne.py +0 -0
  298. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/neg.py +0 -0
  299. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/nllloss.py +0 -0
  300. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/nonzero.py +0 -0
  301. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/nonzero_op.py +0 -0
  302. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/norm_wrappers.py +0 -0
  303. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/ones_op.py +0 -0
  304. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/oracles/__init__.py +0 -0
  305. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/oracles/conv2d_fp64.py +0 -0
  306. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/pad_op.py +0 -0
  307. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/paged_decode_attn.py +0 -0
  308. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/pixel_shuffle.py +0 -0
  309. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/pixel_unshuffle.py +0 -0
  310. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/pow.py +0 -0
  311. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/prod.py +0 -0
  312. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/rand_op.py +0 -0
  313. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/random_wrappers.py +0 -0
  314. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/reciprocal.py +0 -0
  315. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/reduction_wrappers.py +0 -0
  316. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/relu.py +0 -0
  317. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/remainder.py +0 -0
  318. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/repeat_interleave.py +0 -0
  319. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/repeat_op.py +0 -0
  320. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/residual_chain.py +0 -0
  321. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/rmsnorm.py +0 -0
  322. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/rope.py +0 -0
  323. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/rsqrt.py +0 -0
  324. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/scaled_softmax.py +0 -0
  325. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/scatter_op.py +0 -0
  326. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/screen_oracle.py +0 -0
  327. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/selu.py +0 -0
  328. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/shape_wrappers.py +0 -0
  329. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/sigmoid.py +0 -0
  330. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/silu.py +0 -0
  331. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/sin.py +0 -0
  332. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/softmax.py +0 -0
  333. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/softplus.py +0 -0
  334. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/sort_op.py +0 -0
  335. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/spectral_wrappers.py +0 -0
  336. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/sqrt.py +0 -0
  337. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/stack_op.py +0 -0
  338. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/std.py +0 -0
  339. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/strided_copy.py +0 -0
  340. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/sub.py +0 -0
  341. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/sum.py +0 -0
  342. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/tan.py +0 -0
  343. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/tanh.py +0 -0
  344. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/threshold.py +0 -0
  345. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/tiling.yml +0 -0
  346. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/tiling_policy.py +0 -0
  347. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/tiling_sizes.py +0 -0
  348. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/topk.py +0 -0
  349. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/trace_op.py +0 -0
  350. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/tril.py +0 -0
  351. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/triu.py +0 -0
  352. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/unfold_op.py +0 -0
  353. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/unique_op.py +0 -0
  354. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/upsample_bilinear2d.py +0 -0
  355. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/upsample_nearest2d.py +0 -0
  356. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/upsample_nearest3d.py +0 -0
  357. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/var.py +0 -0
  358. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/vector_norm.py +0 -0
  359. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/weight_norm.py +0 -0
  360. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/where.py +0 -0
  361. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/wrappers.py +0 -0
  362. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/ops/zeros_op.py +0 -0
  363. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/quant/__init__.py +0 -0
  364. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/quant/quantized_tensor.py +0 -0
  365. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/random/__init__.py +0 -0
  366. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/random/mt_randn.py +0 -0
  367. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/random/rng_pin.py +0 -0
  368. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/random/rng_stream.py +0 -0
  369. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/random/seeded_draw.py +0 -0
  370. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/shape/__init__.py +0 -0
  371. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/tensor.py +0 -0
  372. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/src/nbxtensor/terminal.py +0 -0
  373. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/tools/device_key_census.py +0 -0
  374. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/tools/device_key_trace.py +0 -0
  375. {nbxtensor-0.0.9 → nbxtensor-0.1.0}/tools/scatter_scan.py +0 -0
@@ -0,0 +1,29 @@
1
+ # The NeuroBrix CLA check: every author of a pull request has signed the NeuroBrix Contributor Assignment Agreement.
2
+ # The check's code and the signatures live in the private repository NeuroBrix/cla-signatures (one copy for every
3
+ # NeuroBrix repository); the pull request's own code is never checked out or run.
4
+ name: CLA
5
+ on:
6
+ pull_request_target:
7
+ types: [opened, synchronize, reopened]
8
+ issue_comment:
9
+ types: [created]
10
+ permissions:
11
+ contents: read
12
+ pull-requests: write
13
+ issues: write
14
+ statuses: write
15
+ concurrency:
16
+ group: cla-${{ github.event.pull_request.number || github.event.issue.number }}
17
+ jobs:
18
+ cla:
19
+ if: github.event_name == 'pull_request_target' || github.event.issue.pull_request
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - name: Check the signatures
23
+ env:
24
+ PR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25
+ STORE_TOKEN: ${{ secrets.CLA_STORE_TOKEN }}
26
+ run: |
27
+ curl -fsSL -H "Authorization: Bearer $STORE_TOKEN" -H "Accept: application/vnd.github.raw" \
28
+ https://api.github.com/repos/NeuroBrix/cla-signatures/contents/check.py -o "$RUNNER_TEMP/check.py"
29
+ python3 "$RUNNER_TEMP/check.py"
@@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.0] - 2026-11-10
11
+ ### Changed
12
+ - **Contributions are made under the NeuroBrix Contributor Assignment Agreement** (docs/legal/ of the neurobrix repository, an individual and an entity version): signed once by a comment on the first pull request, for every NeuroBrix project; the `NeuroBrix CLA` check on every pull request says who has yet to sign. CONTRIBUTING.md explains it.
13
+ - **The authors' contact address is contact@neurobrix.org** (the package metadata), the project's address being neurobrix.org.
14
+
15
+ ### Added
16
+ - **A decoding sequence may outgrow the card's KV pages**: past `card_pages`, `PagedTritonKVCache` moves its oldest
17
+ written pages to `memory.host_spill.HostSpill` (float32 in the attention's layout, bounded by a host budget) and keeps
18
+ decoding; each step's attention over the spilled positions is computed on the host
19
+ (`ops.host_decode_partial`) and joins the card's split partials in the same reduce launch — exact, the split-KV
20
+ merge. Qwen3-30B's attention shape on an M4 Pro: 131 072 spilled positions cost 15 ms per layer and step.
21
+ A prompt longer than the card's pages is prefilled chunk by chunk over the card and the host
22
+ (`memory.paged_kv` `chunk_attention`); on a V100 host with 40 threads, 131 072 spilled positions cost 25.8 ms per
23
+ layer and step.
24
+ - **An attention returns its rows' log-sum-exp**: `scaled_dot_product_attention_wrapper(return_lse=True)` returns the
25
+ natural-log LSE of each query row (fp32) on every route — math, chunked math, the flash kernels and the decode path —
26
+ so partial attentions over split keys merge exactly.
27
+ - **`nbxtensor.ops.token_bitmask`**: a token bitmask applied to a decode step's fp32 logits in place (constrained
28
+ decoding): every token whose bit is clear (bit v % 32 of int32 word v // 32, ceil(vocab / 32) words a row) set to
29
+ -inf before the sampler; the mask on the logits' own device, the element-wise launch's certified tile; a mask of
30
+ another shape or allowing no token refused by name. Torch-free.
31
+ - **A KV cache host tier**: `memory.kv_host_tier` (the prefix index of whole pages, the host page pool, the pages a
32
+ sequence holds), `memory.kv_host_pages` (host pages laid out [page][layer][K, V], pinned or pageable; per-layer copies,
33
+ and `offload_gathered` / `restore_scattered`: every layer's page gathered on the device by one kernel per K and V, then
34
+ one copy per page and run of layers — 43 MB in 21 / 8 ms against 184 / 210 ms per layer on a V100), and the paged
35
+ cache's `tier_*` protocol (layout, length, offload, restore in place, resume).
36
+ - **`nbxtensor.ops.embedding_pool`**: an embedding model's pooling on the host (`pool_hidden`: mean over the kept
37
+ positions, cls, or each sequence's last kept position whatever the padding side; `l2_normalize`), numpy and
38
+ torch-free; refusals by name.
39
+
10
40
  ## [0.0.9] - 2026-11-09
11
41
 
12
42
  ### Fixed
@@ -273,7 +303,8 @@ memory; the fix is in test).
273
303
  - **`flash_decode_split_kernel` and its route**: armed only by an environment switch (`NBX_FLASH_DECODE`, with `NBX_FD_BLOCK_N` and `NBX_FD_SEG`) and measured slower than the vector decode kernels; `flash_decode.py` keeps the fixed-order reduce they share.
274
304
  - **`conv1d_forward_kernel`**: launched by no route (a 1-D convolution runs through `conv2d`).
275
305
 
276
- [Unreleased]: https://github.com/NeuroBrix/nbxtensor/compare/v0.0.8...HEAD
306
+ [Unreleased]: https://github.com/NeuroBrix/nbxtensor/compare/v0.1.0...HEAD
307
+ [0.1.0]: https://github.com/NeuroBrix/nbxtensor/compare/v0.0.9...v0.1.0
277
308
  [0.0.8]: https://github.com/NeuroBrix/nbxtensor/compare/v0.0.5...v0.0.8
278
309
  [0.0.5]: https://github.com/NeuroBrix/nbxtensor/compare/v0.0.4...v0.0.5
279
310
  [0.0.4]: https://github.com/NeuroBrix/nbxtensor/compare/v0.0.3...v0.0.4
@@ -31,6 +31,18 @@ exported here; a pull request on either repository is fine — we carry it acros
31
31
  - **No model knowledge.** The library knows tensors, kernels and devices, never a model by name.
32
32
  - English in code, comments and documentation.
33
33
 
34
+ ## Contributor Assignment Agreement
35
+
36
+ Before your first pull request is merged, you sign the [NeuroBrix Contributor Assignment
37
+ Agreement](https://github.com/NeuroBrix/neurobrix/blob/main/docs/legal/contributor-assignment-agreement.md) — once, for
38
+ every NeuroBrix project (neurobrix, nbxtensor, NBXGrammar, NBX Code, the hub). You assign the rights in your contribution
39
+ to the owner of the NeuroBrix project (named in the NOTICE file) and its successors, and receive back a license to use
40
+ your own contribution as you wish; the owner may license the projects under other terms; no trademark right is involved.
41
+ To sign, post on your pull request the comment `I have read the NeuroBrix Contributor Assignment Agreement and I hereby
42
+ sign it.` — the `NeuroBrix CLA` check then passes. Contributing for a company? Your employer signs the [entity
43
+ agreement](https://github.com/NeuroBrix/neurobrix/blob/main/docs/legal/entity-contributor-assignment-agreement.md) first:
44
+ write to contact@neurobrix.org.
45
+
34
46
  ## Certificates
35
47
 
36
48
  Certificates are the proven kernel settings of a GPU class: see [Certify your own hardware](README.md#certify-your-own-hardware)
@@ -1,5 +1,6 @@
1
1
  nbxtensor
2
2
  Copyright 2025–2026 Hocine Benkelaya
3
+ Owner of the NeuroBrix project (the Owner under the Contributor Assignment Agreement): Hocine Benkelaya
3
4
 
4
5
  Supported and funded by Neural Network Holding Ltd (https://neuralnetworkholding.com).
5
6
  Commercial distribution by WizWorks OÜ (https://wizworks.io).
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: nbxtensor
3
- Version: 0.0.9
3
+ Version: 0.1.0
4
4
  Summary: Run AI models without PyTorch: tensors, Triton kernels, planned memory and certified tuning, wherever Triton runs — NVIDIA, AMD, Intel and Apple GPUs.
5
5
  Project-URL: Homepage, https://github.com/NeuroBrix/nbxtensor
6
6
  Project-URL: Source, https://github.com/NeuroBrix/nbxtensor
7
7
  Project-URL: Issues, https://github.com/NeuroBrix/nbxtensor/issues
8
8
  Project-URL: Changelog, https://github.com/NeuroBrix/nbxtensor/blob/main/CHANGELOG.md
9
- Author-email: Hocine Benkelaya <contact@neurobrix.es>
10
- Maintainer-email: Hocine Benkelaya <contact@neurobrix.es>
9
+ Author-email: Hocine Benkelaya <contact@neurobrix.org>
10
+ Maintainer-email: Hocine Benkelaya <contact@neurobrix.org>
11
11
  License: Apache-2.0
12
12
  License-File: LICENSE
13
13
  License-File: NOTICE
@@ -27,7 +27,8 @@ Description-Content-Type: text/markdown
27
27
 
28
28
  Run AI models without PyTorch, on any GPU Triton supports: tensors, Triton kernels, planned memory and certified tuning.
29
29
 
30
- Runs wherever Triton runs — NVIDIA, AMD, Intel and Apple Silicon GPUs, on Linux, Windows and macOS. Inference first; training is not in this
30
+ Validated on NVIDIA and Apple Silicon GPUs, on Linux, Windows and macOS; AMD and Intel GPUs, through the same Triton
31
+ kernels, are targets not yet validated on a card. Inference first; training is not in this
31
32
  release. Found a bug on your hardware? [Open an issue](https://github.com/NeuroBrix/nbxtensor/issues) — we fix fast.
32
33
 
33
34
  [![PyPI](https://img.shields.io/pypi/v/nbxtensor)](https://pypi.org/project/nbxtensor/)
@@ -4,7 +4,8 @@
4
4
 
5
5
  Run AI models without PyTorch, on any GPU Triton supports: tensors, Triton kernels, planned memory and certified tuning.
6
6
 
7
- Runs wherever Triton runs — NVIDIA, AMD, Intel and Apple Silicon GPUs, on Linux, Windows and macOS. Inference first; training is not in this
7
+ Validated on NVIDIA and Apple Silicon GPUs, on Linux, Windows and macOS; AMD and Intel GPUs, through the same Triton
8
+ kernels, are targets not yet validated on a card. Inference first; training is not in this
8
9
  release. Found a bug on your hardware? [Open an issue](https://github.com/NeuroBrix/nbxtensor/issues) — we fix fast.
9
10
 
10
11
  [![PyPI](https://img.shields.io/pypi/v/nbxtensor)](https://pypi.org/project/nbxtensor/)
@@ -4,13 +4,13 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "nbxtensor"
7
- version = "0.0.9"
7
+ version = "0.1.0"
8
8
  description = "Run AI models without PyTorch: tensors, Triton kernels, planned memory and certified tuning, wherever Triton runs — NVIDIA, AMD, Intel and Apple GPUs."
9
9
  readme = "README.md"
10
10
  license = { text = "Apache-2.0" }
11
11
  requires-python = ">=3.10"
12
- authors = [{ name = "Hocine Benkelaya", email = "contact@neurobrix.es" }]
13
- maintainers = [{ name = "Hocine Benkelaya", email = "contact@neurobrix.es" }]
12
+ authors = [{ name = "Hocine Benkelaya", email = "contact@neurobrix.org" }]
13
+ maintainers = [{ name = "Hocine Benkelaya", email = "contact@neurobrix.org" }]
14
14
  # numpy, triton, pyyaml (the dtype table is a YAML file) and, on Linux, the CUDA runtime. torch is never a dependency, not even an optional one:
15
15
  # nbxtensor never imports torch (R-NBXT 6). Exchange with any other tensor
16
16
  # library goes through DLPack, which the OTHER library imports.
@@ -13,5 +13,5 @@ first publication is 0.0.1, each fix after it increments, the Rust rewrite is
13
13
  """
14
14
 
15
15
  #: the one version number; `pyproject.toml` states the same (tests/test_version.py)
16
- __version__ = "0.0.9"
16
+ __version__ = "0.1.0"
17
17
  __all__: list = []
@@ -0,0 +1,90 @@
1
+ """The positions a decoding sequence spilled from the card's paged cache to host memory (point 10, the mid-decode
2
+ spill; Dell + Mac 2026-11-10): the card keeps the newest positions, the oldest whole pages move here when the card may
3
+ hold no more, and each decode step's attention over them is computed here (ops/host_decode_partial.py), joined to the
4
+ card's as the reduce's last split.
5
+
6
+ Per layer, K and V as float32 in the attention's own layout [H_kv, positions, D], written ONCE per spilled page: a
7
+ per-step conversion and transpose cost 7x the math (measured 2026-11-10, 131 072 positions, M4 Pro). The price is twice
8
+ the card's half-precision bytes per position; `budget_bytes` (the serving layer's, from the profile and the user's cap:
9
+ an int, or a callable giving the bytes the spill may hold now — the share of one host budget the KV tier's parked pages
10
+ leave) bounds it, and a spill past it is refused by name. Grows by doubling up to the budget, never at max_len.
11
+ """
12
+ from __future__ import annotations
13
+
14
+ from typing import List, Optional
15
+
16
+ import numpy as np
17
+
18
+ from nbxtensor.ops.host_decode_partial import host_decode_partial
19
+
20
+
21
+ class HostSpill:
22
+ def __init__(self, num_layers: int, kv_heads: int, k_dim: int, v_dim: int, budget_bytes):
23
+ self.num_layers, self.kv_heads, self.k_dim, self.v_dim = int(num_layers), int(kv_heads), int(k_dim), int(v_dim)
24
+ self._budget = budget_bytes if callable(budget_bytes) else (lambda b=int(budget_bytes): b)
25
+ self.k: List[Optional[np.ndarray]] = [None] * self.num_layers
26
+ self.v: List[Optional[np.ndarray]] = [None] * self.num_layers
27
+ self.held = [0] * self.num_layers # positions each layer holds
28
+
29
+ def position_bytes(self) -> int:
30
+ """Host bytes one spilled position costs across every layer (float32 K and V)."""
31
+ return 4 * self.kv_heads * (self.k_dim + self.v_dim) * self.num_layers
32
+
33
+ @property
34
+ def budget_bytes(self) -> int:
35
+ return int(self._budget())
36
+
37
+ def reach(self) -> int:
38
+ """Positions the budget can hold now."""
39
+ return self.budget_bytes // self.position_bytes()
40
+
41
+ @property
42
+ def length(self) -> int:
43
+ return self.held[0]
44
+
45
+ def nbytes(self) -> int:
46
+ return sum(a.nbytes for a in self.k + self.v if a is not None)
47
+
48
+ def append(self, layer: int, k_pages: np.ndarray, v_pages: np.ndarray) -> None:
49
+ """Layer `layer`'s next spilled pages, in position order: [pages, H_kv, page_tokens, D] as the card pool holds
50
+ them (any float dtype) — converted and laid out once here."""
51
+ n = int(k_pages.shape[0]) * int(k_pages.shape[2])
52
+ end = self.held[layer] + n
53
+ if end > self.reach():
54
+ raise RuntimeError(f"ZERO FALLBACK: spilling to {end} positions in host memory; the host budget "
55
+ f"({self.budget_bytes / 2 ** 20:.0f} MB, {self.position_bytes()} bytes a position across "
56
+ f"{self.num_layers} layers) holds {self.reach()} — the request is past the cache's reach")
57
+ cap = 0 if self.k[layer] is None else self.k[layer].shape[1]
58
+ if end > cap:
59
+ new_cap = min(max(end, 2 * cap), self.reach())
60
+ for arrs, d in ((self.k, self.k_dim), (self.v, self.v_dim)):
61
+ grown = np.zeros((self.kv_heads, new_cap, d), np.float32)
62
+ if arrs[layer] is not None:
63
+ grown[:, :self.held[layer]] = arrs[layer][:, :self.held[layer]]
64
+ arrs[layer] = grown
65
+ for arrs, pages in ((self.k, k_pages), (self.v, v_pages)):
66
+ # [pages, H_kv, P, D] -> [H_kv, pages * P, D]
67
+ flat = np.asarray(pages).transpose(1, 0, 2, 3).reshape(self.kv_heads, n, pages.shape[3])
68
+ arrs[layer][:, self.held[layer]:end] = flat
69
+ self.held[layer] = end
70
+
71
+ def partial(self, layer: int, q: np.ndarray, groups: int, scale: float):
72
+ """The attention partial of query rows q [H, D] (float32, rounded as the card reads them) over this layer's
73
+ spilled positions (acc, m, l)."""
74
+ if self.k[layer] is None:
75
+ return host_decode_partial(q, np.zeros((self.kv_heads, 0, self.k_dim), np.float32),
76
+ np.zeros((self.kv_heads, 0, self.v_dim), np.float32), 0, groups, scale)
77
+ # the scores take, at once, at most what the budget leaves beside the spilled positions themselves
78
+ return host_decode_partial(q, self.k[layer], self.v[layer], self.held[layer], groups, scale,
79
+ scores_bytes=max(0, self.budget_bytes - self.nbytes()))
80
+
81
+ def truncate(self, length: int) -> None:
82
+ """Keep the first `length` spilled positions (a session's matched prefix)."""
83
+ if length > self.length:
84
+ raise RuntimeError(f"ZERO FALLBACK: truncating the host spill to {length} positions; it holds {self.length}")
85
+ self.held = [min(h, int(length)) for h in self.held]
86
+
87
+ def clear(self) -> None:
88
+ self.k = [None] * self.num_layers
89
+ self.v = [None] * self.num_layers
90
+ self.held = [0] * self.num_layers
@@ -0,0 +1,317 @@
1
+ """The KV host tier's raw pages and copies, for the Triton engine's paged cache (memory/paged_kv.py) — the mechanism
2
+ half of the tier whose bookkeeping is memory/kv_host_tier.py (reste_apres_064 point 10).
3
+
4
+ A host page holds one page index of EVERY layer's K and V, contiguous: [layer][K page bytes, V page bytes]. Its memory is
5
+ page-locked (the device's host allocation) when the engine asks for it — a discrete card, whose copies then run as DMA —
6
+ and ordinary pageable host memory otherwise: on unified memory the device's own host allocation is a GPU buffer counted
7
+ in the GPU working set, which is the scarce figure there (the engine decides from the machine's profile; this module
8
+ takes `pinned` as given). A page's K (or V) of one layer is `pool[page]`, a contiguous block of the layer's pool
9
+ `[pages, kv_heads, page_tokens, D]`: one copy per layer and per K/V. Offload waits for the device first (the pages may
10
+ still be written by queued kernels); restore writes into the pools in place (their addresses never move: replay plans
11
+ point at them), inside the cache's fence when it has one. Zero torch (R33)."""
12
+ from __future__ import annotations
13
+
14
+ import ctypes
15
+ from typing import Optional, Sequence
16
+
17
+ import numpy as np
18
+
19
+ from nbxtensor.memory.allocator import DeviceAllocator
20
+
21
+ _H2D, _D2H = 1, 2
22
+
23
+
24
+ class HostPages:
25
+ """Host pages of `num_layers` layers' K pages of `k_page_bytes` and V pages of `v_page_bytes`, allocated in SLICES
26
+ of `slice_pages` as they are needed (`grow`), never beyond `max_pages`: the budget is a ceiling, what is held is what
27
+ the tier parked (a whole budget locked at the first park was ~240 GB page-locked on the rack, ~0.6 s/GB: the Dell's
28
+ review 2026-11-09 21:19). A page lives in one slice; pages of one slice are contiguous (`contiguous`)."""
29
+
30
+ def __init__(self, slice_pages: int, max_pages: int, num_layers: int, k_page_bytes: int, v_page_bytes: int,
31
+ pinned: bool):
32
+ if slice_pages <= 0 or max_pages <= 0 or num_layers <= 0 or k_page_bytes <= 0 or v_page_bytes <= 0:
33
+ raise ValueError(f"HostPages: slices of {slice_pages} of at most {max_pages} pages of {num_layers} layers "
34
+ f"x ({k_page_bytes} + {v_page_bytes}) B")
35
+ self.slice_pages, self.max_pages, self.num_layers = int(slice_pages), int(max_pages), int(num_layers)
36
+ self.k_page_bytes, self.v_page_bytes = int(k_page_bytes), int(v_page_bytes)
37
+ self.page_bytes = self.num_layers * (self.k_page_bytes + self.v_page_bytes)
38
+ self.pinned = bool(pinned)
39
+ self._slices = [] # [(numpy uint8 buffer, pinned pointer or 0, pages)]
40
+
41
+ @classmethod
42
+ def fixed(cls, capacity: int, num_layers: int, k_page_bytes: int, v_page_bytes: int, pinned: bool) -> "HostPages":
43
+ """`capacity` pages allocated at once, one slice."""
44
+ host = cls(capacity, capacity, num_layers, k_page_bytes, v_page_bytes, pinned)
45
+ host.grow()
46
+ return host
47
+
48
+ @property
49
+ def capacity(self) -> int:
50
+ """Pages allocated now."""
51
+ return sum(n for _, _, n in self._slices)
52
+
53
+ def grow(self) -> int:
54
+ """One more slice (the last one cut at `max_pages`); returns the pages added, 0 at the ceiling."""
55
+ n = min(self.slice_pages, self.max_pages - self.capacity)
56
+ if n <= 0:
57
+ return 0
58
+ nb = n * self.page_bytes
59
+ ptr = DeviceAllocator.malloc_host_pinned(nb) if self.pinned else 0
60
+ buf = np.ctypeslib.as_array((ctypes.c_uint8 * nb).from_address(ptr)) if self.pinned else np.empty(nb, np.uint8)
61
+ self._slices.append((buf, ptr, n))
62
+ return n
63
+
64
+ def shrink(self) -> int:
65
+ """The last slice freed (the caller knows it holds no parked page); returns the pages removed."""
66
+ if not self._slices:
67
+ return 0
68
+ _, ptr, n = self._slices.pop()
69
+ if ptr:
70
+ DeviceAllocator.free_host_pinned(ptr)
71
+ return n
72
+
73
+ def _locate(self, host_page: int):
74
+ if not 0 <= host_page < self.capacity:
75
+ raise IndexError(f"HostPages: host page {host_page} outside 0..{self.capacity - 1}")
76
+ for i, (buf, _, n) in enumerate(self._slices):
77
+ if host_page < n:
78
+ return i, buf, host_page
79
+ host_page -= n
80
+
81
+ def contiguous(self, a: int, b: int) -> bool:
82
+ """Host pages `a` and `b` live in one slice (their bytes are one block)."""
83
+ return self._locate(a)[0] == self._locate(b)[0]
84
+
85
+ def page_view(self, host_page: int) -> np.ndarray:
86
+ _, buf, i = self._locate(host_page)
87
+ return buf[i * self.page_bytes:(i + 1) * self.page_bytes]
88
+
89
+ def address(self, host_page: int, layer: int, which: str) -> int:
90
+ _, buf, i = self._locate(host_page)
91
+ off = i * self.page_bytes + layer * (self.k_page_bytes + self.v_page_bytes)
92
+ return buf.ctypes.data + off + (self.k_page_bytes if which == "v" else 0)
93
+
94
+ def close(self) -> None:
95
+ while self._slices:
96
+ self.shrink()
97
+
98
+
99
+ def _page_bytes(pool) -> int:
100
+ return (pool.numel() // int(pool.shape[0])) * pool.element_size()
101
+
102
+
103
+ def offload(k_pools: Sequence, v_pools: Sequence, pages: Sequence[int], host: HostPages,
104
+ host_pages: Sequence[int]) -> None:
105
+ """Copy each device page of `pages` (every layer's K and V) into the host page of the same rank in `host_pages`."""
106
+ if len(pages) != len(host_pages):
107
+ raise ValueError(f"kv_host_pages.offload: {len(pages)} device pages, {len(host_pages)} host pages")
108
+ for i in range(host.num_layers):
109
+ for which, pools, nb in (("k", k_pools, host.k_page_bytes), ("v", v_pools, host.v_page_bytes)):
110
+ if _page_bytes(pools[i]) != nb:
111
+ raise ValueError(f"kv_host_pages: layer {i}'s {which} page is {_page_bytes(pools[i])} B, the host "
112
+ f"page holds {nb}")
113
+ devices = {int(p._device_idx) for p in (*k_pools, *v_pools)}
114
+ for d in devices: # queued kernels may still write the pages
115
+ DeviceAllocator.device_synchronize(d)
116
+ for page, hp in zip(pages, host_pages):
117
+ for i in range(host.num_layers):
118
+ DeviceAllocator.set_device(k_pools[i]._device_idx)
119
+ DeviceAllocator.memcpy(host.address(hp, i, "k"), k_pools[i].data_ptr() + int(page) * host.k_page_bytes,
120
+ host.k_page_bytes, _D2H)
121
+ DeviceAllocator.memcpy(host.address(hp, i, "v"), v_pools[i].data_ptr() + int(page) * host.v_page_bytes,
122
+ host.v_page_bytes, _D2H)
123
+
124
+
125
+ def restore(k_pools: Sequence, v_pools: Sequence, host: HostPages, host_pages: Sequence[int],
126
+ pages: Sequence[int], fence=None, owner=None) -> None:
127
+ """Copy each host page of `host_pages` back into the device page of the same rank in `pages`, in place; inside
128
+ `fence` (drain before, record after) when the cache has one."""
129
+ if len(pages) != len(host_pages):
130
+ raise ValueError(f"kv_host_pages.restore: {len(host_pages)} host pages, {len(pages)} device pages")
131
+ if fence is not None:
132
+ fence.drain(owner)
133
+ for hp, page in zip(host_pages, pages):
134
+ for i in range(host.num_layers):
135
+ DeviceAllocator.set_device(k_pools[i]._device_idx)
136
+ DeviceAllocator.memcpy(k_pools[i].data_ptr() + int(page) * host.k_page_bytes, host.address(hp, i, "k"),
137
+ host.k_page_bytes, _H2D)
138
+ DeviceAllocator.memcpy(v_pools[i].data_ptr() + int(page) * host.v_page_bytes, host.address(hp, i, "v"),
139
+ host.v_page_bytes, _H2D)
140
+ if fence is not None:
141
+ fence.record()
142
+
143
+
144
+ # ---------------------------------------------------------------------------------------------------------------------
145
+ # Gathered copies: on a discrete card, one memcpy per page and per contiguous run of a device's layers, the pages first
146
+ # gathered on the device by one kernel per K and V. The per-layer copies above cost ~30-40 us of call each (V100 PCIe,
147
+ # 125 TinyLlama pages = 5 500 copies of 8 KB: 150-230 ms), one contiguous copy of the same 43 MB 7-21 ms (measured
148
+ # 2026-11-09, campaigns 2026_11_09_release_063/kv_host_timing). Which path a machine takes is the engine's choice from its
149
+ # profile (discrete or unified memory); both are bit-exact.
150
+
151
+ import triton
152
+ import triton.language as tl
153
+
154
+ from nbxtensor.backend.launcher import install as _install_launcher
155
+
156
+ # every kernel[grid] of this module goes through the library's launcher (ops/wrappers.py does the same at import): left
157
+ # to Triton's default driver, the first launch of a fresh process met Triton's own Metal driver, which refuses an
158
+ # NBXTensor argument ('Arg 0: expected an MPS tensor', the Mac 2026-11-09 21:20), and on CUDA upstream's torch-importing one
159
+ _install_launcher()
160
+
161
+ _BITS = {1: tl.int8, 2: tl.int16, 4: tl.int32} # the element's bits, copied as an integer of its size
162
+ _NBX_BITS = {1: "int8", 2: "int16", 4: "int32"}
163
+
164
+
165
+ @triton.jit
166
+ def _kv_page_rows_kernel(table_ptr, pages_ptr, stage_ptr, page_elems, row_len, stage_page_elems, layer_elems, base,
167
+ TO_STAGE: tl.constexpr, ELEM: tl.constexpr, BLOCK: tl.constexpr):
168
+ """One program per (page rank, layer slot, row): the row's `row_len` elements of pool[page] (the layer's pool read
169
+ through its address in `table`) copied, bits unchanged, to or from the staging buffer laid out as host pages
170
+ [page rank][layer slot][K, V] (`base`: the K or V offset inside a layer slot)."""
171
+ r = tl.program_id(0).to(tl.int64)
172
+ s = tl.program_id(1).to(tl.int64)
173
+ row = tl.program_id(2).to(tl.int64)
174
+ page = tl.load(pages_ptr + r).to(tl.int64)
175
+ pool = tl.cast(tl.load(table_ptr + s), tl.pointer_type(ELEM), bitcast=True)
176
+ offs = tl.arange(0, BLOCK)
177
+ m = offs < row_len
178
+ pool_at = pool + page * page_elems + row * row_len + offs
179
+ stage_at = stage_ptr + r * stage_page_elems + s * layer_elems + base + row * row_len + offs
180
+ if TO_STAGE:
181
+ tl.store(stage_at, tl.load(pool_at, mask=m), mask=m)
182
+ else:
183
+ tl.store(pool_at, tl.load(stage_at, mask=m), mask=m)
184
+
185
+
186
+ def _layer_runs(k_pools):
187
+ """{device: [(first layer, last layer + 1), ...]}: each device's layers as contiguous runs (a pipeline split keeps
188
+ a device's layers contiguous; any other placement still works, one run per layer)."""
189
+ runs = {}
190
+ for i, pool in enumerate(k_pools):
191
+ d = int(pool._device_idx)
192
+ cur = runs.setdefault(d, [])
193
+ if cur and cur[-1][1] == i:
194
+ cur[-1] = (cur[-1][0], i + 1)
195
+ else:
196
+ cur.append((i, i + 1))
197
+ return runs
198
+
199
+
200
+ def _copies(host_pages, runs, num_layers, contiguous=lambda a, b: True):
201
+ """The host copies, (first rank, end rank, first layer, end layer, layers before it in a rank's staging slice): one per rank
202
+ and run; consecutive host pages merged into one copy when the card holds every layer (one run (0, num_layers))."""
203
+ if runs == [(0, num_layers)]:
204
+ r0 = 0
205
+ for r in range(1, len(host_pages) + 1):
206
+ if (r == len(host_pages) or host_pages[r] != host_pages[r - 1] + 1
207
+ or not contiguous(host_pages[r - 1], host_pages[r])):
208
+ yield r0, r, 0, num_layers, 0
209
+ r0 = r
210
+ return
211
+ for r in range(len(host_pages)):
212
+ off = 0
213
+ for a, b in runs:
214
+ yield r, r + 1, a, b, off
215
+ off += b - a
216
+
217
+
218
+ def _address_table(pools):
219
+ """The device addresses a shader reads for `pools` (Metal: the pinned wraps' GPU addresses, under a pin the caller
220
+ releases; elsewhere their data pointers), as an int64 table on the current device."""
221
+ from nbxtensor.backend.runtime import gpu_backend
222
+ from nbxtensor.tensor import NBXTensor
223
+ pin = None
224
+ if gpu_backend() == "metal":
225
+ from nbxtensor.backend.triton_ext_driver import pinned_addresses, pinned_gpu_address
226
+ pin = pinned_addresses(*pools)
227
+ pin.__enter__()
228
+ addrs = [pinned_gpu_address(p.data_ptr()) for p in pools]
229
+ else:
230
+ addrs = [p.data_ptr() for p in pools]
231
+ return NBXTensor.from_numpy(np.array(addrs, dtype=np.int64)), pin
232
+
233
+
234
+ def _gathered(k_pools, v_pools, host: HostPages, pages, host_pages, to_host: bool, fence=None, owner=None) -> None:
235
+ from nbxtensor.backend.runtime import set_device as launch_on # Triton's driver on the tensor's device
236
+ from nbxtensor.dtype.nbx_dtype import NBXDtype
237
+ from nbxtensor.tensor import NBXTensor as _T
238
+ if len(pages) != len(host_pages):
239
+ raise ValueError(f"kv_host_pages: {len(pages)} device pages, {len(host_pages)} host pages")
240
+ elem = k_pools[0].element_size()
241
+ if elem not in _BITS or any(p.element_size() != elem for p in (*k_pools, *v_pools)):
242
+ raise ValueError(f"kv_host_pages: pools of element sizes {sorted({p.element_size() for p in (*k_pools, *v_pools)})}"
243
+ f" — one size of 1, 2 or 4 bytes is copied as its bits")
244
+ for i in range(host.num_layers):
245
+ for which, pools, nb in (("k", k_pools, host.k_page_bytes), ("v", v_pools, host.v_page_bytes)):
246
+ if _page_bytes(pools[i]) != nb or not pools[i].is_contiguous():
247
+ raise ValueError(f"kv_host_pages: layer {i}'s {which} pool ({_page_bytes(pools[i])} B a page, "
248
+ f"contiguous {pools[i].is_contiguous()}) is not the host page's {nb} B contiguous page")
249
+ n, kb, vb = len(pages), host.k_page_bytes, host.v_page_bytes
250
+ if not to_host and fence is not None:
251
+ fence.drain(owner)
252
+ for dev, runs in _layer_runs(k_pools).items():
253
+ DeviceAllocator.set_device(dev)
254
+ layers = [i for a, b in runs for i in range(a, b)]
255
+ if to_host:
256
+ DeviceAllocator.device_synchronize(dev) # queued kernels may still write the pages
257
+ stage = _T.empty((n * len(layers) * (kb + vb) // elem,), dtype=getattr(NBXDtype, _NBX_BITS[elem]),
258
+ device=f"cuda:{dev}")
259
+ page_ids = _T.from_numpy(np.asarray(list(pages), dtype=np.int64))
260
+ tables, pins = [], []
261
+ try:
262
+ for which, pools, nb, base in (("k", k_pools, kb, 0), ("v", v_pools, vb, kb)):
263
+ table, pin = _address_table([pools[i] for i in layers])
264
+ tables.append(table)
265
+ pins.append(pin)
266
+ rows = int(np.prod(pools[layers[0]].shape[1:-1]))
267
+ row_len = int(pools[layers[0]].shape[-1])
268
+ grid = (n, len(layers), rows)
269
+ args = (table, page_ids, stage, nb // elem, row_len, len(layers) * (kb + vb) // elem,
270
+ (kb + vb) // elem, base // elem)
271
+ if to_host:
272
+ launch_on(stage) # the launch contract (backend/runtime.set_device)
273
+ _kv_page_rows_kernel[grid](*args, TO_STAGE=True, ELEM=_BITS[elem],
274
+ BLOCK=triton.next_power_of_2(row_len))
275
+ seg = len(layers) * (kb + vb) # this device's slice of one host page, per run
276
+ if to_host:
277
+ DeviceAllocator.device_synchronize(dev)
278
+ for r0, r1, a, b, off in _copies(host_pages, runs, host.num_layers, host.contiguous):
279
+ # host pages r0..r1-1 are consecutive and this card holds every layer: the staging IS their host layout
280
+ nbytes = (r1 - r0 - 1) * seg + (b - a) * (kb + vb)
281
+ h_addr = host.address(host_pages[r0], a, "k")
282
+ d_addr = stage.data_ptr() + r0 * seg + off * (kb + vb)
283
+ if to_host:
284
+ DeviceAllocator.memcpy(h_addr, d_addr, nbytes, _D2H)
285
+ else:
286
+ DeviceAllocator.memcpy(d_addr, h_addr, nbytes, _H2D)
287
+ if not to_host:
288
+ for (which, pools, nb, base), table in zip((("k", k_pools, kb, 0), ("v", v_pools, vb, kb)), tables):
289
+ rows = int(np.prod(pools[layers[0]].shape[1:-1]))
290
+ row_len = int(pools[layers[0]].shape[-1])
291
+ launch_on(stage)
292
+ _kv_page_rows_kernel[(n, len(layers), rows)](
293
+ table, page_ids, stage, nb // elem, row_len, len(layers) * (kb + vb) // elem,
294
+ (kb + vb) // elem, base // elem, TO_STAGE=False, ELEM=_BITS[elem],
295
+ BLOCK=triton.next_power_of_2(row_len))
296
+ DeviceAllocator.device_synchronize(dev)
297
+ finally:
298
+ for pin in pins:
299
+ if pin is not None:
300
+ pin.__exit__(None, None, None)
301
+ if not to_host and fence is not None:
302
+ fence.record()
303
+
304
+
305
+ def offload_gathered(k_pools: Sequence, v_pools: Sequence, pages: Sequence[int], host: HostPages,
306
+ host_pages: Sequence[int]) -> None:
307
+ """`offload`, the pages gathered on the device first (one kernel per K and V) and copied to the host once per page
308
+ and per contiguous run of a device's layers."""
309
+ _gathered(k_pools, v_pools, host, pages, host_pages, to_host=True)
310
+
311
+
312
+ def restore_scattered(k_pools: Sequence, v_pools: Sequence, host: HostPages, host_pages: Sequence[int],
313
+ pages: Sequence[int], fence=None, owner=None) -> None:
314
+ """`restore`, the host pages copied to the device once per page and per run of a device's layers, then scattered
315
+ into the pools in place (one kernel per K and V), inside `fence` when the cache has one."""
316
+ _gathered(k_pools, v_pools, host, pages, host_pages, to_host=False, fence=fence, owner=owner)
317
+