Repository navigation
Fused Qwen3 QK norm + RoPE: on by default on NVIDIA CUDA - #15189
Merged
Merged
Conversation
UNSLOTH_FUSED_QKNORM_ROPE was opt-in. The training path now uses the fused q/k RMSNorm + RoPE kernel by default on CUDA. ROCm keeps the unfused path unless UNSLOTH_FUSED_QKNORM_ROPE=1; =0 (or false/no/off) disables it everywhere.
Member
Author
|
@codex review |
Codex Review SummaryThis 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. |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
danielhanchen
added a commit
that referenced
this pull request
Oct 25, 2026
## Summary #15180 (per-GPU num_warps tables) added `tests/test_norm_arch_warps.py`, whose CUDA case skips with `torch.cuda.is_available()`. `tests/python/test_accelerator_skip_guards.py::test_no_skip_guard_reads_a_spoofable_accelerator_probe` rejects that on main, so `Repo tests (CPU, studio)` is red on unrelated PRs (for example #15189): ``` test_norm_arch_warps.py:114: torch.cuda.is_available() ``` `tests/_zoo_aggressive_cuda_spoof.py` patches `torch.cuda.is_available()` to True for the whole process, so on a CPU-only runner that skip stops skipping whenever it shares a session with `tests/version_compat` or `tests/vllm_compat`. The test is wrong here, not the kernels. ## Change - `tests/test_norm_arch_warps.py`: skip on `has_real_cuda()` from `tests/_shared/real_accelerator.py`, as `test_block_compile.py`, `test_bnb_nf4_override.py` and others do. ## Verification - `tests/python/test_accelerator_skip_guards.py`: `1 failed, 23 passed` on main, `24 passed` with this change. - `tests/test_norm_arch_warps.py` on CPU: `5 passed, 4 skipped`, the same as before. - On a GPU host `has_real_cuda()` is True, so the CUDA cases still run there. On a CPU host it is False.
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.
#13890 added a fused Triton kernel for Qwen3's q/k RMSNorm + RoPE in training. It sits behind
UNSLOTH_FUSED_QKNORM_ROPE=1, which is off by default; the decode variant already ships on. That PR listed T4, older torch and ROCm as its exit criteria. This PR covers the NVIDIA side and turns the training kernel on by default there.Change
New
_qk_norm_rope_default()inunsloth/kernels/qk_norm_rope.py, read once at import intoQK_NORM_ROPE_ENABLED:UNSLOTH_FUSED_QKNORM_ROPE=0/false/no/off: unfused everywhere;1/true/yes/on: fused everywhere, including ROCm;DEVICE_TYPE == "cuda"(NVIDIA, Linux and Windows).ROCm (
DEVICE_TYPE == "hip"), XPU and CPU keep the unfused training path. The fused backward has not been measured on ROCm.Results
Timing. Qwen3 LoRA SFT steps, torch 2.14 (T4 and A100 also on 2.10):
No cell is slower beyond its A/A band. Peak memory is unchanged.
Loss. 50-step runs (20-30 for 8B) from the same LoRA init, seed and data:
Compile and engagement:
Tests
New cases in
tests/test_qk_norm_rope.py:0.The file gives 57 passed on B200 with torch 2.14 and with 2.10. The existing parity cases (bf16 forward bit-identical to unfused, gradients vs an fp64 reference) pass on T4 fp16, A100 bf16 and B200.
Not covered