Optimize CPU operand materialization with blocked pooled copies - #56
Conversation
|
Isolated stacked diff against the #54 head branch: exAClior/omeinsum-rs@perf/complex-gemm...perf/issue-55-materialization — three files, one commit ( |
cee9fae to
0b2d127
Compare
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
0b2d127 to
96c15ce
Compare
|
Scope and memory-retention note: This optimization affects CPU operand materialization across all scalar types and algebra paths, not only large Complex64/TDVP workloads. The blocked copy is expected to help large permutations, but the crossover for tiny permutations has not yet been benchmarked. The thread-local cache may retain up to two 64 MiB buffers per scalar type per thread—a theoretical 128 MiB/type/thread high-water mark. The current contraction path generally needs only one packing buffer at a time, so please advise whether the pool should retain only one buffer or use a lower cap before merge. |
Summary
strided-perm's blocked copyCloses #55.
Why this is separate
This is stacked on #54 because the profiling was discovered while validating its Complex64 contractions, but the fix is generic CPU operand materialization. It is deliberately a separate commit and PR: no Tenferro dependency, benchmark harness, profiling source, Makefile change, or run artifact is included.
Until #54 lands, GitHub will show its prerequisite commits in this PR's main-branch comparison. The materialization change itself is the single commit
cee9faeand touches only:Cargo.tomlsrc/backend/cpu/buffer_pool.rssrc/backend/cpu/contract.rsEvidence
The pre-fix right-layout pack took 137/424 us at
chi=64, versus Tenferro's 16/31 us. Prepacking removed 87%/97% of the public-path gap.With this patch, the reverse-order all-size run improved OMEinsum by 8-20%. Post-fix OMEinsum/Tenferro ratios were 1.00-1.04x across all six right-layout cases. At
chi=64:h1-righth2-rightWarm allocation deltas versus prepacked input fell from 2,359,616/4,718,992 bytes to 800/944 metadata bytes.
The first blocked-copy implementation exposed a SIGSEGV for a zero-sized layout. The final code bypasses the external kernel for
numel == 0, with a dedicated regression test; the existing zero-dimension integration test also passes.Verification
make checkcargo package --allow-dirtyDepends on #54.