Repository navigation
Sycl iq3 crash fix - #30604
Sycl iq3 crash fix#30604
Conversation
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.
7d02596 to
3072478
Compare
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.
3072478 to
be16261
Compare
|
@Titaniumtown @arthw Please review @AdamN1 this should help |
|
Independent confirmation on different hardware and a different model: this PR fixes garbage output I was seeing on a MoE IQ3 model. Setup
Symptom on e467e5b (default
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 |
NeoZhangJianyu
left a comment
There was a problem hiding this comment.
It's good job!
Thank you!
arthw
left a comment
There was a problem hiding this comment.
Thank you for quick fixing!
|
@anantshri Thank you! |
|
@arthw resolved. |
Summary
llama_sampler_dist_apply: Assertion 'found' failed(NaN logits) withQwen3.8-27B-GSQ-RCO-IQ3_S-mtp.gguf+--spec-type draft-mtpggml_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_runhardcodedfg_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 onesfg_plain_ok()excludes from the plain pathggml_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 preservedget_rowsthe 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)test_get_rows_after_mul_matandtest_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)
garbage from the first generated tokens on master; clean with this PR. (
GGML_SYCL_ENABLE_OPT=0also 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 master711780ff— the 22 commits between touch nothing inggml-sycl/ortest-backend-ops.cpp)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