Skip to content

qwen3 seat: BLOOMERY_DRAFT=dspark serves Qwen3.6 (RedHat speculator) and MiniCPM-V 4.7 (its own draft) - #638

Merged
midagedev merged 4 commits into
mainfrom
dspark90
Oct 22, 2026
Merged

midagedev merged 4 commits into
mainfrom
dspark90

Conversation

@midagedev

@midagedev midagedev commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Refs #90.

What. On the qwen3 seat, BLOOMERY_DRAFT=dspark with BLOOMERY_DSPARK_MODEL naming an HF draft directory now serves a whole-card qwen35moe target. It used to be refused with "CardDspark, which this build does not carry yet".

  • The target opens verifying (Qwen35moeModel::open_verifying). The draft runs on the target's card and CUDA context.
  • MiniCPM-V 4.7's draft scores the full vocabulary. It borrows the target's resident Q6_K output.weight in place and its token_embd.weight rows (dspark_hf::Borrowed, dense::load_target_embed). Nothing is copied. One new unsafe block (the in-place head, as the DFlash2 draft has), pinned in tools/unsafe-ratchet.txt.
  • RedHat's Qwen3.6 speculator carries its own reduced head and id map.
  • A draft whose ids, mask id, taps, layer count or hidden width do not fit the target is refused by name before a weight is read. A placed load, --parallel > 1 and a qwen3moe target stay refused by name.

Gate. New gate-gpu-qwen3-dspark (real files). For each target, greedy ids with the draft equal the ids without it. It also checks the chat surface under the draft, the load_draft record, and the cross-target, placed and --parallel 2 refusals. FAIL-first: Body35::open_dspark forced to Ok(None) turns it red.

Run green on the box (round tree, before the rebase): gate-gpu-qwen3-dspark, gate-gpu-qwen35-dspark, gate-gpu-qwen3-serve, gate-serve-draft-rules, gate-q38-serve-rules, gate-app, gate-dspark-read, gate-gpu-lib, gate-gpu-gates-lib, gate-qwen3-plan, gate-levers. The landing batch on this commit follows in a comment.

Second commit (review fixes and ranks 1 and 7):

  • One Spark impl over CardDspark<L> in served.rs. The ds41, raon1 and qwen3 copies are removed.
  • A reduced draft no longer asks the target for a Q6_K head. Sage-A1.5 and Ornith-1.5 take the RedHat draft: their load draft record is the same as Qwen3.6's.
  • BLOOMERY_DRAFT=lookup serves a whole-card qwen35moe target. qwen3moe stays refused by name.
  • The gate has one spawn helper. It adds draft_proposes (FAIL-first: a pass that never drafts turns it red on all four DSpark arms) and lookup_is_served. The recipe uses the release feature list. Three rows are added to tools/defaults-twins.tsv.
  • Green on the box (round tree): gate-gpu-qwen3-dspark, gate-serve-draft-rules, gate-gpu-qwen3-serve, gate-gpu-qwen35moe-verify, gate-gpu-qwen35-dspark, gate-gpu-raon1-dflash, gate-gpu-raon1-e2e, gate-gpu-ds41-draft.
  • The second round ran on minimax-m3.1-flash.

Written by an AI round (deepseek-v4.1-flash) and reviewed by the maintainer's lead session.

🤖 Generated with Claude Code

@github-actions github-actions Bot added documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app needs-gpu Changes code a card must check, and carries no gate run on a card tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 22, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MUST_FIX: the gate misses a draft-bypass regression, and the change adds duplicate orchestration.

Must fix

1. Require evidence that the draft proposes

crates/gpu-gates/src/bin/gate_qwen3_dspark.rs:209
The gate checks loading and output equality but never checks proposal counts. Mutant: keep loading the draft and make Q3::pass at shared/serve_seats/qwen3.rs:1119 run out.push(self.step(last)?); Ok(Drafted::default()). The load record, token equality and chat checks still pass, so a server that never proposes receives PASS.
Add the assertion now, before this gate becomes landing evidence. Insert inside if draft:

check(ok, "draft_proposes", answer["timings"]["draft_n"].as_u64().is_some_and(|n| n > 0));

2. Give the CardDspark adapter one owner

crates/gpu-gates/src/bin/shared/serve_seats/qwen3.rs:851 repeats
crates/gpu-gates/src/bin/shared/serve_seats/raon1.rs:360 and the V4.1 adapter at shared/serve_seats/ds41.rs:1005. Seven methods are identical forwards to CardDspark; the window adapters consume the same optional count. The existing V4.1 and DFlash2 loaders enforce their required windows. R14 forbids the third copy.
Consolidating now removes three impls before their behavior can drift. In served.rs, import app::dspark::CardDspark and bloomery_gpu::dspark::DraftLayers, delete the three seat impls, and add:

impl<B, L> Spark<B> for CardDspark<L>
where
    B: Prompt + Keep + Rows + Rollback + 'static,
    Session<B>: runtime::TappedPrompt<Error = SessionError>,
    L: DraftLayers + 'static,
{
    fn feed_call(&mut self, s: &mut Session<B>, ids: &[u32]) -> Result<u32, SessionError> {
        CardDspark::feed_call(self, s, ids)
    }
    fn forget(&mut self) { CardDspark::forget(self); }
    fn restart(&mut self) -> Result<(), GpuError> { CardDspark::restart(self) }
    fn window(&self) -> usize { CardDspark::window(self).unwrap_or(usize::MAX) }
    fn follows(&self, pos: u32) -> bool { CardDspark::follows(self, pos) }
    fn resident_bytes(&self) -> usize { CardDspark::resident_bytes(self) }
    fn device(&self) -> Result<DeviceId, GpuError> { CardDspark::device(self) }
    fn card(&self) -> &'static str { CardDspark::card(self) }
}

3. Share the gate's server setup

crates/gpu-gates/src/bin/gate_qwen3_dspark.rs:121 and
crates/gpu-gates/src/bin/gate_qwen3_dspark.rs:155 duplicate the environment reset, draft selection, model arguments and spawn. R14 applies to this shared configuration.
One setup prevents the positive and refusal arms from testing different server configurations. Replace start with:

fn spawn(
    case: &Case, draft: Option<&Path>, run: &Path,
    extra: &[&str], env: &[(&str, &str)],
) -> Result<(Served, PathBuf), GateError> {
    std::fs::create_dir_all(run)?;
    let mut cmd = serve_cmd()?;
    cmd.env_remove("BLOOMERY_DRAFT").env_remove("BLOOMERY_DSPARK_MODEL");
    if let Some(draft) = draft {
        cmd.env("BLOOMERY_DRAFT", "dspark").env("BLOOMERY_DSPARK_MODEL", draft);
    }
    cmd.envs(env.iter().copied());
    let mut args = vec![
        "--model", "qwen3", "-m", utf8(&case.model)?,
        "--port", "0", "--parallel", "1",
    ];
    args.extend_from_slice(extra);
    Ok((Served::spawn_cmd(cmd, &args, run)?, run.join("server.err")))
}

Replace refusal's setup through let err with:

let (mut served, err) = spawn(case, draft, run, extra, env)?;

Replace one's call to start with:

let (mut served, err) = spawn(case, draft.then_some(case.draft.as_path()), &run, &[], &[])?;
let addr = served.address(&err, 3000, POLL)?;

Optimization headroom

  • E, Less work: crates/gpu-gates/src/bin/shared/serve_seats/qwen3.rs:857. Target and draft share a card, but tapped rows travel through host memory. Keeping them on device removes 8 × taps.len() × hidden host-device bytes per token fed to the draft [derived: 4-byte readback + 4-byte upload per value], plus blocking readbacks.

Checked

Duplicates: both groups above confirmed. Dryer found no pairs and excluded gpu-gates.
Complexity: diagnostics flag open_with (39), parse_args (18), Q3::open (20), run (58), Body35::open (21), and Body::open (16).
Silent failure: missing refusal logs reach substring checks and fail; the full-history window maps to usize::MAX by contract.
Tests: static mutation analysis confirms the plain-step bypass survives the gate; the proposed draft_n check rejects it. No GPU gates run here.
Gates: the unsafe-ratchet increase has a dated PIN and reason; no numeric bands moved. No escape-catalog pattern matched the cited code.

Notes

The PR body lists green runs without the required card/driver line, paired commit hashes, or commands with output.

Card check: needs-gpu. This pull request changes crates/gpu-gates/Cargo.toml, crates/gpu-gates/src/bin/bloomery_serve.rs, crates/gpu-gates/src/bin/gate_qwen3_dspark.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)

let tokens = ids_of(&answer["tokens"]);
println!("{tag} {} tokens {tokens:?}", case.name);
if draft {
let log = server_log(&err, &[&record::LOAD_DRAFT])?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gate misses a regression that loads the draft but uses only plain steps. Require at least one proposal.

Suggested change
let log = server_log(&err, &[&record::LOAD_DRAFT])?;
check(ok, "draft_proposes", answer["timings"]["draft_n"].as_u64().is_some_and(|n| n > 0));
let log = server_log(&err, &[&record::LOAD_DRAFT])?;

midagedev and others added 2 commits October 22, 2026 14:31
…ator and MiniCPM-V 4.7 with its own draft

A whole-card qwen35moe target opens verifying and takes the HF DSpark draft
on its own card and context. A full-vocabulary draft (MiniCPM-V 4.7's)
borrows the target's resident Q6_K output.weight in place and its
token_embd.weight rows; a reduced one (RedHat's Qwen3.6 speculator) carries
its own head and id map. A draft whose ids, mask, taps, layers or hidden
width do not fit the target is refused by name before a weight is read; a
placed load and --parallel > 1 stay refused by name. gate-gpu-qwen3-dspark
holds each target's greedy ids with the draft equal to the ids without it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t's draft by facts; lookup on qwen35moe

- served.rs holds the one `Spark` impl over `CardDspark<L>`; the ds41, raon1
  and qwen3 copies are gone. A draft with no window reads as the whole
  context (the V4.1 and DFlash2 readers refuse a file without one by name).
- A reduced draft (RedHat's speculator) no longer asks the target for a
  resident Q6_K head it never reads: the target's facts and the borrowed
  head are separate (`dspark_hf::Target`, `Borrowed`). Sage-A1.5 and
  Ornith-1.5 take the RedHat draft with the same load as Qwen3.6.
- BLOOMERY_DRAFT=lookup serves a whole-card qwen35moe target through the
  verifying load and `ServedDraft::lookup`; qwen3moe stays refused by name.
- gate_qwen3_dspark: one spawn helper, `draft_proposes` (FAIL-first against
  a pass that never drafts), `lookup_is_served`, the Sage/Ornith/lookup arms;
  the recipe builds the release feature list; three defaults-twins rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset label Oct 22, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the last review:

Verdict: MUST_FIX: DSpark ignores the selected width mode, the lookup gate accepts a bypass, and the change adds a duplicate refusal and a one-use wrapper.

Must fix

1. Forward the selected width mode to DSpark

crates/gpu-gates/src/bin/shared/serve_seats/qwen3.rs:985
BLOOMERY_DRAFT=dspark BLOOMERY_MTP_WIDTH=fixed is now accepted, but this call drops width; Body35::open_dspark still supplies WidthMode::Cost at line 778. The chooser can cut or suppress proposals despite the requested fixed mode.
Wire it now before fixed-mode runs become misleading evidence. Add these parameters after the card parameter:

// Body3::open_dspark:
_mode: WidthMode,
// Body35::open_dspark:
mode: WidthMode,

Replace the call at line 985:

B::open_dspark(&mut s, path, &dir, ctx, card, width)?.ok_or_else(|| {

Replace WidthMode::Cost, at line 778 with:

mode,

2. Require lookup proposals in the new gate arm

crates/gpu-gates/src/bin/gate_qwen3_dspark.rs:259
Mutant: at the start of Q3::pass (shared/serve_seats/qwen3.rs:1134), when self.draft.slot_drafts(), push self.step(last)? and return Ok(Drafted::default()). Lookup remains attached and named in /props; plain ids still match. Every new lookup assertion passes although no lookup proposal runs.
Close this gap before using the gate as evidence. Use a repetitive prompt that exercises lookup and add inside this arm:

check(ok, "lookup_proposes", answer["timings"]["draft_n"].as_u64().is_some_and(|n| n > 0));

Show this assertion red with the lookup-only bypass planted.

3. Keep the whole-card refusal in one owner

crates/gpu-gates/src/bin/shared/serve_seats/qwen3.rs:1576 duplicates crates/gpu-gates/src/bin/shared/serve_seats/qwen3.rs:1526: both explain the same verifying-load restriction, differing by draft name. R14 applies.
Merge them now while both callers are together. Replace dspark_refusal with:

fn draft_load_refusal(draft: Draft, (placement, why): (String, String)) -> GateError {
    let word = draft.name();
    format!(
        "BLOOMERY_DRAFT={word} needs the whole-card load: {placement} resolved to a placed \
         load, {why}; the draft verifies its rows on a model held whole on the card - \
         serve a load that holds the whole model there, or no draft"
    )
    .into()
}

Delete lookup_load_refusal; replace the refusal match at line 1734 with:

return Err(draft_load_refusal(draft, why));

4. Remove the one-use shape wrapper

crates/gpu-gates/src/bin/shared/dspark_hf.rs:232
shape_of has one caller and only opens HfFile before forwarding to the existing shape owner. Its new function and allowance add no needed behavior.
Remove it while there is one call site. Delete its definition, documentation and allowance; replace the expression at qwen3.rs:715 with:

dspark_hf::shape(dir, &dspark_hf::HfFile::open(dir)?)?.vocab,

Non-blocking

⚠ Lookup slot limit: crates/gpu-gates/src/bin/shared/serve_seats/qwen3.rs:989. A whole-card lookup with --parallel 2 reaches s.add_slots(2), but Body35::new_seq rejects verifying lanes at crates/gpu/src/arch/qwen3moe/body35.rs:2894. Refuse before planning and document the one-slot limit to avoid loading the model before failure. After the slot choice, insert:

if draft == Draft::Lookup && slots > 1 {
    return Err("BLOOMERY_DRAFT=lookup supports one resident slot on this body".into());
}

Checked

Duplicates/elements: both findings concern additions in the interdiff; the refusal fix removes a helper and its dispatch match. Dryer excluded gpu-gates and reported no pairs.
Complexity: parse_args adds flags; run adds lever/refusal branches; Q3::open adds draft dispatch; open_dspark adds conditional borrowing.
Silent failure: missing DSpark/lookup adapters produce named errors; the lookup bypass returns zero proposal counts.
Tests: static mutation analysis confirms the lookup-only bypass survives. DSpark now checks draft_n. No GPU gates run here.
Gates: removed lookup refusal arms have a dated PIN. No C1–C4 escape pattern matched the cited paths.

Notes

The PR lists green runs without the card/driver line, paired commit hashes, or gate commands with output.

Card check: needs-gpu. This pull request changes crates/gpu-gates/Cargo.toml, crates/gpu-gates/src/bin/bloomery_serve.rs, crates/gpu-gates/src/bin/gate_qwen3_dspark.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)

midagedev and others added 2 commits October 22, 2026 16:32
…ard refusal; gate_qwen3_dspark: lookup_proposes

- open_dspark passes the seat's WidthMode instead of WidthMode::Cost.
- dspark_refusal and lookup_load_refusal are one whole_card_refusal; the pinned prefix is unchanged.
- gate_qwen3_dspark: on a prompt whose phrase repeats, the lookup arm's timings.draft_n is above 0, so a
  seat that names the lookup and steps plain is red.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pper

shape_of only opened the draft file and called shape. The seat calls shape.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the last review:

  • DSpark width mode: fixed. The selected mode reaches the shared chooser.
  • Lookup proposal assertion: fixed. A lookup-only plain-step bypass fails the new assertion.
  • Whole-card refusal owner: fixed. Both drafts use one definition.
  • One-use shape wrapper: removed. The caller uses the existing shape reader.
  • Lookup slot-limit advisory: excluded because this increment does not change that path.

Verdict: CLEAN: The earlier must-fix items are resolved, and the incremental diff introduces no new must-fix defect.

Checked

Duplicates: whole_card_refusal replaces two refusal formatters; the one-use shape_of wrapper is removed.
Complexity: one adds a proposal predicate; Body35::open_dspark and Q3::open forward mode; run shares refusal formatting.
Silent failure: 1 optional JSON value followed. Missing, non-integer or zero draft_n fails lookup_proposes; shape-reader errors still propagate.
Tests: static analysis of Q3::pass at qwen3.rs:1136 shows that returning a plain step with default draft counts fails lookup_proposes. Request timings reset, so earlier proposals cannot satisfy it. No GPU gates run here.
Gates: the lookup clause is strengthened; no threshold, tolerance or existing case is relaxed or removed.
Performance: the production edits change load-time wiring and refusal formatting; no additional per-token allocation, launch or copy.
Escape catalog: no C1–C4 pattern matches the incremental diff.

Notes

The PR lists green runs without the card/driver line, paired commit hashes or gate commands with output. It supplies no executed lookup-bypass FAIL-first result.

Card check: needs-gpu. This pull request changes crates/gpu-gates/Cargo.toml, crates/gpu-gates/src/bin/bloomery_serve.rs, crates/gpu-gates/src/bin/gate_qwen3_dspark.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

Not approved: a release freeze is on (#648), and a merge of a needs-gpu change now would change the tree under the release batch.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset needs-gpu Changes code a card must check, and carries no gate run on a card tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant