Repository navigation
Use int64 addressing in _triton_permute_bwd_kernel - #4988
Open
indianspeedster wants to merge 1 commit into
Open
indianspeedster wants to merge 1 commit into
indianspeedster wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/4988
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
The kernel computed `row * cols` in int32 for both its gradient load and its scatter store, so once rows * cols >= 2**31 the addresses overflowed. On MI355X and B200 the access then hits an illegal address. Widen the loaded destination rows and the gradient row offsets to int64. _triton_permute_bwd is the backward of permute_mxfp8_fwd_hp_bwd, so this fixes that path too. Test: test_triton_permute_bwd_addresses_past_int32 covers the store (a small gradient scattered past 2**31 output elements) and the load (a gradient with more than 2**31 elements). It runs the kernel in a child process, so an illegal address or hang becomes a normal test failure.
indianspeedster
force-pushed
the
fix/permute-bwd-int64
branch
from
October 8, 2026 19:52
92839f1 to
70e24da
Compare
indianspeedster
marked this pull request as ready for review
October 8, 2026 20:03
indianspeedster
requested review from
andrewor14,
jerryzh168 and
vkuzo
as code owners
October 8, 2026 20:03
This branch has not been deployed
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.
Summary
_triton_permute_bwd_kernelcomputesrow * colsin int32 for both its gradientload and its scatter store. Once
rows * cols >= 2**31the address overflows andthe access hits an illegal address. This widens the loaded destination rows and
the gradient row offsets to int64.
The size is reachable in practice: DeepSeek-V3-16B with EP=8 and imbalanced
routing sent 1,141,504 rows x 2048 cols = 2,337,800,192 elements through this
kernel.
_triton_permute_bwdis also the backward ofpermute_mxfp8_fwd_hp_bwd,so this fixes that path too.
Split out of #4623 as requested in review. #4623 is stacked on this PR, because
it routes the bf16
permute_and_padbackward through this kernel.Test plan
New test
test_triton_permute_bwd_addresses_past_int32intest/prototype/moe_training/ep/test_kernels.pycovers both sides of the fix:than 231 elements (the last 1024 of those rows start past 231).
small output.
It runs the kernel in a child process with a 120 s timeout, so an illegal address
or hang fails the test instead of crashing the pytest process. The child is
pointed at the same torchao the test imported. Each case needs about 4 GiB of GPU
memory; the test skips with less than 6 GiB free.
test_permute.py+ep/test_kernels.pywith this changemain's kernelTest command on both machines:
pytest test/prototype/moe_training/ep/test_permute.py test/prototype/moe_training/ep/test_kernels.py. MI355X: torch 2.15.0.dev+rocm7.14, triton 3.8.0; becausemaingates these files to SM100, the MI355X runs override that gate locally. B200: torch 2.14.1+cu130, triton 3.8.0.No upstream CI runner has SM100, and these test files are gated to SM100 on
main, so today these tests run in no CI job. After #4987 (which enables them on gfx950) they run in the ROCm regression job (regression_test_rocm.yml, MI350 runner, triggered byciflow/rocmor a push tomain).This PR and #4989 both append tests to the end of
ep/test_kernels.py, sowhichever lands second needs a trivial rebase.
Authored with assistance from an AI coding agent.