Skip to content

Sycl iq3 crash fix - #30604

Merged
Titaniumtown merged 3 commits into
ggml-org:masterfrom
anantshri:sycl-iq3-crash-fix
Oct 21, 2026
Merged

Titaniumtown merged 3 commits into
ggml-org:masterfrom
anantshri:sycl-iq3-crash-fix

Conversation

@anantshri

Copy link
Copy Markdown
Contributor

Summary

  • fixes the crash reported in #29107 (comment): llama_sampler_dist_apply: Assertion 'found' failed (NaN logits) with Qwen3.8-27B-GSQ-RCO-IQ3_S-mtp.gguf + --spec-type draft-mtp
  • root cause: ggml_sycl_fused_dequant_gemm — the plain fused-dequant GEMM that serves dense >8-column mul_mats (every prefill / large batch) — decoded its weight stage with the standard block layout unconditionally (fg_fused_run hardcoded fg_visit_type(src0_type, false, ...)). Once sycl: IQ3 code reorder #29107 installs the persistent IQ3_S/IQ3_XXS reorder, any big-batch mul_mat routed there decodes the reordered SoA bytes as standard blocks → confidently wrong logits (the dist assert is the NaN face under MTP; otherwise garbage generations). The hole was unreachable before sycl: IQ3 code reorder #29107: the only types with SoA A-stages (Q8_0/Q4_K/Q5_K/Q6_K) are exactly the ones fg_plain_ok() excludes from the plain path
  • fix: pass the tensor's reorder flag from the caller through ggml_sycl_fused_dequant_gemm → fg_fused_run → fg_visit_type. Types without an SoA A-stage (IQ3_S/IQ3_XXS today) decline the fused path and the caller falls through to the existing reorder-aware conversion route. SoA-capable types keep the fused fast path; the launch is templated on the reorder bit so a future IQ3 SoA stage cannot reopen the hole. The sycl: IQ3 code reorder #29107 reorder and its decode gains are fully preserved
  • also teaches get_rows the IQ3_S/IQ3_XXS reorder layout (the same hole as Misc. bug: [SYCL] GET_ROWS returns wrong values or NaN on weights reordered by MUL_MAT #30428/sycl : fix get_rows on reordered quantized weights #30430, which cover Q4_0/Q8_0/K-quants but not the types sycl: IQ3 code reorder #29107 made reorderable)
  • adds two regression tests: test_get_rows_after_mul_mat and test_mul_mat_reorder_then_big_batch — both fail on current master and pass with this PR (verified on-device, Arc Pro B70)

Reproducer (~90 s, deterministic on BMG)

llama-cli -m Qwen3.8-27B-GSQ-RCO-IQ3_S-mtp.gguf -t 8 -fa 1 -ngl 999 --ctx-size 8192 \
  --spec-type draft-mtp --spec-draft-n-max 5 --spec-draft-p-min 0.8 \
  --rope-scaling yarn --rope-scale 2 --yarn-orig-ctx 262144 --temp 0.6 -n 96 -p "Write a short essay."

garbage from the first generated tokens on master; clean with this PR. (GGML_SYCL_ENABLE_OPT=0 also hides it on master — that is how the reorder was first isolated from the reporter's config.)

Verification (Intel Arc Pro B70, oneAPI 2026.1.1; validation base 23deec02, applies cleanly on current master 711780ff — the 22 commits between touch nothing in ggml-sycl/ or test-backend-ops.cpp)

gate master this PR
CLI repro (flags above) garbage every run clean ×3, 28.1 t/s
llama-server, reporter's exact flags, 5 min concurrent load garbage in ~93% of requests + SIGSEGVs (libigc, libggml-base) 42/42 clean, no crash, 16.4 t/s/slot
new regression tests (SYCL0) FAIL (NaN / inf) PASS
test-backend-ops MUL_MAT / GET_ROWS / ADD pass pass
IQ3_S llama-bench pp512 / tg128 562.6 / 23.33 561.8 / 23.50 (#29107's decode gain retained)
Q4_K_XL pp512 / tg128 982.5 / 24.34 984.1 / 24.39

Also swept the fix across the full model fleet on B70 (K-quants, MoE, MLA, hybrid-GDN, vision, MTP, IQ1_M/Q8_0/BF16): zero garbage on every model that runs on master.

Requirements

  • I have read the contributing guidelines: yes
  • AI usage disclosure: yes — root-cause analysis, the fix, and the verification matrix were developed with AI assistance (GLM 5.3, running in opencode); all measurements were taken on real hardware and raw logs are available on request.

The persistent IQ3 reorder permutes weight bytes in place on first
small-batch mul_mat and flags the tensor via
extra->optimized_feature.reorder. GET_ROWS ignored the flag and read
the permuted bytes with the standard-layout dequantizer, returning
garbage or NaN rows for any tensor read by both ops (the same hole as
ggml-org#30428/ggml-org#30430, which fix Q4_0/Q8_0/K-quants but not the IQ3 types).

- getrows.cpp: reorder-aware get_rows for IQ3_S/IQ3_XXS - one 32-thread
  work-group per QK_K block of a requested row, calling the existing
  reorder-aware block dequantizers with the global block index
  (row * blocks_per_row + block).
- dequantize.hpp: the two IQ3 reorder block dequantizers now take the
  block index and block output pointer as parameters instead of reading
  get_group(2), mirroring the K-quant refactor in ggml-org#30430; convert.cpp
  callers pass the same values as before.
- test-backend-ops.cpp: test_get_rows_after_mul_mat (mul_mat first, then
  get_rows on the same weight) covering IQ3_XXS and IQ3_S.

Host-side bit-exact validation against the CPU reference dequantizers
(reorder writer + block dequantizer + get_rows indexing ported verbatim):
max |diff| = 0 for all rows/blocks of a 7x3-block tensor.
ggml_sycl_fused_dequant_gemm (the dense >8-column mul_mat path taken by
prefill and large batches) decoded its A stage with the standard block
layout unconditionally: fg_fused_run hardcodes fg_visit_type(..., false).
After ggml-org#29107 made IQ3_S/IQ3_XXS reorderable, any already-installed tensor
routed here was decoded from the reordered SoA bytes as if they were
standard blocks -> confidently wrong logits (the upstream dist-sampler
assert is the NaN face under MTP). The plain path could never meet a
reordered tensor before ggml-org#29107: the only types with SoA decoders
(Q8_0/Q4_K/Q5_K/Q6_K) are exactly the ones fg_plain_ok() excludes.

Wire the tensor's reorder flag through and let fg_visit_layout decline:
for types without an SoA stage (IQ3_S/IQ3_XXS today) the fused path now
returns false and the caller falls through to the reorder-aware f16
conversion route, which decodes correctly. Non-reordered tensors and
SoA-capable types keep the fused fast path unchanged.

Repro/verification (Arc Pro B70, Qwen3.8-27B-GSQ-RCO-IQ3_S-mtp, master
23deec0): every default-config generation turned to garbage; with this
patch the same runs are clean and the reordered MMVQ decode speedup is
retained.
@anantshri
anantshri marked this pull request as ready for review October 15, 2026 14:47
@anantshri
anantshri requested review from a team and ggerganov as code owners October 15, 2026 14:47
@anantshri

Copy link
Copy Markdown
Contributor Author

@Titaniumtown @arthw Please review

@AdamN1 this should help

@github-actions github-actions Bot added testing Everything test related ggml changes relating to the ggml tensor library for machine learning SYCL https://en.wikipedia.org/wiki/SYCL - GPU programming language labels Oct 15, 2026
@hotschmoe

Copy link
Copy Markdown

Independent confirmation on different hardware and a different model: this PR fixes garbage output I was seeing on a MoE IQ3 model.

Setup

  • 2x Intel Arc Pro B70 (BMG-G31), Linux 7.1, compute runtime 26.22, oneAPI 2026.1, AOT bmg-g31, GGML_SYCL_F16=ON
  • llama.cpp master e467e5b (includes sycl: IQ3 code reorder #29107)
  • Model: ISTA-DASLab Qwen3.8-Flash-Next GSQ-RCO IQ3_XXS GGUF. This is a mixed-type quant with 82 IQ3_S and 12 IQ3_XXS tensors, plus Q6_K/Q5_K/Q4_K/IQ4_XS/IQ2_*; token_embd is IQ3_S.
  • llama-server -ngl 99 -fa on -sm layer -np 2 --jinja, greedy, thinking off

Symptom on e467e5b (default GGML_SYCL_ENABLE_OPT)

Return only the integer: 17 * 19. returns 333333 Mountfonoon,O(asp2... or !!!!!!.... It happens with MTP on or off, with one request or two concurrent ones, and for every padded prompt length from 25 to 441 tokens. Some longer prompts, such as a ~107-token coding request, still came out coherent, which is how it went unnoticed at first.

Build / setting 14 arithmetic prompts (25-441 tok) coding prompt
CPU build, same GGUF correct (323) coherent
SYCL e467e5b, default all wrong coherent
SYCL e467e5b, GGML_SYCL_ENABLE_GRAPH=0 / ENABLE_FUSION=0 / ENABLE_DNN=0 wrong coherent
SYCL e467e5b, GGML_SYCL_ENABLE_OPT=0 correct coherent
SYCL e467e5b + this PR (be16261), default OPT 14/14 correct coherent

Per-card and two-card collective health checks passed after every run. I applied the PR diff cleanly onto e467e5b and rebuilt incrementally; I haven't run test-backend-ops on it.

@NeoZhangJianyu NeoZhangJianyu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good job!

Thank you!

@arthw arthw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for quick fixing!

@arthw

arthw commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

@anantshri
Please resolve the conflicts!

Thank you!

@anantshri

Copy link
Copy Markdown
Contributor Author

@arthw resolved.

@arthw arthw added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Oct 21, 2026
@Titaniumtown
Titaniumtown self-requested a review October 21, 2026 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. SYCL https://en.wikipedia.org/wiki/SYCL - GPU programming language testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants