perf(lindblad): store the expm generator cache as blocked flat CSC - #229
Merged
Merged
Conversation
build_mf_cols / build_orbit_rep_cols returned one Vec per column, each reserved at the full L* output count although only in-basis entries are kept. On large bases this over-reserves the cache severalfold and leaves one small allocation per basis string per expm call for the allocator to retain. The cache is now a BlockCsc: blocks of up to 4096 columns, each an exactly sized offsets/rows/vals triple (structure of arrays, 12 B per real entry instead of 16 B). CscOp::dot keeps the same per-thread column partition, so results are bit-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
david-pl
approved these changes
Sep 28, 2026
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.
Stacked on #222 (
split/5-kossakowski).Summary
build_mf_cols/build_orbit_rep_colsreturned oneVecper column, each reserved at the full L* output count although only in-basis entries are kept. The expm generator cache is now aBlockCsc: blocks of up to 4096 columns, each an exactly sizedoffsets/rows/valstriple (structure of arrays, 12 B per real entry instead of 16 B).CscOp::dotkeeps the same per-thread column partition, so results are bit-identical.Single commit,
crates/ppvm-lindblad/src/mf_expm.rsonly.Measurements
pc_stepon the two-leg XY ladder with a local probe (not part of this PR): L = 41 rungs (N = 82),max_basis = 2^18,admit_basis = 3·2^18, dt = 0.1, 25 steps, 4 threads,drop_tol = 0. Apple M4 MacBook Air (fanless, so wall times are only comparable within a rep). Max RSS from/usr/bin/time -l; live-heap peak from a counting global allocator./usr/bin/time -l) drops by about 3–13%. With the macOS system allocator, RSS is not reproducible (768–1237 MiB for the same binary), so the effect cannot be resolved there.Tests:
cargo test -p ppvm-lindbladpasses (8/8) with this change stacked together with the skip-empty-hop2 PR; not yet run on this branch alone (CI will).🤖 Generated with Claude Code