Repository navigation
Description
Topic
Installation or source build
Question
Summary
On a DGX Spark (GB10, compute capability 12.1), trtmc build succeeds for Qwen2.5
models but fails for every Qwen3 model. The prefill engine always builds; the
decode engine fails inside TensorRT's Myelin attention fusion.
The failure is confined to the Qwen3 native KV-cache decode path
(IAttention + key_value_lengths + IKVCacheUpdateLayer). A correct
workaround exists (--dynamic-kv-cache, see below), so this is not a hard
blocker — but the current failure mode is an opaque internal TensorRT exception
rather than an actionable message, and the SM120/121 limitation is undocumented.
Environment
| GPU | NVIDIA GB10 (DGX Spark), compute capability 12.1 (sm_121) |
| Driver | 580.173.02 |
| Arch / OS | aarch64, Ubuntu 24.04.4 LTS |
| CUDA | 13.0 (V13.0.88) |
| TensorRT | 11.1.0.106 (libnvinfer-dev 11.1.0.106-1+cuda13.3; pip tensorrt==11.1.0.106) |
| Build | host build (no container), -DCMAKE_CUDA_ARCHITECTURES=121-real, TRT backend ABI 11_1 |
The C++ build itself is fine: trtmc, libtrtmc_backend_trt_11_1.so, and
libtrtmc_model_qwen.so all compile, and Qwen2.5 bundles run correctly.
Reproduction
trtmc build Qwen/Qwen3-0.6B -o qwen3-0.6b.bundle[trtmc build] Prefill engine built [22.2s] (1144.9 MB)
Internal Error: MyelinCheckException: decompose_composite_ops.cpp:29:
CHECK(composite_op->is_decomposable()) failed.
Attention operation was not supported by a dedicated kernel.
[TRT] [E] Error Code: 10: Internal Error (Could not find any implementation for
node {ForeignNode[(Unnamed Layer* 2) [Cast]...(Unnamed Layer* 2837) [Cast]]})
Error: dual-profile decoder engine build failed
What we isolated
Every row below was run on this machine.
| Model | arch | head_dim | heads x head_dim vs hidden | QK-norm | Result |
|---|---|---|---|---|---|
| Qwen2.5-0.5B-Instruct | qwen2 | 64 | 896 == 896 | no | OK (built + inference correct) |
| Qwen2.5-1.5B-Instruct | qwen2 | 128 | 1536 == 1536 | no | OK (decode engine 5891 MB) |
| Qwen3-0.6B | qwen3 | 128 | 2048 != 1024 | yes | FAIL |
| Qwen3-1.7B | qwen3 | 128 | 2048 == 2048 | yes | FAIL (identical error) |
Ruled out as the cause:
- sm_121 in general — TensorRT compiles engines fine on this GPU. Qwen3
prefill engines build (1145 MB), and both Qwen2.5 models build and run. - head_dim = 128 — Qwen2.5-1.5B has head_dim 128 and builds.
heads * head_dim != hidden_size— Qwen3-1.7B is symmetric (2048 == 2048)
and still fails.- QK-norm — setting
q_norm/k_normtoNonein both decode paths
(dual_profile_decoder_builder.py:689,695andgraph_blocks.py:210,215)
changes nothing; both errors reproduce unchanged. - Attention IO form — adding
attention.query_form = attention.key_value_form = trt.AttentionIOForm.PADDED_BHND
atfamilies/qwen/graph_ops.py:1260does not help. (Tried because SM120/121
support onlykPADDED_BHND, andfamilies/sam2/image_builder.py:141-142is
the only place in the repo that sets this explicitly, while the Qwen native
path relies on the default.)
Qwen3-0.6B additionally fails with --precision fp16, --max-cache-length 4096,
and --recipe qwen.decode_attention_region@2 ... --graph-role decode.
Working workaround
trtmc build Qwen/Qwen3-0.6B --dynamic-kv-cache -o qwen3-0.6b.bundle
trtmc run qwen3-0.6b.bundle --prompt "What is the capital of France? Answer in one word." \
--chat-template --no-thinking
# Generated text: Paris--dynamic-kv-cache disqualifies native-KV routing
(build_routing.py: "native Qwen3 uses one fixed physical KV capacity") and
drops the split layout, landing on the single-engine legacy dense-mask graph in
bf16 — which compiles on sm_121 with QK-norm intact. Verified end-to-end on
Qwen3-0.6B (1516 MB engine, decode 5.9 ms) and Qwen3-1.7B (3958 MB).
Note the combination matters: --dynamic-kv-cache with --precision fp16
still fails, because fp16 trips a separate crash (below).
Why we believe this is SM120/121-specific
TensorRT's fused-attention documentation splits support into two tables
(link):
- Supported Attention Fusions on SM100, SM103, and SM110 — IO form
kPADDED_BHNDandkPACKED_NHD, no sequence-length restriction. - Supported Attention Fusion for Other SM Versions — covers SM75-SM90,
SM120, SM121 — IO formkPADDED_BHNDonly, with tighter constraints.
The repo's validated environments are all datacenter/embedded parts
(benchmarks/performance/environments/{gb300,auto-thor,l4t-thor}.yaml), and the
BYOK kernel exporter hard-gates on compute capability (10, 3)
(families/qwen/kernels/export_flashinfer_decode_attention.py:199). We found no
mention of SM120/121 anywhere in the repo.
This matches a known ecosystem pattern of missing fused-attention kernels on
GB10-class parts: NVIDIA/TensorRT-LLM#11799, sgl-project/sglang#11658,
Dao-AILab/flash-attention#1969, NVIDIA/TensorRT#4743, NVIDIA/TensorRT#4715.
We could not confirm this directly — only one GPU was available, so we cannot
test whether Qwen3 builds on SM100/103. If someone can run
trtmc build Qwen/Qwen3-0.6B on a GB300 or Thor, that would settle it.
Two related problems found along the way
1. --precision fp16 crashes with an internal assertion
fp16 disables native KV (build_routing.py: "native Qwen3 requires BF16") and
uses the legacy dense-mask graph, which crashes differently:
MyelinCheckException: wrap_attention_op_in_kgen.cpp:1909:
CHECK(expected_live_inputs == knode->inputs().size()) failed.
Expected 3 live inputs, got 4
This one looks like a genuine bug rather than a capability gap — it is an
internal consistency check, not a "no kernel available" message. Qwen2.5-0.5B
builds fine in fp16 on the same machine, so it is config-dependent.
2. Hardcoded 1 GB workspace is too small at the default cache length
families/qwen/dual_profile_decoder_builder.py:396 sets
set_memory_pool_limit(trt.MemoryPoolType.WORKSPACE, 1 << 30). Building
Qwen3-0.6B in fp16 at the model-default cache (40960 tokens) requests
2,598,728,448 bytes and fails:
UNSUPPORTED_STATE: Skipping tactic 0 due to insufficient memory on requested
size of 2598728448 detected for tactic 0x0000000000000000.
This host has 121 GB of unified memory, so the cap is the only limit. Raising it
to 8 GB unblocks fp16 prefill (decode still hits problem 1).
Suggested improvements
- Fail with an actionable message.
native_kv_build_capability()already
has a clean list of disqualifying reasons. Consider adding a device-capability
check so unsupported SMs are disqualified there — either falling back to the
legacy graph automatically, or raising an error that names
--dynamic-kv-cache— instead of surfacing a raw Myelin exception. - Document the supported SM range for the Qwen3 native KV path.
- Derive the workspace limit from the request (or make it configurable)
rather than hardcoding 1 GB.
Not viable as workarounds (for the record)
attention.decomposable = Trueatgraph_ops.py:1260: the native bf16
split build then succeeds (prefill + decode, 43 s), but inference produces
garbage tokens and decode is roughly 10x slower. The existing comment
("The prototype deliberately requires TensorRT's fused attention tactic")
explains why this is disabled.- BYOK / TVM-FFI kernel slot: limited to one slot per bundle, enforced in
code atsrc/plugins/tvm_ffi_runtime_bindings.cpp:242
("kernel_slots.json.slots must contain exactly one slot"), so it cannot
replace all 28 decode attention layers. Confirmed experimentally: applying
--recipemoves the fused region start from layer 2 to layer 87 (one
transformer layer carved out) but the build still fails on the rest.
What have you tried?
No response
TensorRT-Model-Connect version
Model and revision
Qwen/Qwen3-0.6B
Environment details
No response
Submission checks
- I searched the documentation and open and closed issues first.
- This question contains no secrets, private URLs, or restricted artifacts.
Activity
yifeif-nv commentedon Aug 21, 2026
Hi @sparkleholic Thanks for raising the issue! Let me take a look at it and get back to you. We'll go get a spark machine and validate the issue
yifeif-nv commentedon Aug 21, 2026
Yes, I have reproduced the case on GB300. SM103 does not have this issue, so this looks like a TRT internal bug on SM121. Thanks for reporting this.
Next, I will find a DGX Spark, reproduce, and see if we can have a good solution (Without the fall back which hurt perf) there.
yifeif-nv commentedon Aug 21, 2026
@sparkleholic under BF16 precision. Can you give --max-cache-length 16384 a try. Basically following the quick start guide here. https://nvidia.github.io/TensorRT-Model-Connect/getting-started/quick-start/
This will still use the native fused attention but limiting the context length. We've observed something similar on SM86 where long context has some issue with the native attention and the underlying issue is under active investigation.
yifeif-nv commentedon Aug 21, 2026
Confirmed the FP16 and 1GB workspace are also bugs.
The FP16 issue is due to the legacy code path, and I will remove it and switch to the native attention path.
For the workspace issue (which is the old hard-coding for short context lengths), I will update that based on the available CUDA memory.
Please stay tuned while we are working on the fix.
yifeif-nv commentedon Aug 21, 2026
Confirmed it's the same internal issue with SM86
Please give the following command a try and it should work. And for the performance solution on Spark, Edge-LLM should provide better performance. You could directly use it or wait for we to add the easy-to-use dispatch wrapper in Model Connect!
fix(qwen): remove legacy fallback
yifeif-nv commentedon Aug 21, 2026
Updated readme first to allow a successful run as a WAR. #961
fix(qwen): use TensorRT workspace default
docs(readme): use native Qwen3 cache length
fix(qwen): allow bounded native KV capacity
fix(qwen): keep FP16 on native KV path
4 remaining items
fix(qwen): keep FP16 on native KV path
fix(qwen): remove legacy fallback
fix(qwen): use TensorRT workspace default
docs(readme): use native Qwen3 cache length
fix(qwen): allow bounded native KV capacity
yifeif-nv commentedon Aug 21, 2026
Hey @sparkleholic I would like to provide an update here.
We fixed the FP16 and the 1GB workspace issues.
For the attention lengths, this is confirmed as an internal bug in TensorRT because we are invoking the wrong kernel on these SMs. We have already confirmed an internal fix; however, I am still working with the team to see whether we can get a fast-track release of TensorRT.
In the meantime, please try to stay with the shorter context lengths to see if they can still fulfill your needs.
Let us know if this works for you and if there are any additional concerns. We can try to assist as well.
sparkleholic commentedon Aug 23, 2026
Thank you for the exceptionally fast review of this issue, @yifeif-nv. Validating on a GB300 within hours and landing the FP16 and workspace fixes the same day was far more than I expected.
I revalidated on current
main(e9132e79) and have to report something important: on sm_121,--max-cache-length 16384now builds successfully but produces numerically wrong output. Details below.1. Silent wrong output on current
mainThis is the command currently documented in the README:
38fe83f7changed the Quick Start line back from--max-cache-length 40960to16384(aftera7a9b01chad moved it the other way), soREADME.md:20-22now shows exactly this invocation annotated# Generated text: Paris. On sm_121 it returns the string above instead.Deterministic across 3 runs, and also garbage without
--chat-template(
"The capital of France is"→echo/off0cription/DDceriesutenantussions今天 ...).Qwen2.5-0.5B on the same build is unaffected and still answers
Paris.This is a regression relative to the tree I originally reported against, and it tracks the tree rather than the TensorRT version. I tested all four cells:
--max-cache-length 16384c926bdc9Parisc926bdc9Parise9132e79e9132e79Note the engine sizes: on
e9132e79both TensorRT versions report the same 2889.0 MB total, whereas onc926bdc9the totals differed by roughly 300 MB. That is consistent with the two trees taking different graph routes for the same command.(For the
e9132e79+ 11.1 row I kept the system debs at 11.2 and pointed CMake atextracted 11.1 headers plus the 11.1 pip wheel's
libnvinfer.so.11; the runtimeconfirmed
ABI resolved: bundle=11.1, backend=trt_11_1, runtime=11.1.0.106.)What I ruled out: the workspace change. I restored the old
set_memory_pool_limit(WORKSPACE, 1 << 30)line locally and got an identical engine size (2889.0 MB) and identical garbage output, so tactic selection under a larger workspace is not the trigger. (At cache=16384 that cap was never binding anyway.)Mechanism (inferred from the diffs, not directly instrumented): on the tree I originally reported (
c926bdc9),native_kv_cache_geometry()requiredcapacity == context, so--max-cache-length 16384was ineligible for the native KV path on a model withmax_position_embeddings=40960and fell through to the legacy graph, which is why the workaround produced correct output.38fe83f7made bounded capacity eligible, anddff5f9e6removed the legacy fallback, so the same command nowruns on the native fused-attention path, the one that is broken on sm_121.
I verified the second half of that directly: restoring the old
capacity != contextcondition makes the build fail closed withError: Qwen3 requires the fixed-capacity native KV path: native Qwen KV requires max_cache_length in [1, max_position_embeddings (40960)], got 16384, confirming there is no longer any fallback route.So the workaround appears to have worked for a different reason than we thought.
It was routing away from native attention, not merely shortening the context.
2. No working path for Qwen3 on sm_121 on current
maine9132e79+ TRT 11.2.1.2trtmc build Qwen/Qwen3-0.6B(default cache 40960)decompose_composite_ops.cpp:29 ... not supported by a dedicated kernel--max-cache-length 16384--dynamic-kv-cacheQwen3 does not support dynamic KV cache ...(dff5f9e6)--precision fp16(default 40960 and 16384)wrap_attention_op_in_kgen.cpp:1922: Expected 3 live inputs, got 4The
--dynamic-kv-cacheroute was my original workaround before you suggested the shorter context;dff5f9e6intentionally closes it, which is reasonable as a design decision, but combined with the above it leaves no working configuration on this architecture.Suggestion: whatever the timeline for the TensorRT fix, it would help a lot if the builder failed closed on SMs where the fused attention kernel is known-bad, rather than producing a build that succeeds cleanly but silently returns wrong tokens. A wrong answer is much harder to notice than a build error. I only caught this because I check generated text after every build.
3. Confirmed fixed
--precision fp16at the default cache no longer dies withinsufficient memory on requested size of 2598728448; it now proceeds to the attention stage. (3f31c9b9,0722c853)build_routing.pynow readsnot in {"fp16", "bf16"}, and FP16 reaches the native path. (bf8c146c) It still fails there on sm_121, with theExpected 3 live inputs, got 4crash, and unlike BF16 the shorter context length does not rescue it.4. TensorRT 11.2.1.2
I also rebuilt the whole stack against 11.2.1.2 (system debs, pip wheel, clean C++ rebuild producing
libtrtmc_backend_trt_11_2.so, bundles recording ABI 11.2), since that is the current default candidate in the CUDA apt repo. The attention issue reproduces unchanged, so the internal fix is not in that public release.Minor note for anyone building on the host rather than in the container:
pyproject.tomlpinsdefault-tensorrt-version = "11.1.0.106", butlibnvinfer-dev's default apt candidate (ubuntu2404/sbsa) is11.2.1.2-1+cuda13.3.An unattended upgrade leaves existing bundles unloadable with
bundle requires TensorRT ABI 11.1 ... TensorRT 11.2.1.2 (ABI 11.2) does not match required ABI 11.1. The error lists every path it searched, which made it trivial to diagnose. No complaint here, just a note that pinning orapt-mark holdis worth documenting.Environment
-DCMAKE_CUDA_ARCHITECTURES=121-reale9132e79, clean rebuild; TensorRT 11.2.1.2 (deb + pip aligned)yifeif-nv commentedon Aug 25, 2026
Hey, thanks for reporting this. This is actually a very good and important observation for us.
Looks like there's definitely some gap in our CI because, unfortunately, we haven't got any SM120 machines in our CI yet. This seems to be a regression that sneaked through.
We will be taking a look at this today and will provide you with an update as soon as we can.
And as a side note, we are also working with the TensorRT core team to see if we can get nightly TensorRT drops that can include bug fixes more often for our users.
fix(qwen): mask native KV attention explicitly
fix(qwen): mask native KV attention explicitly
fix(qwen): mask native KV attention for FP16 and BF16 (#1035)
chaofengw-nv commentedon Aug 26, 2026
Hi @sparkleholic, a follow-up after #1035 was merged.
We have now exercised the workaround directly on an actual DGX Spark:
What is working
TensorRT 11.1.0.106 is fully working in our DGX Spark validation. We used matching 11.1 headers, runtime libraries, backend ABI, and bundle ABI.
The split prefill/decode bundle built successfully, the smoke prompt produced normal text (Paris...), and we did not observe the corrupted multilingual output reported above.
We also ran correctness and performance checks rather than relying only on the smoke prompt:
MMLU five-shot subset (20 samples): TRTMC accuracy 0.45, HF accuracy 0.45, prediction agreement 20/20 (100%), and accuracy drop 0.
Official qwen.generate performance case: green; exact-token-ID validation passed; all 10 measurements were stable.
TRTMC P50 latency was 68.36 ms versus 132.68 ms for the configured HF torch.compile reference.
This represents a 1.94x baseline/TRTMC latency ratio, with 146.19 output tokens/s.
TensorRT 11.2.0.120 selects the same #1035 workaround and successfully builds both split engines on the DGX Spark.
This is currently a build-level verification. We are not yet counting it as a complete DGX Spark qualification. We will repeat the end-to-end Accuracy/Perf run with an exact 11.2 runtime/backend pair.
The workaround in #1035 is intentionally enabled for the affected SM86/SM121 and TensorRT 11.1/11.2 combinations.
PR validation also covered full-model execution on SM86 with TensorRT 11.1 and targeted fused-attention execution with TensorRT 11.1/11.2.
Current limitations
The complete DGX Spark qualification above currently covers Qwen3-0.6B FP16 on TensorRT 11.1.
Accuracy used a 20-sample MMLU subset, not the full dataset or every Qwen3 model and precision.
On the affected TensorRT 11.1/11.2 path, qualified cache capacity is limited to <= 16384.
The model-default capacity of 40960 intentionally fails closed with guidance to use --max-cache-length 16384.
FP16 models use BF16 specifically for native attention and KV-cache storage on this workaround path; the surrounding model remains FP16.
This is a TRTMC-side workaround, not the TensorRT kernel root fix. It retains fused attention and native cache aliasing but replaces key_value_lengths with an explicit active-prefix mask.
TensorRT runtime, backend DSO, and bundle ABI must match exactly. Validation cannot mix artifacts produced for different TensorRT versions.
We will continue following the TensorRT-side fix. Once a public fixed TensorRT build is available, we will rerun the affected-version matrix and expanded Accuracy/Perf coverage on DGX Spark.
We will then requalify or remove the temporary TRTMC workaround as appropriate. We will also post the exact TensorRT 11.2 end-to-end result once the matching-ABI run is complete.
chaofengw-nv commentedon Nov 12, 2026
Closing as resolved. The native-KV decode build failure on SM120/SM121 was fixed by #959 (Qwen3 requires the native-KV path), #1035 (masked native-KV attention for FP16 and BF16) and #1048 (explicit native-KV masking for every fixed-capacity owner), and Qwen3-0.6B FP16 was validated on DGX Spark (GB10) after #1035 as described above. Please reopen if you still see it on current
main.