Repository navigation
Restrict prompt retention to shared arenas - #1079
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: The shared prompt row is validated, copied into sequence-owned storage, and preserved across slot changes.
Non-blocking
⚠ Cover the server retention hook: crates/gpu-gates/src/bin/shared/serve_seats/drafted.rs:800. Both changed GPU regressions call retain_prompt directly, so removing this server call leaves those checks unchanged. Exercise SlotDrafts::prompt_close or prefill_only in a two-slot regression and assert that the draft stays active after a slot switch.
Checked
Duplicates: the model adapters share gpu::draft::retain_hidden_row; the common policy owns the retention transition.
Complexity: hw_close_fold adds retention, refusal and slot-switch test stages. slots_pass separates both prompts from their first steps.
Silent failure: three no-copy states followed: skipped draft, sequence-owned arena, and no waiting row. Copy failures propagate to the caller. The placeholder token is replaced before a draft walk.
Tests: static mutation review only. Removing policy.rs:491 fails the new unit test's cleared-anchor assertion. Qwen's gate asserts retained row bits and refusal of sequence-owned arenas. GLM's clause (z) compares each slot's ids, kept rounds, draft store and position with its isolated run.
Gates: no band, threshold or pin moved; no gate clause removed.
Performance: at most one asynchronous hidden-row copy per retention call; no added copy per steady decode token.
Adversarial checks: source validation, replacement of the placeholder token, and park/unpark of the retained anchor were read.
Escape catalog: C1–C4 do not match.
Notes
Tests and card gates were not run in this review environment. The PR reports card runs but omits the tested commit hashes and nvidia-smi output required for complete GPU evidence.
Card check: needs-gpu. This pull request changes crates/app/src/arch/glm5next/mtp.rs, crates/app/src/arch/qwen3moe/mtp.rs, crates/app/src/arch/qwen3moe/mtp35.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
The review is done and the contribution check passed, so I'm merging this. |
NVFP4 모델에서 요청 두 개를 동시에 처리하고 MTP 초안을 켰을 때 greedy 결과가 달라지던 문제를 고쳤습니다.
What and why
With the MTP draft on and two requests running at once, the Qwen3.8 seat served a prompt differently from a single request. Another slot's step or prompt could overwrite the shared prompt arena before the draft read the waiting hidden row, so the seat stepped the prompt's last id by a different path. That path rounds the last row differently, and a greedy id can differ.
The fix keeps that row. When a drafted prompt ends in a shared arena, the common MTP policy copies the final hidden row into the sequence's own step arena together with its position record. The Qwen3.8 and GLM NextN adapters only map the source, the destination and the position record to one device copy (
gpu::draft::retain_hidden_row). The retain step refuses an arena the sequence already owns, by name. The seat's MTP-only branch (drafts_slots) and its prompt-quantum exception are removed, so the MTP draft uses the same prompt path as the plain run on any slot count. No kernel, flag or constant is added.Release notes: Fixed: with the MTP draft on, two parallel requests on an NVFP4 Qwen3.8 model return the greedy ids of the serial and no-draft runs.
Code shape
The review reads these first. A box left unticked needs one line of why.
copying it (
AGENTS.md"Common code first",docs/rust-quality.mdR14). Where I found an existing copy, Inamed it below.
(tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
tools/check-comments.sh).PIN(YYYY-MM-DD):and its reason.
cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none": none. The row copy lives incrates/gpu/src/draft.rs(retain_hidden_row) and both models call it; the policy side iscrates/app/src/mtp/policy.rsandMtpDraft::retain_promptincrates/app/src/mtp.rs.What I ran
Each fix check was first run with the fix removed, then with it in place. The GPU runs are on a DGX Spark (GB10), see Hardware below.
Policy unit test, CPU:
Without the fix (the retained row's
last_unitis not cleared):With the fix:
Qwen3.8 MTP close gate:
Without the row copy and the shared-arena refusal:
With the fix:
GLM NextN two-slot gate (
(z)now also finishes both prompts before either slot's first step), on the GLM fixture modelglm53-fixture-00001-of-00003.gguf:Real server, NVFP4
Qwen3.8-Flash-Next-NVFP4, built with the shipped feature set (cargo oxide build --arch sm_121a -- -p bloomery-gpu-gates --features glm5next,clef,vision,mimo2,solar2,minimaxm3,flint,gemma-embedding2,hf,checkpoint --release --bin bloomery-serve). Server and client for the four arms (draft off and MTP, two parallel requests and the same two in series):Prompt length 4096, 128 greedy tokens, temperature 0, offsets 0 and 4096. The four arms' ids compared pairwise:
The same server with MTP on two parallel requests at the final head (
--n-predict 4):No speed change is claimed.
Hardware (if the change is for a machine)
Card NVIDIA GB10 (DGX Spark), driver 595.84, CUDA 13.3.
The unit test ran on a Linux CPU host.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.