[GH-ISSUE #4373] [Engine] STRATA_MTP_TOP2 always counts 0 runner-up hits: record_top2() is no longer called #1938

Closed
opened 2026-11-04 01:55:27 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @pschaub on GitHub (Oct 27, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4373

Area

[Engine] (speed, kernels, models, the server and API)

Desktop app, Terminal or source?

Source (START-HERE.bat, setup.sh or a build)

What happened

Note

Claude Opus 5.5 found this bug, fixed it and fully tested the fix on my PC. It also wrote the text below.

The problem: Strata drafts a few tokens ahead with the model's MTP layer, and the full model then checks them. The diagnostic STRATA_MTP_TOP2=1 counts how often a rejected draft would have been right with the draft layer's second choice. That shows whether a second draft branch would pay off. On main it always counts 0, whatever the model does, because nothing calls the function that records the second choice any more.

The fix: Call it again in the two places where it was called when the diagnostic was added. A PR with the fix follows.

What it brings: The diagnostic works again. On my PC the second choice was right for 39 % of the rejected drafts, where main reports 0. Without the variable nothing changes.

Who it helps: Everyone who uses STRATA_MTP_TOP2 to decide about tree drafts or a second draft branch.

Where it breaks: record_top2() is still there:

github.com/Niko1221/Strata@5e8a4cca7d/src/core/mtp.cpp (L556-L574)

2312c83b added it together with two calls in draft(), after the first draft and after each further step:

github.com/Niko1221/Strata@2312c83bfd/src/core/mtp.cpp (L878-L894)

The merge of the Aurora gfx1151 branch onto 0.1.39 (bc6b6f87) kept the function and lost both calls. Since then top2() stays -1, so this comparison never matches:

src/program/generate.cpp#L16680-L16683

if (strata::core::MtpDrafter::top2_env() && !from_sfx && !first_window && a < T_mtp - 1 && a < 8) {
    ++t2_rej[a];
    if (mtp.top2(a) == outv[(size_t) a]) ++t2_hit[a];
}

The "0 of 14" in #2227 comes from this too.

Measurements: Qwen3.8-Flash-Next IQ3_XXS with setup's configuration, 6 fixed chat prompts (greedy, thinking off, max_tokens 300), 36 requests per build in 2 sessions:

build rejected drafts second choice right
main 1,333 0
with the two calls back 1,327 519 (39 %)

Smallest steps or command that reproduce it

  1. Build main with CUDA (I used setup's engine build, CMAKE_CUDA_ARCHITECTURES=120).
  2. Start the server with setup's configuration and STRATA_MTP_TOP2=1 in the environment.
  3. Send a few greedy chat requests with thinking off and max_tokens 300, for example "Explain in two paragraphs how a refrigerator moves heat from inside to outside."
  4. Each request logs strata serve: mtp top2: rejected/runner-up by depth N/0 N/0 N/0 0/0 of N windows, always 0 after the slash.

Reproduction status

Reproduced locally

Strata version

main between 0.2.4.2 and 0.2.5, built from source; the code involved is unchanged in 0.2.7

Graphics card, memory and system

RTX 5090 32 GB · 64 GB RAM · Windows 11 (driver 621.01, CUDA 13.4)

Model, size and settings

Qwen3.8-Flash-Next IQ3_XXS (setup's GSQ-RCO file) · 131072 context · pictures on · setup's configuration for this PC (--spec 4 --spec-min-p 0.5 --expert-cache auto --prefill auto --kv int8 --kv-resident 32768 --vram-reserve-mib 700)

Logs

Two requests, each on main and with the two calls back. These runs use fixed settings (the FIXED list in tools/quant_quality.py), so both builds give the same text and the same windows.

main:

strata serve: mtp top2: rejected/runner-up by depth 30/0 19/0 8/0 0/0 of 154 windows
strata serve: mtp top2: rejected/runner-up by depth 28/0 17/0 12/0 0/0 of 105 windows

with the fix:

strata serve: mtp top2: rejected/runner-up by depth 30/9 19/5 8/1 0/0 of 154 windows
strata serve: mtp top2: rejected/runner-up by depth 28/14 17/4 12/5 0/0 of 105 windows
Originally created by @pschaub on GitHub (Oct 27, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4373 ### Area [Engine] (speed, kernels, models, the server and API) ### Desktop app, Terminal or source? Source (START-HERE.bat, setup.sh or a build) ### What happened > [!NOTE] > Claude Opus 5.5 found this bug, fixed it and fully tested the fix on my PC. It also wrote the text below. **The problem:** Strata drafts a few tokens ahead with the model's MTP layer, and the full model then checks them. The diagnostic `STRATA_MTP_TOP2=1` counts how often a rejected draft would have been right with the draft layer's second choice. That shows whether a second draft branch would pay off. On main it always counts 0, whatever the model does, because nothing calls the function that records the second choice any more. **The fix:** Call it again in the two places where it was called when the diagnostic was added. A PR with the fix follows. **What it brings:** The diagnostic works again. On my PC the second choice was right for 39 % of the rejected drafts, where main reports 0. Without the variable nothing changes. **Who it helps:** Everyone who uses `STRATA_MTP_TOP2` to decide about tree drafts or a second draft branch. **Where it breaks:** `record_top2()` is still there: https://github.com/Niko1221/Strata/blob/5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d/src/core/mtp.cpp#L556-L574 2312c83b added it together with two calls in `draft()`, after the first draft and after each further step: https://github.com/Niko1221/Strata/blob/2312c83bfd593f49d2bcbc70874549a0556dc19b/src/core/mtp.cpp#L878-L894 The merge of the Aurora gfx1151 branch onto 0.1.39 (bc6b6f87) kept the function and lost both calls. Since then `top2()` stays -1, so this comparison never matches: [src/program/generate.cpp#L16680-L16683](https://github.com/Niko1221/Strata/blob/5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d/src/program/generate.cpp#L16680-L16683) ```cpp if (strata::core::MtpDrafter::top2_env() && !from_sfx && !first_window && a < T_mtp - 1 && a < 8) { ++t2_rej[a]; if (mtp.top2(a) == outv[(size_t) a]) ++t2_hit[a]; } ``` The "0 of 14" in #2227 comes from this too. **Measurements:** Qwen3.8-Flash-Next IQ3_XXS with setup's configuration, 6 fixed chat prompts (greedy, thinking off, max_tokens 300), 36 requests per build in 2 sessions: | build | rejected drafts | second choice right | |---|---|---| | main | 1,333 | 0 | | with the two calls back | 1,327 | 519 (39 %) | ### Smallest steps or command that reproduce it 1. Build main with CUDA (I used setup's engine build, `CMAKE_CUDA_ARCHITECTURES=120`). 2. Start the server with setup's configuration and `STRATA_MTP_TOP2=1` in the environment. 3. Send a few greedy chat requests with thinking off and max_tokens 300, for example "Explain in two paragraphs how a refrigerator moves heat from inside to outside." 4. Each request logs `strata serve: mtp top2: rejected/runner-up by depth N/0 N/0 N/0 0/0 of N windows`, always 0 after the slash. ### Reproduction status Reproduced locally ### Strata version main between 0.2.4.2 and 0.2.5, built from source; the code involved is unchanged in 0.2.7 ### Graphics card, memory and system RTX 5090 32 GB · 64 GB RAM · Windows 11 (driver 621.01, CUDA 13.4) ### Model, size and settings Qwen3.8-Flash-Next IQ3_XXS (setup's GSQ-RCO file) · 131072 context · pictures on · setup's configuration for this PC (--spec 4 --spec-min-p 0.5 --expert-cache auto --prefill auto --kv int8 --kv-resident 32768 --vram-reserve-mib 700) ### Logs Two requests, each on main and with the two calls back. These runs use fixed settings (the FIXED list in `tools/quant_quality.py`), so both builds give the same text and the same windows. main: ``` strata serve: mtp top2: rejected/runner-up by depth 30/0 19/0 8/0 0/0 of 154 windows strata serve: mtp top2: rejected/runner-up by depth 28/0 17/0 12/0 0/0 of 105 windows ``` with the fix: ``` strata serve: mtp top2: rejected/runner-up by depth 30/9 19/5 8/1 0/0 of 154 windows strata serve: mtp top2: rejected/runner-up by depth 28/14 17/4 12/5 0/0 of 105 windows ```
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Thanks for taking the time to report this.

Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.11. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6660327509 --> @Niko1221 commented on GitHub (Nov 5, 2026): Thanks for taking the time to report this. Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.11. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1938
No description provided.