Skip to content

[BUG] GGUF_CPP (CPU and CUDA) ggml path error is ~7e-3 to 1e-2 even with fp32 input; whether it's used depends on a timing benchmark (CPU) or on bias presence (CUDA) #4219

Closed

Description

@Qubitium

Severity: low–medium
Version: 7.11.0 @ 9dad249, llama-cpp-python 0.3.36

Summary

ggml quantizes activations to Q8_1 / Q8_K before the K-quant dot product. So GGUF_CPP output differs from the dequantized-weight oracle by well over the 2e-3 tolerance:

Path Relative error vs oracle
CUDA, no bias, fp16 3.6e-3
CUDA, no bias, bf16 7.7e-3
CUDA, no bias, fp32 7.1e-3
CPU 6–10e-3

Which path runs is not stable:

  • CPU: _use_ggml_cpu_matmul (gguf_cpp.py:~949-976) chooses ggml vs dense by a timing benchmark, so the numerics vary from run to run and machine to machine.
  • CUDA with a bias: _finish_ggml_output (~L843-867) discards the ggml result and recomputes a dense fp32 matmul, so the result is exact.

Expected

Either keep the result within tolerance, or document and explicitly gate the activation quantization. Numerics shouldn't depend on timing or on whether a bias exists.


Found during an AI-assisted review (Claude Code) of 9dad249; repros were run on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions