[GH-ISSUE #5252] [GUI] drafting: --draft-conf counts the 32K prefill buffer as resident, underestimates slots (442 vs 8158 actual) and picks 0.8 #3127

Open
opened 2026-11-07 14:38:16 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @yoinp on GitHub (Nov 4, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5252

What happens

expected_slots() in strata_control/drafting.py estimates how many expert slots a card holds with the drafter loaded, and CONF_STEPS turns that number into --draft-conf. The estimate subtracts the whole prefill buffer as if it were resident VRAM:

free = (vram_mib - GAP_OTHER_MIB - SLOT_BASE_MIB - session_mib(ctx, kv) - HEAD_MIB - reserve
        - (PROMPT_BASE_MIB + PROMPT_PER_TOKEN_MIB * chunk))
return max(0, min(MAX_SLOTS, int(free / SLOT_MIB)))

With PROMPT_PER_TOKEN_MIB = 0.66 and --prefill auto:32768, chunk = 32768, so 21.6 GiB is taken off. The engine does not keep that buffer: it lends it to the expert cache (its own log line: the largest chunk up to 8192 whose buffers the expert cache can lend).

Measured (RTX 5090 D 32 GB, Qwen3.8-Flash-Next NVFP4)

Config: --max-context 262144 --kv int8 --kv-resident 32768 --vram-reserve-mib 2048 --prefill auto:32768, drafting: dflash2.

item value
slots the control layer estimates 442 -> conf_for_slots(442) = 0.8
slots the engine actually loads 8158 (expert_slots in /metrics; startup log filling the GPU's expert cache (8158 experts, 21.01 GiB))
what the control layer's own CONF_STEPS should give 8158 >= 7500 -> 0.5

Same config: the estimate says 0.8, the real slot count says 0.5, a whole step apart. CONF_STEPS is calibrated so that fewer slots means a higher confidence, and here the low slot count comes from the estimate being wrong, not from the card really holding few slots.

Reproduce

drafting: dflash2, no user_args: ["--draft-conf", ...], then read the startup log:

[strata] drafting: DFlash2 alone (--draft dflash2, --draft-conf 0.8)

and compare with engine.expert_slots from /metrics (8158).

One thing that hides it

A hand-written --draft-conf 0.5 in user_args survives apply(), so the computed value is overwritten and the wrong estimate never shows up in the log or on screen.

Suggestion

PROMPT_PER_TOKEN_MIB * chunk should not be subtracted whole: either subtract only the part the cache cannot lend, or feed the engine's reported expert slots back into conf_for_slots() (the first-start estimate is off by 20x here, so the constant needs recalibrating).

Originally created by @yoinp on GitHub (Nov 4, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5252 ## What happens `expected_slots()` in `strata_control/drafting.py` estimates how many expert slots a card holds with the drafter loaded, and `CONF_STEPS` turns that number into `--draft-conf`. The estimate subtracts the whole prefill buffer as if it were resident VRAM: ```python free = (vram_mib - GAP_OTHER_MIB - SLOT_BASE_MIB - session_mib(ctx, kv) - HEAD_MIB - reserve - (PROMPT_BASE_MIB + PROMPT_PER_TOKEN_MIB * chunk)) return max(0, min(MAX_SLOTS, int(free / SLOT_MIB))) ``` With `PROMPT_PER_TOKEN_MIB = 0.66` and `--prefill auto:32768`, `chunk = 32768`, so **21.6 GiB** is taken off. The engine does not keep that buffer: it lends it to the expert cache (its own log line: `the largest chunk up to 8192 whose buffers the expert cache can lend`). ## Measured (RTX 5090 D 32 GB, Qwen3.8-Flash-Next NVFP4) Config: `--max-context 262144 --kv int8 --kv-resident 32768 --vram-reserve-mib 2048 --prefill auto:32768`, `drafting: dflash2`. | item | value | |---|---| | slots the control layer estimates | **442** -> `conf_for_slots(442)` = **0.8** | | slots the engine actually loads | **8158** (`expert_slots` in `/metrics`; startup log `filling the GPU's expert cache (8158 experts, 21.01 GiB)`) | | what the control layer's own `CONF_STEPS` should give | 8158 >= 7500 -> **0.5** | Same config: the estimate says 0.8, the real slot count says 0.5, a whole step apart. `CONF_STEPS` is calibrated so that fewer slots means a higher confidence, and here the low slot count comes from the estimate being wrong, not from the card really holding few slots. ## Reproduce `drafting: dflash2`, no `user_args: ["--draft-conf", ...]`, then read the startup log: ``` [strata] drafting: DFlash2 alone (--draft dflash2, --draft-conf 0.8) ``` and compare with `engine.expert_slots` from `/metrics` (8158). ## One thing that hides it A hand-written `--draft-conf 0.5` in `user_args` survives `apply()`, so the computed value is overwritten and the wrong estimate never shows up in the log or on screen. ## Suggestion `PROMPT_PER_TOKEN_MIB * chunk` should not be subtracted whole: either subtract only the part the cache cannot lend, or feed the engine's reported `expert slots` back into `conf_for_slots()` (the first-start estimate is off by 20x here, so the constant needs recalibrating).
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#3127
No description provided.