Repository navigation
serve seats, generate_qwen3moe: the n-gram lookup draft on Qwen3.8 through the seats' one lookup owner - #546
Conversation
…body verifies rows, one owner
…test (Rule::prior) The lookup reports no probabilities, so the width chooser rates it by its calibrated gain alone. Under Rule::DEFAULT that gain starts at 1 and moves 5 % of the way a verify: on Qwen3.8 at 4096 on GB10, a prose prompt whose proposals keep one in five holds the gate open for about 38 verifies of a 128-token decode. Rule::prior makes a position's gain the running mean of what its tests kept, the start counted as that many tests, until the step reaches Rule::calibrate. Rule::DEFAULT has no prior and is unchanged; Lookup::RULE counts the start once, and every lookup chooser (the seats' Lookups, generate_qwen3moe and generate_ds41) is built by it.
…ed at N = 1, 2 and 4
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix defect was found in the changed code.
Non-blocking
⚠ Verify the V4.1 lookup consumer: crates/gpu-gates/src/bin/shared/serve_seats/ds41.rs:1171. This seat now uses incremental contexts and the history callback. The reported GPU runs cover Qwen3.8. Attach a V4.1 lookup serve run covering continuation, rollback, slot switching and saved-state restore.
Checked
Duplicates: 106 new or renamed declarations checked; no duplicate owner found. Dryer reported zero pairs in runtime/levers; gate code was checked manually.
Complexity: new lookup_main (39) combines server/request/cache stages; new lookup_cost_turns (27) combines concurrent requests and record checks. run_arm38 (25) generalizes the existing prompt/decode/report pipeline. Generator run 185→193 adds lookup branches; Q38 open 65→68 adds draft dispatch; Q38 run 130→132 adds refusals; gate run 15→17 adds arm dispatch.
Silent failure: 5 sites followed. Invalid capture nodes fail the gate; empty counted passes error; body() is infallible; a completed step has positive position; the discarded tally is not a Result.
Tests: static mutation audit covered context replacement/cuts, pass-end timing, calibration prior, input refusals, reply validation and TP node order. Assertions reject the corresponding dropped update/guard or reordered nodes. An independent in-memory lookup model matched rebuilt tables over 20,000 cut/replacement cases; Rust tests and GPU gates were not rerun.
Gates: no numeric band relaxed. Card-admission and selector-set changes carry dated PIN reasons. No new unsafe block or kernel reduction change.
Escape catalog: C1–C4 did not match added code.
Notes
Dryer did not search gpu-gates; manual searches covered its changed code. GPU evidence is supplied by the author for the NVIDIA GB10.
Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/bloomery_serve_qwen38.rs, crates/gpu-gates/src/bin/gate_qwen38_serve.rs, crates/gpu-gates/src/bin/generate_ds41.rs … and carries a gate run on the author's card, which counts as verified.
🔨 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. |
|
감사합니다! |
가중치 없는 n-gram lookup 초안(BLOOMERY_DRAFT=lookup)을 V4.1 전용에서 공용 경로로 옮기고, Qwen3.8 서버와 generate_qwen3moe에서도 쓸 수 있게 하는 작업입니다.
Part of #495 (lookup draft on every seat), one DGX Spark (TP=1, #493).
What and why
runtime::Lookupproposes the token that followed the most recent earlier match of the last 3, 2 or 1 tokens. It needs no weights, and itsDraftimpl takes anyVerifytarget. Until now only the V4.1 seat andgenerate_ds41served it, because the seat rebuilt the lookup's tables from the V4.1 body's token history (Body::history), which no other body keeps. This PR gives the lookup one owner that every seat can hold, and serves it on Qwen3.8.runtime::Lookupgainstruncateandstand.stand(pos, last)makes the context what a target standing atposbeforelastholds, keeping what the context already holds of the positions beforepos. A context that already stands atposwith another token (a sampled id where the argmax was pushed) takeslastin its place without a rebuild, because the last token is in no indexed n-gram yet. A cut back needs no call of its own: the next call truncates. A prompt call that continues a cached prefix puts its first id in withstandinstead of rebuilding the tables. A new test drives a context through a prompt call, steps, passes keeping one or two rows, a replaced last token and cuts back, and checks it against a context rebuilt from the history each time, tables and proposal both.drafted::Lookups(crates/gpu-gates/src/bin/shared/serve_seats/drafted.rs) is the seats' one owner of the lookup draft: a window, a context and a width chooser for each resident slot, all verified by the session's two-row pass. A slot's context follows the slot by position, and a pass's cost is read when the pass ends (Choosing::finish_pass), so slots that take turns under--parallel 2each finish their warm-up and keep their own acceptance record. A seat can hand it the body's token history; then a context that falls behind the target (a round of plain steps the draft did not see, a state put back) is rebuilt from it. A seat without one parks the context with the saved state and puts it back with it.SlotDrafts(the Qwen3.8 and GLM seats' draft table) andserved::ServedDraft(the V4.1 and qwen3 seats') both hold aLookups, so the seats keep one call per event and the table picks the draft.drafted::pass_in_turn. Each pass's cost is read when that pass ends, so under--parallelwithBLOOMERY_MTP_WIDTH=costa pass another slot runs in between never counts toward this slot's cost. The default multi-slot MTP round (one_pass) and DSpark do not go through this helper and are unchanged.tools/gpu-gate.shadmits thedraftedarm ofgate_qwen38_serveon a local card, as it already did forlookup, because that arm runs no card-specific paged clause. The plain arm keeps its 3090 pin, and the exception carries a datedPIN(2026-10-20)comment that says why the two arms are admitted.tools/defaults-twins.tsvgains two rows for the pinsBLOOMERY_DRAFT=draftandBLOOMERY_DRAFT=lookupingate_qwen38_serve; both point atslots_default_residency, which runs the seat with the draft lever unset.tools/model-tax.tsvloses the glm and qwen rows fordrafted.rs, whose count of 1 is gone. 14 new tests now run in a gate recipe: threeserve_clienttests ingate-q38-serve-rules, ten tests of the shared draft in the newgate-serve-draft-rules(the other two serve bins that include it), and the TP plan test ofgenerate_glm5nextingate-ds41-place.tools/recipes.pyadds the new gate to two expected selector sets, each with a datedPIN(2026-10-20)comment.Served41) and serves the lookup throughServedDraft, passingBody::historyas the history. Its contexts rebuild from that history at the same points as before, and each slot keeps its own width chooser.bloomery-serve --model qwen38andbloomery-serve-qwen38takeBLOOMERY_DRAFT=lookup: the plain load, the two-row verify pass captured at load (capture verify rows=2), aload draft=lookupline, a context per slot, the prompt cache parking each slot's context with its state, and/propsnaming the draft.BLOOMERY_MTP_HEAD_ROWSandBLOOMERY_MTP_DRAFTbeside it are refused by name, as areBLOOMERY_ROUTE_TRACEandBLOOMERY_PREFILL=steps.generate_qwen3moetakesBLOOMERY_DRAFT=lookupon a qwen4exp file: the plain load, then the same drafted arm the MTP draft runs (run_arm38, now generic over the draft), each pass'stime passrecordkind=lookup, and adraft summaryrecord at the arm's end.drive38_lookupanddrive38_mtpwalk their arms throughSession::arms, as the other drivers do, and thedraft summaryrecord comes from one function,record::draft_summary, whichgenerate_ds41calls too.Rule::DEFAULTthat gain starts at 1 (every id kept) and moves 5 % of the way a verify, which keeps the gate open for tens of verifies on a prompt where the lookup keeps one proposal in five.runtime::width::Rulegainsprior: a position's gain is the running mean of what its tests kept, with the start countedpriortimes, until the step falls tocalibrate.Rule::DEFAULThas no prior, so the MTP and DSpark choosers are unchanged.Lookup::RULEcounts the start once, and every lookup chooser (the seats'Lookups,generate_qwen3moeandgenerate_ds41) is built with it. A new test runs a draft of one id with no probabilities that keeps 0.18 of its proposals, its pair pass at 1.35 of the step: the gate closes by pass 12 underLookup::RULEand after pass 40 under the fixed step, and a draft that keeps 0.7 stays open.lookupby name with the reason: the qwen3moe body (no pass of several rows), qwen35moe and dense qwen35 (they verify only on a load with a lane of delta state a row, which neither binary opens), and glm5next (a load holds two KDA lanes only with its NextN layer). The mimo2 and nemotron seats do not act onBLOOMERY_DRAFT, so the levers parse refuses it set.generate_glm5next --place tpplans its N ranks in one private function,tp_ranks: rank 0 is this card, then one rank per address inBLOOMERY_TP_NODES, in order. One test checks N = 1 (refused by name), N = 2 and N = 4 (three addresses), and the levers test reads three addresses in order. N is data (nodes.len() + 1), not a constant. This commit is in the PR because the first commit already changesgenerate_glm5next.rs, and this closes that file's postponed item, a test of the plan beyond two ranks. The step that reads each node's card census over TCP needs live tier servers, so it is outside the tests.Release notes: Added:
BLOOMERY_DRAFT=lookupserves the n-gram lookup draft on Qwen3.8 inbloomery-serveandgenerate_qwen3moe. Fixed: underBLOOMERY_MTP_WIDTH=costwith several slots, the MTP draft no longer adds the time other slots ran to a slot's cost. Fixed:generate_qwen3moerefuses-n 1with a drafted arm instead of printing a NaN rate.Code shape
Lookupsalone;SlotDraftsandServedDraftdispatch to it, and the V4.1 seat's own arm is gone. A pass's draft counts come from one function,drafted::drafted(moved fromserved.rs), and the Qwen3.8 seat's MTP-only levers are one list (mtp_only_lever), read by both thelookuprefusal and the drafts-nothing refusal.ServedDraft::refuse_mediabecameServedDraft::prefill_media, which also feeds the lookup.lookupare refused by name.generate_qwen3moerefuses-n 1with a drafted arm (BLOOMERY_DRAFT=mtporlookup) before it opens the model, because the prompt call already yields the first token and no pass is left for the draft to verify. Before this, the lookup run printedtok/s(positions)=NaNand exited 0. A--warmthat leaves no counted pass (a drafted pass keeps several positions, so-npast--warmcan still end inside it) is refused by name too; one function,counted_passes, decides that for the SMOKE record, the lookup's draft summary and the MTP summary.Duplication found or removed (
path:line), or "none": the V4.1 seat'sServed41::Lookuparm and itslookup_followsrebuild (crates/gpu-gates/src/bin/shared/serve_seats/ds41.rs) are gone; the V4.1 seat and the Qwen3.8 seat now shareLookups.What I ran
Checks ran on the heads named below. The GPU gates and the MTP serve A/B ran on
4fa0a12b, rebased over #535 (which changed the serve files) onto upstream71ca4de9. The final head62ae0592is that branch rebased onto upstream654f1b0e. Two upstream changes came in between: #526 (accepts.rsandtools/model-tax.tsv) and #537, which moves the hub code intobloomery-model-hf. The #537 rebase needed two edits: the gate recipes this PR adds now list thehffeature as #537's recipes do, andgenerate_glm5next.rscalls #537'sread_tp. Neither touches the runtime, the kernels, the serve seats or the draft code the gates and the A/B exercise, so those results carry to the final head. The unit tests, the mutants, the-n 1run and the decode A/B ran earlier, on the heads named in each section. The third commit changes onlygenerate_glm5next.rs, a levers test and one gate recipe, which no gate here reaches.Lint and recipe checks
just contrib-check --tier t0passed on77ce4285, which carries the same three patches over an earlier upstream main:DONE tier=t0 total=94 red=0.Unit tests
On
e9cb5764on the DGX Spark (cargo oxide test --arch sm_121, featuresdeepseek41,gemma-embedding2):bloomery-gpu-gateslib: 210 passed; 0 failed; 3 ignored.bloomery-serve-qwen38bin: 15 passed; 0 failed.generate_qwen3moebin: 2 passed; 0 failed.On the final head
72876485on one RTX 5090 (--arch sm_86; these tests launch no kernel), with theglm5nextfeature added: the lib passed 210 tests,bloomery-serve-qwen3815,generate_qwen3moe2 andgenerate_glm5next1, with 0 failed.The runtime and app crates last ran on
5692f83a(cargo test):bloomery-runtimelib (width, lookup, DSpark, speculative): 252 passed; 0 failed.bloomery-applib (MTP policy, DSpark): 24 passed; 0 failed.A drafted run with
-n 1The command, on a qwen4exp file with the lookup draft:
BLOOMERY_DRAFT=lookup bash tools/gpu-gate.sh generate_qwen3moe --place gate --tokens "$I" -n 1With the earlier code (
generate_qwen3moe.rsas of5429b65e) it exited 0 and printeddraft summary proposals=0 accepts=0 positions=0 passes=0 tok/s(positions)=NaN. On this branch it exits 1 after 1 s, before the model opens, with the messagedrafting needs -n 2 or more. The same run with-n 8exits 0 and reportspasses=6.Mutants that must fail
Five mutants each made a new test fail, and the tests pass without them. On the DGX Spark:
Lookup::standreplaced by a push (lookup_prompt_discards_the_prior_last_tokenfailed), the refusal of a prompt call with no id removed (a_lookup_prompt_call_of_no_id_is_refusedfailed), and thecounted_passesguard narrowed towarm > 0 &&(a_rate_over_no_counted_pass_is_refusedfailed). On the RTX 5090: the empty-nodesrefusal intp_ranksremoved (N = 1 then planned one rank), and the node order reversed (rank 1 of N = 4 then took the first address instead of the second). Both failedtp_ranks_are_this_card_then_each_node_in_order.Cost read at the end of a pass
drafted::tests::turns_land_each_slots_cost_before_the_other_slots_expensive_passsends two slots through the production helper 12 turns each on a fake clock: a 10 ms step, a 13.5 ms verify for slot 0 and a 400 ms verify for slot 1. With thefinish_passcall removed, the test failed: slot 0's second cost read 413.5 ms instead of 13.5 ms, because the other slot's 400 ms landed in it. With the call in place the drafted tests passed 3 of 3 in each serve binary. The fake clock shows the ordering only; it is not a GPU cost measurement.Runner admission of the MTP arm
bash tools/gpu-gate.shhas a self-test. With thedraftedexception removed, it failed 2 cases (129 of 131 ok), where the arm exited 64 on a local card. With the exception it passes 131 of 131, including the plain arm's 3090 pin.Qwen3.8 MTP serve gate
gate_qwen38_serve --arm draftedpassed 28 of 28 clauses on4fa0a12b(the draft-off ids as reference, greedy and top-k 1 ids equal, draft counts, continuation, cache switch and break-even clauses). The gate printedgate-gpu-qwen38-serve: PASS. It is a function gate, not a speed measurement. The MTP file isMTP/mtp-Qwen3.8-Flash-Next-shared-Q8_0.gguffrom the same model revision below.Qwen3.8 lookup dispatch
The
gate_qwen38_serve --arm lookuparm startsbloomery-serve-qwen38with the draft off, then with lookup (BLOOMERY_MTP_WIDTH=fixedfor lookup only,BLOOMERY_RESIDENCY=off,--parallel 2). It compares both servers' greedy ids and sampled ids requested withn_probs, checks the two-row capture's node count, and requires both rejected and accepted lookup proposals. It erases the resident slots, restores the code and prose conversations in reverse order, and checks that each keeps its cached prefix and ids on a different slot. A third server (BLOOMERY_MTP_WIDTH=cost,--parallel 2, two requests at once) checks that every round takes the two slots' passes in turn and that both slots finish their cost warm-up.D,TandIare the output directory, prompt and token ids fromjust gate-gpu-qwen38-serve; that recipe runs the lookup arm after its plain and MTP arms.On
4fa0a12bthe arm passed 41 of 41 clauses in 226 s and printedgate-gpu-qwen38-serve: PASS. The two-row capture hadnodes=1475, the lookup made 140 proposals and 82 were accepted, all 51 of 51 rounds of the cost server took both slots' passes in turn, and both slots finished their cost warm-up.The prompt-boundary regression runs with
cargo oxide test --arch sm_121 -- -p bloomery-gpu-gates --features deepseek41,gemma-embedding2 --release --bin bloomery-serve-qwen38 lookup_prompt_discards.MTP serve A/B on one DGX Spark
The change adds one clock read per pass under
BLOOMERY_MTP_WIDTH=costwith--parallel 1, so I comparedbloomery-serve-qwen38built from upstream main71ca4de9with the one built from4fa0a12b. Each server started fresh, with the model's MTP file:BLOOMERY_DRAFT=mtp BLOOMERY_MTP_DRAFT="$MTP" BLOOMERY_MTP_WIDTH=cost BLOOMERY_RESIDENCY=off \ bloomery-serve-qwen38 --host 127.0.0.1 --port 0 --ctx-size 4096 --parallel 1Then one
/completionrequest (promptThe capital of France is,n_predict128, temperature 0,cache_promptfalse,ignore_eostrue) and thepredicted_per_secondfrom its timings. Main and the branch alternated for 3 rounds each, after the load average read 0.76 with 6 quiet polls 5 s apart:Delta (head against main, medians): +2.1% tok/s; main's first run (24.309) is a cold start.
I read main's first run as a cold start and did not confirm it. The branch is not slower than main. This shows that the extra clock read has no visible cost. It is not a speed claim, and I did not measure the card's read bandwidth in this sitting.
Decode A/B on one DGX Spark
generate_qwen3moeon four 4096 id prompts,-n 128, graph mode, one lease, measured one6562f72against upstream mainc900efacbefore the later commits (its table iscomparison-r7.json, not the A/B table above). Draft off on this branch equals main within 0.3 %, the lookup ids equal the draft-off ids in every bundle, and the lookup gains where the prompt repeats itself:I carry this A/B to the later heads instead of measuring again.
generate_qwen3moedrives the draft directly and never callsfinish_passorpass_in_turn. Its token loop andLookup::propose,acceptandsteppeddid not change after the measured head, andwidth.rsgained only thefinish_passmethod and a doc sentence. The default one-pass MTP path did not change either. I measured no new MTP speed.Hardware
One DGX Spark. The GPU gates and the A/B above ran on it at
4fa0a12b; the binaries were built in the CUDA 13.3.1 devel container and ran on the host.GPU name, driver and CUDA version, from
nvidia-smi --query-gpu=name,driver_version --format=csv,noheaderand the container banner of the same job:The gate recipe, whose lookup and MTP arms ran in that job, and the output summary of each arm:
Model:
unsloth/Qwen3.8-Flash-Next-GGUFat revision766911a6b7369840a91dbcd95f9f997acaab6cd6, UD-Q4_K_XL.What I ran into
None of this blocks the PR.
62ae0592was not run through the GPU gates or the A/B, for the reason given above; its recipe checks and the runtime and gate host tests passed on it. The unit tests ran one9cb5764and72876485as listed, and the runner self-test (131 of 131 ok) ran on44a35e24; none of them was repeated after the serve: schemajump R2 feeds a run of fixed ids as one prefill call (BLOOMERY_SCHEMAJUMP, on by default) #535 rebase.--place gate(a step near 100 ms), so they show warm-up and slot separation only, not speed.BLOOMERY_MTP_WIDTH=cost, the MTP pass-end read also changes--parallel 1: host work after a pass no longer counts in the cost. In fixed modefinish_passdoes nothing.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.