[WIP] Add Qwen4Exp text model support - #1447
Draft
alifurkanstahl wants to merge 12 commits into
Draft
alifurkanstahl wants to merge 12 commits into
alifurkanstahl wants to merge 12 commits into
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.
Warning
Work in progress — do not merge yet.
This draft is available early so the Qwen4Exp kernels can already be tested
and used while the implementation is still evolving. APIs and implementation
details may still change before this PR leaves draft.
Summary
Adds Liger Kernel support for the Qwen4Exp text stack.
Upstream Qwen4Exp implementation: huggingface/transformers#48337
This PR:
Scope
This PR currently targets the Qwen4Exp text stack.
Follow-ups before leaving draft
hc_count=4;Performance
Measured on an NVIDIA GeForce RTX 5060 Ti, BF16,
B=1,S=2048,H=2048,hc_count=4.Values below are median timings from the standardized Liger benchmark harness.
Speed
Peak memory
The Gated Residual benchmark covers the complete residual read/write boundary around an arbitrary attention/MLP result; it intentionally excludes the intervening attention/MLP block compute.
The grouped-RMS rows compare the Qwen4Exp-specialized fused paths against the generic Liger grouped RMSNorm path rather than against PyTorch.
These are operator microbenchmarks, not end-to-end model training speedups.
Full benchmark results are included in
benchmark/data/all_benchmark_data.csv.Testing Done
Hardware Type: NVIDIA GeForce RTX 5060 Ti
Python: 3.13.9
PyTorch: 2.10.0+cu128
Transformers: 5.16.1
Triton: 3.6.0
run
make testto ensure correctnessrun
make checkstyleto ensure code stylerun
make test-convergenceto ensure convergenceAll Qwen4Exp convergence cases in the suite pass.
make test-convergencecurrently exits non-zero because of four failures unrelated to Qwen4Exp:mini_qwen3_5_moemultimodal — top-k logprob mismatch;mini_qwen3_5_moemultimodal — top-k logprob mismatch;mini_llama4with materialized logits;mini_qwen3_moewith materialized logits.All four failures were reproduced on base commit
6459426using the samePython / PyTorch / Transformers / Triton environment and the same isolated
pytest cases.
The base and this branch reproduce the same failure signatures. The fp32
Qwen3.5-MoE case has minor run-to-run numerical variation while retaining the
same mismatch count and indices; the other checked signatures are deterministic.
These failures therefore appear to be pre-existing and are not introduced by
the Qwen4Exp changes.
Test output