Skip to content

docs(spec): record the temperature 0 block-history argmax flip (#2778) - #2879

Merged
inureyes merged 4 commits into
lablup:mainfrom
hephaex:docs/2778-temperature-0-block-history-flip-v2
Nov 9, 2026
Merged

inureyes merged 4 commits into
lablup:mainfrom
hephaex:docs/2778-temperature-0-block-history-flip-v2

Conversation

@hephaex

@hephaex hephaex commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Refs #2778. Does not close it.

What this is

Documents the deterministic temperature-0 argmax flip observed when a KV history is block-built versus plainly built, and ships the two comparison scripts used to pin it down.

Replaces #2868, which carried 5 unrelated commits from a stale fork base (imagegen and others already merged upstream) inflating the diff to ~70 files / +10430. This branch replays the work directly onto current upstream/main (f45a92cc) as a short linear series (docs, then a script-executable-mode fix, then a CHANGELOG placement fix), so the PR-visible diff is exactly the intended work.

Diff

 CHANGELOG.md                             |   4 +
 docs/temperature-0-block-history-flip.md | 297 +++++++++++++++++++++++++++++++
 scripts/compare_matched_width.py         |  95 ++++++++++
 scripts/matched_width_trace.sh           |  50 ++++++
 4 files changed, 446 insertions(+)

Verification

  • git diff --stat upstream/main b885845f => 4 files, +446, 0 deletions.
  • Author/committer preserved: Mario Cho [email protected].
  • No imagegen, no webui, no Cargo.lock changes.
  • The two scripts are read-only analysis harnesses (trace + matched-width comparison); no model code is touched.

Scope note

This is a spec/documentation change. The temperature-0 flip is characterized and reproducible but not fixed in code here.

Acceptance-criteria status for #2778, stated against the issue's own four criteria:

  1. Target-only reproducer for the Qwen3 pos 197 swing, comparing logits and KV contents of plain and block-built histories — still open. This PR does not deliver it and does not claim to. Criterion 1 asks for a reproducer over both logits and KV contents, not for a code fix. The scripts here cover the logits side of the matched-width comparison; the KV-contents half is not implemented. A specification for that harness is in progress separately and is not part of this PR.
  2. Cause named with evidence via the teacher-forced logit trace — done here.
  3. A fix with its reverted arm failing, or a documented reason it is expected — done here: documented as expected temperature-0 behavior, with the reasoning recorded in docs/temperature-0-block-history-flip.md.
  4. A decision on whether this blocks 0.8.0 — recorded in the issue.

So Refs #2778, not Closes: merging this leaves criterion 1 outstanding, which is the intended state.

…p#2778)

A temperature 0 run through a block verification path (--prompt-lookup or a
draft model) can leave the plain-decode stream near a logit tie: the verify
block builds post-first-row K/V at M = block width, a different quantized
kernel path than the one-token decode step, so the logits differ at rounding
scale and the argmax can flip where the reference's top two logits are tied
or nearly tied. This is the temperature 0 contract, not a defect; no code
change is made.

- docs/temperature-0-block-history-flip.md: the investigation, teacher-forced
  and end-to-end measurements, repro commands, and the limits of the evidence
  (the issue's original 35-logit swing at position 197 is not reproduced).
- scripts/matched_width_trace.sh, scripts/compare_matched_width.py: the
  matched-context (PREFILL = 128 + j) trace harness and comparator that redo
  every Evidence 1 figure.
- CHANGELOG: a Known limitations entry under Unreleased pointing at the
  document (lablup#2778, does not block 0.8.0).

Every number in the document is traceable to a command recorded there.
The script carries a #!/usr/bin/env python3 shebang, so tests/
test_script_executable_modes.py requires Git mode 100755. It was added as
100644, which failed the python-tooling CI job. Mode only; content is
unchanged.
The finding is a behaviour contract, not a defect, and it applies to the
next release rather than to the already-issued v0.8.0 section, so the
entry belongs under ## [Unreleased]. Text is unchanged from the reviewed
revision; only its placement moved.
@hephaex

hephaex commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Status update at head cb5287ab.

CI fix. The first green-checking head (4aa4cc99) tripped python tooling tests because scripts/compare_matched_width.py has a #!/usr/bin/env python3 shebang but was committed as mode 100644. 4aa4cc99 flips it to 100755; the blob is unchanged (301780f8), so it is a mode-only commit.

CHANGELOG placement. The ### Known limitations bullet originally landed at the tail of the already-released ## [v0.8.0] - 2026-11-01 section. cb5287ab moves that exact block (byte-identical, 4 lines) to directly under ## [Unreleased], after its ### Changed bullets. The diff is CHANGELOG.md only, 4 insertions / 4 deletions.

Current state. 3 commits, changed_files=4, +446/-0, mergeable_state=clean, check suite 114777161216 = success (13 success / 17 skipped / 0 failing). Nothing outside CHANGELOG.md, docs/temperature-0-block-history-flip.md and the two scripts/ repro helpers is touched; no src/ path changes, and the flip is documented as a temperature-0 contract rather than fixed in code.

@inureyes inureyes added status:review Under review type:docs Documentation improvements or additions priority:low Low priority area:docs User and developer documentation labels Nov 9, 2026
The maintainer decision on lablup#2778 leaves the root cause open, but the doc and the CHANGELOG entry called the flip a contract and not a bug. Restate them as a known issue with the measured environment, and keep the position 197 swing explicitly unexplained.

Correct claims that do not hold against the tree: benchmarks.md records byte-identical block widths and an exactness probe, so bit-equality across M is not impossible; the unmatched and matched passes cover different positions; the control arm paragraph said arms B and C agree on 0 of 512; the j=0 control counted 384 rows where only 48 exist. Mark the K/V arithmetic explanation as a hypothesis, cite the KV dump posted on the issue, and record that the runs predate the 9f806b36 pin.

Make the repro commands runnable from the fixture directory, and validate input in both scripts with argparse and clear errors instead of tracebacks.
@inureyes

inureyes commented Nov 9, 2026

Copy link
Copy Markdown
Member

Hardening review, pushed as 56a46f3e on top of cb5287ab. Reviewed against #2778.

Findings fixed

  • HIGH: the doc status and CHANGELOG called this "not a bug" and the temperature 0 contract, while the Explain the temperature 0 flip between plain and block-built KV history #2778 decision says the root cause is unknown and the position 197 swing is too large to attribute to rounding. Both now state the cause as open and give each measurement with its environment. The CHANGELOG entry moves to ### Known Issues and no longer lists a harness switch.
  • HIGH: the claim that no quantized kernel set provides bit-equality across M contradicts docs/benchmarks.md, and "no regression" was unsupported. Both are rewritten.
  • MEDIUM: the mechanism is now a hypothesis. Corrected the "same 384 positions" claim, an inverted agreement count, the int8 delta claim and the unreproducible cmp file names, and noted that the runs predate the update: advance MLX pin to 9f806b36 and refresh backend overlays #2876 MLX pin.
  • LOW: compare_matched_width.py and matched_width_trace.sh now validate input and exit with one-line errors. The repro commands use $REPO.

The PR body marks #2778 criterion 2 (cause named) as done; the revised doc does not support that, so #2778 stays open.

Security and performance: analysis scripts only, writing under the caller's output directory; no runtime path changes.

Validation: the 214 Python tooling tests, env var docs, license header and reserved path checks pass, plus a synthetic end-to-end script run with bad-input cases. shellcheck is not installed here. No real-model traces were rerun, so the numbers remain the original M1 Pro measurements.

@inureyes
inureyes merged commit 98b92fb into lablup:main Nov 9, 2026
31 checks passed
@inureyes inureyes added status:done Completed and removed status:review Under review labels Nov 9, 2026
@hephaex
hephaex deleted the docs/2778-temperature-0-block-history-flip-v2 branch November 15, 2026 11:44
@inureyes inureyes added this to the 0.9 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs User and developer documentation priority:low Low priority status:done Completed type:docs Documentation improvements or additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants