Repository navigation
[Refactor 8/9] Block budgets are the machine's spad_budget, not half the scratchpad - #463
Merged
student-Jungmin merged 1 commit intoOct 24, 2026
Conversation
…scratchpad reduction_block_for divided a lane's scratchpad by 2 and gemm_tile_candidates took half of it, the same fact the compiler states as Target.spad_budget, spad_size over the machine's vpu_spad_buffers (2 when unsaid), and refuses a kernel over. Both now read the machine: reduction_block_for divides by CONFIG_MACHINE.spad_buffers, gemm_tile_candidates takes CONFIG_MACHINE.spad_budget per lane and times the lanes for the whole tile. No change on the shipped machines, which state no vpu_spad_buffers: 2 is what they get, and every block and tile is the one before. test_reduction_tiling's new case pins it: a machine of four buffers halves the reduction block and leaves fewer GEMM tiles, each among those of two; on the old code the block stays 8192 too wide. Moved here from PR #445 (spad-budget-tiling), onto pytorchsim/frontend/tiling.py, where this stack moved pytorchsim/codegen/tiling.py.
This was referenced Oct 24, 2026
student-Jungmin
marked this pull request as ready for review
October 24, 2026 14:01
student-Jungmin
changed the base branch from
refactor/r441-7c-cleanup
to
pytorchsim-triton-backend
October 24, 2026 14:01
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.
Draft: waiting for verification (CI and the validation reports) before review.
Part 8 of 9 of the frontend refactor. It is one commit of this part's final state. Stacked on #462 (
refactor/r441-7c-cleanup); review only this PR's commit. It replaces #445, the same change, moved ontopytorchsim/frontend/tiling.py, where this stack movedpytorchsim/codegen/tiling.py.What
reduction_block_fordivided a lane's scratchpad by 2 andgemm_tile_candidatestook half of it: the same fact the compiler states asTarget.spad_budget(spad_size // spad_buffers,vpu_spad_buffers2 when unsaid) and refuses a kernel over. Both now read the machine:reduction_block_fordivides byCONFIG_MACHINE.spad_buffers;gemm_tile_candidatestakesCONFIG_MACHINE.spad_budgeta lane, times the lanes for the whole tile.Behavior change
None on the shipped machines, which state no
vpu_spad_buffers: 2 is what they get, and every block and tile is the one before. A machine that states more buffers (TPU v3 work, PSAL-POSTECH/PyTorchSim-Triton-Backend#343) gets smaller blocks and fewer GEMM tiles.Pinned by
test_reduction_tiling's newtest_the_tile_budget_is_the_machine_s_spad_budget: a machine of four buffers halves the reduction block and leaves fewer GEMM tiles, each among those of two. On the old code the block stays 8192, too wide.Checked locally
PTB 70221f4 with TOGSim 5791272, target tpuv6e:
test_reduction_tiling7/7,test_matmul11/11,test_softmax6/6,test_reduce6/6,test_layernorm,test_module_formpass.test_selectin timing mode passes.