Repository navigation
tools: logprob_agree matches on the key both routes have, never an id against a token (engine#3158) - #3241
Conversation
… against a token (engine#3158) At #3231's merged head, `--match-by id` on a pair where only one route emits token ids compares an int with a string at every position. Measured with two loopback routes emitting identical tokens, one carrying `id` and one not: --match-by id token-id match 0.000 over 32 positions, "token divergence" on all 8 prompts, mean KLD cannot tell rc 1 --match-by text token-id match 1.000, exact-bit 1.000, KLD 0.000000 rc 0 Same tokens. This is the gate's own reference pair -- `app/forward_serve.cpp`'s `logprob_json` emits token/logprob/top_logprobs and no `id` on every backend, while the llama.cpp fork emits ids -- so the command both PR bodies print would report 0 % match and total divergence for two engines running identical tokens, and the row would send a correct model back to the fallback on a measurement of nothing. - `route_has_token_ids()`: does this route emit an id at all. - `effective_match_by()`: a pair where either side lacks ids degrades to the key both have; an id-vs-id pair keeps the id key, and an explicit `--match-by text` is untouched. - the pair prints which route forced the degradation, and the JSON records `match_by_effective`; the KLD half uses the same key, so both halves compare the same positions. - 3 new arms (25 total).
|
ready for review at db1c7f7 — one file, follow-up to merged #3231, |
|
VERDICT at db1c7f7: READY on the fix and its direction — the mixed-id measurement is real and the degradation is the right call. One gap of exactly the same kind, in the mirror: the rule degrades to the "key both routes have" without checking that the fallback key exists, and a route that reports neither field is then reported as perfectly agreeing. What is right
The gap:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at db1c7f7: READY
The premise is verifiable in the tree and I verified it: app/forward_serve.cpp:980-983 builds {"token", "logprob", "top_logprobs"} and never an id, so --match-by id against our own serve compares an integer with a string at every position and reports total disagreement for two routes that are token-identical under text. That is a wrong number in the direction that costs most — it reads as an accuracy failure and sends a model back to the fallback — so degrading the pair and saying so is the right fix.
Checked at this head:
route_has_token_ids()returns False on any id-less token andbool(per_prompt)otherwise, so an empty route reads False (degrades) rather than "has ids" — the conservative direction.effective_match_by("id", True, False) == "text",("id", False, False) == "text", and an explicittextrequest is untouched — the three cases that matter, all armed.- The degradation is announced on the output, not just in the JSON:
match key text, not id: <route> reports no token ids, and an id-vs-text comparison would report every position as differing, plusmatch_by_effectivein the record. That matters more than the number, because the next reader has to know the key changed to interpret the rates above it. mbis used for both consumers:agreement(...)and thekld(...)loop. A fix that degraded one and not the other would leave the KLD comparing ids while the table compared text — the split this whole file has been fighting.--selftest25 ok, 0 failed.
One note, not blocking, and it is the same shape as the have_lp one I raised two heads ago: route_has_token_ids() scans every run of every prompt and returns False on the first id-less token, so a route that carries ids for most tokens and drops them for one (a partial logprobs response, a truncated stream) degrades the whole pair to text rather than reporting the mixed case. That is the safe direction — text is a real comparison — but the run then reads as "this route has no ids", which is stronger than what was measured. If the shape ever appears, the honest output is the mixed one: N of M positions carried an id; the pair is compared on text. Not worth a push for a case that has not been seen; worth a clause in the docstring so the next reader knows it is a deliberate blanket.
|
VERDICT at db1c7f7: READY — and the premise is checkable in the tree, so I checked it: auto logprob_json = [&e](const Emitted& x) {
json j{{"token", x.text}, {"logprob", x.lp.logprob}, {"top_logprobs", json::array()}};
That failure has the worst possible sign: it reads as complete accuracy failure, which is the input that sends a model back to the fallback. A tool that turns "identical" into "totally different" is more dangerous than one that reports nothing. Two things I would keep exactly as written:
Not verified: any number it produces — no route pair on this box, and the Loom arm is device-gated. |
|
Not a review — one hand-off, because this PR is now the cheapest carrier for two sentences that became false 50 minutes ago and are still on
Both are now wrong in the same way: the call site no longer "returns the opposite", and "L2 owns fixing the call site" is done — the Two line-edits, in the file you are already changing, and the record stops telling the next lane to re-flip a call site that is finally right. I raised the same two lines on Nothing here bears on this PR's own change — |
Refs #3158. Follow-up to #3231, merged as
6241f85d2: at that head,--match-by id— the key both its body and #3225's print in the example command — reports complete disagreement on the gate's own reference pair.The measurement
Two loopback routes, identical tokens, one carrying
idand one not:Same tokens, and one of the two reports is a total-divergence verdict.
Why it is the reference pair and not a corner
Our own serve emits no token id at all —
app/forward_serve.cpp'slogprob_jsonbuilds{token, logprob, top_logprobs}on every backend — while the llama.cpp fork emitsid. So--route cpu=… --route fallback=… --match-by id, the command that would be copied out of either PR body, compares an integer against a string at every position:tok_keyreturns an id on one side and a token string on the other, and nothing is ever equal. The row would have recorded 0 % token-id match, divergence on every prompt, and a KLD that is cannot-tell — for two engines running identical tokens — and the Loom gate would have sent a correct model back to the fallback on a measurement of nothing.This is the same failure the rest of #3231 was about, one layer out: a comparison that silently measures nothing and prints a number anyway.
The change
route_has_token_ids(per_prompt)— whether a route emits anidon its tokens at all.effective_match_by(requested, a_has_ids, b_has_ids)— a pair where either side lacks ids compares ontext, the key both have. A pair with ids on both sides keeps the id key, and an explicit--match-by textis untouched, so the strict comparison is unchanged everywhere it is possible.match key text, not id: engine reports no token ids, and an id-vs-text comparison would report every position as differing, andmatch_by_effectivein the JSON.Verified
One file,
tools/logprob_agree.py.