You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
llama.cpp CUDA 13.2 gibberish for IQ3_S / IQ3_XXS, IQ2_M - SOLUTION use CUDA < 13.0 or Unsloth Studio #4849
changed the title [-]llama.cpp CUDA 13.2 gibberish for IQ3_S / IQ3_XXS, IQ2_M quants[/-][+]llama.cpp CUDA 13.2 gibberish for IQ3_S / IQ3_XXS, IQ2_M quants - use CUDA 13.0[/+]on Apr 4, 2026
IQ2_M is also affected -- not just IQ3_S/IQ3_XXS. The bug boundary appears to be IQ3 and below (IQ2_M, IQ3_XXS, IQ3_S broken) vs IQ4 and above (IQ4_XS, IQ4_NL, Q4_K_M all fine).
changed the title [-]llama.cpp CUDA 13.2 gibberish for IQ3_S / IQ3_XXS, IQ2_M quants - use CUDA 13.0[/-][+]llama.cpp CUDA 13.2 gibberish for IQ3_S / IQ3_XXS, IQ2_M - **SOLUTION use CUDA < 13.0 or Unsloth Studio**[/+]on Apr 4, 2026
changed the title [-]llama.cpp CUDA 13.2 gibberish for IQ3_S / IQ3_XXS, IQ2_M - **SOLUTION use CUDA < 13.0 or Unsloth Studio**[/-][+]llama.cpp CUDA 13.2 gibberish for IQ3_S / IQ3_XXS, IQ2_M - `SOLUTION use CUDA < 13.0 or Unsloth Studio`[/+]on Apr 4, 2026
Ran 290 individual tests across all combinations of: 2 models x 13 quant types x 6 build configs x 2 flash-attention settings. Every CUDA 13.2 "GIBBERISH" result was manually verified to have a corresponding "OK" result on CUDA 12.8, CPU, and CUDA 13.0 for the same quant.
Test harness: llama.cpp commit 650bf14, prompt "Hello! Can you tell me a short joke?", -n 64 --temp 0.0 --top-k 1 --ctx-size 512 --no-mmap -ngl 999
GPU: RTX PRO 6000 Blackwell Server Edition (compute 12.0, 96GB)
Builds tested:
CPU-only (CUDA 12.8 binary with CUDA_VISIBLE_DEVICES='')
CUDA 12.8 (nvcc V12.8.93)
CU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ents both FA-on and FA-off results (they were always identical -- flash attention setting has no effect on this bug).
Key Findings
CUDA 13.0 is completely unaffected -- zero failures across all 104 CUDA 13.0 tests (including +cuBLAS). This confirms the regression is specific to CUDA 13.2.
CPU-only is completely unaffected -- confirming this is a CUDA codegen bug, not a model/quant format issue.
cuBLAS workaround does NOT help -- GGML_CUDA_FORCE_CUBLAS=ON produces identical gibberish on CUDA 13.2. For Qwen IQ3_S+cuBLAS, it additionally crashes with SIGABRT.
Flash attention on/off has no effect -- the bug manifests identically regardless of FA setting.
The affected quant types differ by model architecture:
Gemma-4-31B: IQ2_M, IQ3_XXS, Q2_K_XL broken (low-bit IQ quantization + Q2_K)
Qwen3.5-35B-A3B: IQ3_S, IQ4_XS, IQ4_NL broken (mid-range IQ quantization)
Notably, Qwen's IQ2_M and IQ2_XXS work fine on CUDA 13.2, while they break on Gemma. And Gemma's IQ4_XS and IQ4_NL work fine, while they break on Qwen.
Standard K-quants are unaffected on both models: Q3_K_XL and above (Q3_K_XL, Q4_K_M, Q4_K_XL, Q5_K_XL, Q6_K_XL, Q8_0) all work correctly on CUDA 13.2.
The fact that different IQ quant types break on different model architectures suggests the CUDA 13.2 compiler generates incorrect code for specific dequantization kernel instantiations, likely depending on tensor shape parameters (which differ between Gemma-4-31B and Qwen3.5-35B-A3B MoE).
Root Cause Analysis: CUDA 13.2 NVVM Optimizer (cicc) Bug
Finding: -Xcicc -O1 Fixes the Issue
We rebuilt llama.cpp with CUDA 13.2 at different NVVM optimizer levels (-Xcicc -ON) to isolate the bug:
cicc opt level
Gemma IQ3_XXS
Qwen IQ3_S
Qwen IQ4_XS
-Xcicc -O0
OK
OK
OK
-Xcicc -O1
OK
OK
OK
-Xcicc -O2
GIBBERISH
GIBBERISH
GIBBERISH
-Xcicc -O3 (default)
GIBBERISH
GIBBERISH
GIBBERISH
The bug is introduced by the NVVM IR optimizer (cicc) at optimization level O2.
What Does NOT Fix It
Flag
Result
nvcc -O0 (host only)
Still broken
--fmad=false
Still broken
--ptxas-options=-O0
Still broken
GGML_CUDA_FORCE_CUBLAS=ON
Still broken
Flash attention on/off
No effect
This rules out ptxas (the PTX-to-SASS assembler) and host-side compilation as the cause.
PTX Analysis
Comparing the PTX output from cicc -O1 (working) vs cicc -O2 (broken) for mmvq.cu:
O1 PTX: 110,942 lines
O2 PTX: 226,284 lines (2x larger)
The O2 optimizer aggressively inlines and transforms the code, more than doubling the PTX size. The miscompilation likely occurs during this aggressive inlining/optimization of the IQ dequantization functions.
Which Kernels Are Affected
The broken kernels share structural patterns not present in the working kernels:
This is a more targeted workaround than downgrading to CUDA 12.8 entirely, though using CUDA 12.8 or 13.0 remains the safest option.
Suggested Action for NVIDIA
The bug is in the CUDA 13.2 cicc (NVVM IR) optimizer at O2+ and affects dequantization kernels that use device-side lookup tables and __byte_perm/__vcmpne4/__vsub4 intrinsics. A reduced test case focusing on the get_int_from_table_16() function from llama.cpp's vecdotq.cuh (which chains 5 __byte_perm calls) or the __vcmpne4+__vsub4 sign-application pattern would likely be sufficient to reproduce.
NVIDIA is already tracking this via the llama.cpp upstream issues -- CC @gaugarg-nv@prewaskar-nv if they can investigate the cicc O2 regression specifically.
Reacted by xyehya, leko, Abhishek Dash, Thireus ☠, Foo Bar, SmallAndSoft, magikRUKKOLA, Chanif Rusydi, sakharovaan and KrisKale42
The CUDA 13.2 cicc/NVVM O2 miscompilation is fixed in CUDA 13.3. @dcbishop reported it fixed here, and a previously failing quant was independently retested successfully under CUDA 13.3 in ggml-org/llama.cpp#21255. The same compiler issue was also tracked in ggml-org/llama.cpp#21371.
The root cause is in NVIDIA's compiler rather than Unsloth. Anyone still pinned to the 13.2 toolkit can build with -DCMAKE_CUDA_FLAGS="-Xcicc -O1" or use the CUDA 13.0 binaries from unslothai/llama.cpp b8746. @danielhanchen did extensive reproduction and root-cause analysis above. Closing as resolved upstream.
@oobabooga the latest version of llama-cpp shipped with unsloth studio v2026.8.16 (installed release: unslothai/llama.cpp@b10360-mix-87da1a2 (tag b10360)) is still affected by this bug. Even though the issue is "resolved" upstream, shouldn't we keep it open until we have patched the default shipped version ?
Activity
[-]llama.cpp CUDA 13.2 gibberish for IQ3_S / IQ3_XXS, IQ2_M quants[/-][+]llama.cpp CUDA 13.2 gibberish for IQ3_S / IQ3_XXS, IQ2_M quants - use CUDA 13.0[/+]danielhanchen commentedon Apr 4, 2026
Reproduced on an RTX PRO 6000 Blackwell Server Edition (compute 12.0, 96GB VRAM).
Setup:
CMAKE_CUDA_ARCHITECTURES=120Results -- Gemma-4-31B-it (unsloth/gemma-4-31b-it-GGUF):
[Start thinking] * User wants a short joke... Why don't scientists trust atoms?deHH laesLH laHse지원KLHLeHsenH坐es الأخرىHal laHLLteLH...CHistTLBalal/THHS singlealalistHHalingLH/alLHLalHen...[Start thinking] * User wants a short joke... Why don't scientists trust atoms?laistySS own own own laBoge// own own own own de que que la la...[Start thinking] * User wants a "short joke"... Why don't scientists trust atoms?[Start thinking] * User wants a short joke... Why don't scientists trust atoms?[Start thinking] * User wants a short joke... Why don'...Results -- Qwen3.5-35B-A3B (unsloth/Qwen3.5-35B-A3B-GGUF):
[Start thinking] Thinking Process: 1. Analyze the Request...I\ns,\nHello!(2 p: wjg')'. 1 and 1 0 *+ abort/core dumpAll tests used:
-n 64 --temp 0.0 --top-k 1 --ctx-size 512 --no-mmap -ngl 999Additional findings beyond the original report:
GGML_CUDA_FORCE_CUBLAS=ONdoes not help on this configuration -- still produces gibberish, and for Qwen IQ3_S it actually crashes with an abort/core dump. This differs from Eval bug: gemma-4-31B-it-UD-IQ3_XXS.gguf (unsloth) produces gibberish on blackwell (RTX 5080 tested) with GGML_CUDA=ON compilation VS normal correct output with BLAS/CPU compilations ggml-org/llama.cpp#21371 where cuBLAS was reported as a workaround.Upstream issues: ggml-org/llama.cpp#21255 and ggml-org/llama.cpp#21371. NVIDIA has acknowledged and CC'd the CUDA compiler team.
[-]llama.cpp CUDA 13.2 gibberish for IQ3_S / IQ3_XXS, IQ2_M quants - use CUDA 13.0[/-][+]llama.cpp CUDA 13.2 gibberish for IQ3_S / IQ3_XXS, IQ2_M - **SOLUTION use CUDA < 13.0 or Unsloth Studio**[/+][-]llama.cpp CUDA 13.2 gibberish for IQ3_S / IQ3_XXS, IQ2_M - **SOLUTION use CUDA < 13.0 or Unsloth Studio**[/-][+]llama.cpp CUDA 13.2 gibberish for IQ3_S / IQ3_XXS, IQ2_M - `SOLUTION use CUDA < 13.0 or Unsloth Studio`[/+]danielhanchen commentedon Apr 4, 2026
Comprehensive Cartesian Combo Testing Results
Ran 290 individual tests across all combinations of: 2 models x 13 quant types x 6 build configs x 2 flash-attention settings. Every CUDA 13.2 "GIBBERISH" result was manually verified to have a corresponding "OK" result on CUDA 12.8, CPU, and CUDA 13.0 for the same quant.
Test harness: llama.cpp commit 650bf14, prompt "Hello! Can you tell me a short joke?",
-n 64 --temp 0.0 --top-k 1 --ctx-size 512 --no-mmap -ngl 999GPU: RTX PRO 6000 Blackwell Server Edition (compute 12.0, 96GB)
Builds tested:
CUDA_VISIBLE_DEVICES='')GGML_CUDA_FORCE_CUBLAS=ONGGML_CUDA_FORCE_CUBLAS=ONAll builds targeting
CMAKE_CUDA_ARCHITECTURES=120.Gemma-4-31B-it (
unsloth/gemma-4-31b-it-GGUF)Qwen3.5-35B-A3B (
unsloth/Qwen3.5-35B-A3B-GGUF)Each cell represents both FA-on and FA-off results (they were always identical -- flash attention setting has no effect on this bug).
Key Findings
CUDA 13.0 is completely unaffected -- zero failures across all 104 CUDA 13.0 tests (including +cuBLAS). This confirms the regression is specific to CUDA 13.2.
CPU-only is completely unaffected -- confirming this is a CUDA codegen bug, not a model/quant format issue.
cuBLAS workaround does NOT help --
GGML_CUDA_FORCE_CUBLAS=ONproduces identical gibberish on CUDA 13.2. For Qwen IQ3_S+cuBLAS, it additionally crashes with SIGABRT.Flash attention on/off has no effect -- the bug manifests identically regardless of FA setting.
The affected quant types differ by model architecture:
Standard K-quants are unaffected on both models: Q3_K_XL and above (Q3_K_XL, Q4_K_M, Q4_K_XL, Q5_K_XL, Q6_K_XL, Q8_0) all work correctly on CUDA 13.2.
The fact that different IQ quant types break on different model architectures suggests the CUDA 13.2 compiler generates incorrect code for specific dequantization kernel instantiations, likely depending on tensor shape parameters (which differ between Gemma-4-31B and Qwen3.5-35B-A3B MoE).
Upstream: ggml-org/llama.cpp#21255 and ggml-org/llama.cpp#21371
danielhanchen commentedon Apr 4, 2026
Root Cause Analysis: CUDA 13.2 NVVM Optimizer (cicc) Bug
Finding:
-Xcicc -O1Fixes the IssueWe rebuilt llama.cpp with CUDA 13.2 at different NVVM optimizer levels (
-Xcicc -ON) to isolate the bug:-Xcicc -O0-Xcicc -O1-Xcicc -O2-Xcicc -O3(default)The bug is introduced by the NVVM IR optimizer (cicc) at optimization level O2.
What Does NOT Fix It
nvcc -O0(host only)--fmad=false--ptxas-options=-O0GGML_CUDA_FORCE_CUBLAS=ONThis rules out ptxas (the PTX-to-SASS assembler) and host-side compilation as the cause.
PTX Analysis
Comparing the PTX output from
cicc -O1(working) vscicc -O2(broken) for mmvq.cu:The O2 optimizer aggressively inlines and transforms the code, more than doubling the PTX size. The miscompilation likely occurs during this aggressive inlining/optimization of the IQ dequantization functions.
Which Kernels Are Affected
The broken kernels share structural patterns not present in the working kernels:
static __device__arrays in constant memory):iq2s_grid[1024],iq3s_grid[512],iq3xxs_grid[256],kvalues_iq4nl[16]__byte_permintrinsic chains for table lookup emulation (IQ4_NL, IQ4_XS)__vcmpne4+__vsub4XOR-subtract sign-negation pattern (IQ2_S, IQ3_XXS, IQ3_S)The working K-quants (Q3_K, Q4_K, Q5_K, Q6_K, Q8_0) use none of these -- they decode purely via bit-shifts and masks.
Workaround
Adding
-Xcicc -O1to the CUDA compilation flags completely fixes the issue on CUDA 13.2 while retaining most optimizations:Or for users building llama.cpp:
cmake -DCMAKE_CUDA_FLAGS="-Xcicc -O1" ...This is a more targeted workaround than downgrading to CUDA 12.8 entirely, though using CUDA 12.8 or 13.0 remains the safest option.
Suggested Action for NVIDIA
The bug is in the CUDA 13.2
cicc(NVVM IR) optimizer at O2+ and affects dequantization kernels that use device-side lookup tables and__byte_perm/__vcmpne4/__vsub4intrinsics. A reduced test case focusing on theget_int_from_table_16()function from llama.cpp'svecdotq.cuh(which chains 5__byte_permcalls) or the__vcmpne4+__vsub4sign-application pattern would likely be sufficient to reproduce.NVIDIA is already tracking this via the llama.cpp upstream issues -- CC @gaugarg-nv @prewaskar-nv if they can investigate the cicc O2 regression specifically.
gaugarg-nv commentedon Apr 4, 2026
@danielhanchen Thanks for the detailed root cause analysis. I have passed on this information to CUDA compiler team.
Panchovix commentedon Apr 9, 2026
Can confirm this issue as well on my setup.
ChanifRusydi commentedon Apr 12, 2026
Can anyone confirm whether using CUDA 13.1 would working fine?
Panchovix commentedon Apr 12, 2026
@ChanifRusydi it does!
danielhanchen commentedon Apr 12, 2026
https://github.com/unslothai/llama.cpp/releases/tag/b8746 for now has pre-compiled binaries for CUDA 13.0 (which work in CUDA 13.2 since CUDA is backwards compatible) - I would use those for now.
dcbishop commentedon Jun 3, 2026
Seems like this is fixed with CUDA 13.3
oobabooga commentedon Jul 28, 2026
The CUDA 13.2 cicc/NVVM O2 miscompilation is fixed in CUDA 13.3. @dcbishop reported it fixed here, and a previously failing quant was independently retested successfully under CUDA 13.3 in ggml-org/llama.cpp#21255. The same compiler issue was also tracked in ggml-org/llama.cpp#21371.
The root cause is in NVIDIA's compiler rather than Unsloth. Anyone still pinned to the 13.2 toolkit can build with
-DCMAKE_CUDA_FLAGS="-Xcicc -O1"or use the CUDA 13.0 binaries from unslothai/llama.cpp b8746. @danielhanchen did extensive reproduction and root-cause analysis above. Closing as resolved upstream.hippalectryon-0 commentedon Aug 14, 2026
@oobabooga the latest version of llama-cpp shipped with unsloth studio v2026.8.16 (
installed release: unslothai/llama.cpp@b10360-mix-87da1a2 (tag b10360)) is still affected by this bug. Even though the issue is "resolved" upstream, shouldn't we keep it open until we have patched the default shipped version ?