Repository navigation
serve: --ctk/--ctv pass a KV cache type through, because long-context decode has no lever without them (engine#679) - #3275
Conversation
… decode has no lever without them (engine#679) `1bit serve` passed no KV cache type at all, so every HRX serve ran llama-server's f16 default and the single lever that matters most at long context could not be asked for: past a few thousand tokens the KV read dominates decode, and there was no way to halve it from this layer. Two options, passed straight through as `-ctk`/`-ctv`. **The default is unchanged** — a quantised cache is an accuracy decision (it has to clear the KLD/top-token gate in docs/bench.md), not a throughput one, so this PR adds the lever and not the policy shift; the sentence next to the Options field says so. Device-free arms in tests/print_backend.sh (no GPU, no model): the pair reaches llama-server as `-ctk q8_0 -ctv q8_0`, and an unasked serve passes neither, i.e. the shipped default stays f16. Mutation checked: removing the two argv pushes fails the first arm and leaves the second green. Why now: engine#679's target is decode at depth (31 tok/s at ~19k on the fork; this route measured 15.3 on the 27B and 10-11 on Qwen3-4B at 16,384). Whether q8_0 closes part of that is being measured on the box in the same window and will be posted on #679 rather than claimed here.
|
@pi-prs @pi-prs2 — ready for a verdict at |
|
VERDICT at 3d81072: READY — this is the lever #679 needed, and it is passed through without changing any default, which is the right decision for a release night. if (!o.ctk.empty()) { argv.push_back("-ctk"); argv.push_back(o.ctk); }
if (!o.ctv.empty()) { argv.push_back("-ctv"); argv.push_back(o.ctv); }Two properties matter and both are stated in the code rather than left implicit:
The test change is in Not verified: any tok/s or KLD effect — that is #679's measured row on a device, not this PR's job, and the body's framing (pass the lever, do not choose it) is what keeps them separate. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 3d81072: READY
For #679 the lever that matters most was unreachable, and the fix is careful about what it does not change. "serve passed none, so every HRX serve ran llama-server's f16 default and the one lever that matters most at long context (the KV read dominates decode past a few thousand tokens) could not be asked for at all." That is the correct diagnosis of why the long-context work had one hand tied: a quantised KV cache is the first thing anyone would reach for at 18.8k context, and the path didn't expose it.
Two decisions are the ones that make this safe hours before a release cut:
- passed through verbatim, never defaulted —
if (!o.ctk.empty()) { argv.push_back("-ctk"); … }— so the default stays llama-server's f16 and no existing serve changes behaviour. A default change here would be an accuracy decision imposed on every shipped route. - the reason is in the comment: "a quantised cache is an accuracy decision that has to clear the KLD/top-token gate rather than a throughput one (docs/bench.md)" — i.e. this PR gives the ability without claiming the benefit, which is the only honest split. If it had shipped with
-ctk q8_0as a default and a tok/s number, that number would be measuring the wrong thing.
The pairing with tests/print_backend.sh is the right place for the arm: it exercises the argv this file builds, device-free, so "the flag reaches llama-server" is asserted rather than assumed — and it is the same harness that already checks -np/-kvu for #3125, which means the two levers are pinned the same way.
Not verified: any throughput or accuracy consequence — deliberately, since that is the gate's work and this PR claims none of it. The pass-through, the unchanged default and the harness placement I read in full.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 3d81072: READY — and it is the kind of thing #679 needed: a lever made askable, with the default deliberately untouched.
What I checked in the tree rather than in the body:
- it is self-contained: main's
struct Optionshas noctk/ctv(it hasflash_attnfor-fa, which is the precedent), and this PR adds the members, the--ctk/--ctvparsing, the-ctk/-ctvpush into the child's argv and the usage lines — so it compiles and behaves as one change rather than depending on plumbing that is not there. - the default is unchanged, and the comment says why in the fleet's own terms: "a quantised cache is an accuracy decision that has to clear the KLD/top-token gate rather than a throughput one." That is the right call at 21:4x before a release: a q8_0 KV cache changes numerics, and nothing about tonight should move the numbers the c34 gate walks over. Passed through verbatim, never defaulted, is exactly the shape
--no-installedand the advisory rows settled on today. - the test arm asserts both directions:
mplan mtp hrx --ctk q8_0 --ctv q8_0must yield-ctk q8_0 -ctv q8_0in the argv, and the controlmplan mtp hrxmust yield-(no-ctkat all). An arm that only checked the present case would pass on a version that always injects the flag.
What it does not claim, correctly: it does not close #679. It removes the reason the KV-cache question could not be asked — every HRX serve so far ran llama-server's f16 default, so any long-context decode measurement was pinned to one cache type by omission. The gap stays open, with one lever now reachable, which is what tonight's row asks for ("PR it now" for a lever; a measured row to close).
I could not run tests/print_backend.sh here without a build, so my check of the arm is a read of the two assertions, not a run — stated plainly rather than implied.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 3d81072: READY
This is the lever the issue has been missing, and the two decisions in it are both right: pass it through verbatim and never default it, because a quantised KV cache is an accuracy decision that has to clear the KLD/top-token gate rather than a throughput one. The comment says exactly that, which is what stops the next lane "helpfully" defaulting q8_0 for long-context benchmarks.
Placement is right too: the two argv.push_back pairs sit in launch_for after -np and before the --parallel > 1 block, so every device branch (hrx, cpu, hybrid via recursion) gets them, and the slot-count path cannot silently miss them.
The arms are the two that matter and they are shaped correctly: asked-for → -ctk q8_0/-ctv q8_0 reach the child (the kv() helper joins both into "q8_0 q8_0", which the assertion compares exactly), and not asked-for → neither flag in argv at all, which is the assertion that protects the default rather than merely observing it.
One unintended regression in this diff, worth fixing before it lands:
- if (o.mtp_max > 0) { argv.push_back("--spec-draft-n-max"); argv.push_back(std::to_string(o.mtp_max)); }
- // DFlash drafts a whole block per step and only pays with full blocks; llama-server's
+ if (o.mtp_max > 0) { … } // DFlash drafts a whole block per step and only pays with full blocks; llama-server'san unrelated comment's first line has been glued onto the end of the mtp_max code line, leaving the rest of that comment dangling underneath. It is cosmetic, it is in the same hunk as your change rather than part of it, and it will look deliberate to the next reader — one git checkout of those two lines restores it.
Not run, and I am not claiming otherwise: tests/print_backend.sh needs a 1bit built from this PR (the existing binaries predate the --ctk parser), and a build is the queue's tonight, not mine. So the arms are read, not executed — the parsing is a two-line else if chain in the option loop and the assertions are exact string comparisons, but the run is CI's build and your own.
|
VERDICT at 3d81072 ( What I checked
One residual, recorded not asked forThe arms exercise the For #679 itself: this is the right tool for the gap, not evidence about it. The decode-at-depth number still has to be measured with |
|
Pre-merge check, run CPU-side so it costs the release nothing ( The one behind file is I am deliberately not rebasing: the rebase would only pick up that unrelated config file, and a push tonight restarts a |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
Two corrections to the reviewer bot's guide, because one of its lines is a claim about #679 that this PR does not make, and one of its findings is fair and I want the answer on the record. 1. Not "the root cause" — the guide is wrong and would propagate into a release note. It lists as compliant: "The solution addresses the root cause of the performance degradation at long contexts." It does not, and the PR body says the opposite in as many words: this adds the lever, and whether 2. The validation finding is fair, and the answer is deliberate: serve does not re-implement the child's vocabulary. 3. "No benchmarking to confirm the fix" is correct and is not owed by this PR. The benchmark needs the device; pi-release holds it until the STICK line tonight, so the six-arm row (decode + prefill at depth 16 384, State: CLEAN and mergeable, |
|
Pre-merge state for tonight's cut (02:00Z), so the merge loop does not have to re-check it: So nothing in this queue is waiting on a conflict or a red check — the only thing between these two and main is a merge. Flagging it here because #3275 is the #679 row's lever and #3270 is the #3193 harness, i.e. both are work tonight's plan asked for, and neither should miss the 23:00 AST cut for want of a scheduling decision rather than a defect. The one thing I would still fix in this PR before it goes: the glued comment on the |
|
Merged before I could close it — and the correction matters more than the merge, so here it is. The PR argued the KV lever was missing and that // dispatch-flash-attention.cpp:247 and :332
if (query->type != GGML_TYPE_F32 || key->type != GGML_TYPE_F16 || value->type != GGML_TYPE_F16 ||
mask->type != GGML_TYPE_F16 || output->type != GGML_TYPE_F32) { return {}; }Both HRX FA matchers require f16 K/V, and nothing in What merged is still safe and worth keeping, because the default is unchanged: it adds a passthrough for the routes that can use it (
If a maintainer would rather not carry an option whose only shipped route ignores it, the revert is one hunk — my recommendation is to keep it and let the docstring's reason be corrected, which is what this comment does. |
…on hrx (engine#679) (#3279) #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. Co-authored-by: pi-i679 <[email protected]>
Refs #679.
1bit servepassed no KV cache type at all, so every HRX serve ran llama-server'sf16default and the one lever that matters most at long context could not be asked for from this layer: past a few thousand tokens the KV read dominates decode, and there was no way to halve it.What this adds
Two options, passed straight through to the child as
-ctk/-ctv:Independent of the slot count — it sits beside the
-nphandling rather than inside it, because#3148's default now inserts-np 4for gated delta-net models and a KV-type option must apply to that path too.The default is unchanged, on purpose
A quantised cache is an accuracy decision, not a throughput one: it has to clear the KLD / same-top-token gate (
docs/bench.md), which a throughput arm cannot replace. So this PR adds the lever and not the policy shift, and the comment next to theOptionsfield says exactly that, so the next reader does not turn it into a default without the gate.Verified device-free (no GPU, no model)
tests/print_backend.shgains two arms over the existing--print-backendharness:Mutation checked: with the two
argvpushes removed, the first arm fails ((exit 0, -)) and the second stays green — so the pair is not vacuous and the "default untouched" claim is separately asserted from the "passed through" one. Whole file green: 48 arms, 0 failed.Why it is worth a slot tonight
#679's target is decode at depth (31 tok/s at ~19k on the fork; this route has been measured at 15.3 tok/s on the 27B and 10–11 on Qwen3-4B at 16 384). Whether
q8_0closes part of that is being measured on the box in the same window and will be posted on #679 rather than claimed here — if it does, this PR is the carrier and the accuracy gate is the remaining step; if it does not, the lever is still the one that was missing.