stackformers 5.1.0__tar.gz → 5.1.1__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-5.1.0 → stackformers-5.1.1}/CHANGELOG.md +9 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/PKG-INFO +1 -1
- {stackformers-5.1.0 → stackformers-5.1.1}/pyproject.toml +1 -1
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/DEVLOG.md +13 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/__init__.py +2 -2
- stackformers-5.1.0/stackformers/dimension_rounding.py → stackformers-5.1.1/stackformers/alignment.py +1 -1
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/README.md +4 -4
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/config.py +7 -7
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/feedforward/README.md +4 -4
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/feedforward/config.py +4 -4
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_config.py +7 -7
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/feedforward/test_config.py +6 -8
- stackformers-5.1.0/tests/test_dimension_rounding.py → stackformers-5.1.1/tests/test_alignment.py +4 -4
- {stackformers-5.1.0 → stackformers-5.1.1}/uv.lock +1 -1
- {stackformers-5.1.0 → stackformers-5.1.1}/.claudeignore +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/.github/pull_request_template.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/.github/workflows/check.yml +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/.gitignore +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/.python-version +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/.vscode/settings.json +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/AGENTS.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/CITATION.cff +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/CONTRIBUTING.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/Justfile +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/LICENSE +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/PLAN.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/README.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/docs/api-guide.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/docs/assets/social-preview.jpg +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/docs/assets/social-preview.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/docs/compatibility.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/docs/improvement-plan.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/docs/inference.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/docs/research.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/examples/README.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/examples/causal_language_model.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/examples/encoder_decoder_onnxruntime.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/examples/image_encoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/examples/padded_and_packed.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/examples/point_cloud_encoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/examples/subclassed_encoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/pyrefly.toml +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/pytest.ini +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/ruff.toml +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/_decoder_equations.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/_projection_packing.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/_result.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/all_valid_decoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/__init__.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/all_valid.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/bias.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/cache.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/cache_validation.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/cached.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/cross_attn.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/distance_bias.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/factory.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/layout.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/masking.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/onnx_backend.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/ops.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/packed_cross_attn.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/packed_self_attn.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/protocols.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/self_attn.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/attention/varlen_backend.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/config.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/cross_attender.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/decoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/decoder_cache.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/encoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/feedforward/DEVLOG.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/feedforward/__init__.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/feedforward/factory.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/feedforward/geglu.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/feedforward/gelu.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/feedforward/hardswish_glu.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/feedforward/packed_geglu.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/feedforward/packed_hardswish_glu.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/feedforward/packed_swiglu.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/feedforward/protocols.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/feedforward/relu_squared.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/feedforward/swiglu.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/layers.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/mlm/README.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/mlm/config.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/mlm/head.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/mlm/head_cosine.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/mlm/masking.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/mlm/protocols.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/mlm/wrapper.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/norm/README.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/norm/__init__.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/norm/config.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/norm/factory.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/norm/protocols.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/packing.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/positional/README.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/positional/__init__.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/positional/config.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/positional/factory.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/positional/learned.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/positional/none.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/positional/protocols.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/positional/rope1d.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/positional/rope2d.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/positional/rope_nd.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/positional/validation.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/preallocated_decoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/presets/README.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/presets/__init__.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/presets/cross_attender.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/presets/decoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/presets/encoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/presets/variable_width_encoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/py.typed +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/result/README.md +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/result/__init__.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/stackformers/sequence.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/__init__.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/__init__.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/legacy_api_rc1.json +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_all_valid.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_cached.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_contracts.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_cross_attn.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_cross_attn_cache.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_distance_bias.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_empty_rows.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_factory.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_geometry.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_kernels.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_legacy_api.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_masking.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_onnx_backend.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_ops.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_packed_cross_attn.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_packed_self_attn.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_sdpa_export.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_self_attn.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/attention/test_varlen_backend.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/conftest.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/export_utils.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/feedforward/__init__.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/feedforward/legacy_swiglu_4_6.json +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/feedforward/test_factory.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/feedforward/test_geglu.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/feedforward/test_gelu.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/feedforward/test_hardswish_glu.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/feedforward/test_packed_geglu.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/feedforward/test_packed_hardswish_glu.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/feedforward/test_packed_swiglu.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/feedforward/test_relu_squared.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/feedforward/test_swiglu.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/mlm/__init__.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/mlm/test_empty_selection.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/mlm/test_head.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/mlm/test_head_cosine.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/mlm/test_masking.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/mlm/test_wrapper.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/norm_topology_helpers.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/positional/__init__.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/positional/test_cacheable.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/positional/test_learned_pos.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/positional/test_rope.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/positional/test_rope_nd.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/presets/__init__.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/presets/test_cross_attender.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/presets/test_decoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/presets/test_encoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/presets/test_projection_packing.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/presets/test_variable_width_encoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_all_valid_decoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_core_results.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_cross_attender.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_decoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_decoder_cache.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_decoder_equations.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_encoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_encoder_decoder_example.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_examples.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_export_utils.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_layers.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_norm.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_packing.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_preallocated_decoder.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_projection_packing.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_public_api.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_result.py +0 -0
- {stackformers-5.1.0 → stackformers-5.1.1}/tests/test_sequence.py +0 -0
|
@@ -6,6 +6,15 @@ 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.1]
|
|
10
|
+
|
|
11
|
+
### Improvements
|
|
12
|
+
|
|
13
|
+
- Rename `DimensionRoundingConfig` to `AlignmentConfig` and the attention/feed-forward
|
|
14
|
+
config field `dimension_rounding` to `alignment`. Import the shared type from
|
|
15
|
+
`stackformers` or `stackformers.alignment`; update existing configuration payloads to
|
|
16
|
+
use `alignment`. Rounding behavior and defaults are unchanged.
|
|
17
|
+
|
|
9
18
|
## [5.1.0]
|
|
10
19
|
|
|
11
20
|
### New Features
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: stackformers
|
|
3
|
-
Version: 5.1.
|
|
3
|
+
Version: 5.1.1
|
|
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
|
|
@@ -822,3 +822,16 @@ and 252 expected failures on this machine.
|
|
|
822
822
|
|
|
823
823
|
No throughput benchmark or training ablation establishes a speed or quality benefit. Rounding
|
|
824
824
|
only selects internal geometry; other matrix dimensions and the workload still affect efficiency.
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
## Alignment configuration naming
|
|
828
|
+
|
|
829
|
+
Rename the shared policy to `AlignmentConfig` in `alignment.py` and its config field to
|
|
830
|
+
`alignment`, reflecting the hardware goal while retaining `rounding_mode` for the mechanism.
|
|
831
|
+
Update imports, config payloads, tests, and module documentation together. The floor/ceil
|
|
832
|
+
behavior, zero-width rejection, and disabled defaults remain unchanged. This is the requested
|
|
833
|
+
5.1.1 patch naming correction; callers using the previous names must update them.
|
|
834
|
+
|
|
835
|
+
Validation: repository formatting, lint, and type checks pass; 264 focused alignment,
|
|
836
|
+
attention/feed-forward config, factory, and projection-packing tests pass. Runtime version
|
|
837
|
+
reports 5.1.1.
|
|
@@ -5,6 +5,7 @@ from typing import TYPE_CHECKING
|
|
|
5
5
|
|
|
6
6
|
__version__ = version("stackformers")
|
|
7
7
|
|
|
8
|
+
from stackformers.alignment import AlignmentConfig
|
|
8
9
|
from stackformers.all_valid_decoder import (
|
|
9
10
|
AllValidCachedDecoderWrapper,
|
|
10
11
|
AllValidCrossAttentionCacheBuilder,
|
|
@@ -65,7 +66,6 @@ from stackformers.decoder_cache import (
|
|
|
65
66
|
CachedSandwichNormDecoderLayer,
|
|
66
67
|
DecoderCrossAttentionCacheBuilder,
|
|
67
68
|
)
|
|
68
|
-
from stackformers.dimension_rounding import DimensionRoundingConfig
|
|
69
69
|
from stackformers.encoder import Encoder
|
|
70
70
|
from stackformers.feedforward import (
|
|
71
71
|
GEGLU,
|
|
@@ -176,7 +176,7 @@ from stackformers.sequence import (
|
|
|
176
176
|
)
|
|
177
177
|
|
|
178
178
|
__all__ = [
|
|
179
|
-
"
|
|
179
|
+
"AlignmentConfig",
|
|
180
180
|
"AllValid",
|
|
181
181
|
"materialize_padding_mask",
|
|
182
182
|
"AllValidCachedDecoderWrapper",
|
stackformers-5.1.0/stackformers/dimension_rounding.py → stackformers-5.1.1/stackformers/alignment.py
RENAMED
|
@@ -7,7 +7,7 @@ from pydantic import BaseModel, Field
|
|
|
7
7
|
from stackformers.result import Err, Ok, Result
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
class
|
|
10
|
+
class AlignmentConfig(BaseModel, frozen=True):
|
|
11
11
|
"""Choose a width multiple and direction; this changes parameter shapes, not padding."""
|
|
12
12
|
|
|
13
13
|
multiple_of: int = Field(gt=0, description="Positive multiple required of the rounded width.")
|
|
@@ -148,16 +148,16 @@ retain mask-only metadata for compatibility with existing exported cache structu
|
|
|
148
148
|
|
|
149
149
|
## Optional dimension rounding
|
|
150
150
|
|
|
151
|
-
Every variant accepts `
|
|
151
|
+
Every variant accepts `alignment: AlignmentConfig | None`, imported from
|
|
152
152
|
`stackformers`. The default `None` preserves existing widths and warnings. For example:
|
|
153
153
|
|
|
154
154
|
```python
|
|
155
|
-
from stackformers import
|
|
155
|
+
from stackformers import AlignmentConfig
|
|
156
156
|
|
|
157
|
-
rounding =
|
|
157
|
+
rounding = AlignmentConfig(multiple_of=64, rounding_mode="ceil")
|
|
158
158
|
```
|
|
159
159
|
|
|
160
|
-
Pass `
|
|
160
|
+
Pass `alignment=rounding` to the config to round `dim_head`.
|
|
161
161
|
`"floor"` rounds down; `"ceil"` rounds up and is the default. Exact multiples stay unchanged;
|
|
162
162
|
a result of zero is rejected during config validation. The external model width stays unchanged.
|
|
163
163
|
This selects actual parameter shapes rather than padding tensors, so enabling it can change
|
|
@@ -16,7 +16,7 @@ from pydantic import (
|
|
|
16
16
|
)
|
|
17
17
|
|
|
18
18
|
from stackformers._result import unwrap_or_raise
|
|
19
|
-
from stackformers.
|
|
19
|
+
from stackformers.alignment import AlignmentConfig
|
|
20
20
|
from stackformers.result import Err, Ok, Result
|
|
21
21
|
|
|
22
22
|
_ALIGN = 64 # tensor-core alignment for FP16/BF16
|
|
@@ -61,7 +61,7 @@ class _SelfAttentionConfigBase(BaseModel, frozen=True):
|
|
|
61
61
|
description="Model (embedding) dimension — input and output width of the attention sublayer.", # noqa: E501
|
|
62
62
|
)
|
|
63
63
|
heads: int = Field(default=8, gt=0, description="Number of query heads.")
|
|
64
|
-
|
|
64
|
+
alignment: AlignmentConfig | None = None
|
|
65
65
|
dim_head: int = Field(
|
|
66
66
|
default=64,
|
|
67
67
|
validate_default=True,
|
|
@@ -109,8 +109,8 @@ class _SelfAttentionConfigBase(BaseModel, frozen=True):
|
|
|
109
109
|
@classmethod
|
|
110
110
|
def _round_dim_head(cls, value: int, info: ValidationInfo) -> int:
|
|
111
111
|
"""Resolve head geometry before admission, warnings, and module construction."""
|
|
112
|
-
match info.data.get("
|
|
113
|
-
case
|
|
112
|
+
match info.data.get("alignment"):
|
|
113
|
+
case AlignmentConfig() as rounding:
|
|
114
114
|
return unwrap_or_raise(rounding.round_dimension(value))
|
|
115
115
|
case _:
|
|
116
116
|
return value
|
|
@@ -211,7 +211,7 @@ class _CrossAttentionConfigBase(BaseModel, frozen=True):
|
|
|
211
211
|
description="Model (embedding) dimension — input and output width of the attention sublayer.", # noqa: E501
|
|
212
212
|
)
|
|
213
213
|
heads: int = Field(default=8, gt=0, description="Number of query heads.")
|
|
214
|
-
|
|
214
|
+
alignment: AlignmentConfig | None = None
|
|
215
215
|
dim_head: int = Field(
|
|
216
216
|
default=64,
|
|
217
217
|
validate_default=True,
|
|
@@ -246,8 +246,8 @@ class _CrossAttentionConfigBase(BaseModel, frozen=True):
|
|
|
246
246
|
@classmethod
|
|
247
247
|
def _round_dim_head(cls, value: int, info: ValidationInfo) -> int:
|
|
248
248
|
"""Resolve head geometry before admission, warnings, and module construction."""
|
|
249
|
-
match info.data.get("
|
|
250
|
-
case
|
|
249
|
+
match info.data.get("alignment"):
|
|
250
|
+
case AlignmentConfig() as rounding:
|
|
251
251
|
return unwrap_or_raise(rounding.round_dimension(value))
|
|
252
252
|
case _:
|
|
253
253
|
return value
|
|
@@ -40,16 +40,16 @@ result of the first.
|
|
|
40
40
|
|
|
41
41
|
## Optional dimension rounding
|
|
42
42
|
|
|
43
|
-
Every variant accepts `
|
|
43
|
+
Every variant accepts `alignment: AlignmentConfig | None`, imported from
|
|
44
44
|
`stackformers`. The default `None` preserves existing widths and warnings. For example:
|
|
45
45
|
|
|
46
46
|
```python
|
|
47
|
-
from stackformers import
|
|
47
|
+
from stackformers import AlignmentConfig
|
|
48
48
|
|
|
49
|
-
rounding =
|
|
49
|
+
rounding = AlignmentConfig(multiple_of=64, rounding_mode="ceil")
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
Pass `
|
|
52
|
+
Pass `alignment=rounding` to the config to round `inner_dim` after the gated or
|
|
53
53
|
non-gated width formula.
|
|
54
54
|
`"floor"` rounds down; `"ceil"` rounds up and is the default. Exact multiples stay unchanged;
|
|
55
55
|
a result of zero is rejected during config validation. The external model width stays unchanged.
|
|
@@ -9,7 +9,7 @@ from pydantic import BaseModel, Field, model_validator
|
|
|
9
9
|
from typing_extensions import override
|
|
10
10
|
|
|
11
11
|
from stackformers._result import unwrap_or_raise
|
|
12
|
-
from stackformers.
|
|
12
|
+
from stackformers.alignment import AlignmentConfig
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class _FFBase(BaseModel):
|
|
@@ -17,7 +17,7 @@ class _FFBase(BaseModel):
|
|
|
17
17
|
|
|
18
18
|
dim: int = Field(gt=0)
|
|
19
19
|
mult: float = Field(default=4.0, gt=0.0)
|
|
20
|
-
|
|
20
|
+
alignment: AlignmentConfig | None = None
|
|
21
21
|
dropout: float = Field(default=0.0, ge=0.0, le=1.0)
|
|
22
22
|
|
|
23
23
|
_ALIGN = 64 # tensor-core alignment for FP16/BF16
|
|
@@ -41,8 +41,8 @@ class _FFBase(BaseModel):
|
|
|
41
41
|
def inner_dim(self) -> int:
|
|
42
42
|
"""Return the effective hidden width, applying optional rounding after GLU scaling."""
|
|
43
43
|
dimension = self._unrounded_inner_dim
|
|
44
|
-
match self.
|
|
45
|
-
case
|
|
44
|
+
match self.alignment:
|
|
45
|
+
case AlignmentConfig() as rounding:
|
|
46
46
|
return unwrap_or_raise(rounding.round_dimension(dimension))
|
|
47
47
|
case None:
|
|
48
48
|
return dimension
|
|
@@ -6,7 +6,7 @@ import pytest
|
|
|
6
6
|
import torch
|
|
7
7
|
from pydantic import ValidationError
|
|
8
8
|
|
|
9
|
-
from stackformers import
|
|
9
|
+
from stackformers import AlignmentConfig
|
|
10
10
|
from stackformers.attention.config import (
|
|
11
11
|
CrossAttentionConfig,
|
|
12
12
|
PackedCrossAttentionConfig,
|
|
@@ -44,8 +44,8 @@ def config_type(request: pytest.FixtureRequest) -> AttentionConfigType:
|
|
|
44
44
|
@pytest.mark.parametrize(("mode", "expected"), [("floor", 64), ("ceil", 128)])
|
|
45
45
|
def test_rounded_geometry(config_type: AttentionConfigType, mode: str, expected: int) -> None:
|
|
46
46
|
"""Store effective head width while preserving model width and GQA grouping."""
|
|
47
|
-
rounding =
|
|
48
|
-
config = config_type(dim=256, heads=4, kv_heads=2, dim_head=70,
|
|
47
|
+
rounding = AlignmentConfig.model_validate({"multiple_of": 64, "rounding_mode": mode})
|
|
48
|
+
config = config_type(dim=256, heads=4, kv_heads=2, dim_head=70, alignment=rounding)
|
|
49
49
|
assert config.dim == 256
|
|
50
50
|
assert config.dim_head == expected
|
|
51
51
|
assert config.groups == 2
|
|
@@ -55,7 +55,7 @@ def test_rounded_geometry(config_type: AttentionConfigType, mode: str, expected:
|
|
|
55
55
|
|
|
56
56
|
def test_default_head_width_is_rounded(config_type: AttentionConfigType) -> None:
|
|
57
57
|
"""Omitting dim_head still applies the explicitly chosen rounding policy."""
|
|
58
|
-
config = config_type(dim=512,
|
|
58
|
+
config = config_type(dim=512, alignment=AlignmentConfig(multiple_of=128))
|
|
59
59
|
assert config.dim_head == 128
|
|
60
60
|
|
|
61
61
|
|
|
@@ -72,7 +72,7 @@ def test_floor_rejects_zero(config_type: AttentionConfigType) -> None:
|
|
|
72
72
|
config_type(
|
|
73
73
|
dim=512,
|
|
74
74
|
dim_head=32,
|
|
75
|
-
|
|
75
|
+
alignment=AlignmentConfig(multiple_of=64, rounding_mode="floor"),
|
|
76
76
|
)
|
|
77
77
|
|
|
78
78
|
|
|
@@ -86,8 +86,8 @@ def tokens(device_dtype: tuple[torch.device, torch.dtype]) -> PaddedTensor:
|
|
|
86
86
|
@pytest.mark.parametrize("mode", ["floor", "ceil"])
|
|
87
87
|
def test_rounded_forward(config_type: AttentionConfigType, mode: str, tokens: PaddedTensor) -> None:
|
|
88
88
|
"""Rounded geometry constructs the same projections as an explicit head width."""
|
|
89
|
-
rounding =
|
|
90
|
-
config = config_type(dim=256, heads=4, kv_heads=2, dim_head=70,
|
|
89
|
+
rounding = AlignmentConfig.model_validate({"multiple_of": 64, "rounding_mode": mode})
|
|
90
|
+
config = config_type(dim=256, heads=4, kv_heads=2, dim_head=70, alignment=rounding)
|
|
91
91
|
explicit = config_type(dim=256, heads=4, kv_heads=2, dim_head=config.dim_head)
|
|
92
92
|
match config, explicit:
|
|
93
93
|
case SelfAttentionConfig(), SelfAttentionConfig():
|
|
@@ -6,7 +6,7 @@ import pytest
|
|
|
6
6
|
import torch
|
|
7
7
|
from pydantic import TypeAdapter, ValidationError
|
|
8
8
|
|
|
9
|
-
from stackformers import
|
|
9
|
+
from stackformers import AlignmentConfig
|
|
10
10
|
from stackformers.feedforward.config import (
|
|
11
11
|
FeedForwardConfig,
|
|
12
12
|
GEGLUConfig,
|
|
@@ -56,8 +56,8 @@ def test_hidden_width(
|
|
|
56
56
|
config_type: FeedForwardConfigType, mode: str, gated: int, non_gated: int
|
|
57
57
|
) -> None:
|
|
58
58
|
"""Rounding follows GLU scaling and survives discriminated JSON serialization."""
|
|
59
|
-
rounding =
|
|
60
|
-
config = config_type(dim=257,
|
|
59
|
+
rounding = AlignmentConfig.model_validate({"multiple_of": 64, "rounding_mode": mode})
|
|
60
|
+
config = config_type(dim=257, alignment=rounding)
|
|
61
61
|
expected = non_gated if config.kind in ("gelu", "relu_squared") else gated
|
|
62
62
|
assert config.inner_dim == expected
|
|
63
63
|
restored = TypeAdapter(FeedForwardConfig).validate_json(config.model_dump_json())
|
|
@@ -81,9 +81,7 @@ def test_disabled_rounding(config_type: FeedForwardConfigType) -> None:
|
|
|
81
81
|
def test_floor_rejects_zero(config_type: FeedForwardConfigType) -> None:
|
|
82
82
|
"""A zero-width floor is rejected before constructing any layers."""
|
|
83
83
|
with pytest.raises(ValidationError, match="positive width"):
|
|
84
|
-
config_type(
|
|
85
|
-
dim=1, dimension_rounding=DimensionRoundingConfig(multiple_of=64, rounding_mode="floor")
|
|
86
|
-
)
|
|
84
|
+
config_type(dim=1, alignment=AlignmentConfig(multiple_of=64, rounding_mode="floor"))
|
|
87
85
|
|
|
88
86
|
|
|
89
87
|
@pytest.fixture
|
|
@@ -98,8 +96,8 @@ def test_rounded_forward(
|
|
|
98
96
|
config_type: FeedForwardConfigType, mode: str, tokens: torch.Tensor
|
|
99
97
|
) -> None:
|
|
100
98
|
"""Construction from rounded widths matches explicitly chosen hidden geometry."""
|
|
101
|
-
rounding =
|
|
102
|
-
config = config_type(dim=257,
|
|
99
|
+
rounding = AlignmentConfig.model_validate({"multiple_of": 64, "rounding_mode": mode})
|
|
100
|
+
config = config_type(dim=257, alignment=rounding)
|
|
103
101
|
scale = 1.0 if config.kind in ("gelu", "relu_squared") else 2 / 3
|
|
104
102
|
# Add half a unit to avoid float truncation at an exact hidden-width boundary.
|
|
105
103
|
reference_config = config_type(dim=257, mult=(config.inner_dim + 0.5) / (257 * scale))
|
stackformers-5.1.0/tests/test_dimension_rounding.py → stackformers-5.1.1/tests/test_alignment.py
RENAMED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import pytest
|
|
4
4
|
from pydantic import ValidationError
|
|
5
5
|
|
|
6
|
-
from stackformers import
|
|
6
|
+
from stackformers import AlignmentConfig
|
|
7
7
|
from stackformers.result import Err, Ok
|
|
8
8
|
|
|
9
9
|
|
|
@@ -13,13 +13,13 @@ from stackformers.result import Err, Ok
|
|
|
13
13
|
)
|
|
14
14
|
def test_round_dimension(mode: str, dimension: int, expected: int) -> None:
|
|
15
15
|
"""Rounding is directional and leaves exact multiples unchanged."""
|
|
16
|
-
config =
|
|
16
|
+
config = AlignmentConfig.model_validate({"multiple_of": 64, "rounding_mode": mode})
|
|
17
17
|
assert config.round_dimension(dimension) == Ok(expected)
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
def test_zero_floor() -> None:
|
|
21
21
|
"""A floor below one multiple is a recoverable failure."""
|
|
22
|
-
result =
|
|
22
|
+
result = AlignmentConfig(multiple_of=64, rounding_mode="floor").round_dimension(63)
|
|
23
23
|
assert isinstance(result, Err)
|
|
24
24
|
assert str(result.error) == "Dimension rounding must produce a positive width"
|
|
25
25
|
|
|
@@ -31,4 +31,4 @@ def test_zero_floor() -> None:
|
|
|
31
31
|
def test_invalid_policy(payload: dict[str, int | str]) -> None:
|
|
32
32
|
"""Reject invalid multiples and unsupported rounding modes at the boundary."""
|
|
33
33
|
with pytest.raises(ValidationError):
|
|
34
|
-
|
|
34
|
+
AlignmentConfig.model_validate(payload)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|