Repository navigation
Studio kernels: cold probes check capture on the operand's card, MOSS q/k RoPE int64 offsets, Gemma-4 band route int32 guard - #18141
Merged
Conversation
The kernel multiplied the token index by the fused-QKV row stride in int32, which wraps past 2**31 (a 9216-wide row past 233k tokens). The row index is now int64 before any stride product; the output bits are unchanged. The new CPU test lowers the kernel to TTIR and fails on main.
…nel's int32 limit The long-band route called large_head_attention directly, skipping the int32 span check the large-head router applies on its own path (large_head_attention._shapes_qualify), so a long enough sliding layer reached the int32-addressed kernel. The band route now keeps masked SDPA past that limit. The new test fails on main.
…g before a cold probe verdict() checked torch.cuda.is_current_stream_capturing() before entering the operand's device, so with another card current it read that card's stream and could start the timing / equality probe inside a capture on the operand's card. The check now runs under torch.cuda.device(x.device), with the probe. The new test fails on main.
…and's card too The same order as the row-mod verdict: both cold verdicts read is_current_stream_capturing() on the current card before switching to the operand's. The query now runs under torch.cuda.device(x.device). The new tests fail on main.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
[skip ci]
danielhanchen
added a commit
that referenced
this pull request
Nov 20, 2026
…ot drive (3.2, 3.3) (#18592) `tests/test_diffusion_moss_qk_rope_offsets.py` (#18141) checks that the MOSS q/k RMSNorm + RoPE kernel uses int64 row offsets by lowering it to TTIR offline. Its skip guard only checked that the NVIDIA backend loads, then drove the Triton 3.6+ compiler API: `ASTSource(..., constexprs=...)` and `make_ir(target, options, ...)`. On Triton 3.2 `ASTSource` takes `constants=` and the test fails with `TypeError: ASTSource.__init__() got an unexpected keyword argument 'constexprs'`. On Triton 3.3 `make_ir` has no target argument and the test fails with `TypeError: ASTSource.make_ir() takes 5 positional arguments but 6 were given`. Both versions pass the backend check, so the test reports a failure without ever checking any arithmetic. ## Change The module-level guard also checks that `ASTSource.__init__` takes `constexprs` and `ASTSource.make_ir` takes `target`, and skips the module when either is missing. The TTIR lowering and the int64 assertions are unchanged. ## Tests `tests/test_diffusion_moss_qk_rope_offsets.py`, run with each Triton: - Triton 3.2.0 (torch 2.6 CPU): fails on main with the `constexprs` TypeError, skips here. - Triton 3.3.0 (torch 2.7.1 CPU): fails on main with the `make_ir` TypeError, skips here. - Triton 3.8.0 (torch 2.14 CPU): passes on main and here, still lowering the kernel and checking the `arith.muli` row offsets. Suite (`tests/test_diffusion_moss_qk_rope_offsets.py`, `tests/test_diffusion_moss_speed_routes.py`, Triton 3.8 on CPU): 17 passed, 0 failed on both main and this branch. ## Not proven here The arithmetic is not checked on Triton 3.2 or 3.3 at all: the test skips there. Driving those APIs would not help yet, because on Triton 3.3 the kernel itself fails to lower offline with `NameError('tl is not defined')` (`_qk_rope_kernel()` imports `tl` inside the factory). That is a separate kernel issue and this change does not touch it. Triton 3.4, 3.5 and 3.6 were not run here.
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.
Three fixes from a re-check of recent kernel PRs.
verdict()of the MiniMax-H3 row-mod kernel (video_minimax_h3_rowmod.py), the H3 q/k norm (video_minimax_h3_qknorm.py) and the FLUX.3 q/k RoPE (diffusion_flux3_qk_rope.py) readtorch.cuda.is_current_stream_capturing()on the current card before switching to the operand's card. With another card current, the timing / equality probe could start inside a CUDA graph capture on the operand's card, then cache a failure or raise. The query now runs undertorch.cuda.device(x.device), with the probe.unsloth/models/_block_compile.pycalledlarge_head_attentiondirectly and skipped the int32 span check the large-head router applies on its own path (_shapes_qualify), so a long enough sliding layer reached the int32-addressed kernel. The band route now keeps masked SDPA past that limit.GPU results, base (main 62d66cb) vs this branch
Capture probes, Kaggle 2x T4 (sm75), torch 2.11.0+cu130: cuda:0 current, a
torch.cuda.graphcapture active on cuda:1, operand on cuda:1, cold call, probe runs counted.verdict{exact: False, use: False}; the next eager call still returns the cached failure{exact: True, use: True}verdictCannot copy between CPU and CUDA tensors during CUDA graph captureverdictThe captured graph itself replayed correctly in both arms; the defect is the probe running inside the capture and the cached failure or raise.
MOSS and band route, L4 (sm89), Colab, torch 2.12.1+cu130, Triton 3.7.1:
Tests
studio/backend/tests/test_diffusion_capture_probe_device.pyandtest_h3_row_mod.py::test_cold_verdict_asks_about_capture_on_the_operand_card: on the T4 pair base 3 failed / 14 passed, this branch 17 passed (two-card tests included).studio/backend/tests/test_diffusion_moss_qk_rope_offsets.pylowers the kernel to TTIR and rejects i32 row-stride products: fails on main; on the L4 base 1 failed / 8 passed, this branch 9 passed, and the existing MOSS fused GPU tests pass in both arms.tests/test_block_compile.py::test_gemma4_long_band_past_int32_keeps_the_plain_route: fails on main; on the L4 base 1 failed / 83 passed, this branch 84 passed (4 skips, the same version gates in both arms).test_block_compile.py.Not covered