Skip to content

[Refactor 8/9] Block budgets are the machine's spad_budget, not half the scratchpad - #463

Merged
student-Jungmin merged 1 commit into
pytorchsim-triton-backendfrom
refactor/r441-7d-spad-budget
Oct 24, 2026
Merged

student-Jungmin merged 1 commit into
pytorchsim-triton-backendfrom
refactor/r441-7d-spad-budget

Conversation

@student-Jungmin

Copy link
Copy Markdown
Collaborator

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 onto pytorchsim/frontend/tiling.py, where this stack moved pytorchsim/codegen/tiling.py.

What

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 // spad_buffers, 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 a 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 new test_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_tiling 7/7, test_matmul 11/11, test_softmax 6/6, test_reduce 6/6, test_layernorm, test_module_form pass.
  • test_select in timing mode passes.

…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.
@student-Jungmin
student-Jungmin marked this pull request as ready for review October 24, 2026 14:01
@student-Jungmin
student-Jungmin changed the base branch from refactor/r441-7c-cleanup to pytorchsim-triton-backend October 24, 2026 14:01
@student-Jungmin
student-Jungmin merged commit 254e845 into pytorchsim-triton-backend Oct 24, 2026
@YWHyuk
YWHyuk deleted the refactor/r441-7d-spad-budget branch October 27, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant