stackformers 6.0.0rc3__tar.gz → 6.0.0rc8__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 (239) hide show
  1. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/CHANGELOG.md +117 -0
  2. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/PKG-INFO +1 -1
  3. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/pyproject.toml +1 -1
  4. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/DEVLOG.md +101 -0
  5. stackformers-6.0.0rc8/stackformers/attention2d/README.md +145 -0
  6. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention2d/__init__.py +1 -1
  7. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention2d/coordinates.py +13 -9
  8. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention2d/cross_attn_pooling.py +2 -5
  9. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention2d/factory.py +1 -1
  10. stackformers-6.0.0rc8/stackformers/attention2d/figures/window_cross_attention_2d.svg +632 -0
  11. stackformers-6.0.0rc8/stackformers/attention2d/figures/window_self_attention_2d.svg +632 -0
  12. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention2d/query_anchors.py +25 -2
  13. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention2d/self_attn.py +2 -3
  14. stackformers-6.0.0rc8/stackformers/attention2d/sequence.py +220 -0
  15. stackformers-6.0.0rc8/stackformers/attention2d/windows.py +110 -0
  16. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/encoder2d/README.md +18 -2
  17. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/encoder2d/window_stage.py +2 -3
  18. stackformers-6.0.0rc8/tests/attention2d/test_export.py +120 -0
  19. stackformers-6.0.0rc8/tests/attention2d/test_sequence.py +126 -0
  20. stackformers-6.0.0rc8/tests/attention2d/test_windows.py +142 -0
  21. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/encoder2d/test_encoder.py +29 -10
  22. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/encoder2d/test_window_stage.py +23 -3
  23. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/uv.lock +1 -1
  24. stackformers-6.0.0rc3/stackformers/attention2d/README.md +0 -77
  25. stackformers-6.0.0rc3/stackformers/attention2d/_geometry_module.py +0 -52
  26. stackformers-6.0.0rc3/stackformers/attention2d/centroid_queries.py +0 -36
  27. stackformers-6.0.0rc3/stackformers/attention2d/figures/window_cross_attention_2d.svg +0 -1
  28. stackformers-6.0.0rc3/stackformers/attention2d/figures/window_self_attention_2d.svg +0 -1
  29. stackformers-6.0.0rc3/stackformers/attention2d/geometry_precision.py +0 -17
  30. stackformers-6.0.0rc3/stackformers/attention2d/packed_windows.py +0 -134
  31. stackformers-6.0.0rc3/stackformers/attention2d/sequence.py +0 -149
  32. stackformers-6.0.0rc3/stackformers/attention2d/windows.py +0 -9
  33. stackformers-6.0.0rc3/tests/attention2d/test_export.py +0 -33
  34. stackformers-6.0.0rc3/tests/attention2d/test_packed_windows.py +0 -50
  35. stackformers-6.0.0rc3/tests/attention2d/test_sequence.py +0 -54
  36. stackformers-6.0.0rc3/tests/attention2d/test_windows.py +0 -12
  37. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/.claudeignore +0 -0
  38. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  39. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  40. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/.github/pull_request_template.md +0 -0
  41. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/.github/workflows/check.yml +0 -0
  42. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/.gitignore +0 -0
  43. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/.python-version +0 -0
  44. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/.vscode/settings.json +0 -0
  45. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/AGENTS.md +0 -0
  46. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/CITATION.cff +0 -0
  47. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/CONTRIBUTING.md +0 -0
  48. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/Justfile +0 -0
  49. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/LICENSE +0 -0
  50. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/PLAN.md +0 -0
  51. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/README.md +0 -0
  52. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/docs/api-guide.md +0 -0
  53. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/docs/assets/social-preview.jpg +0 -0
  54. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/docs/assets/social-preview.md +0 -0
  55. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/docs/compatibility.md +0 -0
  56. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/docs/improvement-plan.md +0 -0
  57. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/docs/inference.md +0 -0
  58. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/docs/research.md +0 -0
  59. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/examples/README.md +0 -0
  60. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/examples/causal_language_model.py +0 -0
  61. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/examples/encoder_decoder_onnxruntime.py +0 -0
  62. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/examples/image_encoder.py +0 -0
  63. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/examples/padded_and_packed.py +0 -0
  64. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/examples/point_cloud_encoder.py +0 -0
  65. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/examples/spatial_encoder.py +0 -0
  66. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/examples/subclassed_encoder.py +0 -0
  67. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/pyrefly.toml +0 -0
  68. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/pytest.ini +0 -0
  69. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/ruff.toml +0 -0
  70. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/__init__.py +0 -0
  71. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/_decoder_equations.py +0 -0
  72. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/_projection_packing.py +0 -0
  73. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/_result.py +0 -0
  74. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/alignment.py +0 -0
  75. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/all_valid_decoder.py +0 -0
  76. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/README.md +0 -0
  77. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/__init__.py +0 -0
  78. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/all_valid.py +0 -0
  79. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/bias.py +0 -0
  80. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/cache.py +0 -0
  81. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/cache_validation.py +0 -0
  82. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/cached.py +0 -0
  83. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/config.py +0 -0
  84. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/cross_attn.py +0 -0
  85. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/distance_bias.py +0 -0
  86. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/factory.py +0 -0
  87. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/layout.py +0 -0
  88. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/masking.py +0 -0
  89. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/onnx_backend.py +0 -0
  90. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/ops.py +0 -0
  91. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/packed_cross_attn.py +0 -0
  92. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/packed_self_attn.py +0 -0
  93. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/protocols.py +0 -0
  94. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/self_attn.py +0 -0
  95. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention/varlen_backend.py +0 -0
  96. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/attention2d/protocols.py +0 -0
  97. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/config.py +0 -0
  98. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/cross_attender.py +0 -0
  99. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/decoder.py +0 -0
  100. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/decoder_cache.py +0 -0
  101. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/encoder.py +0 -0
  102. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/encoder2d/__init__.py +0 -0
  103. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/encoder2d/_callable_stage.py +0 -0
  104. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/encoder2d/encoder.py +0 -0
  105. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/encoder2d/layer.py +0 -0
  106. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/encoder2d/protocols.py +0 -0
  107. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/encoder2d/tokenwise.py +0 -0
  108. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/feedforward/DEVLOG.md +0 -0
  109. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/feedforward/README.md +0 -0
  110. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/feedforward/__init__.py +0 -0
  111. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/feedforward/config.py +0 -0
  112. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/feedforward/factory.py +0 -0
  113. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/feedforward/geglu.py +0 -0
  114. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/feedforward/gelu.py +0 -0
  115. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/feedforward/hardswish_glu.py +0 -0
  116. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/feedforward/packed_geglu.py +0 -0
  117. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/feedforward/packed_hardswish_glu.py +0 -0
  118. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/feedforward/packed_swiglu.py +0 -0
  119. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/feedforward/protocols.py +0 -0
  120. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/feedforward/relu_squared.py +0 -0
  121. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/feedforward/swiglu.py +0 -0
  122. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/layers.py +0 -0
  123. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/mlm/README.md +0 -0
  124. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/mlm/config.py +0 -0
  125. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/mlm/head.py +0 -0
  126. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/mlm/head_cosine.py +0 -0
  127. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/mlm/masking.py +0 -0
  128. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/mlm/protocols.py +0 -0
  129. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/mlm/wrapper.py +0 -0
  130. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/norm/README.md +0 -0
  131. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/norm/__init__.py +0 -0
  132. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/norm/config.py +0 -0
  133. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/norm/factory.py +0 -0
  134. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/norm/protocols.py +0 -0
  135. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/packing.py +0 -0
  136. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/positional/README.md +0 -0
  137. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/positional/__init__.py +0 -0
  138. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/positional/config.py +0 -0
  139. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/positional/factory.py +0 -0
  140. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/positional/learned.py +0 -0
  141. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/positional/none.py +0 -0
  142. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/positional/protocols.py +0 -0
  143. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/positional/rope1d.py +0 -0
  144. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/positional/rope2d.py +0 -0
  145. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/positional/rope_nd.py +0 -0
  146. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/positional/validation.py +0 -0
  147. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/preallocated_decoder.py +0 -0
  148. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/presets/README.md +0 -0
  149. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/presets/__init__.py +0 -0
  150. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/presets/cross_attender.py +0 -0
  151. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/presets/decoder.py +0 -0
  152. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/presets/encoder.py +0 -0
  153. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/presets/variable_width_encoder.py +0 -0
  154. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/py.typed +0 -0
  155. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/result/README.md +0 -0
  156. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/result/__init__.py +0 -0
  157. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/stackformers/sequence.py +0 -0
  158. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/__init__.py +0 -0
  159. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/__init__.py +0 -0
  160. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/legacy_api_rc1.json +0 -0
  161. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_all_valid.py +0 -0
  162. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_cached.py +0 -0
  163. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_config.py +0 -0
  164. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_contracts.py +0 -0
  165. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_cross_attn.py +0 -0
  166. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_cross_attn_cache.py +0 -0
  167. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_distance_bias.py +0 -0
  168. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_empty_rows.py +0 -0
  169. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_factory.py +0 -0
  170. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_geometry.py +0 -0
  171. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_kernels.py +0 -0
  172. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_legacy_api.py +0 -0
  173. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_masking.py +0 -0
  174. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_onnx_backend.py +0 -0
  175. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_ops.py +0 -0
  176. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_packed_cross_attn.py +0 -0
  177. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_packed_self_attn.py +0 -0
  178. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_sdpa_export.py +0 -0
  179. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_self_attn.py +0 -0
  180. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention/test_varlen_backend.py +0 -0
  181. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention2d/conftest.py +0 -0
  182. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention2d/test_coordinates.py +0 -0
  183. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention2d/test_cross_attn_pooling.py +0 -0
  184. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention2d/test_factory.py +0 -0
  185. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention2d/test_query_anchors.py +0 -0
  186. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/attention2d/test_self_attn.py +0 -0
  187. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/conftest.py +0 -0
  188. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/encoder2d/conftest.py +0 -0
  189. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/encoder2d/test_layer.py +0 -0
  190. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/export_utils.py +0 -0
  191. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/feedforward/__init__.py +0 -0
  192. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/feedforward/legacy_swiglu_4_6.json +0 -0
  193. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/feedforward/test_config.py +0 -0
  194. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/feedforward/test_factory.py +0 -0
  195. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/feedforward/test_geglu.py +0 -0
  196. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/feedforward/test_gelu.py +0 -0
  197. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/feedforward/test_hardswish_glu.py +0 -0
  198. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/feedforward/test_packed_geglu.py +0 -0
  199. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/feedforward/test_packed_hardswish_glu.py +0 -0
  200. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/feedforward/test_packed_swiglu.py +0 -0
  201. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/feedforward/test_relu_squared.py +0 -0
  202. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/feedforward/test_swiglu.py +0 -0
  203. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/mlm/__init__.py +0 -0
  204. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/mlm/test_empty_selection.py +0 -0
  205. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/mlm/test_head.py +0 -0
  206. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/mlm/test_head_cosine.py +0 -0
  207. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/mlm/test_masking.py +0 -0
  208. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/mlm/test_wrapper.py +0 -0
  209. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/norm_topology_helpers.py +0 -0
  210. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/positional/__init__.py +0 -0
  211. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/positional/test_cacheable.py +0 -0
  212. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/positional/test_learned_pos.py +0 -0
  213. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/positional/test_rope.py +0 -0
  214. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/positional/test_rope_nd.py +0 -0
  215. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/presets/__init__.py +0 -0
  216. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/presets/test_cross_attender.py +0 -0
  217. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/presets/test_decoder.py +0 -0
  218. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/presets/test_encoder.py +0 -0
  219. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/presets/test_projection_packing.py +0 -0
  220. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/presets/test_variable_width_encoder.py +0 -0
  221. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_alignment.py +0 -0
  222. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_all_valid_decoder.py +0 -0
  223. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_core_results.py +0 -0
  224. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_cross_attender.py +0 -0
  225. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_decoder.py +0 -0
  226. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_decoder_cache.py +0 -0
  227. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_decoder_equations.py +0 -0
  228. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_encoder.py +0 -0
  229. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_encoder_decoder_example.py +0 -0
  230. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_examples.py +0 -0
  231. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_export_utils.py +0 -0
  232. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_layers.py +0 -0
  233. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_norm.py +0 -0
  234. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_packing.py +0 -0
  235. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_preallocated_decoder.py +0 -0
  236. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_projection_packing.py +0 -0
  237. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_public_api.py +0 -0
  238. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_result.py +0 -0
  239. {stackformers-6.0.0rc3 → stackformers-6.0.0rc8}/tests/test_sequence.py +0 -0
@@ -6,6 +6,123 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
6
6
  adheres to [Semantic Versioning](https://semver.org/): MAJOR for breaking public API changes,
7
7
  MINOR for backwards-compatible features, PATCH for bug fixes and internal changes.
8
8
 
9
+ ## [6.0.0rc8]
10
+
11
+ ### Backwards Incompatible Changes
12
+
13
+ - Restore actual rectangular `window_size=(height,width)` membership. This changes
14
+ attention groups and pooled placement from rc6's consecutive row-major chunks.
15
+ - Make constructor `alignment=` and `PackedTensor2d.align(...)` prepare rectangular
16
+ window-order storage as well as zero padding. `PackedTensor2d.window_size` records
17
+ this order; direct construction defaults to `(1,1)` for row-major storage.
18
+ Use the factories for consistent feature, position, and integer-grid ordering.
19
+
20
+ ### Improvements
21
+
22
+ - Partition matching prepared storage by creating cumulative sequence lengths and
23
+ borrowing the exact feature and position tensors. Self-attention retains the
24
+ prepared output order; pooling attaches output-window metadata without copying
25
+ attention output or query-position buffers.
26
+ - Pack other layouts during preparation and restore the original layout for
27
+ self-attention. Window-shape changes may require repacking; initial construction
28
+ and dense output conversion are separate from metadata-only partitioning.
29
+ - Show batch, sample, window, and pixel grouping in both spatial diagrams, including
30
+ the shared buffers and sample/window cumulative sequence boundaries.
31
+ - Verify rectangular membership, storage identity, compiled preparation, and encoder
32
+ execution without feature repacking. Extend ONNX Runtime checks to prepared and
33
+ row-major inputs with one or two samples at opsets 18–25.
34
+
35
+ ## [6.0.0rc6]
36
+
37
+ ### Backwards Incompatible Changes
38
+
39
+ - Group consecutive stored tokens into attention sequences instead of rearranging
40
+ rectangular tiles. A window contains `wh*ww` tokens in existing storage order;
41
+ this changes attention membership and pooled output placement versus rc5.
42
+ - Consolidate partitioning into `attention2d.windows.partition_windows`, which returns
43
+ a 1D `PackedTensor` and its bound merge operation. Remove `packed_windows.py`.
44
+
45
+ ### Improvements
46
+
47
+ - Add `PackedTensor2d.align(n)` and `alignment=` to both constructors. Accept a shared
48
+ positive axis multiple or a `(height, width)` pair, padding data and positions
49
+ with zeros. Already aligned records retain their storage.
50
+ - Borrow aligned features and positions when partitioning. Generate device-side
51
+ int32 sequence boundaries for existing native variable-length attention; ONNX
52
+ export uses int64 boundaries for compatibility with the installed exporter.
53
+ - Avoid feature and position concatenation for a single grid. Preserve packed
54
+ execution, mask-free alignment, and existing attention backend code.
55
+
56
+ ## [6.0.0rc5]
57
+
58
+ ### Backwards Incompatible Changes
59
+
60
+ - Remove custom geometry-policy signature buffers and checkpoint hooks. Built-in
61
+ position and query policies are ordinary modules. When loading an older state
62
+ dictionary, remove its `_geometry_signature` entries and reconstruct the original
63
+ policies explicitly; learned parameter names and tensor shapes are unchanged.
64
+ - Move `CentroidQueryPositions` into `attention2d.query_anchors` and the position
65
+ precision helper into `attention2d.coordinates`. Root package imports remain the
66
+ same; update imports that referenced the retired internal modules.
67
+
68
+ ### Improvements
69
+
70
+ - Remove three spatial wrapper/helper modules while preserving coordinate and
71
+ centroid arithmetic, packed execution, and the existing attention backend.
72
+
73
+ ## [6.0.0rc4]
74
+
75
+ ### Backwards Incompatible Changes
76
+
77
+ - Retain shape-derived per-grid dimensions in `PackedTensor2d.grid_shapes`. Direct
78
+ record construction must provide this tuple consistently with existing metadata;
79
+ prefer `from_list` or the new `from_tensor` constructor.
80
+
81
+ ### Improvements
82
+
83
+ - Replace data-dependent window topology discovery with reshape, zero alignment,
84
+ window rearrangement, and a bound inverse. Preserve arbitrary supplied absolute
85
+ positions and the existing packed spatial model API.
86
+ - Add `PackedTensor2d.from_tensor(data, abs_positions=positions)` for batched 2D
87
+ structures. List views and dense output conversion use known grid dimensions
88
+ without reading device metadata.
89
+
90
+ ### Bug Fixes
91
+
92
+ - Restore verified ONNX export through tensor I/O adapters that retain packed model
93
+ execution. Runtime parity covers static and dynamic spatial dimensions at opsets
94
+ 18–25 for attention, pooling, shared encoder stages, and composed encoders.
95
+ With the installed exporter, use deferred runtime shape assertions during capture
96
+ and `optimize=False` during conversion to avoid an invalid optimized graph.
97
+ Python layout metadata must stay outside ONNX graph outputs.
98
+
99
+ ## [6.0.0rc3]
100
+
101
+ ### Backwards Incompatible Changes
102
+
103
+ - Make 2D attention and encoders packed-only. Replace `PaddedTensor2d` construction
104
+ with `PackedTensor2d.from_list(...)`; spatial layers accept and return packed records.
105
+ Remove spatial `masks=` arguments and support for excluded interior slots.
106
+ - Return a raw dense feature tensor from `PackedTensor2d.to_padded()`, rather than a
107
+ spatial record. Use the packed record for positions and shape metadata. Remove the
108
+ separate dense spatial ONNX path; packed dynamic ONNX export remains unverified.
109
+ - Include zero alignment slots in attention and pooling centroids instead of masking
110
+ them out. This changes results at partially filled window boundaries.
111
+ - Rename `PhysicalCoordinates` to `AbsolutePositions` and pass `abs_positions` through
112
+ by default. Select `NormalizedWindowCoordinates` explicitly to normalize complete
113
+ windows. Updated normalization and centroid checkpoint signatures require an
114
+ explicit migration for older geometry policies.
115
+ - Simplify injected geometry protocols to packed inputs: implement
116
+ `WindowCoordinates.packed(context)` and `QueryPositions.packed(context, features)`
117
+ without source-slot arguments or dense methods.
118
+
119
+ ### Improvements
120
+
121
+ - Prepare aligned windows by direct scatter and restore their layout without sorting.
122
+ Compute query centroids with indexed reductions instead of token-by-query expansion.
123
+ - Remove spatial masking copies from encoder normalization and feed-forward adapters.
124
+ Preserve the existing 1D attention backend and its variable-length kernel dispatch.
125
+
9
126
  ## [6.0.0rc2]
10
127
 
11
128
  ### Bug Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: stackformers
3
- Version: 6.0.0rc3
3
+ Version: 6.0.0rc8
4
4
  Summary: Composable PyTorch transformers for vision, spatial, and sequence research
5
5
  Project-URL: Homepage, https://github.com/Red-Eyed/stackformers
6
6
  Project-URL: Repository, https://github.com/Red-Eyed/stackformers
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "stackformers"
7
- version = "6.0.0rc3"
7
+ version = "6.0.0rc8"
8
8
  description = "Composable PyTorch transformers for vision, spatial, and sequence research"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -928,3 +928,104 @@ baseline of 10.05, 7.21, and 35.33 ms respectively, encoder latency is approxima
928
928
  unchanged within a few percent; pooling is about twelve percent lower. Raw results
929
929
  are in work_dir/mac_2d_packed_only.json. Matched aligned inputs and seeded weights
930
930
  agree numerically; border-padding semantics differ for unaligned inputs.
931
+
932
+
933
+ ## Shape-derived windows with PackedTensor2d retained
934
+
935
+ Version 6.0.0rc4 keeps PackedTensor2d as the spatial API and introduces known
936
+ per-grid shape metadata. Partitioning now reshapes each grid, zero-aligns it,
937
+ rearranges windows, calls the existing packed 1D attention, and reverses the bound
938
+ rearrangement. Absolute positions remain arbitrary supplied values and never
939
+ substitute for logical grid dimensions. No attention backend files change.
940
+
941
+ Real ONNX tests replace the graph-capture-only check. Sixty-four static/dynamic
942
+ cases pass at opsets 18–25 for self-attention, pooling, shared encoder stages, and
943
+ a composed encoder, including singleton and aligned runtime dimensions and
944
+ arbitrary position graph inputs. Tensor I/O adapters construct packed records
945
+ inside the traced model. Direct mixed Python/tensor record outputs remain an
946
+ exporter limitation. Dynamic conversion uses optimize=False to avoid an invalid
947
+ graph produced by the installed optimizer; runtime optimization remains available.
948
+
949
+ Alternating paired CPU benchmarks against 51a8211 show no material encoder speedup:
950
+ 35.00 to 34.74 ms for two blocks plus pooling on 64x256x96 data, four threads,
951
+ float32, batch one. Self-attention is unchanged (9.89 to 9.92 ms), while pooling
952
+ improves 6.45 to 6.22 ms. GPU performance remains unmeasured. The design and export
953
+ simplifications are established; a broad performance improvement is not.
954
+
955
+
956
+ ## Consolidate spatial policies
957
+
958
+ Version 6.0.0rc5 removes three wrapper/helper files: the geometry checkpoint base,
959
+ the separate centroid policy wrapper, and the precision helper module. Coordinate
960
+ policies now own precision selection, and query_anchors owns both centroid policy
961
+ and arithmetic. The strategy names exported by the package remain unchanged;
962
+ normalization and centroid formulas are unchanged. Position and query strategies
963
+ are ordinary nn.Modules without a custom checkpoint identity protocol.
964
+
965
+ Older state dictionaries require removal of _geometry_signature entries and an
966
+ explicit construction recipe. No learned weights or attention backend code change.
967
+
968
+ Validation for the policy consolidation: 372 targeted spatial and public API tests
969
+ pass, including the 64-case ONNX Runtime matrix. Formatting, lint, and types pass.
970
+
971
+
972
+ ## Contiguous chunks for native packed attention
973
+
974
+ Version 6.0.0rc6 uses consecutive stored tokens as attention sequences, as selected
975
+ by the caller, instead of rearranging rectangular tiles. Alignment is available
976
+ through PackedTensor2d.align and both constructors. Features and arbitrary absolute
977
+ positions receive matching zero padding. For already aligned inputs, partitioning
978
+ borrows both tensors and creates only cumulative lengths; the self-attention merge
979
+ also borrows the output storage. Single-grid construction avoids concatenation.
980
+
981
+ Native cumulative lengths use int32 on the input device. Export uses int64 because
982
+ the installed ONNX repeat_interleave lowering produces incompatible Range types
983
+ from int32 counts. Existing attention backend code remains unchanged. Partition
984
+ implementation and tests now live in windows.py, removing another module.
985
+
986
+ All 389 targeted spatial and public API tests pass, including 64 static/dynamic
987
+ ONNX Runtime cases at opsets 18–25. Checks cover gradients, arbitrary positions,
988
+ alignment, exact storage identity, and independent consecutive-chunk references.
989
+ Compiled execution retains native int32 boundaries; the export-only workaround
990
+ reads the actual export context because Dynamo folds is_exporting() to true during
991
+ ordinary compilation as well. Formatting, lint, and Pyrefly pass.
992
+ Window membership and pooled placement differ from rc5, so old latency comparisons
993
+ are not numerical-equivalence evidence for this change. CUDA kernel latency and
994
+ model quality remain unmeasured on this Mac.
995
+
996
+
997
+ ## Rectangular windows with reusable packed storage
998
+
999
+ Version 6.0.0rc7 corrects window membership after the diagram exposed the distinction
1000
+ between rectangular spatial tiles and consecutive row-major chunks. A 4x4 window
1001
+ on an 8x8 sample must use four adjacent columns from each of four adjacent rows.
1002
+ Permutation equivariance permits reordering within a window; it does not preserve
1003
+ behavior when window membership changes.
1004
+
1005
+ Constructors with alignment and the align helper now prepare contiguous rectangular
1006
+ windows and retain their window_size in the spatial record. Features, arbitrary
1007
+ positions, and integer topology follow the same order. For matching prepared storage,
1008
+ partitioning creates native cumulative lengths while borrowing both tensor objects.
1009
+ Self-attention retains that layout. Pooling attaches query-tile layout metadata to
1010
+ existing output and position buffers without moving them. Input layouts with another
1011
+ window shape require preparation; dense conversions can also move data.
1012
+
1013
+ The batch diagrams show two samples becoming eight attention sequences by changing
1014
+ sample boundaries [0,64,128] to window boundaries [0,16,32,48,64,80,96,112,128].
1015
+ Indexed-token checks now verify actual rectangular slices and sample isolation,
1016
+ rather than only pointer identity or agreement with a row-major chunk reference.
1017
+ Window shape changes are covered even for equal-area rectangles. Encoder regression
1018
+ checks reject feature packing or spatial unpacking on matching prepared inputs.
1019
+
1020
+ Initial packing is separate from the metadata-only path. A different shape after
1021
+ pooling may require repacking before the next encoder stage. Existing attention
1022
+ backend files and their kernel dispatch remain unchanged. CUDA latency and model
1023
+ quality remain unmeasured; this change establishes geometry and storage contracts.
1024
+
1025
+ Validation covers 599 distinct targeted spatial and public API cases across the
1026
+ main run and the added prepared-encoder checks. The 256-case ONNX Runtime matrix
1027
+ covers static/dynamic dimensions, one/two samples, row-major/prepared storage, all
1028
+ four spatial compositions, and opsets 18–25. On the indexed two-sample example,
1029
+ feature and position tensor identity is preserved, and partition profiling contains
1030
+ only arange, empty, and resize_ for boundary allocation. The local proof is saved in
1031
+ work_dir/rc7_partition_proof.json. These checks do not establish GPU throughput.
@@ -0,0 +1,145 @@
1
+ # Packed spatial attention
2
+
3
+ The 2D adapters prepare existing `PackedTensor` inputs, call existing 1D attention,
4
+ and restore spatial layout. There is one execution path. Kernel selection,
5
+ `varlen_attn`, and the SDPA compatibility fallback belong to `attention/`.
6
+
7
+ ```python
8
+ from stackformers import PackedTensor2d, WindowSelfAttention2d, CrossAttnPooling2d
9
+
10
+ source = PackedTensor2d.from_list(grids, abs_positions=positions, alignment=4)
11
+ attention = WindowSelfAttention2d(96, window_size=(4, 4), num_heads=4)
12
+ pooling = CrossAttnPooling2d(96, window_size=(4, 4), output_window_size=(2, 2))
13
+ output = pooling(attention(source))
14
+ ```
15
+
16
+ ## Rectangles and alignment
17
+
18
+ Every input sample is a complete rectangle. `PackedTensor2d` concatenates features
19
+ and absolute positions with known `grid_shapes`, per-sample `cu_seqlens`,
20
+ `spatial_shapes`, integer `grid_indices`, and `max_spatial_shape`. `window_size`
21
+ records its rectangular storage order; `(1,1)` is ordinary row-major storage.
22
+ Supplied `abs_positions` can be nonuniform. Logical grid rows and columns determine
23
+ window membership independently of position values. Omitted positions default to
24
+ regular row/column coordinates. Constructors validate external inputs; direct
25
+ record construction trusts metadata, including storage order.
26
+
27
+ Preparation zero-aligns each rectangle to complete windows, like convolution
28
+ padding. Synthetic feature and position slots are zero and participate in
29
+ attention. There are no spatial masks, excluded slots, neighbor searches, or sorts.
30
+ `source.align(n)` rounds both grid axes up to multiples of `n` and packs each `n×n`
31
+ window contiguously; a tuple selects rectangular window dimensions. Both
32
+ constructors accept the same `alignment=` option. Features, positions, and integer
33
+ grid indices follow the same window order. Matching prepared records are returned
34
+ unchanged. The default alignment of one retains row-major storage.
35
+
36
+ Partitioning returns an existing 1D `PackedTensor` and a bound merge operation.
37
+ Each sequence contains the `wh*ww` tokens of an actual rectangular tile. For matching
38
+ prepared storage, partitioning borrows the exact feature and position tensors and
39
+ creates device-side int32 boundaries, matching native `varlen_attn`. For example,
40
+ two 8×8 samples prepared for 4×4 windows use sample boundaries `[0,64,128]` and
41
+ attention boundaries `[0,16,32,48,64,80,96,112,128]` over the same buffers.
42
+
43
+ Initial packing may move data. Changing the window shape may require repacking,
44
+ even when the new window has the same area. Layers automatically prepare other
45
+ layouts; use constructor `alignment=` or call `align(...)` once before repeated
46
+ matching-window layers to keep that preparation outside their execution.
47
+
48
+ The bound inverse restores each grid without discovering its topology from device
49
+ tensors. Self-attention retains matching prepared storage; for other inputs it
50
+ restores the original storage order and crops temporary padding. Pooling retains
51
+ attention output and query-position buffers directly, recording the output tile's
52
+ window order without a spatial rearrangement.
53
+ The pooled extent is `ceil(H/wh)*oh` by `ceil(W/ww)*ow`.
54
+
55
+ `to_list()` restores rectangular feature grids; undoing window order may copy.
56
+ `to_padded()` is an optional output
57
+ adapter returning a raw dense feature tensor, never a separate spatial record or
58
+ an execution path. Spatial layers accept and return `PackedTensor2d` only.
59
+ Conversions retain gradients. `to_list()` uses known `grid_shapes` without reading
60
+ device values. `PackedTensor2d.from_tensor(data, abs_positions=positions)` packs
61
+ `[b,H,W,d]` data and `[b,H,W,2]` supplied positions. Shapes are retained from tensor
62
+ dimensions, independently of position values. Direct record construction now also
63
+ requires consistent `grid_shapes` and `window_size`; prefer the factories to keep
64
+ metadata consistent. Omitting `window_size` in direct construction means row-major.
65
+
66
+ ## Positions and queries
67
+
68
+ `AbsolutePositions` passes `abs_positions` through unchanged. It is the default.
69
+ `NormalizedWindowCoordinates` is an explicit alternative that centers complete
70
+ windows and scales each axis by mean adjacent-slot spacing. Singleton axes and
71
+ zero spacing use scale one. Its source frame is bound into the query transform.
72
+ Neither policy constructs an intermediate sequence representation.
73
+
74
+ Default RoPEND uses unit minimum separation and maximum separation
75
+ `(max(2,wh-1), max(2,ww-1))`. Inject `rope` with calibration appropriate for other
76
+ position scales. Injected attention owns its encoding; do not supply both.
77
+ The existing default RoPEND does not differentiate through rotary positions.
78
+
79
+ Pooling repeats learned query features per window. `CentroidQueryPositions`
80
+ views each rectangular window as `[wh,ww]` and assigns its slots to output regions
81
+ using `floor(row*oh/wh)` and
82
+ `floor(col*ow/ww)`. Indexed reductions compute region centroids, including zero
83
+ alignment positions. Regions with no assigned source slots use the whole-window
84
+ centroid. Queries attend to the entire source window; regions determine positions
85
+ only. Accumulation promotes half precision to float32 and preserves float64.
86
+
87
+ ## Extension and compatibility
88
+
89
+ Implement `SelfAttn`, `CrossAttn`, `WindowCoordinates`, or `QueryPositions`
90
+ structurally in a separate file and inject it. Position and query policies accept
91
+ complete packed windows. Stateful collaborators must be modules so device moves,
92
+ optimizers, and checkpoints include their state.
93
+
94
+ Built-in position and query policies are ordinary modules. Save their construction
95
+ recipe alongside weights; there is no custom checkpoint-policy signature or loading
96
+ hook. For older checkpoints, remove `_geometry_signature` entries before loading
97
+ and explicitly reconstruct the original policies. Learned parameter names remain
98
+ unchanged. `CentroidQueryPositions` and its arithmetic live together in
99
+ `query_anchors.py`; coordinate policies own their accumulation-precision helper.
100
+
101
+ Automatic normalization, spatial source masks, and the separate dense spatial API
102
+ have been removed. Zero alignment slots participate in boundary attention.
103
+
104
+ ## ONNX export
105
+
106
+ ONNX Runtime parity is tested at opsets 18 through 25 for self-attention, pooling,
107
+ shared 1D encoder stages, and a composed spatial encoder. Tests cover static and
108
+ dynamic spatial dimensions, singleton axes, aligned and unaligned boundaries, and
109
+ arbitrary absolute positions supplied as graph inputs. Existing attention code is
110
+ unchanged.
111
+
112
+ During export, preparation creates int64 boundaries to avoid a type mismatch in the
113
+ installed exporter's `repeat_interleave` lowering. Eager and compiled execution
114
+ retain the native int32 contract.
115
+
116
+ Use a tensor I/O export adapter: accept data and absolute-position tensors, construct
117
+ `PackedTensor2d.from_tensor(...)` inside `forward`, call the existing spatial model,
118
+ and expose output data and positions as tensors. The model itself still consumes
119
+ and returns `PackedTensor2d`. Python layout tuples are metadata, not ONNX outputs;
120
+ exporting the mixed Python/tensor record directly is not supported by the installed
121
+ exporter. See the complete adapter and regression cases in
122
+ [`tests/attention2d/test_export.py`](../../tests/attention2d/test_export.py).
123
+
124
+ For dynamic spatial dimensions, export with the tested settings:
125
+
126
+ ```python
127
+ exported = torch.export.export(
128
+ adapter,
129
+ (data, abs_positions),
130
+ dynamic_shapes=dynamic_shapes,
131
+ prefer_deferred_runtime_asserts_over_guards=True,
132
+ )
133
+ program = torch.onnx.export(exported, opset_version=18, optimize=False)
134
+ ```
135
+
136
+ `optimize=False` avoids an invalid graph generated by the installed exporter's
137
+ optimizer for dynamic packed graphs. This does not disable ONNX Runtime's own graph
138
+ optimizations. The number of packed grids remains static per exported graph;
139
+ spatial dimensions and supplied positions can vary. Real GPU throughput and model
140
+ quality require target-workload measurement.
141
+
142
+ See [spatial encoders](../encoder2d/README.md) for partition reuse across 1D blocks.
143
+
144
+ ![Window self-attention](figures/window_self_attention_2d.svg)
145
+ ![Cross-attention pooling](figures/window_cross_attention_2d.svg)
@@ -1,9 +1,9 @@
1
1
  """Spatial records, window adapters, and replaceable geometry policies."""
2
2
 
3
- from stackformers.attention2d.centroid_queries import CentroidQueryPositions
4
3
  from stackformers.attention2d.coordinates import AbsolutePositions, NormalizedWindowCoordinates
5
4
  from stackformers.attention2d.cross_attn_pooling import CrossAttnPooling2d
6
5
  from stackformers.attention2d.protocols import QueryPositions, SelfAttn2d, WindowCoordinates
6
+ from stackformers.attention2d.query_anchors import CentroidQueryPositions
7
7
  from stackformers.attention2d.self_attn import WindowSelfAttention2d
8
8
  from stackformers.attention2d.sequence import PackedTensor2d
9
9
 
@@ -5,24 +5,28 @@ from __future__ import annotations
5
5
  from typing import TYPE_CHECKING
6
6
 
7
7
  import torch
8
+ import torch.nn as nn
8
9
  from einops import rearrange
9
10
 
10
- from stackformers.attention2d._geometry_module import GeometryModule
11
- from stackformers.attention2d.geometry_precision import accumulation_positions
12
11
  from stackformers.attention2d.windows import validate_window
13
12
 
14
13
  if TYPE_CHECKING:
15
14
  from collections.abc import Callable
16
15
 
16
+ from jaxtyping import Float
17
+ from torch import Tensor
18
+
17
19
  from stackformers.sequence import PackedTensor
18
20
 
19
21
 
20
- class AbsolutePositions(GeometryModule):
21
- """Pass supplied absolute positions through unchanged."""
22
+ def accumulation_positions(positions: Float[Tensor, "... c"]) -> Float[Tensor, "... c"]:
23
+ """Promote half precision while retaining supplied float64 coordinate information."""
24
+ dtype = torch.float64 if positions.dtype == torch.float64 else torch.float32
25
+ return positions.to(dtype=dtype)
22
26
 
23
- def __init__(self) -> None:
24
- """Version the identity position policy for checkpoint loading."""
25
- super().__init__(1, 1, ())
27
+
28
+ class AbsolutePositions(nn.Module):
29
+ """Pass supplied absolute positions through unchanged."""
26
30
 
27
31
  def packed(
28
32
  self, context: PackedTensor
@@ -36,13 +40,13 @@ def _absolute_packed(queries: PackedTensor) -> PackedTensor:
36
40
  return queries
37
41
 
38
42
 
39
- class NormalizedWindowCoordinates(GeometryModule):
43
+ class NormalizedWindowCoordinates(nn.Module):
40
44
  """Optionally center complete windows and scale by mean adjacent-axis spacing."""
41
45
 
42
46
  def __init__(self, window: tuple[int, int]) -> None:
43
47
  """Bind the rectangular window topology independently of supplied positions."""
44
48
  validate_window(window)
45
- super().__init__(2, 2, window)
49
+ super().__init__()
46
50
  self.window = window
47
51
 
48
52
  def packed(
@@ -14,10 +14,9 @@ from stackformers.attention2d.factory import (
14
14
  build_window_coordinates,
15
15
  build_window_cross_attention,
16
16
  )
17
- from stackformers.attention2d.packed_windows import partition_packed_windows
18
17
  from stackformers.attention2d.protocols import QueryPositions, WindowCoordinates
19
18
  from stackformers.attention2d.sequence import PackedTensor2d
20
- from stackformers.attention2d.windows import validate_window
19
+ from stackformers.attention2d.windows import partition_windows, validate_window
21
20
  from stackformers.positional.protocols import PosEncoding
22
21
 
23
22
 
@@ -66,9 +65,7 @@ class CrossAttnPooling2d(nn.Module):
66
65
  """Prepare aligned packed windows, delegate attention, and restore the grid layout."""
67
66
  if input.x.shape[-1] != self.dim:
68
67
  raise ValueError("input channel dimension must equal dim")
69
- windows = partition_packed_windows(
70
- input, self.window_size, self.output_window_size, crop=False
71
- )
68
+ windows = partition_windows(input, self.window_size, self.output_window_size, crop=False)
72
69
  queries = self.query_positions.packed(windows.tokens, self.queries)
73
70
  context, transform_queries = self.coordinates.packed(windows.tokens)
74
71
  attention_queries = transform_queries(queries)
@@ -10,8 +10,8 @@ from stackformers.attention import (
10
10
  build_cross_attn,
11
11
  build_self_attn,
12
12
  )
13
- from stackformers.attention2d.centroid_queries import CentroidQueryPositions
14
13
  from stackformers.attention2d.coordinates import AbsolutePositions
14
+ from stackformers.attention2d.query_anchors import CentroidQueryPositions
15
15
  from stackformers.positional import RoPENDConfig, RotaryEmbeddingND
16
16
 
17
17
  if TYPE_CHECKING: