« All posts

Tesla P100's silent FP16 precision bug in llama.cpp fixed

A 3-line CUDA patch in llama.cpp fixes a years-old silent FP16 precision bug on Tesla P100 GPUs, with zero performance cost.

llama.cpp's CUDA code contains a flag that routes certain GPU architectures onto a fast fp16 math path. The GTX 10-series and P40 (sm_61) were exempted from this path long ago, but the P100 (sm_60) — ironically the one Pascal card with genuine fast fp16 hardware — never got the same exemption. The result was a quiet precision bug that went unnoticed for years.

The issue surfaced when the same model produced inconsistent quality floors across different machines, and was confirmed via KL-divergence measurements: median KLD dropped from 0.0023 to 0.000001 (~2300x tighter), and top-token agreement rose from 96.5% to 99.9%. The fix costs nothing in performance — decode speed actually measured about 1.4% faster after patching, since real workloads are bound by GEMM and memory bandwidth rather than the fp16 vector path.

The 3-line patch shipped in turboquant v0.3.0 and only affects sm_60; other architectures, including Volta and newer plus the already-exempt P40/1080, are untouched. With P100s selling for around $80 and offering 16GB of HBM2 at 732 GB/s, this fix makes an already cheap card meaningfully more attractive for local inference.