Repository navigation
[Frontend] A prefill's block is bounded by one query block's scratch, not S / BQ of them - #402
Merged
Merged
Conversation
… not S / BQ of them The static query loop's blocks each die once their block has stored, and the compiler (PyTorchSim-Triton-Backend's torchsim-share-spad-buffers) gives them one set of scratchpad buffers. The bound therefore no longer grows with S: S 4096 keeps splash's 1024 block instead of 512, and S 8192 keeps 1024 instead of 128. This needs the compiler pin to carry that pass: on a compiler without it, a 1024 block at S >= 4096 overruns the scratchpad. test_fused_sdpa spad: doubling S keeps min(S, SPLASH_BLOCK); doubling D halves the block until one row per lane overruns the bound and the plan declines.
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
attention.fused_planbounds a prefill's block by one query block's scratch, not by S / BQ blocks of it.The prefill kernel's static query loop makes a new set of q, K^T, V, score and accumulator buffers per query block, each dead once its block has stored.
_fitstookcopies=S // blocksets of them, so the bound grew with S and the block was halved to fit: S 4096 ran at 512 and S 8192 at 128, against splash's 1024 on v6e. A smaller block runs the same rows as more, shorter steps, each paying the matrix unit's fill and drain again.Depends on
PyTorchSim-Triton-Backend #227,
torchsim-share-spad-buffers, which gives the query blocks one set of scratchpad buffers. On a compiler without it, a 1024 block at S >= 4096 overruns the scratchpad. Draft until #227 is on PTB main and this repository's compiler pin carries it. The pin bump goes in with this PR.Test
tests/ops/attention/test_fused_sdpa.pyspad:The S case fails on the tree before this change.
Numbers (local, labelled)
These were measured with PTB's validation harness:
validation/attention/simulate_shapes.py --bundle. The bundle's prefill specs carry the blocks this change gives (1024 at S >= 4096). The compiler is PTB main with its open PRs #222, #223, #227 and #228 stacked, at TOGSim e2d7a49. The ratio is TOGSim time ÷ v6elatency_ns.CI numbers follow once the pin carries #227.
🤖 Generated with Claude Code