Skip to content

[Refactor 3/9] post-grad rewrites as Inductor graph patterns; conv decompositions leave the global table - #452

Merged
student-Jungmin merged 1 commit into
pytorchsim-triton-backendfrom
refactor/r441-4-postgrad-patterns
Oct 24, 2026
Merged

student-Jungmin merged 1 commit into
pytorchsim-triton-backendfrom
refactor/r441-4-postgrad-patterns

Conversation

@student-Jungmin

@student-Jungmin student-Jungmin commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Transposed conv, zero-length GEMM and conv1d go through post-grad rewrites; the depthwise conv decomposition runs in the dispatcher.
  • Pinned by test_conv_transpose, test_zero_length_gemm and test_conv_decomposition.

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 gather for 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.

@student-Jungmin
student-Jungmin force-pushed the refactor/r441-4-postgrad-patterns branch from 13f1c47 to 7cd3f48 Compare October 24, 2026 07:32
@student-Jungmin student-Jungmin changed the title [Refactor 4/8] post-grad rewrites as Inductor graph patterns; conv decompositions leave the global table [Refactor 3/5] post-grad rewrites as Inductor graph patterns; conv decompositions leave the global table Oct 24, 2026
@student-Jungmin
student-Jungmin changed the base branch from refactor/r441-3-registration to refactor/r441-2-fused-kernel October 24, 2026 07:32
@student-Jungmin
student-Jungmin force-pushed the refactor/r441-4-postgrad-patterns branch from 7cd3f48 to d427f57 Compare October 24, 2026 08:17
… 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
student-Jungmin force-pushed the refactor/r441-4-postgrad-patterns branch from d427f57 to 9a4db9d Compare October 24, 2026 11:15
@student-Jungmin
student-Jungmin force-pushed the refactor/r441-2-fused-kernel branch from 1deaa3a to 8fbacef Compare October 24, 2026 11:15
@student-Jungmin student-Jungmin changed the title [Refactor 3/5] post-grad rewrites as Inductor graph patterns; conv decompositions leave the global table [Refactor 3/6] post-grad rewrites as Inductor graph patterns; conv decompositions leave the global table Oct 24, 2026
@student-Jungmin student-Jungmin changed the title [Refactor 3/6] post-grad rewrites as Inductor graph patterns; conv decompositions leave the global table [Refactor 3/7] post-grad rewrites as Inductor graph patterns; conv decompositions leave the global table Oct 24, 2026
@student-Jungmin student-Jungmin changed the title [Refactor 3/7] post-grad rewrites as Inductor graph patterns; conv decompositions leave the global table [Refactor 3/8] post-grad rewrites as Inductor graph patterns; conv decompositions leave the global table Oct 24, 2026
@student-Jungmin student-Jungmin changed the title [Refactor 3/8] post-grad rewrites as Inductor graph patterns; conv decompositions leave the global table [Refactor 3/9] post-grad rewrites as Inductor graph patterns; conv decompositions leave the global table Oct 24, 2026
@student-Jungmin
student-Jungmin marked this pull request as ready for review October 24, 2026 14:00
@student-Jungmin
student-Jungmin changed the base branch from refactor/r441-2-fused-kernel to pytorchsim-triton-backend October 24, 2026 14:00
@student-Jungmin
student-Jungmin merged commit 54f7755 into pytorchsim-triton-backend Oct 24, 2026
@YWHyuk
YWHyuk deleted the refactor/r441-4-postgrad-patterns branch October 27, 2026 07:47
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