Repository navigation
[Frontend] A reduction's blocks fill the tile budget, and its kept axis is read from its strides - #411
Merged
YWHyuk merged 1 commit intoOct 22, 2026
Conversation
…is is read from its strides Two changes to the block a reduction kernel is pinned with. A reduction along its contiguous axis kept XBLOCK at the lane count (128) and took only R0_BLOCK from the tile budget. With a short reduced axis the tile was 0.8% of the budget: Qwen3-8B's q_norm ([T, 32, 128], RMSNorm over 128) ran 128 x 128 tiles, 256 of them at T 1024, each waiting on its DMA. kept_axis_rows_block now takes as many rows of R0_BLOCK as the budget the other blocks use (one lane's, times the lanes) holds, at least the lane cover: 128 -> 16384 rows for q_norm. Which axis is contiguous came from Inductor's reduction hint, OUTER meaning the kept axis. Inductor leaves the hint DEFAULT for any kernel of at least num_sm * 64 rows (ir.py num_splits), whatever its strides, so the GEMV 1 x 4096 @ 4096 x 24576 (gate_up at decode) took the row path, 192 programs each reading 256-B runs of the weight at a 48 KiB stride, while the same GEMV at N 4096 (q_proj) took the kept-axis one. _kept_axis_contiguous now reads the unit-stride axis of the kernel's largest read (MemoryDep strides, bytes from numbytes_hint).
This was referenced Oct 22, 2026
student-Jungmin
added a commit
to PSAL-POSTECH/PyTorchSim-Triton-Backend
that referenced
this pull request
Nov 10, 2026
…e tile budget (PyTorchSim #411) The 31 qwen3_8b workloads whose kernels change when PyTorchSim pins a reduction's blocks to the tile budget and reads its kept axis from strides (PSAL-POSTECH/PyTorchSim#411, 38bbf999), built with #409's bundle.py on it: every layer, q_norm, k_norm and rmsnorm at T >= 256, gate_up at T 1 (the GEMV #270 names) and down at T 4096 (a template timed again). The other 85 are byte-equal and stay. bundle.json is main's.
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.
Cause (found by the compiler's validation error loop: PSAL-POSTECH/PyTorchSim-Triton-Backend#269, #270, #271)
XBLOCKat the lane count (128) and took onlyR0_BLOCKfrom the tile budget. With a short reduced axis the tile is a sliver of the budget: Qwen3-8B's q_norm / k_norm (RMSNorm over 128, fused with rope in the layer) run as 128 x 128 tiles, one DMA wait each.DEFAULTfor any kernel of at leastnum_sm * 64rows, whatever its strides, so gate_up at decode (1 x 4096 @ 4096 x 24576) took the row path:XBLOCK=128, R0_BLOCK=4096, grid=(192), each program reading 256-B runs of the weight at a 48 KiB stride ([TOGSim] Trace-bridge dependency + SRAM version redesign #270), while q_proj (N 4096) took the kept-axis path.Change
kept_axis_rows_blocktakes as many rows ofR0_BLOCKas the budget the other blocks use holds (one lane's, times the lanes), at least the lane cover._kept_axis_contiguousreads the unit-stride axis of the kernel's largest read (MemoryDep strides, bytes fromnumbytes_hint) instead of the hint.Tests:
tests/system/test_reduction_tiling.py(pass locally).Numbers (compiler CI, qwen3_8b suite; TOGSim ÷ v6e). The bundle rebuilt with this PR is PSAL-POSTECH/PyTorchSim-Triton-Backend#273 (31 of 116 workloads change). Before: main 4b2b1ad, run 39632293777. After: main 23b108c, run 39686040845; the compiler is the same in both.
Open: the norms are now faster than v6e. rmsnorm runs 0.63–0.79 at T ≥ 128 (0.37 at T 1, unchanged), q_norm 0.66–0.83, k_norm 0.53–0.79. Before, they were 0.68–0.90 (rmsnorm), 2.39–5.24 (q_norm) and 0.94–3.51 (k_norm). The geomean moved from slow to fast by about the same distance (1.50 → 0.655), so this group is not better; it needs its own cause (what a large norm tile costs on v6e that TOGSim does not charge).