Skip to content

Accelerate FP32 pooling and expose NumPy native bags with memory preferences - #80

Merged
initial-d merged 5 commits into
mainfrom
codex/direct-native-bags
Nov 16, 2026
Merged

initial-d merged 5 commits into
mainfrom
codex/direct-native-bags

Conversation

@initial-d

@initial-d initial-d commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

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_array interface 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 -O3 setting. 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 -O3 run 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.

@initial-d
initial-d merged commit 633cde3 into main Nov 16, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant