Repository navigation
Fused QKNorm + RoPE: keep type promotion for mixed dtype tables, reuse grad in the trainable norm fallback - #14200
Merged
Merged
Conversation
… tables, reuse grad in the trainable norm fallback
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. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! 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". |
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
Two follow-ups for the opt-in fused QKNorm + RoPE kernel (
UNSLOTH_FUSED_QKNORM_ROPE=1, #13890). The flag-off path is untouched:qwen3.py,rope_embedding.pyandrms_layernorm.pydo not change.apply_rotary_pos_embdoes the same: the tables follow the activation dtype and the product uses normal torch promotion. The fused kernel now casts to the table dtype only in the no-indices mode, so each mode matches the unfused kernel it replaces. When the dtypes already match, nothing changes: 72 output and gradient tensors are byte-identical between the old and new kernel._unfusednow passesreuse_grad = Trueto both norms, as the flag-off Qwen3 path does. The norm output only feeds the RoPE kernel there.Tests
tests/test_qk_norm_rope.py(GPU, tiny shapes):test_mixed_dtype_tables_match_unfused: fp32 and fp16 activations against bf16 tables, with and without indices. The two indexed cases fail on main; the no-indices cases pass on both.test_trainable_norm_fallback_reuses_grad_buffer: peak memory goes from 24,450,048 to 20,255,744 bytes. Fails on main.All 44 tests in the file pass here, including the existing fullgraph / no graph break tests.
Not covered here