Skip to content

[Performance] Re-evaluate the default Qwen3.5 GDN kernel on DGX Spark (GB10) #51544

Backlog

Description

@harheem

Feature request

Could we evaluate preferring the existing Hub function path for Qwen3.5 Gated DeltaNet on GB10?

On main, use_kernels now defaults to True (#47773). On GB10 (SM121) with PyTorch 2.10–2.12, the Qwen3_5GatedDeltaNet mapping replaces the whole layer with Atlas-Inference/gdn. With other PyTorch versions there is no Atlas build, so kernelize already falls back to the Hub function path: the Transformers layer calling kernels-community/fla for the gated delta rule. On the same PyTorch 2.12.1, that function path was 12–16% faster than Atlas for BF16 prefill in my runs.

Related: #51543. With the Atlas layer, the cache passed by generate() does not reach the GDN state. Removing the SM121 entry would avoid that too, but this issue is only about prefill speed.

Motivation

Environment: DGX Spark, GB10 (compute capability 12.1), Ubuntu 24.04 aarch64, driver 580.178.04, Python 3.12.3, PyTorch 2.12.1+cu130, CUDA 13.0, Triton 3.7.1, kernels==0.19.1. Transformers main at 953768968c63bf87295136251f9c0da29386a30e. The relevant files are unchanged at b53bc453c22bd71ec7fa651ea4073c8ef223aa31. Neither flash-linear-attention nor causal-conv1d was installed.

Change: deleting only the SM121 CUDA entry from Qwen3_5GatedDeltaNet in src/transformers/integrations/hub_kernels.py. The AMD entry and the function mappings were left as they were. In both conditions, use_kernels resolved to True with nothing passed to from_pretrained. The forward traces confirm the path:

  • Atlas: forward from Atlas-Inference/gdn@531ae67 (torch212-cxx11-cu130-aarch64-linux).
  • Without the entry: the Transformers layer calling chunk_gated_delta_rule from kernels-community/fla@2c095f7.

Workload:

  • Model: autotrust/AutoTrust-Decider-Mini-9B at 7ac669b8fb476ba926491e3d1c39f9330d68dbed, a Qwen3.5-9B fine-tune with its LoRA adapter merged. Layer shapes are those of Qwen3.5-9B.
  • BF16, batch size 1, random token IDs, use_cache=False, logits_to_keep=1.
  • Run order: without Atlas → Atlas → Atlas → without Atlas, each in a fresh process.
  • Each length had two warm-ups and five timed forwards. The table shows the mean of the two per-run medians, and the reduction within each adjacent pair.
Tokens Atlas (ms) Hub FLA (ms) Latency reduction Pair 1 / pair 2
512 219.57 193.20 12.0% 10.4% / 13.6%
2,048 775.44 663.31 14.5% 15.6% / 13.3%
8,192 3,015.31 2,518.12 16.5% 16.8% / 16.2%
Prefill latency per forward, Atlas vs Hub FLA, at 512, 2,048 and 8,192 tokens

The chart shows every timed forward: two runs × five per path, with the line at the median of those ten. The table uses the mean of the two per-run medians, so the two differ by a few ms.

Peak allocated memory was within 0.1 GiB between the two paths. Last-token logits compared across paths at all three lengths:

  • Top-1 matched in 6/6 comparisons, and top-20 overlap was 20/20.
  • Max |Δlogit| was 0.086 and max KL was 6.2e-5.
  • Repeated runs of the same path were bit-identical.

A second check, with cached generation on the official Qwen/Qwen3.6-27B (BF16, a 1,024-token prompt, 256 greedy tokens, three runs). This compares Hub FLA with Atlas after forwarding its cache as in #51543:

  • TTFT was 13.5% lower: 917 ms against 1,061 ms.
  • Decode was 0.9% higher: 4.317 against 4.280 tok/s, which I would treat as noise.

So the gain is in prefill. That is where single-pass workloads such as classifiers and decision models spend their time.

Limits:

  • This measures the whole path the mapping selects. The convolution and norm implementations can also differ between the two paths, and my trace does not record which convolution ran in the function path.
  • I measured on one DGX Spark. I have not checked the AMD Strix Halo entry, which this change would leave as it is.

Reproduction. This is a condensed version of the timing loop used for the table. --without-atlas drops the SM121 entry from the cached mapping before loading, which has the same effect as the one-entry source change:

python time_gdn_prefill.py --merge-adapter
python time_gdn_prefill.py --merge-adapter --without-atlas
time_gdn_prefill.py
"""Time Qwen3.5 BF16 prefill on GB10 with the default kernel mapping, or with the SM121 Atlas entry removed."""

import argparse
import statistics
import time

import torch
from transformers import AutoModelForCausalLM

parser = argparse.ArgumentParser()
parser.add_argument("--model", default="autotrust/AutoTrust-Decider-Mini-9B")
parser.add_argument("--revision", default="7ac669b8fb476ba926491e3d1c39f9330d68dbed")
parser.add_argument("--merge-adapter", action="store_true", help="merge the checkpoint's LoRA from its adapter/ subfolder")
parser.add_argument("--without-atlas", action="store_true", help="drop the Qwen3_5GatedDeltaNet SM121 entry before loading")
parser.add_argument("--device", default="cuda:0")
args = parser.parse_args()

if args.without_atlas:
    from transformers.integrations.hub_kernels import get_kernel_mapping_transformers

    # The mapping is a cached dict that is registered when the model is kernelized.
    entries = get_kernel_mapping_transformers()["Qwen3_5GatedDeltaNet"]
    for device in [d for d in entries if getattr(d, "type", None) == "cuda"]:
        del entries[device]

model = AutoModelForCausalLM.from_pretrained(
    args.model, revision=args.revision, dtype=torch.bfloat16, device_map=args.device
)
if args.merge_adapter:
    from peft import PeftModel

    model = PeftModel.from_pretrained(model, args.model, subfolder="adapter", revision=args.revision).merge_and_unload()
model.eval()

gdn = next(m for m in model.modules() if type(m).__name__.endswith("GatedDeltaNet"))
print(f"use_kernels={model.use_kernels}  GDN forward from {gdn.forward.__module__}")

sync = torch.cuda.synchronize if args.device.startswith("cuda") else (lambda: None)
vocab = model.config.get_text_config().vocab_size
for length in (512, 2048, 8192):
    g = torch.Generator().manual_seed(1 + length)
    ids = torch.randint(10, min(vocab, 30000), (1, length), generator=g).to(model.device)
    times = []
    with torch.inference_mode():
        for _ in range(2):  # warm-up, including kernel load and Triton autotune
            model(input_ids=ids, use_cache=False, logits_to_keep=1)
        for _ in range(5):
            sync()
            start = time.perf_counter()
            model(input_ids=ids, use_cache=False, logits_to_keep=1)
            sync()
            times.append((time.perf_counter() - start) * 1000)
    print(f"{length:>5} tokens: median {statistics.median(times):8.2f} ms  ({', '.join(f'{t:.1f}' for t in times)})")
The one-entry source change used for the table
--- a/src/transformers/integrations/hub_kernels.py
+++ b/src/transformers/integrations/hub_kernels.py
             # GB10/SM121 GDN fast path; dense and MoE share it
             "Qwen3_5GatedDeltaNet": {
-                Device(
-                    type="cuda",
-                    properties=CUDAProperties(min_capability=121, max_capability=121),
-                ): LayerRepository(
-                    repo_id="Atlas-Inference/gdn",
-                    layer_name="Qwen3_5GatedDeltaNet",
-                    revision="531ae679ab5c13a3bf49607e1b6e6459300772e9",
-                    trust_remote_code=True,  # TODO: remove when publisher is trusted
-                ),

Links: mapping at the measured commit, GB10 Atlas integration #46423 and #49452.

Your contribution

I can open a PR with the one-entry change. If it helps the decision, I can also run cached decoding and other Qwen3.5 sizes on GB10.

Activity

  1. added
    Feature request
    on Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions