Add fused QK-Norm + RoPE kernel for Qwen3#1286
Open
zhangxin81 wants to merge 1 commit into
Open
Conversation
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
Add a fused Triton QK-Norm + RoPE path for Qwen3 and wire it into the optional Qwen3 monkey patch path.
This PR:
qk_norm_ropeTriton op with forward/backwardqk_norm_ropeflag toapply_liger_kernel_to_qwen3Testing Done
make testto ensure correctnessmake checkstyleto ensure code style (targeted local ruff/import/format checks on changed Python files)make test-convergenceto ensure convergenceAdditional validation completed locally:
liger_kernelsuccessfully in a scratch Python 3.12 venvruff checkpassed for all changed Python filesruff format --checkpassed for all changed Python filespy_compilepassed for the new Python filesNote: full
make test/ convergence runs were not executed in this shell environment because the default local Python environment did not have the CUDA/PyTorch stack installed.Benchmark Summary
From the supplied performance report (report file intentionally not included in this PR):
Correctness
Performance (bsz=4, seq_len=2048, H100 80GB)
BF16
FP32
Profiler summary
For the qwen3 4B/8B bf16 case, the report states the unfused path spent ~84.8 ms self CUDA time across many elementwise/cast kernels, while the fused path reduced that to ~10.2 ms dominated by the fused Triton forward/backward kernels.
Notes for reviewers
qk_norm_rope=Falseby default.