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
[BUG] GGUFCudaKernel (AUTO for GGUF Q4_0 on CUDA) crashes on zero-row input: 'GGML plan has no scratch tensors' (every other kernel, incl. GGUFCppKernel on CPU, returns an empty output) #4743
GGUFCudaKernel.forward (nn_modules/qlinear/gguf_cpp.py:1924-1975) has no empty-input guard. GGUF_CPP_CUDA is the kernel AUTO picks for Q4_0/Q8_0-style GGUF checkpoints on CUDA. On a zero-row input (x.shape == (0, K) or (B, 0, K)) it builds a ggml plan with zero-sized tensors and raises:
RuntimeError: GGUFCudaKernel GGML plan has no scratch tensors. (gguf_cpp.py:1204, since #4436)
RuntimeError: GGUFCudaKernel failed to allocate GGML backend tensors. (before #4436)
Every other CUDA kernel returns an empty (..., N) output for M=0 through BaseQuantLinear.input_rows() / empty_linear_output(). That covers Marlin, ExLlamaV2, Triton, Torch, all AWQ kernels, QQQ, FP8, NF12, GGUF_TRITON and GGUF_TORCH, and EXL3 after #4550. So does the CPU sibling GGUFCppKernel, which returns (0, N) and (2, 0, N) for the same tensors. M=0 is a real case: MoE experts that receive no tokens and empty batch slices. It has been fixed per-kernel before (#4042 Hadamard M=0, #4550 EXL3 M=0).
Repro
Qwen2.5-0.5B-Instruct quantized on main with GGUFConfig(bits=4) (Q4_0), loaded with BACKEND.AUTO, which selects GGUFCudaKernel for all 168 modules:
GGUFCudaKernel Q4_0
(0, 4864) -> RuntimeError GGUFCudaKernel GGML plan has no scratch tensors.
(2, 0, 4864) -> RuntimeError GGUFCudaKernel GGML plan has no scratch tensors.
(1, 4864) -> (1, 896)
The same happens on the Q4_K_M checkpoint with BACKEND.GGUF_CPP_CUDA, in fp16 and bf16, for every projection.
Suggested fix
At the top of GGUFCudaKernel.forward, do the same as the other kernels:
This must come before the plan cache, so no plan or arena growth happens for M=0. Add M=0 to the GGUF CUDA tests (test_gguf_triton_empty_launch.py covers only Triton).
Severity
Low-medium. It is a crash on a supported shape for the AUTO GGUF CUDA kernel, and nothing falls back.
Claiming. Will add the M=0 guard to GGUFCudaKernel.forward (before the plan cache, per the suggestion) plus a regression test that also covers the Q4_K_M path, and verify every other GGUF kernel already returns an empty output for the same shapes.
Activity
Qubitium commentedon Nov 17, 2026
Agent claim released:
agent-53ba17eb4d83finished this issue.Pull request: #4778
claiming: fix on a worktree, PR when green
Qubitium commentedon Nov 17, 2026
Claiming. Will add the M=0 guard to
GGUFCudaKernel.forward(before the plan cache, per the suggestion) plus a regression test that also covers the Q4_K_M path, and verify every other GGUF kernel already returns an empty output for the same shapes.fix(gguf): return an empty output for zero-row GGUF CUDA inputs (#4743)…
fix(gguf): return an empty output for M=0 on the CUDA kernel (#4743) (#…
refactor(gguf): drop the duplicated M=0 guard in GGUFCudaKernel.forwa…