stackformers 5.0.0rc21__tar.gz → 5.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 (193) hide show
  1. stackformers-5.1.0/.github/ISSUE_TEMPLATE/bug_report.md +27 -0
  2. stackformers-5.1.0/.github/ISSUE_TEMPLATE/feature_request.md +21 -0
  3. stackformers-5.1.0/.github/pull_request_template.md +13 -0
  4. stackformers-5.1.0/.github/workflows/check.yml +36 -0
  5. {stackformers-5.0.0rc21 → stackformers-5.1.0}/CHANGELOG.md +75 -0
  6. stackformers-5.1.0/CITATION.cff +11 -0
  7. stackformers-5.1.0/CONTRIBUTING.md +31 -0
  8. stackformers-5.1.0/PKG-INFO +201 -0
  9. stackformers-5.1.0/README.md +150 -0
  10. stackformers-5.0.0rc21/README.md → stackformers-5.1.0/docs/api-guide.md +22 -22
  11. stackformers-5.1.0/docs/assets/social-preview.jpg +0 -0
  12. stackformers-5.1.0/docs/assets/social-preview.md +25 -0
  13. stackformers-5.1.0/docs/compatibility.md +42 -0
  14. stackformers-5.1.0/docs/improvement-plan.md +79 -0
  15. stackformers-5.1.0/docs/research.md +76 -0
  16. {stackformers-5.0.0rc21 → stackformers-5.1.0}/examples/causal_language_model.py +5 -2
  17. {stackformers-5.0.0rc21 → stackformers-5.1.0}/examples/encoder_decoder_onnxruntime.py +16 -15
  18. {stackformers-5.0.0rc21 → stackformers-5.1.0}/examples/image_encoder.py +3 -3
  19. {stackformers-5.0.0rc21 → stackformers-5.1.0}/examples/point_cloud_encoder.py +2 -2
  20. {stackformers-5.0.0rc21 → stackformers-5.1.0}/examples/subclassed_encoder.py +2 -5
  21. {stackformers-5.0.0rc21 → stackformers-5.1.0}/pyproject.toml +6 -4
  22. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/DEVLOG.md +31 -0
  23. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/__init__.py +2 -0
  24. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/README.md +20 -0
  25. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/config.py +34 -1
  26. stackformers-5.1.0/stackformers/dimension_rounding.py +27 -0
  27. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/feedforward/README.md +20 -0
  28. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/feedforward/config.py +16 -2
  29. stackformers-5.1.0/tests/attention/test_config.py +122 -0
  30. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/export_utils.py +5 -2
  31. stackformers-5.1.0/tests/feedforward/test_config.py +114 -0
  32. stackformers-5.1.0/tests/test_dimension_rounding.py +34 -0
  33. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_export_utils.py +1 -1
  34. {stackformers-5.0.0rc21 → stackformers-5.1.0}/uv.lock +1 -1
  35. stackformers-5.0.0rc21/PKG-INFO +0 -399
  36. {stackformers-5.0.0rc21 → stackformers-5.1.0}/.claudeignore +0 -0
  37. {stackformers-5.0.0rc21 → stackformers-5.1.0}/.gitignore +0 -0
  38. {stackformers-5.0.0rc21 → stackformers-5.1.0}/.python-version +0 -0
  39. {stackformers-5.0.0rc21 → stackformers-5.1.0}/.vscode/settings.json +0 -0
  40. {stackformers-5.0.0rc21 → stackformers-5.1.0}/AGENTS.md +0 -0
  41. {stackformers-5.0.0rc21 → stackformers-5.1.0}/Justfile +0 -0
  42. {stackformers-5.0.0rc21 → stackformers-5.1.0}/LICENSE +0 -0
  43. {stackformers-5.0.0rc21 → stackformers-5.1.0}/PLAN.md +0 -0
  44. {stackformers-5.0.0rc21 → stackformers-5.1.0}/docs/inference.md +0 -0
  45. {stackformers-5.0.0rc21 → stackformers-5.1.0}/examples/README.md +0 -0
  46. {stackformers-5.0.0rc21 → stackformers-5.1.0}/examples/padded_and_packed.py +0 -0
  47. {stackformers-5.0.0rc21 → stackformers-5.1.0}/pyrefly.toml +0 -0
  48. {stackformers-5.0.0rc21 → stackformers-5.1.0}/pytest.ini +0 -0
  49. {stackformers-5.0.0rc21 → stackformers-5.1.0}/ruff.toml +0 -0
  50. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/_decoder_equations.py +0 -0
  51. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/_projection_packing.py +0 -0
  52. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/_result.py +0 -0
  53. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/all_valid_decoder.py +0 -0
  54. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/__init__.py +0 -0
  55. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/all_valid.py +0 -0
  56. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/bias.py +0 -0
  57. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/cache.py +0 -0
  58. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/cache_validation.py +0 -0
  59. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/cached.py +0 -0
  60. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/cross_attn.py +0 -0
  61. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/distance_bias.py +0 -0
  62. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/factory.py +0 -0
  63. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/layout.py +0 -0
  64. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/masking.py +0 -0
  65. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/onnx_backend.py +0 -0
  66. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/ops.py +0 -0
  67. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/packed_cross_attn.py +0 -0
  68. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/packed_self_attn.py +0 -0
  69. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/protocols.py +0 -0
  70. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/self_attn.py +0 -0
  71. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/attention/varlen_backend.py +0 -0
  72. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/config.py +0 -0
  73. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/cross_attender.py +0 -0
  74. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/decoder.py +0 -0
  75. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/decoder_cache.py +0 -0
  76. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/encoder.py +0 -0
  77. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/feedforward/DEVLOG.md +0 -0
  78. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/feedforward/__init__.py +0 -0
  79. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/feedforward/factory.py +0 -0
  80. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/feedforward/geglu.py +0 -0
  81. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/feedforward/gelu.py +0 -0
  82. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/feedforward/hardswish_glu.py +0 -0
  83. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/feedforward/packed_geglu.py +0 -0
  84. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/feedforward/packed_hardswish_glu.py +0 -0
  85. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/feedforward/packed_swiglu.py +0 -0
  86. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/feedforward/protocols.py +0 -0
  87. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/feedforward/relu_squared.py +0 -0
  88. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/feedforward/swiglu.py +0 -0
  89. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/layers.py +0 -0
  90. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/mlm/README.md +0 -0
  91. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/mlm/config.py +0 -0
  92. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/mlm/head.py +0 -0
  93. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/mlm/head_cosine.py +0 -0
  94. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/mlm/masking.py +0 -0
  95. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/mlm/protocols.py +0 -0
  96. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/mlm/wrapper.py +0 -0
  97. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/norm/README.md +0 -0
  98. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/norm/__init__.py +0 -0
  99. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/norm/config.py +0 -0
  100. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/norm/factory.py +0 -0
  101. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/norm/protocols.py +0 -0
  102. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/packing.py +0 -0
  103. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/positional/README.md +0 -0
  104. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/positional/__init__.py +0 -0
  105. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/positional/config.py +0 -0
  106. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/positional/factory.py +0 -0
  107. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/positional/learned.py +0 -0
  108. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/positional/none.py +0 -0
  109. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/positional/protocols.py +0 -0
  110. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/positional/rope1d.py +0 -0
  111. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/positional/rope2d.py +0 -0
  112. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/positional/rope_nd.py +0 -0
  113. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/positional/validation.py +0 -0
  114. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/preallocated_decoder.py +0 -0
  115. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/presets/README.md +0 -0
  116. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/presets/__init__.py +0 -0
  117. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/presets/cross_attender.py +0 -0
  118. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/presets/decoder.py +0 -0
  119. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/presets/encoder.py +0 -0
  120. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/presets/variable_width_encoder.py +0 -0
  121. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/py.typed +0 -0
  122. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/result/README.md +0 -0
  123. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/result/__init__.py +0 -0
  124. {stackformers-5.0.0rc21 → stackformers-5.1.0}/stackformers/sequence.py +0 -0
  125. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/__init__.py +0 -0
  126. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/__init__.py +0 -0
  127. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/legacy_api_rc1.json +0 -0
  128. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_all_valid.py +0 -0
  129. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_cached.py +0 -0
  130. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_contracts.py +0 -0
  131. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_cross_attn.py +0 -0
  132. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_cross_attn_cache.py +0 -0
  133. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_distance_bias.py +0 -0
  134. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_empty_rows.py +0 -0
  135. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_factory.py +0 -0
  136. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_geometry.py +0 -0
  137. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_kernels.py +0 -0
  138. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_legacy_api.py +0 -0
  139. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_masking.py +0 -0
  140. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_onnx_backend.py +0 -0
  141. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_ops.py +0 -0
  142. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_packed_cross_attn.py +0 -0
  143. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_packed_self_attn.py +0 -0
  144. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_sdpa_export.py +0 -0
  145. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_self_attn.py +0 -0
  146. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/attention/test_varlen_backend.py +0 -0
  147. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/conftest.py +0 -0
  148. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/feedforward/__init__.py +0 -0
  149. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/feedforward/legacy_swiglu_4_6.json +0 -0
  150. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/feedforward/test_factory.py +0 -0
  151. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/feedforward/test_geglu.py +0 -0
  152. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/feedforward/test_gelu.py +0 -0
  153. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/feedforward/test_hardswish_glu.py +0 -0
  154. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/feedforward/test_packed_geglu.py +0 -0
  155. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/feedforward/test_packed_hardswish_glu.py +0 -0
  156. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/feedforward/test_packed_swiglu.py +0 -0
  157. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/feedforward/test_relu_squared.py +0 -0
  158. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/feedforward/test_swiglu.py +0 -0
  159. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/mlm/__init__.py +0 -0
  160. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/mlm/test_empty_selection.py +0 -0
  161. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/mlm/test_head.py +0 -0
  162. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/mlm/test_head_cosine.py +0 -0
  163. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/mlm/test_masking.py +0 -0
  164. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/mlm/test_wrapper.py +0 -0
  165. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/norm_topology_helpers.py +0 -0
  166. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/positional/__init__.py +0 -0
  167. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/positional/test_cacheable.py +0 -0
  168. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/positional/test_learned_pos.py +0 -0
  169. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/positional/test_rope.py +0 -0
  170. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/positional/test_rope_nd.py +0 -0
  171. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/presets/__init__.py +0 -0
  172. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/presets/test_cross_attender.py +0 -0
  173. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/presets/test_decoder.py +0 -0
  174. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/presets/test_encoder.py +0 -0
  175. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/presets/test_projection_packing.py +0 -0
  176. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/presets/test_variable_width_encoder.py +0 -0
  177. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_all_valid_decoder.py +0 -0
  178. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_core_results.py +0 -0
  179. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_cross_attender.py +0 -0
  180. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_decoder.py +0 -0
  181. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_decoder_cache.py +0 -0
  182. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_decoder_equations.py +0 -0
  183. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_encoder.py +0 -0
  184. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_encoder_decoder_example.py +0 -0
  185. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_examples.py +0 -0
  186. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_layers.py +0 -0
  187. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_norm.py +0 -0
  188. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_packing.py +0 -0
  189. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_preallocated_decoder.py +0 -0
  190. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_projection_packing.py +0 -0
  191. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_public_api.py +0 -0
  192. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_result.py +0 -0
  193. {stackformers-5.0.0rc21 → stackformers-5.1.0}/tests/test_sequence.py +0 -0
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: Bug report
3
+ about: Report incorrect behavior with a minimal reproducer
4
+ ---
5
+
6
+ ## Expected and observed behavior
7
+
8
+ Describe what you expected and what happened. Include the full traceback if relevant.
9
+
10
+ ## Minimal reproducer
11
+
12
+ ```python
13
+ # Include imports, model configuration, input shapes, and the failing call.
14
+ ```
15
+
16
+ ## Environment
17
+
18
+ - Stackformers version or commit:
19
+ - Python and PyTorch versions:
20
+ - Operating system, device, and dtype:
21
+ - Eager, compiled, exported, or ONNX Runtime execution:
22
+ - ONNX and ONNX Runtime versions, if relevant:
23
+
24
+ ## Additional context
25
+
26
+ For numerical or performance issues, include sequence lengths, padded/packed layout,
27
+ attention configuration, and whether a backend fallback warning appeared.
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: Feature request
3
+ about: Propose a capability with a concrete research or deployment use case
4
+ ---
5
+
6
+ ## Use case
7
+
8
+ What are you trying to build, and where does the current API fall short?
9
+
10
+ ## Proposed behavior
11
+
12
+ Describe the desired interface or show a small usage example.
13
+
14
+ ## Existing alternatives
15
+
16
+ Can existing components or a custom collaborator express this? Explain the limitation.
17
+
18
+ ## Evidence and compatibility
19
+
20
+ Link relevant methods or implementations. Note any required device, dtype, compile/export,
21
+ or checkpoint compatibility. Separate desired behavior from measured results.
@@ -0,0 +1,13 @@
1
+ ## Problem and resulting behavior
2
+
3
+ Describe the concrete problem and how this change affects users.
4
+
5
+ ## Validation
6
+
7
+ List the checks run and their results. For behavior changes, include relevant numerical,
8
+ shape, or compatibility coverage. For documentation changes, verify examples and links.
9
+
10
+ ## Compatibility and documentation
11
+
12
+ Describe migration requirements, configuration/checkpoint changes, and affected guides.
13
+ For performance claims, include reproducible measurements and the tested environment.
@@ -0,0 +1,36 @@
1
+ name: Check
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ check:
14
+ name: Python ${{ matrix.python }} CPU
15
+ runs-on: ubuntu-latest
16
+ timeout-minutes: 60
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ python: ["3.11", "3.12"]
21
+ steps:
22
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
23
+ - uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
24
+ with:
25
+ version: "0.12.1"
26
+ python-version: ${{ matrix.python }}
27
+ enable-cache: true
28
+ - uses: extractions/setup-just@v4
29
+ with:
30
+ just-version: "1.48.0"
31
+ - name: Install locked development environment
32
+ run: uv sync --locked --group dev
33
+ - name: Report environment
34
+ run: uv run python -c "import platform, torch; print(platform.python_version()); print(torch.__version__)"
35
+ - name: Format, lint, type-check, and test
36
+ run: just check
@@ -6,6 +6,81 @@ 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
+ ## [5.1.0]
10
+
11
+ ### New Features
12
+
13
+ - Add optional `DimensionRoundingConfig(multiple_of=..., rounding_mode="floor" | "ceil")`
14
+ to all attention and feed-forward variants through `dimension_rounding`. Round attention
15
+ head widths and feed-forward hidden widths without changing the external model dimension.
16
+ Defaults preserve existing geometry; opting in may change parameter counts and checkpoint
17
+ shapes. Zero-width rounding results fail config validation.
18
+
19
+ ## [5.0.0]
20
+
21
+ ### Highlights
22
+
23
+ - Release the 5.0 candidate series as stable, with canonical tensor batches, composable
24
+ architecture variants, and cached deployment adapters. Library runtime behavior is unchanged
25
+ from `5.0.0rc22`; the sections below summarize migration from 4.x and earlier candidates.
26
+
27
+ ### Backwards Incompatible Changes
28
+
29
+ - Attention configurations are immutable. Construct a new configuration and model instead of
30
+ assigning architecture fields on an existing `SelfAttentionConfig` or `CrossAttentionConfig`.
31
+ - Cross-attention requires matching padded/packed query and context layouts. Convert both inputs
32
+ to the same layout before calling it; mixed layouts raise `ValueError`.
33
+ - Custom reconstruction heads must return a differentiable zero loss when no tokens are selected.
34
+ For an empty prediction tensor, return `prediction.sum()`.
35
+ - Custom layers and attention implementations must accept and forward the runtime visibility
36
+ keywords they support (`self_attn_mask` and `cross_attn_mask`).
37
+ - Consumers of core outcomes from early candidates must replace the external `returns` API with
38
+ `stackformers.result.Ok` / `Err` keyword matching. Earlier `AllValidInput` callers must use
39
+ `PaddedTensor(x, AllValid(), positions)`.
40
+
41
+ ### Deprecations
42
+
43
+ - Prefer `PaddedTensor` and `PackedTensor` to the retained `PaddedInput` and `PackedInput` aliases.
44
+ Use their constructors and conversion methods instead of deprecated sequence helpers. No
45
+ removal version is assigned; see `5.0.0rc21` for the full compatibility list.
46
+
47
+ ### New Features
48
+
49
+ - Add list/nested-tensor adapters and padded/packed conversions preserving valid tokens,
50
+ gradients, and custom coordinates where documented.
51
+ - Add variable-width encoders, per-call attention visibility, and the HardSwishGLU variant.
52
+ - Add opt-in projection packing and unpacking for attention and gated feed-forward modules.
53
+ Convert before constructing an optimizer and save the resulting configuration with weights.
54
+ - Add cached encoder-decoder deployment adapters, including separate all-valid and preallocated
55
+ cache strategies. Their supported classes, opsets, and ownership contracts are documented in
56
+ `docs/inference.md`; custom forwards require their own deployment integration.
57
+
58
+ ### Bug Fixes
59
+
60
+ - Return finite zero losses for empty built-in MLM selections and zero attention contributions
61
+ when every key is excluded.
62
+ - Fix attention-mask and dynamic GQA export paths covered by the PyTorch/ONNX Runtime tests.
63
+
64
+ ### Documentation
65
+
66
+ - Lead installation with PyPI commands for pip and uv. Document opt-in prerelease upgrades with
67
+ `--pre` or `--prerelease allow`; keep repository cloning in contributor instructions.
68
+ - Add research reproducibility, compatibility, and citation guidance alongside runnable examples.
69
+
70
+ ## [5.0.0rc22]
71
+
72
+ ### Documentation
73
+
74
+ - Lead the README with research use cases and current tensor examples; preserve detailed
75
+ API, migration, and configuration contracts in a dedicated guide.
76
+ - Add software citation metadata, research reproducibility guidance, compatibility scope,
77
+ and contributor onboarding. Update runnable examples to use `PaddedTensor` rather than
78
+ deprecated aliases and constructors.
79
+
80
+ ### Developers
81
+
82
+ - Add a Python 3.11/3.12 CPU CI matrix running the existing `just check` quality gate.
83
+
9
84
  ## [5.0.0rc21]
10
85
 
11
86
  ### Deprecations
@@ -0,0 +1,11 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use Stackformers in research, cite this software and report the exact version or commit used."
3
+ type: software
4
+ title: Stackformers
5
+ authors:
6
+ - family-names: Stupakov
7
+ given-names: Vadym
8
+ repository-code: "https://github.com/Red-Eyed/stackformers"
9
+ url: "https://github.com/Red-Eyed/stackformers"
10
+ license: MIT
11
+ abstract: "Composable PyTorch transformer components for research on vision, spatial, and sequence models."
@@ -0,0 +1,31 @@
1
+ # Contributing
2
+
3
+ Bug reports should include the Stackformers version or commit, Python/PyTorch versions,
4
+ device and dtype, a minimal reproducer, and the expected and observed behavior.
5
+ Open reports and proposals in the [issue tracker](https://github.com/Red-Eyed/stackformers/issues).
6
+
7
+ ## Development
8
+
9
+ Install uv and just, then run:
10
+
11
+ ```bash
12
+ git clone https://github.com/Red-Eyed/stackformers.git
13
+ cd stackformers
14
+ just sync
15
+ just check
16
+ ```
17
+
18
+ Use the [Justfile](Justfile) recipes for formatting, linting, type-checking, testing, and builds.
19
+ The same checks include library code, tests, and examples. Read [AGENTS.md](AGENTS.md) for
20
+ repository design and testing conventions.
21
+
22
+ ## Proposing a component
23
+
24
+ Explain the research use case and why existing composition cannot express it. Keep each
25
+ variant focused, define its configuration next to its implementation, and extend the owning
26
+ module's factory and README. Implement protocols structurally. Include numerical and shape
27
+ coverage appropriate to the behavior, with compile/export checks when claiming those paths.
28
+
29
+ For public API changes, describe compatibility and migration. For performance claims, provide
30
+ reproducible measurements with hardware, versions, dtype, shapes, and timing methodology.
31
+ Do not add performance or accuracy claims based only on a synthetic smoke example.
@@ -0,0 +1,201 @@
1
+ Metadata-Version: 2.5
2
+ Name: stackformers
3
+ Version: 5.1.0
4
+ Summary: Composable PyTorch transformers for vision, spatial, and sequence research
5
+ Project-URL: Homepage, https://github.com/Red-Eyed/stackformers
6
+ Project-URL: Repository, https://github.com/Red-Eyed/stackformers
7
+ Project-URL: Documentation, https://github.com/Red-Eyed/stackformers#documentation
8
+ Project-URL: Changelog, https://github.com/Red-Eyed/stackformers/blob/main/CHANGELOG.md
9
+ Project-URL: Bug Tracker, https://github.com/Red-Eyed/stackformers/issues
10
+ Author-email: Vadym Stupakov <vadim.stupakov@gmail.com>
11
+ License: MIT License
12
+
13
+ Copyright (c) 2026 Vadym Stupakov
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ of this software and associated documentation files (the "Software"), to deal
17
+ in the Software without restriction, including without limitation the rights
18
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ copies of the Software, and to permit persons to whom the Software is
20
+ furnished to do so, subject to the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be included in all
23
+ copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ SOFTWARE.
32
+ License-File: LICENSE
33
+ Keywords: attention,computer-vision,point-cloud,pytorch,research,transformer
34
+ Classifier: Development Status :: 5 - Production/Stable
35
+ Classifier: Intended Audience :: Science/Research
36
+ Classifier: License :: OSI Approved :: MIT License
37
+ Classifier: Programming Language :: Python :: 3
38
+ Classifier: Programming Language :: Python :: 3.11
39
+ Classifier: Programming Language :: Python :: 3.12
40
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
41
+ Classifier: Typing :: Typed
42
+ Requires-Python: >=3.11
43
+ Requires-Dist: beartype>=0.18
44
+ Requires-Dist: einops>=0.7
45
+ Requires-Dist: jaxtyping>=0.2
46
+ Requires-Dist: numpy>=2.4.4
47
+ Requires-Dist: pydantic>=2.0
48
+ Requires-Dist: torch>=2.2
49
+ Requires-Dist: typing-extensions>=4.12
50
+ Description-Content-Type: text/markdown
51
+
52
+ # Stackformers
53
+
54
+ [![CI](https://github.com/Red-Eyed/stackformers/actions/workflows/check.yml/badge.svg)](https://github.com/Red-Eyed/stackformers/actions/workflows/check.yml)
55
+ [![PyPI](https://img.shields.io/badge/install-PyPI-blue.svg)](https://pypi.org/project/stackformers/)
56
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
57
+
58
+ **Composable PyTorch transformers for research.**
59
+
60
+ Build vision, spatial, and sequence models with interchangeable attention, positional
61
+ encodings, normalization, and feedforward components. Start with a preset, then replace
62
+ individual components as your experiments evolve.
63
+
64
+ - **Experiment with architecture:** explicit, serializable configurations and structural
65
+ protocols let you supply your own components.
66
+ - **Work with variable-length data:** run the same encoder weights on padded or packed
67
+ token batches, with explicit token coordinates.
68
+ - **Connect research and deployment:** examples cover image patches, point clouds,
69
+ causal modeling, custom components, and cached ONNX Runtime decoding.
70
+
71
+ ## Install
72
+
73
+ Install from [PyPI](https://pypi.org/project/stackformers/) with pip:
74
+
75
+ ```bash
76
+ pip install --upgrade stackformers
77
+ ```
78
+
79
+ Or add it to your uv project:
80
+
81
+ ```bash
82
+ uv add stackformers
83
+ ```
84
+
85
+ ### Try the latest prerelease
86
+
87
+ Use `--pre` to include newer prereleases when upgrading:
88
+
89
+ ```bash
90
+ pip install --upgrade --pre stackformers
91
+ ```
92
+
93
+ With uv:
94
+
95
+ ```bash
96
+ uv add --upgrade --prerelease allow stackformers
97
+ ```
98
+
99
+ For an existing virtual environment, `uv pip install --upgrade --pre stackformers`
100
+ is also supported. These commands select the newest compatible published version,
101
+ including prereleases. Pin the version you validate for an experiment; see the
102
+ [research guide](docs/research.md).
103
+
104
+ ## Run your first encoder
105
+
106
+ ```python
107
+ import torch
108
+ import stackformers as sf
109
+
110
+ model = sf.TransformerEncoder(
111
+ sf.plain_encoder_config(dim=64, heads=1, num_layers=2, ff_mult=3.0)
112
+ ).eval()
113
+
114
+ sequences = [torch.randn(8, 64), torch.randn(5, 64)]
115
+ padded = sf.PaddedTensor.from_list(sequences)
116
+ with torch.no_grad():
117
+ padded_output = model(padded) # (2, 8, 64)
118
+ packed_output = model(padded.to_packed()) # (13, 64)
119
+ ```
120
+
121
+ The two calls share model weights. Packed output contains valid tokens only; padded output
122
+ retains batch and sequence axes. See the [layout parity example](examples/padded_and_packed.py)
123
+ for a numerical comparison. Packed input does not guarantee faster execution: backend,
124
+ hardware, dtype, and length distribution matter.
125
+
126
+ ## Explore examples
127
+
128
+ Browse complete examples for common tasks:
129
+
130
+ | Your task | Example |
131
+ | --- | --- |
132
+ | Image patches and 2-D positions | [Image encoder](examples/image_encoder.py) |
133
+ | Continuous spatial coordinates | [Point-cloud encoder](examples/point_cloud_encoder.py) |
134
+ | Unequal sequence lengths | [Padded and packed](examples/padded_and_packed.py) |
135
+ | Replace a model component | [Custom encoders](examples/subclassed_encoder.py) |
136
+ | Autoregressive token modeling | [Causal language model](examples/causal_language_model.py) |
137
+ | Export an encoder–decoder | [ONNX Runtime guide](examples/README.md#encoderdecoder-onnx-runtime) |
138
+
139
+ The [examples guide](examples/README.md) includes commands for running the repository examples.
140
+
141
+ These are integration examples with synthetic inputs, not trained models or task-accuracy
142
+ benchmarks. Stackformers provides transformer components; your application owns tokenization,
143
+ data processing, training, and task heads.
144
+
145
+ ## What can you change?
146
+
147
+ | Component | Included choices |
148
+ | --- | --- |
149
+ | Attention | Global self/cross attention, local self-attention, GQA/MQA |
150
+ | Token layout | Padded or packed, with explicit positions |
151
+ | Positional encoding | RoPE-1D, RoPE-2D, continuous-coordinate RoPE-ND, or none |
152
+ | Feedforward | SwiGLU, HardSwishGLU, GEGLU, GELU, ReLU² |
153
+ | Normalization | RMSNorm, LayerNorm; pre, post, sandwich, or reordered placement |
154
+ | Model assembly | Encoders, decoders, cross-attenders, variable-width encoders |
155
+ | Deployment | Projection packing, compile/export paths, cached decoder adapters |
156
+
157
+ Presets build components from discriminated Pydantic configurations. For deeper changes,
158
+ wire modules directly or implement an owning module's protocol. The
159
+ [configuration and API guide](docs/api-guide.md) covers both approaches.
160
+
161
+ ## Compatibility and limits
162
+
163
+ - Global attention uses PyTorch SDPA. Eligible CUDA fp16/bf16 packed workloads use
164
+ PyTorch's variable-length attention; other paths can fall back to padded execution.
165
+ - Compile and export support depend on the component and input path. Eager list/nested
166
+ adapters and deployment cache strategies have separate contracts.
167
+ - Cached deployment supports specified built-in classes; custom forward overrides need
168
+ their own deployment integration.
169
+ - No speedup or downstream accuracy improvement is claimed without a matching benchmark.
170
+
171
+ See [compatibility evidence](docs/compatibility.md) and
172
+ [inference contracts](docs/inference.md) before selecting a deployment path.
173
+
174
+ ## Documentation
175
+
176
+ - [Examples and expected behavior](examples/README.md)
177
+ - [Research reproducibility and citation](docs/research.md)
178
+ - [API, layouts, configuration, and migration](docs/api-guide.md)
179
+ - [Deployment and inference](docs/inference.md)
180
+ - [Release history](CHANGELOG.md)
181
+ - [Contributing](CONTRIBUTING.md)
182
+ - [Adoption and evidence roadmap](docs/improvement-plan.md)
183
+
184
+ ## Development
185
+
186
+ ```bash
187
+ git clone https://github.com/Red-Eyed/stackformers.git
188
+ cd stackformers
189
+ just sync
190
+ just check
191
+ ```
192
+
193
+ The [Justfile](Justfile) owns formatting, linting, type-checking, tests, and builds.
194
+
195
+ ## Citation and license
196
+
197
+ If Stackformers contributes to your research implementation, cite the software using
198
+ [CITATION.cff](CITATION.cff) and report the exact version or commit used. No associated
199
+ research paper or conference endorsement is implied.
200
+
201
+ Released under the [MIT license](LICENSE).
@@ -0,0 +1,150 @@
1
+ # Stackformers
2
+
3
+ [![CI](https://github.com/Red-Eyed/stackformers/actions/workflows/check.yml/badge.svg)](https://github.com/Red-Eyed/stackformers/actions/workflows/check.yml)
4
+ [![PyPI](https://img.shields.io/badge/install-PyPI-blue.svg)](https://pypi.org/project/stackformers/)
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
+
7
+ **Composable PyTorch transformers for research.**
8
+
9
+ Build vision, spatial, and sequence models with interchangeable attention, positional
10
+ encodings, normalization, and feedforward components. Start with a preset, then replace
11
+ individual components as your experiments evolve.
12
+
13
+ - **Experiment with architecture:** explicit, serializable configurations and structural
14
+ protocols let you supply your own components.
15
+ - **Work with variable-length data:** run the same encoder weights on padded or packed
16
+ token batches, with explicit token coordinates.
17
+ - **Connect research and deployment:** examples cover image patches, point clouds,
18
+ causal modeling, custom components, and cached ONNX Runtime decoding.
19
+
20
+ ## Install
21
+
22
+ Install from [PyPI](https://pypi.org/project/stackformers/) with pip:
23
+
24
+ ```bash
25
+ pip install --upgrade stackformers
26
+ ```
27
+
28
+ Or add it to your uv project:
29
+
30
+ ```bash
31
+ uv add stackformers
32
+ ```
33
+
34
+ ### Try the latest prerelease
35
+
36
+ Use `--pre` to include newer prereleases when upgrading:
37
+
38
+ ```bash
39
+ pip install --upgrade --pre stackformers
40
+ ```
41
+
42
+ With uv:
43
+
44
+ ```bash
45
+ uv add --upgrade --prerelease allow stackformers
46
+ ```
47
+
48
+ For an existing virtual environment, `uv pip install --upgrade --pre stackformers`
49
+ is also supported. These commands select the newest compatible published version,
50
+ including prereleases. Pin the version you validate for an experiment; see the
51
+ [research guide](docs/research.md).
52
+
53
+ ## Run your first encoder
54
+
55
+ ```python
56
+ import torch
57
+ import stackformers as sf
58
+
59
+ model = sf.TransformerEncoder(
60
+ sf.plain_encoder_config(dim=64, heads=1, num_layers=2, ff_mult=3.0)
61
+ ).eval()
62
+
63
+ sequences = [torch.randn(8, 64), torch.randn(5, 64)]
64
+ padded = sf.PaddedTensor.from_list(sequences)
65
+ with torch.no_grad():
66
+ padded_output = model(padded) # (2, 8, 64)
67
+ packed_output = model(padded.to_packed()) # (13, 64)
68
+ ```
69
+
70
+ The two calls share model weights. Packed output contains valid tokens only; padded output
71
+ retains batch and sequence axes. See the [layout parity example](examples/padded_and_packed.py)
72
+ for a numerical comparison. Packed input does not guarantee faster execution: backend,
73
+ hardware, dtype, and length distribution matter.
74
+
75
+ ## Explore examples
76
+
77
+ Browse complete examples for common tasks:
78
+
79
+ | Your task | Example |
80
+ | --- | --- |
81
+ | Image patches and 2-D positions | [Image encoder](examples/image_encoder.py) |
82
+ | Continuous spatial coordinates | [Point-cloud encoder](examples/point_cloud_encoder.py) |
83
+ | Unequal sequence lengths | [Padded and packed](examples/padded_and_packed.py) |
84
+ | Replace a model component | [Custom encoders](examples/subclassed_encoder.py) |
85
+ | Autoregressive token modeling | [Causal language model](examples/causal_language_model.py) |
86
+ | Export an encoder–decoder | [ONNX Runtime guide](examples/README.md#encoderdecoder-onnx-runtime) |
87
+
88
+ The [examples guide](examples/README.md) includes commands for running the repository examples.
89
+
90
+ These are integration examples with synthetic inputs, not trained models or task-accuracy
91
+ benchmarks. Stackformers provides transformer components; your application owns tokenization,
92
+ data processing, training, and task heads.
93
+
94
+ ## What can you change?
95
+
96
+ | Component | Included choices |
97
+ | --- | --- |
98
+ | Attention | Global self/cross attention, local self-attention, GQA/MQA |
99
+ | Token layout | Padded or packed, with explicit positions |
100
+ | Positional encoding | RoPE-1D, RoPE-2D, continuous-coordinate RoPE-ND, or none |
101
+ | Feedforward | SwiGLU, HardSwishGLU, GEGLU, GELU, ReLU² |
102
+ | Normalization | RMSNorm, LayerNorm; pre, post, sandwich, or reordered placement |
103
+ | Model assembly | Encoders, decoders, cross-attenders, variable-width encoders |
104
+ | Deployment | Projection packing, compile/export paths, cached decoder adapters |
105
+
106
+ Presets build components from discriminated Pydantic configurations. For deeper changes,
107
+ wire modules directly or implement an owning module's protocol. The
108
+ [configuration and API guide](docs/api-guide.md) covers both approaches.
109
+
110
+ ## Compatibility and limits
111
+
112
+ - Global attention uses PyTorch SDPA. Eligible CUDA fp16/bf16 packed workloads use
113
+ PyTorch's variable-length attention; other paths can fall back to padded execution.
114
+ - Compile and export support depend on the component and input path. Eager list/nested
115
+ adapters and deployment cache strategies have separate contracts.
116
+ - Cached deployment supports specified built-in classes; custom forward overrides need
117
+ their own deployment integration.
118
+ - No speedup or downstream accuracy improvement is claimed without a matching benchmark.
119
+
120
+ See [compatibility evidence](docs/compatibility.md) and
121
+ [inference contracts](docs/inference.md) before selecting a deployment path.
122
+
123
+ ## Documentation
124
+
125
+ - [Examples and expected behavior](examples/README.md)
126
+ - [Research reproducibility and citation](docs/research.md)
127
+ - [API, layouts, configuration, and migration](docs/api-guide.md)
128
+ - [Deployment and inference](docs/inference.md)
129
+ - [Release history](CHANGELOG.md)
130
+ - [Contributing](CONTRIBUTING.md)
131
+ - [Adoption and evidence roadmap](docs/improvement-plan.md)
132
+
133
+ ## Development
134
+
135
+ ```bash
136
+ git clone https://github.com/Red-Eyed/stackformers.git
137
+ cd stackformers
138
+ just sync
139
+ just check
140
+ ```
141
+
142
+ The [Justfile](Justfile) owns formatting, linting, type-checking, tests, and builds.
143
+
144
+ ## Citation and license
145
+
146
+ If Stackformers contributes to your research implementation, cite the software using
147
+ [CITATION.cff](CITATION.cff) and report the exact version or commit used. No associated
148
+ research paper or conference endorsement is implied.
149
+
150
+ Released under the [MIT license](LICENSE).