Repository navigation
fix(kolibri1): primary top-k rows were one position behind the generated chain - #3486
Merged
Merged
Conversation
…were one position behind the generated chain scripts/gen-kolibri1-primary-topk-rows.py scored the teacher-forced chain at pos = len(p_ids) - 1 + k, but vLLM's prompt_logprobs[i] is the predictive distribution over full[i], so the distribution that predicts gen[k] sits at len(p_ids) + k. Every emitted row carried the previous position's distribution and the membership skip tested the wrong window, which silently dropped 54 of 256 positions. A peer measured generated[k] == rows[k+1].top1 at 195/195 on the landed fixture. The writer now uses pos = len(p_ids) + k and replaces the silent skip with two loud failures (missing distribution, top-1 CHECK) — under greedy decode gen[k] must be the argmax of its own predictive distribution, so a skip can only mean a diverged chain. The rows were re-emitted from the primary oracle (the /tmp/opencode/aaiv + /tmp/opencode/vllmsrc vLLM 0.31.0+cpu environment, tensor_parallel_size=4 mp): 256/256 positions, zero skips, top-1 CHECK green on every position, and a second run reproduced the file byte-for-byte. Impact: the threeway absolute magnitudes collapse from ~5.8 nats of phantom gap to hundredths of a nat (prod gap mean 5.806 -> -0.028, cos 0.9814 -> 0.9991, KL 7.070 -> 0.017) while every rank percentage is unchanged, so the localai-org#3469 mode ordering and the localai-org#3482 bf16-dot red line (97.0% -> 98.0%) stand. Margin instruments shift to the corrected 256-row file (top1_top2 median 3.8913 -> 3.7989; top6_top7 < 0.1-nat rows 58/202 -> 69/256). No test reads the rows file's content, so no recorded anchor changes. The llama.cpp per-position top-20 goldens (commit 62318cd57, GGUF sha256 76ddb05e458cce1a, BF16, greedy, 256/256 self-consistent) land alongside as kolibri1_llamacpp_topk_rows.json. Numbers and analysis: docs/bench-evidence/kolibri1-primary-rows-offbyone-20261020/report.md. FOLLOWING_AGENTS_PROTOCOL Following-Agents-Protocol: true AI-Assisted: true Assisted-by: AGENT:zai/glm-5.3-flash [maki]
The lane read the pull request body before the protocol paragraph was corrected; the body now validates (agent-pr-body.py exit 0). No tree change. FOLLOWING_AGENTS_PROTOCOL Following-Agents-Protocol: true AI-Assisted: true Assisted-by: AGENT:zai/glm-5.3-flash [maki]
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.
The primary-oracle top-100 rows fixture stored each generated position one step behind its own predictive distribution, and every downstream absolute number built on it was a cross-position comparison.
The bug
scripts/gen-kolibri1-primary-topk-rows.pyscored the teacher-forced chain atpos = len(p_ids) - 1 + k. vLLM'sprompt_logprobs[i]is the predictive distribution OVERfull[i], so the distribution that predictsgen[k]sits atlen(p_ids) + k. Every emitted row (gen_index = k) therefore held the previous position's distribution, and the skip (if not any(tid == gid)) tested membership in that wrong window — silently dropping 54 of 256 positions. A peer measuredgenerated[k] == rows[k+1].top1at 195/195 positions on the landed fixture (#3463).The fix
pos = len(p_ids) + k, the stale index comment corrected, and the silent skip replaced by two loud failures (missing distribution; a top-1 CHECK). Under greedy decodegen[k]must be the argmax of the distribution that predicted it, so the old skip path can now only mean a diverged chain, and the generator aborts instead of emitting a shifted row.Re-emission
Reran the generator against the primary oracle in the same environment as the original run (
/tmp/opencode/aaivvenv +/tmp/opencode/vllmsrcsource build, vLLM 0.31.0+cpu,aleph_alpha_inferenceplugin,tensor_parallel_size=4mp on this host, greedy,prompt_logprobs=100), overwritingtests/vllm/models/kolibri1_primary_topk_rows.json:generated[k] == rows[k].top1at 256/256 (old: 63/202);Corrected numbers (old lagged vs new)
kolibri1-threeway-analysis.pyover the four captured dump dirs, same 202 dump positions:Margin instruments (all 8 prompts): top1_top2 median 3.8913 -> 3.7989 (p10 1.0849 -> 0.4812); top6_top7 median 0.1855 -> 0.1901, min 0.0028 -> 0.0018; rows with top6_top7 < 0.1 nats 58/202 -> 69/256. Every same-index old margin changed (0/202 identical) — no old margin label is trustworthy.
Impact on prior analyses
#3469(three-way numerics): the mode ORDERING stands — rank percentages are unchanged in every mode, and the corrected table keeps prod/after_bf16dot at the top with the same 98%/97% split. The absolute gap/cos/KL columns are superseded by the table above: they measured our position k against the primary's position k-1. Our production bf16-dot default's real logprob gap to the primary is -0.03 nats, cos 0.9991, KL 0.017.#3482red line (bf16-dot adoption gate): STANDS. The gate was top-1 agreement computed on a consistent-but-lagged alignment; corrected alignment gives the same 97.0% -> 98.0% BEFORE -> AFTER move. The corrected absolute values still rank after_bf16dot as the loosest mode (gap +0.020 nats, KL 0.051), same conclusion.test_kolibri1_w3.cppclassifies flips from OUR logit gaps, not from this file. Instruments that quoted primary margins shift to the corrected column; the corrected file shows a slightly larger knife-edge tail (69 positions below 0.1 nats on top6_top7).grep -rl primary_topk_rows tests/finds only the path macro and manifest provenance), so no recorded anchor changes and nothing was loosened.llama.cpp goldens
tests/vllm/models/kolibri1_llamacpp_topk_rows.jsonlands with this change: 8 prompts x 32 positions of per-position token-ids + top-20 logprobs from llama.cpp commit62318cd57, GGUF sha25676ddb05e458cce1a023d42cd4f13dc8e8152fbb6501c1f680918fc7d2a0fcefd, BF16, greedy; 256/256 rows with top-1 == emitted token.Gates
check-agent-record, staged preflight (style suites, trailer suites, record gates) green. The single preflight failure,check-windows-portability.py, is environmental on this host (dotnet/pwsh invocation) and fails identically on pristineorigin/main61d333e52; this change touches no Windows surface. Full numbers and method:docs/bench-evidence/kolibri1-primary-rows-offbyone-20261020/report.md. Local issueISSUE-LOCAL-01M5CQ4GMFF9ZAYYMFYDV6WZ3Qclosed with the dated resolution.The change was produced under the repository agent protocol; the human submitter reviewed and owns it.
NOTE ON GOLDENS-CHAIN OVERLAP: the re-emitted rows' generated_ids are byte-identical to the old file's, and they do NOT match the committed kolibri1_goldens.json chains on every prompt (3/8 exact, 126/256 positions). That is pre-existing and expected: the rows are emitted from the primary oracle serving Kolibri-1-bf16-clean through vLLM, while the goldens are the pure-torch reference over Kolibri-1-bf16 — different artifacts, same weights. The near-tie re-rank shape of the differences is documented in the three-way analysis; nothing in this PR changes it.
FOLLOWING_AGENTS_PROTOCOL
Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:zai/glm-5.3-flash [maki]