Repository navigation
Description
Name and Version
$ llama-cli --version
version: 0.3.0-dev (build 1, commit d077b4c)
built with GNU 13.3.0 for Linux aarch64
Also reproduced on the pre-merge PR #27742 branch at 035e2273.
Operating systems
Linux
GGML backends
CUDA
Hardware
NVIDIA DGX Spark (GB10, compute capability 12.1 / sm_121), aarch64, 121 GiB unified memory, Ubuntu 24.04.4.
CUDA toolkit 13.0 (nvcc 13.0.88), driver 580.173.02 — toolkit matches driver (this matters for this arch; see the toolkit/driver reports in #27742).
Models
unsloth/Qwen3.8-Flash-Next-GGUF — UD-IQ1_S (67.55 GiB) and UD-IQ3_XXS (76.32 GiB). Both reproduce identically.
Problem description & steps to reproduce
qwen4exp aborts at kernel launch when the KV depth reaches the model's native context_length of 262144. No YaRN, no context extension, no --override-kv.
llama-bench -m Qwen3.8-Flash-Next-UD-IQ1_S-00001-of-00003.gguf \
-ngl 999 -fa 1 -lm none -r 1 -v -p 512 -n 128 -d 0,32768,131072,262144
Depths 0, 32768 and 131072 complete normally; the 262144 point aborts:
| depth | pp512 (t/s) | tg128 (t/s) |
|---|---|---|
| 0 | 788.09 | 37.12 |
| 32768 | 549.96 | 23.98 |
| 131072 | 259.65 | 11.18 |
| 262144 | abort | abort |
A prior report of the same failure exists inside PR #27742 (by @hyungraekim-bagelcode, on an ASUS Ascent GX10 — also GB10/sm_121), reached via YaRN-extended context. That thread is now closed and locked, so filing here: the abort also occurs at the native boundary with no rope scaling, and it is present in master after the merge.
First Bad Commit
Not bisected. Present both at PR #27742 035e2273 and at master d077b4c21466 (post-merge), so it is not a regression introduced by the merge.
Relevant log output
CUDA error: invalid argument
current device: 0, in function ggml_cuda_kernel_launch at ggml/src/ggml-cuda/common.cuh:1668
cudaLaunchKernelEx(&pdl_cfg.cfg, kernel, std::forward<Args>(args)... )
ggml/src/ggml-cuda/ggml-cuda.cu:107: CUDA error
Backtrace (default build):
#3 ggml_cuda_error(...)
#4 rms_norm_mul_f32_cuda(...)
#5 ggml_cuda_op_rms_norm_fused(ggml_backend_cuda_context&, ggml_tensor*, ggml_tensor*)
#6 ggml_cuda_try_fuse(ggml_backend_cuda_context*, ggml_cgraph*, int)
#7 ggml_backend_cuda_graph_compute(ggml_backend*, ggml_cgraph*)
#8 ggml_backend_sched_graph_compute_async()
#9 llama_context::graph_compute(ggml_cgraph*, bool)
What was ruled out
- Not OOM. A 2-second memory sampler ran throughout every attempt; minimum available unified memory was 20, 25, 29 and 34 GiB across four runs. No
out of memory, no failedcudaMallocin any log. - Not the fusion path. With
GGML_CUDA_DISABLE_FUSION=1the abort persists, and the backtrace changes to the unfused path — same error, same depth:#4 rms_norm_f32_cuda(...) #5 ggml_cuda_op_rms_norm(ggml_backend_cuda_context&, ggml_tensor*) #6 ggml_backend_cuda_graph_compute(ggml_backend*, ggml_cgraph*) <- no try_fuse frame - Not PDL. With
GGML_CUDA_PDL=0the abort persists and moves to the classic launch path —common.cuh:1674, statementcudaGetLastError(), sameinvalid argument. So both launch mechanisms reject the same configuration, which points at the launch configuration itself rather than atcudaLaunchKernelEx. - Not quantization. Identical on UD-IQ1_S and UD-IQ3_XXS.
Possible cause (not verified)
rms_norm_f32_cuda (ggml/src/ggml-cuda/norm.cu) builds its grid as:
const dim3 blocks_num(nrows, nchannels, nsamples);grid.y and grid.z are limited to 65535 on CUDA (only grid.x is 2³¹−1), and an over-limit dimension is exactly what makes a launch fail with invalid argument on both launch APIs. That would also explain why the failure is a hard step rather than a gradual degradation.
Scope of this report: I did not instrument the build, so I do not have the actual nrows/nchannels/nsamples at the failing launch, and I did not bisect the exact threshold between 131072 and 262144. The grid-dimension explanation above is a hypothesis consistent with the evidence, not something I verified.
Activity
dragosbas commentedon Aug 28, 2026
Your hypothesis is correct, and I can confirm it with a threshold measurement from the two-stream side of the same bug. Full analysis in #27835 (comment 5454764836); short version here since your report is the
n_stream == 1case.The offending tensor is built at
src/models/qwen4exp.cpp:552:n_blocks*n_streamlands inne[2], whichnorm.cu:353(and:307for the unfused path, which is why yourGGML_CUDA_DISABLE_FUSION=1test still aborted) maps ontogridDim.y, capped at 65535.With
n_blocks = ceil(n_kv / r)andr = 4fromqwen4exp.attention.compress_ratios, a single stream overflows atn_kv >= 262144exactly — which is the boundary you and the reporter in #27742 both hit at the native context depth.n_streamis per-ubatch (llama_memory_hybrid_idx_context::get_n_stream()returnssinfo.s1 - sinfo.s0 + 1), so with two concurrent slots the same limit arrives atn_kv > 131068.I reproduced that two-stream threshold on 2x RTX 3090 and got the control for free inside one run: two slots sharing a ubatch at
n_kv = 116 803completed normally, the same pair atn_kv = 138 982aborted 170 ms later.ceil(116803/4)*2 = 58 402versusceil(138982/4)*2 = 69 492.The two-line fix in #27835 (normalize before the reshape, so the large count goes to
gridDim.x) removes your case as well, since it never putsn_blockson the limited axis. Validated here: 6/6 concurrent requests served with the deep slot decoding atn_kv = 144 701.pentar69 commentedon Aug 30, 2026
Independent reproduction on sm_86 (1× RTX 3090, CUDA 12.8.1, driver 595.84), master at
62acc89c— different arch and toolkit from both existing reports, single stream (-np 1).UD-IQ4_XS,
-ngl 999 --n-cpu-moe 48 -ub 1024 -fa on -ctk q8_0 -ctv q8_0, YaRN ×2 +--override-kv qwen4exp.context_length=int:524288(512K slot allocates at 20.7 GiB). A ~320K-token prefill aborts deterministically (two runs, 1698 s / 1707 s) on the ubatch crossing exactly 262144 — lastprint_timingline isn_tokens = 261120:Supporting the
n_blocksthreshold analysis above: raisingcontext_lengthvia--override-kvdoes not move the crash point — it still fires at 262144, so the trigger is the size threshold, notn_ctx_trainlogic. Full server log available on request.anhyeuviolet commentedon Sep 1, 2026
I hit the same crash on a different Blackwell part and instrumented the launch, so here are the actual grid numbers.
Hardware: 2x RTX PRO Blackwell (5000 48GB + 4500 32GB), cc 12.0, driver 580
open, CUDA 13.0.1, Ubuntu 22.04. Model is Qwen3.8-Flash-Next UD-Q2_K_XL,
-c 1048576 --parallel 4(262144 per slot),--cache-type-k/v q8_0.Confirming your PDL finding:
GGML_CUDA_PDL=0does not help here either. It only moves the abort fromcommon.cuh:1668(thecudaLaunchKernelExpath) tocommon.cuh:1674(the plain<<<>>>path). Same function, same message, so the launch configuration itself is what gets rejected.The numbers. I patched
norm.cuto print the grid right before the launch whenever a dimension is over the limit. Two crashes, both inrms_norm_mul_f32_cuda:The print and the abort land in the same log second and the same PID, so this is the launch that fails. Your grid-dimension hypothesis is correct:
yis the one over 65535,zis fine, andxis sitting at 1 while it could go to 2^31-1.Two things worth noting:
ygrows with context length, it is not a fixed function of the configuredn_ctx. That is why the crash is not immediate — it needs enough context to pushnchannelspast 65535. On our box that works out to roughly 80-95k tokens, and a user independently reported the failure at ~30% of a 262k window, which matches.-ubdoes not avoid it. I tried-ub 256andystill reached 110336, so the channel count does not track the micro-batch size.Reproducer. One slot prefilling a very long prompt while other slots send short requests. Single-slot runs are fine — I pushed 160912 tokens through one slot with no trouble. That lines up with #27911, where
-np 1is unaffected.A fix that works for us. The kernels take
nchannelsfromgridDim.yand the channel index fromblockIdx.y, so the channel dimension can be split into chunks of at most 65535 as long as the kernel can still compute the global channel index. Pointer arithmetic alone is not enough — it breaks thedstoffset (which multiplies bynchannels) and thefastmodulobroadcast indices formul/add.What I did instead, in
norm_f32,rms_norm_f32andl2_norm_f32, was add two trailing parameters:and wrap each of the four host helpers in a loop over channel chunks, passing
ch0and the truenchannels. When nothing is over the limit there is exactly one chunk withch_base = 0, so the existing path is unchanged.Results on our box:
test-backend-ops -o RMS_NORM51/51, plusNORMandL2_NORMpassing.I am not opening a PR since this is a workaround shaped around our own build, but happy to share the diff or test a proper patch on this hardware if that helps.
github-actions commentedon Oct 16, 2026
This issue was closed because it has been inactive for 14 days since being marked as stale.
adamlawi commentedon Oct 16, 2026
For the record, since this was closed as stale: the bug is fixed in master by #27941 (
36b101543, merged 2026-09-01).build_qsa_top_kinsrc/models/qwen4exp.cppnow appliesbuild_normbeforeggml_reshape_3d, so the block count goes tone1instead ofgridDim.y. That is the change @dragosbas described above.On our side, a prefill on a CUDA build after the fix went past the threshold (264192 tokens) without the abort. That run was on a different CUDA host, not the GB10 from the original report, and I haven't re-run it on sm_121.
The "not planned" label is only the stale bot. This was fixed (completed), but I don't have permission to change the close reason.