stackformers 6.0.0rc3__tar.gz → 6.0.0rc9__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.
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/CHANGELOG.md +135 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/PKG-INFO +1 -1
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/docs/api-guide.md +8 -14
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/docs/inference.md +5 -5
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/examples/README.md +3 -2
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/examples/encoder_decoder_onnxruntime.py +3 -2
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/pyproject.toml +1 -1
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/DEVLOG.md +136 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/__init__.py +0 -41
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/README.md +5 -5
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/cache.py +3 -3
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/cached.py +2 -2
- stackformers-6.0.0rc9/stackformers/attention/onnx_backend.py +140 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/ops.py +5 -3
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/packed_self_attn.py +1 -2
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/self_attn.py +1 -2
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/varlen_backend.py +5 -5
- stackformers-6.0.0rc9/stackformers/attention2d/README.md +150 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention2d/__init__.py +1 -1
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention2d/coordinates.py +13 -9
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention2d/cross_attn_pooling.py +2 -5
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention2d/factory.py +1 -1
- stackformers-6.0.0rc9/stackformers/attention2d/figures/window_cross_attention_2d.svg +632 -0
- stackformers-6.0.0rc9/stackformers/attention2d/figures/window_self_attention_2d.svg +632 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention2d/query_anchors.py +25 -2
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention2d/self_attn.py +2 -3
- stackformers-6.0.0rc9/stackformers/attention2d/sequence.py +220 -0
- stackformers-6.0.0rc9/stackformers/attention2d/windows.py +110 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/decoder_cache.py +11 -11
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/encoder2d/README.md +18 -2
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/encoder2d/window_stage.py +2 -3
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/mlm/README.md +5 -2
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/sequence.py +3 -130
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_all_valid.py +11 -11
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_config.py +2 -1
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_contracts.py +10 -12
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_cross_attn.py +5 -5
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_cross_attn_cache.py +13 -16
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_distance_bias.py +10 -10
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_empty_rows.py +2 -2
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_geometry.py +8 -7
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_kernels.py +17 -12
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_legacy_api.py +10 -9
- stackformers-6.0.0rc9/tests/attention/test_onnx_backend.py +115 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_ops.py +61 -5
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_packed_cross_attn.py +8 -8
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_packed_self_attn.py +4 -3
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_self_attn.py +18 -24
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_varlen_backend.py +9 -4
- stackformers-6.0.0rc9/tests/attention2d/test_export.py +120 -0
- stackformers-6.0.0rc9/tests/attention2d/test_sequence.py +126 -0
- stackformers-6.0.0rc9/tests/attention2d/test_windows.py +142 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/encoder2d/test_encoder.py +29 -10
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/encoder2d/test_window_stage.py +23 -3
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/mlm/test_empty_selection.py +3 -2
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/mlm/test_masking.py +1 -1
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/mlm/test_wrapper.py +9 -10
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/norm_topology_helpers.py +7 -2
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/positional/test_cacheable.py +4 -4
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/presets/test_cross_attender.py +6 -5
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/presets/test_decoder.py +6 -5
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/presets/test_encoder.py +14 -13
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/presets/test_projection_packing.py +5 -4
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/presets/test_variable_width_encoder.py +12 -15
- stackformers-6.0.0rc9/tests/sequence_helpers.py +37 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_all_valid_decoder.py +25 -25
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_core_results.py +7 -6
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_cross_attender.py +9 -4
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_decoder.py +17 -17
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_decoder_cache.py +32 -35
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_decoder_equations.py +8 -6
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_encoder.py +5 -4
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_encoder_decoder_example.py +4 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_layers.py +9 -5
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_packing.py +9 -13
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_preallocated_decoder.py +7 -7
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_public_api.py +1 -16
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_sequence.py +46 -51
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/uv.lock +1 -1
- stackformers-6.0.0rc3/stackformers/attention/onnx_backend.py +0 -54
- stackformers-6.0.0rc3/stackformers/attention2d/README.md +0 -77
- stackformers-6.0.0rc3/stackformers/attention2d/_geometry_module.py +0 -52
- stackformers-6.0.0rc3/stackformers/attention2d/centroid_queries.py +0 -36
- stackformers-6.0.0rc3/stackformers/attention2d/figures/window_cross_attention_2d.svg +0 -1
- stackformers-6.0.0rc3/stackformers/attention2d/figures/window_self_attention_2d.svg +0 -1
- stackformers-6.0.0rc3/stackformers/attention2d/geometry_precision.py +0 -17
- stackformers-6.0.0rc3/stackformers/attention2d/packed_windows.py +0 -134
- stackformers-6.0.0rc3/stackformers/attention2d/sequence.py +0 -149
- stackformers-6.0.0rc3/stackformers/attention2d/windows.py +0 -9
- stackformers-6.0.0rc3/tests/attention/test_onnx_backend.py +0 -42
- stackformers-6.0.0rc3/tests/attention2d/test_export.py +0 -33
- stackformers-6.0.0rc3/tests/attention2d/test_packed_windows.py +0 -50
- stackformers-6.0.0rc3/tests/attention2d/test_sequence.py +0 -54
- stackformers-6.0.0rc3/tests/attention2d/test_windows.py +0 -12
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/.claudeignore +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/.github/pull_request_template.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/.github/workflows/check.yml +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/.gitignore +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/.python-version +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/.vscode/settings.json +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/AGENTS.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/CITATION.cff +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/CONTRIBUTING.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/Justfile +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/LICENSE +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/PLAN.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/README.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/docs/assets/social-preview.jpg +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/docs/assets/social-preview.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/docs/compatibility.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/docs/improvement-plan.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/docs/research.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/examples/causal_language_model.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/examples/image_encoder.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/examples/padded_and_packed.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/examples/point_cloud_encoder.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/examples/spatial_encoder.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/examples/subclassed_encoder.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/pyrefly.toml +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/pytest.ini +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/ruff.toml +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/_decoder_equations.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/_projection_packing.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/_result.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/alignment.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/all_valid_decoder.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/__init__.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/all_valid.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/bias.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/cache_validation.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/config.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/cross_attn.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/distance_bias.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/factory.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/layout.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/masking.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/packed_cross_attn.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention/protocols.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/attention2d/protocols.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/config.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/cross_attender.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/decoder.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/encoder.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/encoder2d/__init__.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/encoder2d/_callable_stage.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/encoder2d/encoder.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/encoder2d/layer.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/encoder2d/protocols.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/encoder2d/tokenwise.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/feedforward/DEVLOG.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/feedforward/README.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/feedforward/__init__.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/feedforward/config.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/feedforward/factory.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/feedforward/geglu.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/feedforward/gelu.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/feedforward/hardswish_glu.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/feedforward/packed_geglu.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/feedforward/packed_hardswish_glu.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/feedforward/packed_swiglu.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/feedforward/protocols.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/feedforward/relu_squared.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/feedforward/swiglu.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/layers.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/mlm/config.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/mlm/head.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/mlm/head_cosine.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/mlm/masking.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/mlm/protocols.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/mlm/wrapper.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/norm/README.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/norm/__init__.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/norm/config.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/norm/factory.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/norm/protocols.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/packing.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/positional/README.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/positional/__init__.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/positional/config.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/positional/factory.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/positional/learned.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/positional/none.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/positional/protocols.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/positional/rope1d.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/positional/rope2d.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/positional/rope_nd.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/positional/validation.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/preallocated_decoder.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/presets/README.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/presets/__init__.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/presets/cross_attender.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/presets/decoder.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/presets/encoder.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/presets/variable_width_encoder.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/py.typed +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/result/README.md +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/stackformers/result/__init__.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/__init__.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/__init__.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/legacy_api_rc1.json +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_cached.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_factory.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_masking.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention/test_sdpa_export.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention2d/conftest.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention2d/test_coordinates.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention2d/test_cross_attn_pooling.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention2d/test_factory.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention2d/test_query_anchors.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/attention2d/test_self_attn.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/conftest.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/encoder2d/conftest.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/encoder2d/test_layer.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/export_utils.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/feedforward/__init__.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/feedforward/legacy_swiglu_4_6.json +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/feedforward/test_config.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/feedforward/test_factory.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/feedforward/test_geglu.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/feedforward/test_gelu.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/feedforward/test_hardswish_glu.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/feedforward/test_packed_geglu.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/feedforward/test_packed_hardswish_glu.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/feedforward/test_packed_swiglu.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/feedforward/test_relu_squared.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/feedforward/test_swiglu.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/mlm/__init__.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/mlm/test_head.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/mlm/test_head_cosine.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/positional/__init__.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/positional/test_learned_pos.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/positional/test_rope.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/positional/test_rope_nd.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/presets/__init__.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_alignment.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_examples.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_export_utils.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_norm.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_projection_packing.py +0 -0
- {stackformers-6.0.0rc3 → stackformers-6.0.0rc9}/tests/test_result.py +0 -0
|
@@ -6,6 +6,141 @@ 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.0rc9]
|
|
10
|
+
|
|
11
|
+
### Backwards Incompatible Changes
|
|
12
|
+
|
|
13
|
+
- Remove deprecated sequence metadata records, input aliases, and compatibility
|
|
14
|
+
helpers. Use `PaddedTensor` and `PackedTensor`, their factory and conversion
|
|
15
|
+
methods, and their stored validity, boundaries, and positions instead.
|
|
16
|
+
- Carry the original context tensor record in decoder cross-attention caches
|
|
17
|
+
instead of separate legacy sequence metadata.
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
- Enable optimized direct spatial ONNX export by emitting a standard ONNX subgraph
|
|
22
|
+
for packed token indices, avoiding the exporter's invalid `repeat_interleave`
|
|
23
|
+
rewrite. Native PyTorch execution is unchanged. Export tensor adapters directly;
|
|
24
|
+
conversion of pre-captured `ExportedProgram` graphs bypasses this lowering and
|
|
25
|
+
can still encounter the upstream optimizer failure.
|
|
26
|
+
|
|
27
|
+
## [6.0.0rc8]
|
|
28
|
+
|
|
29
|
+
### Backwards Incompatible Changes
|
|
30
|
+
|
|
31
|
+
- Restore actual rectangular `window_size=(height,width)` membership. This changes
|
|
32
|
+
attention groups and pooled placement from rc6's consecutive row-major chunks.
|
|
33
|
+
- Make constructor `alignment=` and `PackedTensor2d.align(...)` prepare rectangular
|
|
34
|
+
window-order storage as well as zero padding. `PackedTensor2d.window_size` records
|
|
35
|
+
this order; direct construction defaults to `(1,1)` for row-major storage.
|
|
36
|
+
Use the factories for consistent feature, position, and integer-grid ordering.
|
|
37
|
+
|
|
38
|
+
### Improvements
|
|
39
|
+
|
|
40
|
+
- Partition matching prepared storage by creating cumulative sequence lengths and
|
|
41
|
+
borrowing the exact feature and position tensors. Self-attention retains the
|
|
42
|
+
prepared output order; pooling attaches output-window metadata without copying
|
|
43
|
+
attention output or query-position buffers.
|
|
44
|
+
- Pack other layouts during preparation and restore the original layout for
|
|
45
|
+
self-attention. Window-shape changes may require repacking; initial construction
|
|
46
|
+
and dense output conversion are separate from metadata-only partitioning.
|
|
47
|
+
- Show batch, sample, window, and pixel grouping in both spatial diagrams, including
|
|
48
|
+
the shared buffers and sample/window cumulative sequence boundaries.
|
|
49
|
+
- Verify rectangular membership, storage identity, compiled preparation, and encoder
|
|
50
|
+
execution without feature repacking. Extend ONNX Runtime checks to prepared and
|
|
51
|
+
row-major inputs with one or two samples at opsets 18–25.
|
|
52
|
+
|
|
53
|
+
## [6.0.0rc6]
|
|
54
|
+
|
|
55
|
+
### Backwards Incompatible Changes
|
|
56
|
+
|
|
57
|
+
- Group consecutive stored tokens into attention sequences instead of rearranging
|
|
58
|
+
rectangular tiles. A window contains `wh*ww` tokens in existing storage order;
|
|
59
|
+
this changes attention membership and pooled output placement versus rc5.
|
|
60
|
+
- Consolidate partitioning into `attention2d.windows.partition_windows`, which returns
|
|
61
|
+
a 1D `PackedTensor` and its bound merge operation. Remove `packed_windows.py`.
|
|
62
|
+
|
|
63
|
+
### Improvements
|
|
64
|
+
|
|
65
|
+
- Add `PackedTensor2d.align(n)` and `alignment=` to both constructors. Accept a shared
|
|
66
|
+
positive axis multiple or a `(height, width)` pair, padding data and positions
|
|
67
|
+
with zeros. Already aligned records retain their storage.
|
|
68
|
+
- Borrow aligned features and positions when partitioning. Generate device-side
|
|
69
|
+
int32 sequence boundaries for existing native variable-length attention; ONNX
|
|
70
|
+
export uses int64 boundaries for compatibility with the installed exporter.
|
|
71
|
+
- Avoid feature and position concatenation for a single grid. Preserve packed
|
|
72
|
+
execution, mask-free alignment, and existing attention backend code.
|
|
73
|
+
|
|
74
|
+
## [6.0.0rc5]
|
|
75
|
+
|
|
76
|
+
### Backwards Incompatible Changes
|
|
77
|
+
|
|
78
|
+
- Remove custom geometry-policy signature buffers and checkpoint hooks. Built-in
|
|
79
|
+
position and query policies are ordinary modules. When loading an older state
|
|
80
|
+
dictionary, remove its `_geometry_signature` entries and reconstruct the original
|
|
81
|
+
policies explicitly; learned parameter names and tensor shapes are unchanged.
|
|
82
|
+
- Move `CentroidQueryPositions` into `attention2d.query_anchors` and the position
|
|
83
|
+
precision helper into `attention2d.coordinates`. Root package imports remain the
|
|
84
|
+
same; update imports that referenced the retired internal modules.
|
|
85
|
+
|
|
86
|
+
### Improvements
|
|
87
|
+
|
|
88
|
+
- Remove three spatial wrapper/helper modules while preserving coordinate and
|
|
89
|
+
centroid arithmetic, packed execution, and the existing attention backend.
|
|
90
|
+
|
|
91
|
+
## [6.0.0rc4]
|
|
92
|
+
|
|
93
|
+
### Backwards Incompatible Changes
|
|
94
|
+
|
|
95
|
+
- Retain shape-derived per-grid dimensions in `PackedTensor2d.grid_shapes`. Direct
|
|
96
|
+
record construction must provide this tuple consistently with existing metadata;
|
|
97
|
+
prefer `from_list` or the new `from_tensor` constructor.
|
|
98
|
+
|
|
99
|
+
### Improvements
|
|
100
|
+
|
|
101
|
+
- Replace data-dependent window topology discovery with reshape, zero alignment,
|
|
102
|
+
window rearrangement, and a bound inverse. Preserve arbitrary supplied absolute
|
|
103
|
+
positions and the existing packed spatial model API.
|
|
104
|
+
- Add `PackedTensor2d.from_tensor(data, abs_positions=positions)` for batched 2D
|
|
105
|
+
structures. List views and dense output conversion use known grid dimensions
|
|
106
|
+
without reading device metadata.
|
|
107
|
+
|
|
108
|
+
### Bug Fixes
|
|
109
|
+
|
|
110
|
+
- Restore verified ONNX export through tensor I/O adapters that retain packed model
|
|
111
|
+
execution. Runtime parity covers static and dynamic spatial dimensions at opsets
|
|
112
|
+
18–25 for attention, pooling, shared encoder stages, and composed encoders.
|
|
113
|
+
With the installed exporter, use deferred runtime shape assertions during capture
|
|
114
|
+
and `optimize=False` during conversion to avoid an invalid optimized graph.
|
|
115
|
+
Python layout metadata must stay outside ONNX graph outputs.
|
|
116
|
+
|
|
117
|
+
## [6.0.0rc3]
|
|
118
|
+
|
|
119
|
+
### Backwards Incompatible Changes
|
|
120
|
+
|
|
121
|
+
- Make 2D attention and encoders packed-only. Replace `PaddedTensor2d` construction
|
|
122
|
+
with `PackedTensor2d.from_list(...)`; spatial layers accept and return packed records.
|
|
123
|
+
Remove spatial `masks=` arguments and support for excluded interior slots.
|
|
124
|
+
- Return a raw dense feature tensor from `PackedTensor2d.to_padded()`, rather than a
|
|
125
|
+
spatial record. Use the packed record for positions and shape metadata. Remove the
|
|
126
|
+
separate dense spatial ONNX path; packed dynamic ONNX export remains unverified.
|
|
127
|
+
- Include zero alignment slots in attention and pooling centroids instead of masking
|
|
128
|
+
them out. This changes results at partially filled window boundaries.
|
|
129
|
+
- Rename `PhysicalCoordinates` to `AbsolutePositions` and pass `abs_positions` through
|
|
130
|
+
by default. Select `NormalizedWindowCoordinates` explicitly to normalize complete
|
|
131
|
+
windows. Updated normalization and centroid checkpoint signatures require an
|
|
132
|
+
explicit migration for older geometry policies.
|
|
133
|
+
- Simplify injected geometry protocols to packed inputs: implement
|
|
134
|
+
`WindowCoordinates.packed(context)` and `QueryPositions.packed(context, features)`
|
|
135
|
+
without source-slot arguments or dense methods.
|
|
136
|
+
|
|
137
|
+
### Improvements
|
|
138
|
+
|
|
139
|
+
- Prepare aligned windows by direct scatter and restore their layout without sorting.
|
|
140
|
+
Compute query centroids with indexed reductions instead of token-by-query expansion.
|
|
141
|
+
- Remove spatial masking copies from encoder normalization and feed-forward adapters.
|
|
142
|
+
Preserve the existing 1D attention backend and its variable-length kernel dispatch.
|
|
143
|
+
|
|
9
144
|
## [6.0.0rc2]
|
|
10
145
|
|
|
11
146
|
### Bug Fixes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: stackformers
|
|
3
|
-
Version: 6.0.
|
|
3
|
+
Version: 6.0.0rc9
|
|
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
|
|
@@ -44,20 +44,14 @@ compile/export with dynamic output shapes. Same-layout conversions return the or
|
|
|
44
44
|
record. Packed list slices and jagged output share value storage; callers must avoid
|
|
45
45
|
mutating shared buffers. Nested adapters require PyTorch's jagged tensor API.
|
|
46
46
|
|
|
47
|
-
###
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
`
|
|
52
|
-
`
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
as deprecated compatibility APIs. Metadata records and helper functions use static
|
|
56
|
-
PEP 702 deprecation markers without runtime warning wrappers, keeping old graph paths
|
|
57
|
-
traceable. Use tensor constructors, conversion methods, `materialize_padding_mask`, and
|
|
58
|
-
`tensor.cu_seqlens.shape[0] - 1` instead. Existing decoder cache outputs retain their
|
|
59
|
-
mask-only metadata structure; cached calls also accept `PaddedTensor` directly.
|
|
60
|
-
No removal version is assigned.
|
|
47
|
+
### Sequence API migration
|
|
48
|
+
|
|
49
|
+
The deprecated input aliases, metadata-only sequence records, and construction/conversion
|
|
50
|
+
helpers have been removed. Use `PackedTensor` and `PaddedTensor` with explicit positions,
|
|
51
|
+
or their `from_list` constructors to generate sequential positions. Convert layouts with
|
|
52
|
+
`tensor.to_packed()` and `tensor.to_padded()`. Use `materialize_padding_mask(tensor)` at
|
|
53
|
+
boundaries requiring a boolean mask, and `tensor.cu_seqlens.shape[0] - 1` for packed batch
|
|
54
|
+
size. Cached calls and cache builder outputs now carry the full `PaddedTensor` context.
|
|
61
55
|
|
|
62
56
|
## Composition
|
|
63
57
|
|
|
@@ -7,7 +7,7 @@ selected automatically from tensor values, a batch size of one, or evaluation mo
|
|
|
7
7
|
|
|
8
8
|
Load an ordinary checkpoint into the ordinary model, then call `sf.to_packed(model)` before
|
|
9
9
|
building wrappers. Alternatively, construct with packed attention/feed-forward configs and
|
|
10
|
-
load a matching packed checkpoint. `
|
|
10
|
+
load a matching packed checkpoint. `PackedTensor` describes a sequence layout; it does not
|
|
11
11
|
select packed projections. Default presets still construct ordinary projections.
|
|
12
12
|
|
|
13
13
|
Packing retains parameter values, normalization, RoPE, output projections, dtype/device,
|
|
@@ -23,7 +23,7 @@ project only Q. Graph structure is verified separately from eager numerical pari
|
|
|
23
23
|
|
|
24
24
|
## Explicit validity
|
|
25
25
|
|
|
26
|
-
Use `sf.
|
|
26
|
+
Use `sf.PaddedTensor(x, sf.AllValid(), abs_positions)` only when every token is valid. The
|
|
27
27
|
mask field is required and accepts either a boolean tensor or the explicit `AllValid()`
|
|
28
28
|
marker. There is no `None` mode or omitted-mask default. `SequenceInput` retains just its
|
|
29
29
|
padded and packed layouts. This replaces the prerelease `AllValidInput` record.
|
|
@@ -37,7 +37,7 @@ cases. Cross-attention query and context masks are handled independently.
|
|
|
37
37
|
`AllValid` is stateless and registered as a zero-leaf pytree, so it contributes no graph input.
|
|
38
38
|
`sf.materialize_padding_mask(input)` adapts to consumers requiring a boolean tensor: existing
|
|
39
39
|
tensors retain identity, and only the marker allocates an all-true mask. Attention does not
|
|
40
|
-
call this adapter on its all-valid path.
|
|
40
|
+
call this adapter on its all-valid path.
|
|
41
41
|
|
|
42
42
|
`sf.AllValidCachedDecoderWrapper` requires exactly one token and batch size one. Its self
|
|
43
43
|
cache includes only valid past tokens, and the new token is appended before attention.
|
|
@@ -53,9 +53,9 @@ builder = sf.AllValidCrossAttentionCacheBuilder(decoder)
|
|
|
53
53
|
cached = sf.AllValidCachedDecoderWrapper(decoder)
|
|
54
54
|
|
|
55
55
|
with torch.no_grad():
|
|
56
|
-
cross = builder(sf.
|
|
56
|
+
cross = builder(sf.PaddedTensor(memory_x, sf.AllValid(), memory_positions))
|
|
57
57
|
past = cached.empty_cache(dtype=torch.float32)
|
|
58
|
-
result = cached(sf.
|
|
58
|
+
result = cached(sf.PaddedTensor(token_x, sf.AllValid(), token_positions), cross, past)
|
|
59
59
|
past = result.self_kv_cache
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -34,7 +34,7 @@ boundaries suitable for separate C++ ONNX Runtime sessions:
|
|
|
34
34
|
1. Eager PyTorch calls `model(source, target)` with the existing Stackformers API.
|
|
35
35
|
2. `encoder.onnx` runs once and returns encoder memory.
|
|
36
36
|
3. `decoder_cross_cache.onnx` consumes that memory once and returns one dense cross-attention K/V
|
|
37
|
-
cache plus the context mask.
|
|
37
|
+
cache plus the context values, mask, and positions.
|
|
38
38
|
4. `cached_decoder.onnx` consumes one target token, the cross cache, a required growing self cache,
|
|
39
39
|
and `step_i`; it returns the decoder output and the self cache for the next call.
|
|
40
40
|
|
|
@@ -48,7 +48,8 @@ The ONNX tensors have explicit names suitable for equivalent C++ `Ort::Value` ma
|
|
|
48
48
|
|
|
49
49
|
- Encoder inputs: `source_x`, `source_mask`, `source_positions`.
|
|
50
50
|
- Encoder outputs and cache-builder inputs: `memory_x`, `memory_mask`, `memory_positions`.
|
|
51
|
-
- Cache outputs and cached-decoder inputs: `cross_kv_cache`, `context_mask
|
|
51
|
+
- Cache outputs and cached-decoder inputs: `cross_kv_cache`, `context_x`, `context_mask`,
|
|
52
|
+
`context_positions`.
|
|
52
53
|
- Other cached-decoder inputs: `target_x`, `target_mask`, `target_positions`, `self_kv_cache`,
|
|
53
54
|
`step_i`.
|
|
54
55
|
- Cached-decoder outputs: `decoder_output`, `self_kv_cache_out`.
|
|
@@ -35,7 +35,7 @@ LAYERS = 2
|
|
|
35
35
|
EXAMPLE_BATCH = 2
|
|
36
36
|
MAX_SOURCE_TOKENS = 6
|
|
37
37
|
MAX_TARGET_TOKENS = 4
|
|
38
|
-
CROSS_CACHE_NAMES = ("cross_kv_cache", "context_mask")
|
|
38
|
+
CROSS_CACHE_NAMES = ("cross_kv_cache", "context_x", "context_mask", "context_positions")
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
class ExampleResult(NamedTuple):
|
|
@@ -125,7 +125,8 @@ def _cached_decoder_dynamic_shapes(
|
|
|
125
125
|
for tensor in target_input:
|
|
126
126
|
shapes[tensor] = {0: batch}
|
|
127
127
|
shapes[cross_cache.kv] = {2: batch, 4: source_tokens}
|
|
128
|
-
|
|
128
|
+
for tensor in cross_cache.context:
|
|
129
|
+
shapes[tensor] = {0: batch, 1: source_tokens}
|
|
129
130
|
shapes[self_kv_cache] = {2: batch, 4: past_tokens}
|
|
130
131
|
dynamic_shapes: dict[str, object] = shapes.dynamic_shapes(
|
|
131
132
|
module,
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "stackformers"
|
|
7
|
-
version = "6.0.
|
|
7
|
+
version = "6.0.0rc9"
|
|
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,139 @@ 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.
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
## Optimized packed spatial ONNX exports
|
|
1035
|
+
|
|
1036
|
+
Enabling exporter optimization reproduced an invalid dynamic spatial graph: ONNX
|
|
1037
|
+
Script's ReshapeReshape rewrite left dangling shape inputs inside the
|
|
1038
|
+
repeat_interleave lowering. Disabling the exporter optimizer avoided the failure
|
|
1039
|
+
but also disabled useful exporter fusions.
|
|
1040
|
+
|
|
1041
|
+
An internal onnx_lowering decorator keeps the original repeat_interleave native
|
|
1042
|
+
implementation and emits a standard ONNX subgraph only during direct ONNX capture.
|
|
1043
|
+
Exported packed indices come from label changes scattered at nonempty sequence
|
|
1044
|
+
starts and cumulatively summed across token positions. Nonempty starts are unique,
|
|
1045
|
+
and label jumps preserve batch numbering across leading, interior, and trailing
|
|
1046
|
+
empty sequences. A sentinel slot handles entirely empty inputs. This avoids both
|
|
1047
|
+
the broken lowering and scatter reductions that prevent legacy opset conversion.
|
|
1048
|
+
Existing einops layout transformations, native eager/compiled/torch.export
|
|
1049
|
+
execution, attention equations, and kernel routing remain unchanged. No installed
|
|
1050
|
+
dependencies are patched, and callers need no translation tables or registration.
|
|
1051
|
+
|
|
1052
|
+
Spatial export tests and examples now use direct torch.onnx.export with
|
|
1053
|
+
optimize=True. A pre-captured ExportedProgram cannot reselect Python branches and
|
|
1054
|
+
can still hit the upstream optimizer bug; this workaround applies to direct export.
|
|
1055
|
+
Regression coverage checks empty sequences with int32/int64 boundaries, full-graph
|
|
1056
|
+
compilation with dynamic-output capture, and optimized dynamic ONNX execution.
|
|
1057
|
+
These changes address export correctness; target-device latency and CUDA execution
|
|
1058
|
+
remain unmeasured.
|
|
1059
|
+
|
|
1060
|
+
Validation includes all 256 static/dynamic spatial exports at opsets 18–25 with
|
|
1061
|
+
optimize=True, required module coverage, and 1,622 isolated root-level integration
|
|
1062
|
+
tests. Formatting, lint, and Pyrefly pass. Optional coverage has 107 passes and 252
|
|
1063
|
+
expected failures. Four opset-15 RoPE2D/RoPEND conversion failures reproduce on the
|
|
1064
|
+
untouched committed baseline; they remain outside this fix. The lowered packed
|
|
1065
|
+
index graph passes the ONNX checker, contains only standard ai.onnx operators, and
|
|
1066
|
+
preserves runtime indices when empty-sequence placement changes.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"""stackformers public API."""
|
|
2
2
|
|
|
3
3
|
from importlib.metadata import version
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
5
4
|
|
|
6
5
|
__version__ = version("stackformers")
|
|
7
6
|
|
|
@@ -173,24 +172,12 @@ from stackformers.presets.variable_width_encoder import (
|
|
|
173
172
|
from stackformers.result import Err, Ok, Result
|
|
174
173
|
from stackformers.sequence import (
|
|
175
174
|
AllValid,
|
|
176
|
-
PackedSequence,
|
|
177
175
|
PackedTensor,
|
|
178
|
-
PaddedSequence,
|
|
179
176
|
PaddedTensor,
|
|
180
|
-
SequenceInfo,
|
|
181
177
|
SequenceInput,
|
|
182
178
|
lengths_to_cu_seqlens,
|
|
183
|
-
make_packed,
|
|
184
|
-
make_packed_input,
|
|
185
|
-
make_padded,
|
|
186
|
-
make_padded_input,
|
|
187
179
|
materialize_padding_mask,
|
|
188
|
-
packed_batch_size,
|
|
189
|
-
packed_to_padded,
|
|
190
|
-
padded_to_key_padding_mask,
|
|
191
|
-
padded_to_packed,
|
|
192
180
|
position_ids_from_packed,
|
|
193
|
-
to_seq_info,
|
|
194
181
|
)
|
|
195
182
|
|
|
196
183
|
__all__ = [
|
|
@@ -226,25 +213,11 @@ __all__ = [
|
|
|
226
213
|
"Ok",
|
|
227
214
|
"Err",
|
|
228
215
|
# sequences
|
|
229
|
-
"PaddedSequence",
|
|
230
|
-
"PackedSequence",
|
|
231
|
-
"SequenceInfo",
|
|
232
216
|
"PaddedTensor",
|
|
233
217
|
"PackedTensor",
|
|
234
|
-
"PaddedInput",
|
|
235
|
-
"PackedInput",
|
|
236
218
|
"SequenceInput",
|
|
237
|
-
"make_padded",
|
|
238
|
-
"make_packed",
|
|
239
|
-
"make_padded_input",
|
|
240
|
-
"make_packed_input",
|
|
241
|
-
"to_seq_info",
|
|
242
219
|
"lengths_to_cu_seqlens",
|
|
243
220
|
"position_ids_from_packed",
|
|
244
|
-
"packed_batch_size",
|
|
245
|
-
"packed_to_padded",
|
|
246
|
-
"padded_to_key_padding_mask",
|
|
247
|
-
"padded_to_packed",
|
|
248
221
|
# protocols
|
|
249
222
|
"PosEncoding",
|
|
250
223
|
"SelfAttn",
|
|
@@ -378,17 +351,3 @@ __all__ = [
|
|
|
378
351
|
"MLMWrapper",
|
|
379
352
|
"MLMOutput",
|
|
380
353
|
]
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
if TYPE_CHECKING:
|
|
384
|
-
PackedInput = PackedTensor
|
|
385
|
-
PaddedInput = PaddedTensor
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
def __getattr__(name: str) -> type[PackedTensor] | type[PaddedTensor]:
|
|
389
|
-
"""Resolve legacy input aliases with the sequence module's deprecation guidance."""
|
|
390
|
-
from stackformers import sequence
|
|
391
|
-
|
|
392
|
-
if name in ("PackedInput", "PaddedInput"):
|
|
393
|
-
return sequence.__getattr__(name)
|
|
394
|
-
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
@@ -53,7 +53,7 @@ allocating a dense pair mask on the packed fast path.
|
|
|
53
53
|
|
|
54
54
|
**Packed attention with automatic fallback.** `PackedTensor` normally routes to `varlen_attn`, which requires CUDA and `float16`/`bfloat16`. `packed_attn_or_fallback` calls `try_varlen_attn`; a `None` result means take the padded path — scatter q/k/v to padded layout, run `F.scaled_dot_product_attention`, and gather the result back to packed (same weights, same output shape `(nt, h, d)`). The fallback runs **silently** for the expected CPU/float32/`torch.export` route, and **with a `UserWarning` explaining why** when the kernel was eligible but unusable: it failed to import, an attention bias is present (no bias slot), or the call raised a runtime/signature error (unsupported GPU or a changed experimental API). Dropout works on the fallback path; it is silently skipped only when `varlen_attn` is used (which does not accept a dropout argument).
|
|
55
55
|
|
|
56
|
-
**`torch.export` and `torch.compile` compatibility.** All scatter/gather helpers in `ops.py` (`_cu_to_indices`, `_packed_heads_to_padded`, `_padded_heads_to_packed`)
|
|
56
|
+
**`torch.export` and `torch.compile` compatibility.** All scatter/gather helpers in `ops.py` (`_cu_to_indices`, `_packed_heads_to_padded`, `_padded_heads_to_packed`) avoid Python-side iteration over data-dependent lengths. Native execution uses `repeat_interleave` to recover token batch indices and `arange(nt) - cu[batch_idx]` for positions. During direct ONNX capture, the `onnx_lowering` decorator selects an explicit standard-ONNX subgraph from `onnx_backend.py`. It scatters label changes at nonempty sequence starts and cumulatively sums them; unique starts and label jumps preserve numbering across empty sequences. This avoids the installed ONNX Script optimizer's invalid `ReshapeReshape` rewrite without changing native eager, compiled, or `torch.export` behavior. Callers use ordinary `torch.onnx.export(model, args, ...)` without custom operators or registration. Converting an already captured `ExportedProgram` bypasses Python dispatch, so use direct ONNX export for this workaround.
|
|
57
57
|
|
|
58
58
|
**GQA / MQA.** Set `kv_heads < heads` in either config. Key and value heads are repeated via
|
|
59
59
|
`einops.repeat` before the dot-product. For padded inputs, repeat in token-major layout before
|
|
@@ -141,10 +141,10 @@ updated protocol.
|
|
|
141
141
|
To add a new attention bias, write an `nn.Module` satisfying `AttnBias` (take `PaddedTensor`, return a broadcastable `(b, h, n, s)` tensor or `None`), give it a config with a `kind` discriminator, join it to the `AttnBiasConfig` union, and add one `match` arm to `build_attn_bias`.
|
|
142
142
|
|
|
143
143
|
Packed execution takes `PackedTensor` directly, including at the varlen/fallback boundary;
|
|
144
|
-
callers do not construct a second metadata record.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
144
|
+
callers do not construct a second metadata record. Cached cross-attention accepts a
|
|
145
|
+
`PaddedTensor` as context validity. Cache builders return that original context record
|
|
146
|
+
alongside projected keys and values, preserving values, validity, and coordinates without
|
|
147
|
+
constructing separate metadata records.
|
|
148
148
|
|
|
149
149
|
## Optional dimension rounding
|
|
150
150
|
|
|
@@ -8,7 +8,7 @@ if TYPE_CHECKING:
|
|
|
8
8
|
from jaxtyping import Float
|
|
9
9
|
from torch import Tensor
|
|
10
10
|
|
|
11
|
-
from stackformers.sequence import
|
|
11
|
+
from stackformers.sequence import PaddedTensor
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class CrossAttentionKVCache(NamedTuple):
|
|
@@ -23,14 +23,14 @@ class CrossAttentionKVCache(NamedTuple):
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
class DecoderCrossAttentionCache(NamedTuple):
|
|
26
|
-
"""Dense context cache and
|
|
26
|
+
"""Dense context cache and tensor record shared by every decoder step.
|
|
27
27
|
|
|
28
28
|
The leading dimensions of ``kv`` are layer and K/V selector. Keeping every layer in one
|
|
29
29
|
tensor gives ONNX Runtime C++ one required ``Ort::Value`` instead of a variable-length list.
|
|
30
30
|
"""
|
|
31
31
|
|
|
32
32
|
kv: Float[Tensor, "layers two b kv_h s dh"]
|
|
33
|
-
context:
|
|
33
|
+
context: PaddedTensor
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
class DecoderStepOutput(NamedTuple):
|
|
@@ -27,7 +27,7 @@ if TYPE_CHECKING:
|
|
|
27
27
|
from jaxtyping import Float
|
|
28
28
|
|
|
29
29
|
from stackformers.positional.protocols import PosEncoding
|
|
30
|
-
from stackformers.sequence import
|
|
30
|
+
from stackformers.sequence import PaddedTensor
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
def _project_qkv(
|
|
@@ -220,7 +220,7 @@ class CachedCrossAttentionWrapper(nn.Module):
|
|
|
220
220
|
self,
|
|
221
221
|
input: PaddedTensor,
|
|
222
222
|
cache: CrossAttentionKVCache,
|
|
223
|
-
context: PaddedTensor
|
|
223
|
+
context: PaddedTensor,
|
|
224
224
|
) -> Tensor:
|
|
225
225
|
"""Attend one padded target input to a preprojected fixed context."""
|
|
226
226
|
attention = self.attention
|