Repository navigation
Conversation
Assisted-by: OpenAI coding assistant
bri-prism
left a comment
There was a problem hiding this comment.
Thanks for the careful write-up. One problem with the premise: llama.cpp's attention builder sets
GGML_PREC_F32 on every flash attention node (build_attn_mha in llama-graph.cpp), so with this PR the
CPU path with an F16 KV cache and the CUDA/HIP vec and tile kernels switch to F32 accumulation for every
model, not only for graphs that opt in. That is a default precision and performance change, and there
are no speed numbers yet.
It also instantiates both accumulator variants for every tile and vec kernel, which roughly doubles those
template instances and adds a lot of CUDA/HIP build time.
To move forward I would need:
- llama-bench before/after on CPU, an NVIDIA GPU (vec path) and an AMD GPU (tile path), at least pp512
and tg128 with the default F16 cache. - Evidence that F16 accumulation hurts a real model (KLD or greedy divergence against an F32 reference),
not only the synthetic cancellation inputs. - A FLASH_ATTN_EXT case in test-backend-ops instead of a standalone test, so every backend is checked.
- A build and test run on this branch, including a GPU without fast FP16, since the float tile path was
restructured too.
Since this is upstream ggml code, I would also suggest raising it with ggml-org first. If only one model
needs it, an opt-in that leaves the default dispatch unchanged would be much easier to take here.
Overview
Honor the existing
GGML_PREC_F32accumulation request in the CPU F16-KV fallback and the generic CUDA/HIP flash-attention tile and vector paths. These paths can currently retain the running value numerator in F16 despite that request, losing small contributions during cancellation.CPU, tile and vector changes stay together because they enforce one existing operator contract and the same public regression. The first historical tile-only correction still failed vector cases. This branch is independent of model/tokenizer changes and starts at
prism@6447906; implementations and regression are extracted fromJohnUzoka/llama.cpp@3d1930a(original based7b2896, an ancestor ofprism).Additional information
Recorded validation, not a new test run
The 2026-11-11 canonical correctness record records the same public probe against before/after shared libraries:
ROCm0)Toolchain and runtime identity and the source-patch application record retain provenance.
No build, tests, linters or formatters were run during this extraction; this separated branch has not been independently built. Historical hardware coverage is Ryzen 3700X CPU and Windows HIP RX6600, F16 KV. NVIDIA CUDA and MUSA have not been validated. Dispatch coverage comments describe source expectations, not a kernel trace. No speed, perplexity or model-quality improvement is claimed; full CI,
test-backend-ops, and other hardware remain unrun here. The focused public-API regression is used because a differently rounded backend reference can conceal this accumulator-contract failure.Requirements