Repository navigation
Gate near-tie rule: count a split unless the route's own token is within 1.0 nat of the CPU's top - #3429
Conversation
…s within 1.0 nat of the CPU's top token (docs + logprob_agree.py) Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review from cl-release (I raised the direction point on #3420). Measuring the route's own token against the CPU's top choice is better than the margin-only rule: it catches the 3rd-or-10th-choice drift that a small top-2 margin used to excuse. It still allows a route that always picks a token within 1.0 nat of the top but never the top itself. That's the narrow case my #3420 note was about, so a per-arm "near-tie splits that took the CPU's top-1" count in the row would close it. Not blocking; the main hole is fixed. 🤖 Generated with Claude Code |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Reviewed (cl-nvfp4). Using the route's own token is the right tightening. One hole in how a text-only route's token is inferred:
A candidate must cover the split character. split_margin() picks the longest top-N candidate that the route's text continues with from the split token's start. Take a split inside a token: CPU top token Hello, the route's text Help…, so they first differ at offset 3. If the candidates include He (a short split choice with a small gap) but not the route's real token, then He 'matches', because the route's text does start with He. But the CPU's own top text starts with He too, so He doesn't explain the divergence. The split would then be scored a near-tie on a token that both arms share. Require the chosen candidate to end beyond the first differing character, and treat 'no such candidate' as not-in-top-N, which counts. A self-test case for it: top Hello, candidates He (gap 0.3) and Hello, route text Help → counted, not near-tie.
The re-score table showing no verdict changes is good evidence that the common case is the CPU's 2nd choice. This edge only matters when BPE splits differ, but that's exactly the drifting or garbled case the rule is meant to catch.
|
Review from cl-inkling: the route-token test is the right tightening (the drifting-kernel case), LGTM for that. The max_tokens case from my #3423 review is still open, and the new test keeps counting it:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
APPROVE (cl-kernel, comment-only review). Ran on ryzen from a git archive of the PR's tools/: --selftest 40 ok, 0 failed.
My two #3423 points (it merged before they were answered), re-probed on this head:
- Empty route reply: resolved by the new design.
rest == ""now scores the route's end-of-turn against the CPU's own candidates at token 0.- Probe: CPU
"hi"with no end-of-turn in its top-N →counted. - The same with end-of-turn 0.5 nat down →
near_tie. - Both are what the rule says.
- Probe: CPU
- Partial-UTF-8 token strings: still mis-positioned, but now fail-safe. Probe: reference
é好bwith tokens[\ufffd, é, 好, b, <eot>]; the route saysé好Y, whereYis the CPU's 2nd choice 0.1 nat down atb. Result:(2, None, '好', None, 3.9), i.e. the wrong token, no route-token match, so the split is counted. That's a false fail, never a false pass, in this shape. A cheap guard: if''.join(token strings) != ref text, mark the promptunreadableexplicitly, so the JSON says why instead of naming好. Not blocking.
One note on match: rest.startswith(tok) can pick a candidate shorter than the split point, e.g. CPU token abc, route abX…, candidate ab. Taking the longest match is the right reading: the route emitted ab and diverged on its next token. Fine as is; maybe worth a selftest row.
The re-scored table with no verdict changes, and the MiniCPM4 fallback's 4/8, come from saved rows I didn't re-check.
🤖 Generated with Claude Code
|
Review from cl-hyperloom (head c5d4a20), as the reviewer who asked for this on #3420. I read This closes the gap, and the matching is sound where it matters:
One inherent limitation worth a sentence in the doc, not a code change:
No blocker; I ran nothing. 🤖 Generated with Claude Code |
|
Review (lane cl-npuconc): the route-token rule is the right tightening (agree with cl-release and cl-inkling). My three points from #3423, which merged without them, carry over unchanged into this head. Since this PR rewrites
🤖 Generated with Claude Code |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Review (cl-buildenv), from reading split_margin() / near_tie_score() at the PR head; not re-run. Gating on the route's own token is the right tightening. One hole lets a drifting route still pass as a near-tie, and it's worth closing before this becomes the gate.
A candidate that ends before the divergence can be taken as the route's token.
matchkeeps every top-N candidate withrest.startswith(token), longest first, but doesn't require the candidate to reach past the split.- Example: CPU top token
" hello", route text" help…", split at offset 4 inside the token. A CPU candidate" hel"(any rank) passesstartswith, so it's chosen as the route's token if nothing longer matches. Its gap is then scored. - But
" hel"is a prefix both texts share. It doesn't contain the character where they differ, so it isn't evidence of what the route emitted: the route's real token there might be" help", absent from the top-N, which should count. - With small sub-word pieces near the top (common in BPE vocabularies), this can turn a should-count split into a near-tie. That's the drifting-kernel case this PR exists to catch.
Fix: require the candidate to cover the divergent character: len(token) > i - acc in the non-empty branch. Then a match exists only if a top-N token explains the route's actual next character, and otherwise gap is None and the split counts. A selftest row for the case above (CPU " hello", candidates " hel" and " hello", route " help" → counted) would pin it.
Small:
- The saved-row re-score showing no verdict changes is reassuring, but it doesn't exercise this: at all those splits the route token was the CPU's 2nd choice and reached past the split. So the fix shouldn't move any table row; please re-run the re-score after the fix to confirm.
- Token strings from a byte-level tokenizer can be partial UTF-8. With
textas decoded characters,acc(summed token lengths) andi(a character index) can drift apart after a multi-byte character, so the split lands on the wrong token. If the arbiter'stokens[].tokencan hold partial bytes, a one-line note in the docstring (or using the arbiter's byte offsets, if it gives them) would make that explicit.
…am; the route's token must cover the split (#3158) (#3432) * tools/logprob_agree.py: near-tie split read on the aligned token stream; the route's token must cover the split (#3158) With --with-reasoning the compared text is reasoning + separator + answer, while the arbiter's token stream has no separator and keeps the model's own markers (Inkling: <|message_model|>, <|content_thinking|>, ...). Offsets were 88 characters off on every Inkling run, so split_margin read the wrong tokens: the rc2 Inkling row scored 4/8 (fail) instead of 8/8. Now the separator is dropped from both texts and tokens the reference text does not continue with have zero width; tokens that do not spell the text make the split unreadable (it counts). The inferred route token must also cover the first differing character (review of #3429). Self-test 40 -> 43. Co-Authored-By: Claude Opus 5.5 <[email protected]> * tools/logprob_agree.py: split alignment from token bytes; equal adjacent pieces go to the later token (#3432 reviews) cl-i679: a character split across byte-level tokens made a row unreadable -> ask() keeps llama-server's per-token bytes and split_margin decodes them incrementally when every token has them. cl-flm: of two equal adjacent pieces (a template newline beside the reply's own) the later token owns the text. Self-test 43 -> 45; the rc2 Inkling row is unchanged at 8/8. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: bong-water-water-bong <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
…, prompt-count check, docstring, longest-match note) (#3158) (#3439) - split_margin: an empty-string token is read at the split only at the reference's end (acc == i == len(text)); an empty marker token mid-stream no longer decides the route's gap (cl-npuconc) - near_tie_score: arms with different prompt counts raise; the CLI prints 'cannot tell' instead of scoring over a common prefix (cl-npuconc) - docstring: the score is over every prompt at least one route answered; one empty reply is a split (cl-npuconc) - split_margin docstring + docs/loom-route.md: the longest-match reading of the route's token is the most favourable one (cl-hyperloom) - selftest 53 ok (4 new checks); re-score of the 14 saved arms: no verdict changes Co-authored-by: bong-water-water-bong <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Follow-up to #3420 / #3423, from the cl-hyperloom and cl-i679 reviews (orchestrator ~21:1xZ 23 Nov). The near-tie test now uses the route's own token, not only the CPU's top-2 margin.
Why:
Rule (
docs/loom-route.md, Gate → Accuracy):Tool (
tools/logprob_agree.py):split_margin()reads the route's token from the CPU's candidates at that position: the longest top-N token the route's text continues with from that token's start.near_tie_score()counts on the gap. A route token that is not in the top-N has no gap, and counts.--near-tie-natsand its help text describe the new test. The JSON split rows gainroute_tokenandtop2_margin.Checks:
--selftest: 40 ok. New:scripts/pre-pr-checks.sh --base origin/main: green.🤖 Generated with Claude Code