Repository navigation
Add GB10/SM121 Hub-kernel path for Qwen3.6 Gated DeltaNet - #46423
Conversation
vasqu
left a comment
There was a problem hiding this comment.
Just have 2 smaller questions but that is exciting!
| pass | ||
|
|
||
|
|
||
| @use_kernel_forward_from_hub("Qwen3_5MoeGatedDeltaNet") |
There was a problem hiding this comment.
Any reason we make the distinction here? It should be the same as the non-moe as we only handle the GDN x conv1d path here, no?
There was a problem hiding this comment.
The GDN core is identical for dense and MoE (the MoE-ness only lives in the MLP, not the attention), so we'll collapse it to one shared name and dropped the redundant entry. Thanks for pointing this out!
There was a problem hiding this comment.
Ah ig the qwen 3 next variation is not included because of the different memory layout of the projections (fused vs split)?
There was a problem hiding this comment.
That's right, Qwen3-Next uses fused projection weights (in_proj_qkvz, in_proj_ba) while Qwen3.5 deletes those and uses split ones (in_proj_qkv/z/b/a). Our kernel reuses the host module's projections, so it's written against the split layout
There was a problem hiding this comment.
Thanks, yes that makes sense!
|
I believe I've addressed your comments @vasqu just wanted to bring up some blockers for the |
|
Hey @AzeezIsh 👋 Yes that's true, I think we also need to slightly rewrite the logic in transformers (as we limited this quite a bit before trusted kernels was a thing), see transformers/src/transformers/integrations/hub_kernels.py Lines 430 to 434 in 94246e6 I'm working on upgrading the minimum kernels version so we can use the proper in-built feature (see #46039 for syncing to latest kernels) Yes the issue is known (#46399). The underlying issue is that modular always inherited that decorator so we need something that disallows it. I will try working on it to unblock this. |
| layer_name="Qwen3_5GatedDeltaNet", | ||
| revision="v0", | ||
| # TODO: drop once Atlas-Inference is an allow-listed publisher | ||
| trust_remote_code=True, |
There was a problem hiding this comment.
Inherently agree with this, would it be ok to wait until we figure this out
- Get you to be a trusted publisher
- I fix to latest kernels and the associated issues
There was a problem hiding this comment.
Thanks @vasqu, that works for me on both counts!
On the trusted-publisher and kernels-version path yes, happy to wait until that lands. No rush on my end. Once Atlas-Inference is allow-listed (or the layer moves under kernels-community) and the min-kernels bump in #46039 goes in, I can drop the trust_remote_code=True from the mapping entry.
Also confirmed #46440 fixes it! I rebased onto main (so the no_inherit_decorator change is in) and re-ran the full e2e on a second, clean GB10 (SM121) box, fresh env, pulling Atlas-Inference/gdn@v0 from the Hub:
- use_kernels=False -> pure-torch Gated DeltaNet fallback.
- use_kernels=True -> GDN forward swapped to the Atlas Hub kernel (build/torch212-cxx11-cu130-aarch64-linux/layers.py auto-selected).
- Full greedy generate() runs end to end through the attention + partial-rotary path with no crash (the old ValueError from Qwen3.5: use_kernels=True crashes with ValueError on apply_rotary_pos_emb registration - missing decorator #46399 is gone).
- Greedy token IDs are identical to the torch fallback (exact parity).
There was a problem hiding this comment.
Awesome that's good to hear! I will work on the versioning with kernels and we should get a first pass this week in then.
Let me nudge internally re trusted publishers 🫡 this is some awesome work!
There was a problem hiding this comment.
Yup, sorry there were a lot of delays and unexpected issues I encountered but I finally merged my PR!
Can you sync with main? I would plan to let this live as trust remote code but pin a revision along with it for now 🤗 We can also add a small todo
There was a problem hiding this comment.
Let's also add some small docs about benchmark numbers. I think that would be very nice 🫡
There was a problem hiding this comment.
Thanks @vasqu, both done. Synced with main, conflict-free (the kernels bump and #46440 are both in, so it uses the in-built CUDAProperties gate). Kept it as trust_remote_code with a pinned revision (Atlas-Inference/gdn@v0) plus a TODO to drop trust_remote_code once Atlas-Inference is allow-listed :)
Also added before/after numbers to the dense and MoE usage docs. GB10/SM121, bf16, 1024-token prompt, greedy:
Qwen3.6-27B TTFT 1.66s -> 1.11s (1.49x), decode 4.11 -> 4.14 tok/s
Qwen3.6-35B-A3B TTFT 0.73s -> 0.53s (1.38x), decode 16.3 -> 16.7 tok/s
Greedy token IDs are identical between the two paths for exact parity, and the kernel only engages on SM121.
Ready for another look when you get a chance!
|
For the second issue: #46440 - this should fix the problem allowing non inheritance where needed |
|
CI Dashboard: View test results in Grafana |
…rk docs Rebase the Qwen3.6 GB10/SM121 Gated DeltaNet kernel path onto current main: use the in-built CUDAProperties capability gate, share one Atlas-Inference/gdn mapping entry across the dense and MoE Gated DeltaNet, and pin the kernel revision (trust_remote_code with a TODO to drop once Atlas-Inference is an allow-listed publisher). Add GB10/SM121 benchmark numbers to the Qwen3.5/3.6 usage docs.
bdce881 to
90bc799
Compare
vasqu
left a comment
There was a problem hiding this comment.
Just one small nit, then we can merge. Very nice!
| ## Usage tips and notes | ||
|
|
||
| - Layers are hybrid: [`Qwen3_5TextConfig`]'s `layer_types` is a per-layer list of `"linear_attention"` or `"full_attention"` that encodes the 3:1 Gated DeltaNet / Gated Attention stack. The DeltaNet path (`Qwen3NextGatedDeltaNet`) needs the optional `causal_conv1d` (from [Dao-AILab](https://github.com/Dao-AILab/causal-conv1d)) and `fla` packages for its fast kernels — without them, the model silently falls back to slower and more memory hungry PyTorch ops. | ||
| - On NVIDIA GB10 (compute capability 12.1 / SM121) neither `causal_conv1d` nor `fla` ship an SM121 build, so the DeltaNet path always falls back to the slow PyTorch reference. Passing `use_kernels=True` to [`~PreTrainedModel.from_pretrained`] swaps the Gated DeltaNet conv1d and delta-rule cores for a compute-capability-gated Hub kernel ([`Atlas-Inference/gdn`](https://huggingface.co/Atlas-Inference/gdn)); every other GPU keeps the existing path. The kernel is numerically faithful to the fallback (identical greedy output) and speeds up prefill. Measured on `Qwen/Qwen3.6-27B` (bf16, GB10/SM121, 1024-token prompt, greedy decode of 256 tokens): |
There was a problem hiding this comment.
I would just add a small note that you also need kernels to be installed pip install kernels==0.15.2
There was a problem hiding this comment.
Good call @vasqu, added a note in both the dense and MoE docs that loading the mapped kernel needs the kernels package (pip install kernels==0.15.2). Also merged latest main to bring the branch up to date, thanks!
Document that use_kernels=True needs the kernels package (pip install kernels==0.15.2) in the Qwen3.5 and Qwen3.5-MoE usage docs.
|
[For maintainers] Suggested jobs to run (before merge) run-slow: qwen3_5, qwen3_5_moe |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
Let's go 🥳 thanks a lot for sticking through |
|
Thanks so much @vasqu, plan to push more work up for DGX along with the Strix Halo too. Likely need to enable that arch (gfx1151) to run transformers as well! Will link an issue/PR for this to follow up :) |
|
Yep, dont hesitate to cc me. If idk, I can at least forward internally as well 🤗 |
|
Btw @AzeezIsh https://github.com/huggingface/kernels/releases/tag/v0.16.0 might be interesting for you as well, we will also adopt kernels signing bit by bit 🤗 |
…e#46423) * Sync GB10/SM121 Gated DeltaNet Hub-kernel path with main; add benchmark docs Rebase the Qwen3.6 GB10/SM121 Gated DeltaNet kernel path onto current main: use the in-built CUDAProperties capability gate, share one Atlas-Inference/gdn mapping entry across the dense and MoE Gated DeltaNet, and pin the kernel revision (trust_remote_code with a TODO to drop once Atlas-Inference is an allow-listed publisher). Add GB10/SM121 benchmark numbers to the Qwen3.5/3.6 usage docs. * Note kernels package install for GB10/SM121 Gated DeltaNet Hub kernel Document that use_kernels=True needs the kernels package (pip install kernels==0.15.2) in the Qwen3.5 and Qwen3.5-MoE usage docs. * small nits --------- Co-authored-by: vasqu <[email protected]>
|
Hey @vasqu! Wanted to quickly revisit this conversation, I heard slack is the place to be... Also congrats :) |
On a DGX Spark (GB10, compute capability 12.1) the
flaandcausal_conv1dfast paths have no SM121 build, so Qwen3.6 falls back to the slow pure-torch Gated DeltaNet (is_fast_path_available=False). Register a compute-capability- gated Hub kernel (Atlas-Inference/gdn) for the Qwen3.6 GDN layers so GB10 users get a fast path automatically; every other GPU keeps the existing path.Qwen3_5GatedDeltaNet(Qwen3.6-27B dense) andQwen3_5MoeGatedDeltaNet(Qwen3.6-35B-A3B) with@use_kernel_forward_from_hub(...)in the modular files; regenerate modeling via the modular converter.CUDAProperties(min=121, max=121)-gated entries inintegrations/hub_kernels.py.The kernel is a stateless
kernelslayer: it reuses the host module's projections, gated RMSNorm, and out_proj and replaces only the conv1d and gated-delta-rule cores. Output parity vs the torch fallback is cosine >= 0.9999 on GB10; a full-model greedygenerate()produces identical token IDs.What does this PR do?
The two decorators in the
modular_*.pyfiles (withmodeling_*.pyregenerated by the converter) plus the two gated entries inintegrations/hub_kernels.py.Verified on GB10 (SM121), bf16:
DynamicCache(prefill + 8 decode), using the published Hub kernelAtlas-Inference/gdn@v0: 27B0.999970, 35B-A3B0.999967reproduced on a second, clean box via an unauthenticated Hub pull.kernel_layer_nameset,kernelize()swaps the forward, parity unchanged.generate()(Qwen3_5MoeForCausalLM): identical token IDs vs the torch fallback, GDN layers confirmed swapped to the Atlas kernel.Context: follow-up to huggingface/kernels-community#866 (@sayakpaul asked to show how the Atlas SM121 kernels can be used in transformers). No overlapping PR exists. One non-blocking follow-up for reviewers: the mapped kernel currently needs
trust_remote_code=TrueuntilAtlas-Inferenceis added to thekernelstrusted-publisher allowlist (or the layer is hosted underkernels-community)Code Agent Policy
Before submitting
Who can review?
@drbh (kernels integration) and @Cyrilvallez (text models / Qwen3.6).