Repository navigation
Accelerate FP32 pooling and expose NumPy native bags with memory preferences - #80
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FP32 native bag reduction used the general per-element dtype decoder, making pooling expensive after the raw-gather optimization. Expose independent FP32 dimensions to compiler vectorization while preserving original-row order, FP64 products/sums and FP32 output. Add a NumPy-only
embedding_bag_arrayinterface and optional raw mmap fusion for callers prioritizing row-staging memory.The default keeps staged/vectorized reduction: on existing AG News/DBpedia seed-3 tables (6.99M–34.05M rows), paired public NumPy mean-pooling calls improve 1.71–1.80× at batch 1 and 2.98–3.12× at batch 32, with every feature checked against source FP64-to-FP32 results. Fusion removes the 2 MiB row matrix but loses throughput against staged vectorization in the AG News ablation, so it is opt-in. The Zstd control stays around 1.01×. These are pooling calls, not full-model speedups or new capacity savings.
Wheels and Makefile native builds now use the measured strict
-O3setting. A fresh Python 3.12 build loaded outside the checkout passed NumPy bag/mode-switch checks without importing Torch; an additional 45-test local native-O3run passed.Validation: 381 local tests passed (149 optional skips), 56 remote native/PyTorch tests passed without skips, and ASan/UBSan passed locally/remotely. Includes FP32/FP16/BF16, weighted sums, padding, empty bags, forwarding, caches, chunking and output validation. Existing formats and ABI signatures remain compatible; default older-library loading stays supported.
Commands, compiler diagnostics, hashes, all 27 timing cells and the fusion ablation are in
evidence/native_bag_vectorization_20261116/(~750 KB compressed). Initial phases fully hashed inputs; the final default run explicitly reuses those frozen hashes, rechecks trace hashes and every source feature, and records parent provenance. No weights, tables or corpus files are added.