Repository navigation
Chunk large simulations over voxels across every GPU by default - #44
Merged
Merged
Conversation
execution="auto" is the default. A call too small to repay a launch, or one carrying an autograd graph, runs where its tensors are; a larger one is cut into voxel chunks sized to each card's free memory less a reserve and dealt to every visible GPU, from the host or from a card, with the answer written back where the inputs live. Every pass (forward, jvp, vjp, vjp_jvp) and every physics model chunks: slice profiles, per-voxel rotation pairs, MT lineshape, exchange and tabulated pools, pTx shims. Backward passes run under the policy their forward pass ran under. ModelOperator sizes its chunks on the time series before projection. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PrEk8PfzyAojw2pKzoTiHd
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PrEk8PfzyAojw2pKzoTiHd
mcencini
marked this pull request as ready for review
October 13, 2026 09:21
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.
What changed
execution="auto"is the default for simulators, estimators andModelOperator. A call too small to repay a launch, or one carrying an autograd graph, runs where its tensors are. A larger call is cut into voxel chunks sized to each card's free memory less a 512 MiB reserve and dealt to every visible GPU. This works whether the volume starts on the host or on a card, and the answer is written back on the input's device.Every pass (forward, jvp, vjp, vjp_jvp) and every physics model is chunked: shaped-pulse slice profiles, per-voxel rotation pairs (pTx dynamic transmit), MT lineshape, exchange and tabulated pools, shims and diffusion. A backward pass runs under the policy its forward pass ran under.
ModelOperatorsizes its chunks on the full time series before projection.Why
Matteo asked for this in the thread "blochsim host/device chunking audit": keep the trimmed public API from #41, but run large problems with a bounded VRAM footprint over both cards, the way bartorch's Toeplitz NUFFT does. Before this change:
The audit and the agreed plan are in the project plan
blochsim-execution-audit.md.Validation
pytest tests -n auto: everything passes on CPU. The one exception is a 3-second timing test intests/optim/test_design.py, which failed under xdist contention and passes on its own.tests/sequence/test_chunks.pycompares the whole volume with the chunked volume on all four passes. It covers echo-train, spoiled and shimmed volumes, tabulated pools (2f, 3s/profile, 4s/dynamic, 4s/shimmed), the slice profile, the dynamic pair, and the GPU kernels through_gpu_host. Chunk widths are 1, 2, 4, 7 and 64, over 1 to 3 devices.test_design.pytakes 60 Adam iterations at 0.59 to 0.62 s on this branch against 0.50 to 0.61 s onmain, best of 3, which is within noise. Small design calls with a graph never reach the chunker.pytest tests/sequence/test_chunks.py tests/sequence/test_offload.py tests/sequence/test_execution.py;Documentation impact
docs/explanations/execution.md: the TL;DR, Capabilities, Division of responsibility and Method sections are rewritten for the new default.AGENTS.mdanddocs/developer-guide/documentation.mdno longer name the private knobs.Checklist
pytest tests/passes locally, and a new test covers what changed.pre-commit run --all-filesis clean:ruff formatandruff checkboth pass.bash scripts/build_docs.shstill builds. The build is running now.🤖 Generated with Claude Code
https://claude.ai/code/session_01PrEk8PfzyAojw2pKzoTiHd
Generated by Claude Code