Repository navigation
serve: warn that a quantised KV cache takes attention off the device on hrx (engine#679) - #3279
Conversation
…on hrx (engine#679) #3275 added --ctk/--ctv as a passthrough so a long-context serve could ask for a smaller KV cache. On hrx that is a foot-gun rather than a lever, and the matcher is explicit about it: dispatch-flash-attention.cpp:247 and :332 -- both HRX FA matchers if (query->type != GGML_TYPE_F32 || key->type != GGML_TYPE_F16 || value->type != GGML_TYPE_F16 || ...) return {}; No registration anywhere in dispatch_registration/ accepts a quantised K or V, so a quantised cache does not read less: the matchers DECLINE and attention runs on the CPU -- a large slowdown with nothing printed. So say it, once, in the same voice as the other placement warnings, naming both types and the consequence. Deliberately a warning and not a refusal: the cpu route serves quantised caches legitimately, and a future HRX K/V-quant matcher should not need this line edited to become reachable. Arms (device-free, tests/print_backend.sh): a quantised --ctk prints the warning, an explicit --ctk f16 does not, and an unasked serve still passes no -ctk/-ctv at all.
PR Reviewer Guide 🔍(Review updated until commit 58d6d16)Here are some key observations to aid the review process:
|
|
VERDICT at 58d6d16: READY — it is the warning that makes #3275's new flag safe on HRX, and the reason is checked in the matchers rather than asserted. // both HRX flash-attention matchers require f16 K/V (dispatch-flash-attention.cpp:247 and :332) and no registration
// accepts a quantised K or V. A quantised cache therefore does not read less -- it makes the matchers DECLINE and
// attention runs on the CPU. Warn once … Not refused: the cpu route serves quantised caches legitimatelyThree properties, and each is why this is the right instrument rather than a refusal:
Test lands in |
|
Un-drafted: CI is clean and the verdict is READY at It missed the 23:00 cut, so it rides c35 — which costs nothing: it changes no default (f16 stays), it only makes the flag #3275 added shout instead of silently moving attention to the CPU. No rebase pushed, no further commits; the branch is |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 58d6d16: READY
The claim is falsifiable and I checked it at the source, in the fork at the engine's current pin (7737fa364):
dispatch-flash-attention.cpp:247 if (query->type != GGML_TYPE_F32 || key->type != GGML_TYPE_F16 || value->type != GGML_TYPE_F16 ||
dispatch-flash-attention.cpp:332 … identical predicate, the second matcher …
key/value must be GGML_TYPE_F16 in both, and neither returns anything else — so a --ctk q8_0 graph makes both matchers return {} and the node falls to whatever else accepts it, which is the CPU. The warning's sentence ("does not read less — it makes the matchers DECLINE") is exactly right, and it is the kind of thing that would otherwise be measured as "q8_0 KV made decode 30 % slower for no reason".
Three things I would keep exactly as they are:
- a warning, not a refusal — the
cpuroute serves quantised caches legitimately, and the comment says the reason: a future HRX K/V-quant matcher should not need this warning edited to become reachable. That is the right side of the line to err on for a foot-gun that only costs speed. f16asked for explicitly is silent — the second arm (--ctk f16→ no warning) is what makes the first arm mean something; a warning that fires on everyhrxserve would be noise and would be switched off.- the condition is per-flag (
!o.ctk.empty() && o.ctk != "f16", and the same forctv), so--ctk q8_0 --ctv f16warns and the message prints the effective pair (o.ctk.empty() ? "f16" : …), which is what a reader needs to see.
Placement is right too: inside launch_for, after the -np block and before the argv push, so it fires for hybrid as well — that route recurses into auto_gguf_device(o), which is hrx on this build, and that is the case where the warning matters most because hybrid's decode is the HRX path.
Not run: tests/print_backend.sh needs a 1bit built from this PR (the binaries here predate the flag), so the two arms are read, not executed — the parsing is a two-line else if chain and the arms assert on $scratch/err with exact substrings, so the run is CI's build.
|
Persistent review updated to latest commit 58d6d16 |
Refs #679, and it corrects the premise of #3275, which merged an hour ago.
What #3275 introduced, and what it cannot do here
--ctk/--ctvnow pass a KV cache type through to llama-server. The reason given was that a quantised cache halves the KV read that dominates long-context decode. On--device hrxthat is false, and the matcher says so:Both HRX FA matchers require f16 K/V, and nothing in
dispatch_registration/accepts a quantised K or V (grep key->type == GGML_TYPE_Q8_0→ nothing). So--ctk q8_0does not read less — it makes the matchers decline and attention runs on the CPU: a large slowdown, with nothing printed to say why.The change
One warning, in the same voice as the other placement warnings, naming both types and the consequence:
A warning, not a refusal, on purpose:
--device cpuserves quantised caches legitimately, and a future HRX K/V-quant matcher should not need this line edited before it can be reached.Arms (device-free, no GPU, no model)
tests/print_backend.sh, over the existing--print-backendharness:--ctkprints the warning;--ctk f16prints nothing;-ctk/-ctvat all (the default stays llama-server's f16).Why this is a draft tonight
The release holds the device and this branch is at current main, where I have no built tree — so the honest state is "CI is the build". I would rather it verifies in c35 than claim a local run I did not do. Ask when CI is green: a verdict, then it merges whenever the queue allows.