Repository navigation
[Refactor 3/9] post-grad rewrites as Inductor graph patterns; conv decompositions leave the global table - #452
Merged
student-Jungmin merged 1 commit intoOct 24, 2026
Conversation
student-Jungmin
force-pushed
the
refactor/r441-4-postgrad-patterns
branch
from
October 24, 2026 07:32
13f1c47 to
7cd3f48
Compare
student-Jungmin
changed the base branch from
refactor/r441-3-registration
to
refactor/r441-2-fused-kernel
October 24, 2026 07:32
student-Jungmin
force-pushed
the
refactor/r441-4-postgrad-patterns
branch
from
October 24, 2026 08:17
7cd3f48 to
d427f57
Compare
… decompositions leave the global table post_grad_pass registers each rewrite with register_rewrite, an Inductor graph pattern whose function returns the replacement or a Decline: the node stays, logged with where it runs, and both routes count in CALLS. A transposed convolution and a zero-length GEMM are post-grad rewrites instead of lowering patches, and a 1-D convolution is a 2-D one over a height of 1. The depthwise conv2d decomposition runs in the dispatcher, before AOTAutograd, so npu no longer writes into Inductor's global decomposition table. test_conv_transpose, test_zero_length_gemm and test_conv_decomposition pin them; docs/post_grad_rewrite.md and .ko.md say how to add a rewrite. Comments and docstrings in the files this part changes are at most three lines, none inside a function body.
student-Jungmin
force-pushed
the
refactor/r441-4-postgrad-patterns
branch
from
October 24, 2026 11:15
d427f57 to
9a4db9d
Compare
student-Jungmin
force-pushed
the
refactor/r441-2-fused-kernel
branch
from
October 24, 2026 11:15
1deaa3a to
8fbacef
Compare
student-Jungmin
marked this pull request as ready for review
October 24, 2026 14:00
student-Jungmin
changed the base branch from
refactor/r441-2-fused-kernel
to
pytorchsim-triton-backend
October 24, 2026 14:00
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 3 of 9 of the frontend refactor. It is one commit (7cd3f48) of this part's final state, so each part reviews on its own. Stacked on #450 (
refactor/r441-2-fused-kernel); review only this PR's commit.What
post_grad_pass registers each rewrite with register_rewrite, an Inductor graph pattern whose
function returns the replacement or a Decline: the node stays, logged with where it runs, and
both routes count in CALLS. A transposed convolution and a zero-length GEMM are post-grad rewrites
instead of lowering patches, and a 1-D convolution is a 2-D one over a height of 1. The depthwise
conv2d decomposition runs in the dispatcher, before AOTAutograd, so npu no longer writes into
Inductor's global decomposition table. test_conv_transpose, test_zero_length_gemm and
test_conv_decomposition pin them; docs/post_grad_rewrite.md and .ko.md say how to add a rewrite.
Behavior change
Checked locally
At this PR's tip, with PTB 522042a (this branch's pin) and TOGSim b9c9519, everything passes: test_add 5/5, test_matmul 11/11, test_histc, test_eager, test_patch_scope 8/8, test_custom_fused_kernel, test_topk, test_conv_transpose 5/5, test_zero_length_gemm 7/7.
No cycle numbers here: nothing in this part is meant to change a kernel's cycles. The CI validation report is the check.
Comments and docstrings in the files these parts change are at most three lines, none inside a function body. What they no longer say is in the commit message. Test files whose only change here is an import rename (test_result -> check_result) and scripts/ keep their comments, as this change did not touch that code.
Known gap
On the compiler pin (PTB 522042a), test_conv_decomposition's depthwise_grad case fails in the compiler's lower step. It reports
runtime attribute: the index tile of "torchsim.transfer" ... is no one entry per position of its gatherfor the forward stencil kernel of the training graph. The other 6 cases pass. On #441 the same backward does not run at all (convolution_backward_overrideable: NotImplementedError). On the earlier compiler (PTB 1b35878) the case passed. Cause: PTB's fit-transfers-to-descriptor folded the gather's data tile but not its tile-shaped index tile. Fixed in PSAL-POSTECH/PyTorchSim-Triton-Backend#351; with it, all 11 cases pass. This case needs a compiler pin that carries #351.