Repository navigation
tools: compare drafted and plain IDs on recorded BF16 near-ties - #3841
Merged
Merged
Conversation
ashhart
added a commit
that referenced
this pull request
Nov 19, 2026
ashhart
force-pushed
the
lead/draft-divergence-tool
branch
from
November 19, 2026 09:57
35dacd0 to
5659431
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
tools/draft_divergence.py, a harness that checks drafted decoding returns exactly the token IDs plain decoding does, on the prompts most likely to break that: near-ties in recorded BF16 raw logits.Speculative decoding verifies several draft tokens at once, so its arithmetic can run in a different order than a one-token step. A near-tie between the top two logits is where a different order could flip a token. TensorFold's rule is that drafted output equals plain output; this tool tests it where it is most fragile.
How it works:
tools/zig/qwen27_margins.py's spacing and verdict).draftflag, not a depth).The live API does not expose raw logits, so the report carries the recorded source's score pair at the first mismatch. Given raw scores recorded for each run, the tool also says whether a mismatch was a near-tie (label
near-tie) or a real fault (labelbug).Twenty fixture tests (
tools/tests/test_draft_divergence.py) build requests through an injected client, with no device, model or socket.tools/draft_divergence.mdhas usage.Checked on this head: the new tests (20 pass),
zig build check-release-paths, and the lean check (no new problems).