Skip to content

serve: connect dense qwen35 to the existing native Qwen seat - #339

Merged
juliankang4 merged 4 commits into
midagedev:mainfrom
juliankang4:contribution/dense-qwen-pr-20261015
Oct 16, 2026
Merged

juliankang4 merged 4 commits into
midagedev:mainfrom
juliankang4:contribution/dense-qwen-pr-20261015

Conversation

@juliankang4

@juliankang4 juliankang4 commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

This carries #251 by @Burntgogi forward. His commits are unchanged; our follow-up commit fixes two placement problems found while testing a real dense model.

What and why

Burntgogi connected dense qwen35 generation to the existing Qwen seat and Body35 for #88. His follow-up commits made the server and CLI reject malformed decision metadata through model_file::decision_type, reused serve_open35 for CLI load options, and added an architecture-neutral header regression. The last review approved those fixes.

This branch rebases that work onto current main. His three commits stay separate, with their authors, messages and order intact. Our commit adds two fixes to the shared placement code in crates/gpu-gates/src/bin/shared/qwen3moe_place.rs:

  1. A dense whole-card shortage keeps its typed PlacementError::CardBudgetFloor, as the review required. Before, Whole::dense_refusal turned the shortage into a string, so the default-context ladder could not tell it was a memory shortage and stopped instead of trying the next smaller context. Now the ladder halves the context (16384, then 8192). Other refusals still propagate as errors.
  2. A dense 27B model loaded on a GB10 was refused because PlaceQ3::qwen35_on asked for placed-router scratch first, and a dense model has no router. A backbone with zero experts now reuses the arena of the existing whole-card load. Routed files keep the existing path. No refusal was removed.

Release notes: Added: Dense Qwen generation through the existing native Qwen seat.

Code shape

  • No second copy. The decision marker reader, the Qwen load-options owner and the placement owner remain shared.
  • Model code holds only architecture facts. No model or kernel implementation was added.
  • Dead code is gone. No new production helper or option.
  • No silent failure. Only genuine memory shortages become a retry. Malformed and unsupported loads stay errors.
  • Comments state what is true now.
  • No relaxed gate. The new host-only gate gate-qwen3-plan opens no card; no selector or assertion was removed.
  • Clippy and a full contrib-check were not run here.

What I ran

Hardware: one NVIDIA GB10 (driver 595.84, CUDA image 13.3.1) for the model runs. The test and gate runs used the same family of machines with --arch sm_121.

Final head 5fd5e67f95554a01057ad99bd43a4bc9cf342200, base ac66556d0831f934ebb2c3efcf2f2f7fe9862854. The checks below ran on the earlier head 18feed6d3a198340e497d33842db14d9949e1b8c. The final rebase left all four commits patch-identical in git range-diff, so I did not rerun them on the rebased head.

Shortage regression. It uses a dense tensor with no experts and the real whole_need, dense_refusal, short_or and choose_ctx_of. The card budget equals the lower rung's need, so the probe sequence must be [16384, 8192], for checked and unchecked loads.

cargo oxide test --arch sm_121 -- -p bloomery-gpu-gates --features gpu --bin generate_qwen3moe --release dense_shortage_halves_the_default_context -- --nocapture
  • Before the fix, the test panicked with expected typed CardBudgetFloor, got whole fit at ctx 16384 (the error was an untyped string).
  • After the fix, it passes: 1 passed; 0 failed.

Real dense 27B load. I ran Qwen3.8-27B-Q4_K_M.gguf on the GB10 with the commit before the arena change and then with the fixed commit:

cargo oxide build --arch sm_121 -- -p bloomery-gpu-gates --features gpu --bin generate_qwen3moe --release
BLOOMERY_REF_MODEL=Qwen3.8-27B-Q4_K_M.gguf target/release/generate_qwen3moe --prompt Hello -n 4 --ctx 512 --mode eager
  • Before the fix, the load stopped with qwen3moe placed load: a router (this chain's FFNs are dense) and exit code 1.
  • After the fix, it reports whole fit at ctx 512, load arch=qwen35 with 64 layers in eager mode with an f16 cache, then generates tokens [11, 353, 2688, 264] (", I'm a").

This shows the model loads and generates. It is not a speed measurement or an accuracy comparison.

just contrib-check --tier t0 passed all 85 units. The first t0 run caught nine orphaned copies of a #[test] in an included module. I moved the body beside its private owner with one test entry and one gate recipe, and no checker was weakened. tools/gate-paths.tsv has the derived entries from recipes.py check --fill.

What I ran into

This does not block review. No oracle comparison of dense logits, eager and graph agreement, or HTTP and native parity was run, so token correctness against the reference is unverified. The shortage test uses synthetic placement data, not an HTTP server under card pressure. Device-linked frontend compilation, mac-static and the full GPU gate set were not run here.

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

@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 16, 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: dense serving stops on a memory shortage instead of selecting a smaller default context.

Must fix

1. Preserve the typed memory shortage for dense context selection

crates/gpu-gates/src/bin/shared/qwen3moe_place.rs:923 now sends dense files through unplaced_qwen35_slots. For bloomery-serve --model qwen3 -m dense.gguf with --ctx and --place unset, choose a card that holds the model at a lower context rung but not the initial target. The whole-fit probe returns Whole::Short; the dense model has no routed experts, so unplaced calls dense_refusal at line 639, which returns a string error. short_or at line 1008 recognizes only typed shortages. The error propagates through serve_choice into choose_ctx, which stops instead of halving. The server exits although a smaller context fits.

Cost: fix the existing refusal owner before dense callers acquire separate retry logic.

Replace Whole::dense_refusal with the following. The existing short_in reader recognizes this placement error.

fn dense_refusal(&self, ctx: usize) -> GateError {
    if let Whole::Short(n) = self {
        let (margin, beside) = match n.load {
            WholeLoad::Checked { arena, reserve } => (reserve, arena),
            WholeLoad::Unchecked => (n.card.margin_bytes, 0),
        };
        return PlacementError::CardBudgetFloor {
            card: n.card.name.clone(),
            budget: n.budget,
            floor: n.need,
            dense: n.weights,
            kv: n.kv,
            context: n.card.context_bytes,
            scratch: n.card.scratch_bytes,
            reserves: n.card.reserve_bytes(),
            margin,
            beside,
        }
        .into();
    }
    format!(
        "{}: a dense backbone has no routed experts to move to the host tier",
        self.line(ctx)
    )
    .into()
}

Add a regression with a card budget between the initial target's need and a lower rung's need. Assert that default context selection reaches the lower rung; restoring the string error must fail it.

Checked

Error path: traced the new dense dispatch through the whole-fit probe, dense refusal, typed shortage reader and context ladder.
Fix: WholeLoad is Copy; the proposed error's fields match WholeNeed and CardBudgetFloor. The existing short_in reader accepts this variant.
Tests: the decision-marker regression asserts that malformed metadata errors; the PR body reports its FAIL-first run. The context fallback needs the regression requested above.
Scope: full review; this is a new reachable behavior path. No ledger lessons apply. Escape catalog C1–C4 do not match this finding.

Notes

Dryer did not run. Validation was static; no builds or tests were executed. The PR supplies no NVIDIA gate evidence and reports device-linked frontend compilation and dense runtime validation as outstanding.

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

@Burntgogi

Copy link
Copy Markdown
Contributor

I am refreshing our diagnostic follow-up #254 against this successor parent rather than duplicating the frontend. I am preparing the focused typed-shortage correction from review-5550636450 and a current-main integration branch, preserving your commits. I will share the fix/range here for your branch; I will not rewrite your fork branch or claim NVIDIA validation from host checks.

@juliankang4

Copy link
Copy Markdown
Collaborator Author

@Burntgogi 고맙습니다. typed shortage 수정은 이미 이 PR의 다음 push에 들어 있습니다. 같은 작업을 두 번 하시지 않도록 먼저 알려 드립니다.

  • 마지막 커밋 하나에 두 가지를 고쳤습니다. 하나는 리뷰가 요구한 typed CardBudgetFloor 부족 오류입니다. 다른 하나는 dense 27B를 GB10에서 실제로 올릴 때 placed router scratch를 먼저 요구해서 a router (this chain's FFNs are dense)로 거부되던 문제입니다. 전문가가 없는 backbone은 기존 whole load arena를 다시 씁니다.
  • 같은 Qwen3.8 27B Q4_K_M 파일로 수정 전에는 그 거부를 재현했고, 수정 뒤에는 GB10에서 올라가 토큰 4개를 생성했습니다.
  • Burntgogi님의 커밋 세 개는 author와 내용을 그대로 두었습니다. 지금 current main 위로 rebase해서 검사를 돌리는 중이고, 끝나면 이 브랜치에 push합니다.

#254를 이 PR 위로 새로 맞추시는 것은 좋습니다. 이 push가 올라가면 #254의 native load가 GB10에서도 열릴 것입니다. 그래서 #254는 Burntgogi님께 맡기고, 저는 따로 이어받지 않겠습니다. GB10에서 돌려 볼 것이 있으면 말씀해 주세요.

(AI 코딩 에이전트가 작성한 코멘트이며, 내용은 제가 확인했습니다.)

@juliankang4
juliankang4 force-pushed the contribution/dense-qwen-pr-20261015 branch from ab68f00 to f9fb472 Compare October 16, 2026 19:23
github-actions[bot]
github-actions Bot previously approved these changes Oct 16, 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: CLEAN: No must-fix defect was established in the changed paths.

Non-blocking

⚠ Dense generation validation: docs/contrib/qwen35-generation.md:76. The reported model run covers four eager CLI tokens.
Attach dense forced-ID logits, eager/graph agreement and HTTP/native parity results from the documented clause on the contributor's card. This checks the new serving path before more dense models depend on it.

⚠ Arena regression coverage: crates/gpu-gates/src/bin/shared/qwen3moe_place.rs:368. The shortage test constructs Whole::Short directly.
Restoring unconditional placed_arena_bytes leaves the shortage regression green because it never calls qwen35_on. Add a dense fixture through qwen35_on that asserts planning succeeds, and show it fails with that mutant. This prevents recurrence of the separate no-router load failure.

Checked

Duplicates: 13 new functions, types and constants searched; no duplicate with a net-reducing fix identified. No dryer pairs were available.

Complexity: qwen35_on 8→13 adds arena selection and architecture reporting; CLI run 162→164 adds draft refusal; serve_load 19→20 adds an explicit unsupported-architecture arm. No complexity-only finding.

Silent failure: 8 changed absence/error sites followed. Missing architectures and malformed decision markers reach named errors; diagnostic placeholders do not select a model.

Tests, static mutation review: decision_type line 36, non-string→absent; Family::from_name line 23, drop qwen35; decode_mma line 45, flip !=; dense_refusal line 652, typed shortage→string. Each makes an assertion fail. The changed Python self-test still rejects its unsupported serves-arm mutant. The arena mutant is uncovered as noted above.

Gates: no pins, tolerances or cases relaxed. The PR reports FAIL-first for the new shortage regression.

Escape catalog: C1–C4 do not match the changed code.

Performance: changes affect admission and loading; no per-token allocation, launch, copy or synchronization term changes.

Notes

dryer did not run, according to diagnostics.
Static review only; builds and GPU gates were not run here.
The supplied commit IDs differ from the reviewed head. No qualifying gate log with the required nvidia-smi line is supplied.

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

Burntgogi added a commit to Burntgogi/bloomery that referenced this pull request Oct 16, 2026
Replay only the three unique diagnostics commits onto the corrected midagedev#339 parent, retaining its authors and main's Nemotron and embedding changes. Include the server's current gemma-embedding2 required feature in stamped native builds, and document the exact parent pins, diagnostic-only comparison boundary, cross-fork base constraint, and host/static/reference smoke commands.

Verification: intentionally unrun in this worktree; integration owner performs fresh verification after integration. No CUDA or full-model inference claim.
@Burntgogi

Copy link
Copy Markdown
Contributor

Focused typed-shortage correction submitted directly to your parent branch: juliankang4#1 (f9102a2 + 492218d). Isolated metadata and all test-ownership checks pass; actual host source-owner execution selects half/quarter/default rungs, while original string refusal fails. Current-main support is Burntgogi/bloomery:support/qwen35-339-current (3845e27), preserving your authorship and current Nemotron/embedding changes. Our #254 follow-up is replayed after that parent, not submitted as a second frontend. NVIDIA execution remains separate. The independently submitted #359 makes Card reserve sums fallible; integration/source-correctness-20261016 includes the checked callsite adaptation and passes the combined metadata check.

@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: CLEAN: The changed admission and placement paths preserve named refusals and context retries.

Non-blocking

⚠ Complete dense execution evidence: docs/contrib/qwen35-generation.md:76. The reported run generates four tokens in eager mode. Attach dense reference-logit, eager/graph and HTTP/native parity results, including prefix reuse and resident slots. This checks the newly admitted execution paths before serving depends on them.

⚠ Cover the dense arena selection: crates/gpu-gates/src/bin/shared/qwen3moe_place.rs:368. Replacing this branch with placed_arena_bytes restores the no-router refusal while the synthetic shortage test still passes. Add a dense-header planner case to the existing test module and gate recipe. It protects the second placement fix at its owner.

Checked

Duplicates: 13 new functions, types and constants checked; no duplicate owner found. Dryer supplied no pairs.
Complexity: qwen35_on 8→13 adds arena selection and architecture reporting; cli::run 162→164 adds a draft guard; serve_load 19→20 adds family/refusal arms. These are branches in existing orchestration functions.
Silent failure: 8 fallback/absence sites followed; missing architecture and malformed markers reach named errors. The unchecked arena arm has no producer in whole_load.
Tests, static mutation check: stringifying the shortage at crates/gpu-gates/src/bin/shared/qwen3moe_place.rs:652 fails the typed-error assertion.
Tests, static mutation check: treating malformed metadata as absent at crates/gpu-gates/src/model_file.rs:37 fails the error assertion.
Tests, static mutation check: dropping the dense arm at crates/gpu-gates/src/qwen_seat.rs:23, or flipping != at line 45, fails the family or flash-selection assertions. The arena mutant remains uncovered.
Gates: no pin, tolerance or case removed or relaxed; the new shortage clause has reported FAIL-first evidence. Gate-path changes only add selections.
Escape catalog: C1–C4 do not match. Python syntax parsing passed.

Notes

Dryer did not run; diagnostics reports no eligible changed Rust files. Device gates were not run during this review. The supplied evidence lacks the required nvidia-smi line and just gate-* run output.

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

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit ea4b622 into midagedev:main Oct 16, 2026
6 checks passed
juliankang4 pushed a commit that referenced this pull request Oct 17, 2026
Replay only the three unique diagnostics commits onto the corrected #339 parent, retaining its authors and main's Nemotron and embedding changes. Include the server's current gemma-embedding2 required feature in stamped native builds, and document the exact parent pins, diagnostic-only comparison boundary, cross-fork base constraint, and host/static/reference smoke commands.

Verification: intentionally unrun in this worktree; integration owner performs fresh verification after integration. No CUDA or full-model inference claim.
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 gpu-verified 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.

3 participants