Repository navigation
model: count the Qwen3.8 ubatch arena's rows by the arena's own allocation - #889
Merged
juliankang4 merged 1 commit intoOct 27, 2026
Merged
Conversation
…ation The plan counted 130,852 f32 and 12 u32 a position for the ubatch walk's arena (523,456 B), but the arena Arena38::wide allocates holds 124,100 f32 and 12 u32 (496,448 B): it has held no query rows since the prefill flash norms and turns the queries in its staging (6,144 f32), and no separate beta and alpha rows or one-row indexer queries since those joined one buffer each (96 and 512 f32). Every Qwen3.8 plan set aside 27,008 B a ubatch position the load never uses, 110,624,768 B at 4,096 positions. place::UBATCH_ARENA_TOKEN_BYTES now names the arena's share at 496,448 B, and UBATCH_TOKEN_BYTES is it plus the walk's own buffers, the record and the host sums (617,337 B, was 644,345). The ignored GPU test hw_a_ubatch_arena_holds_a_position_the_bytes_the_plan_counts allocates the arena at 2,048 and 4,096 rows and holds the growth a row to that constant, both ways. The card-experts plans gain that room: every pinned A6000 and 3090 plan row holds more routed experts on the card (2 to 76 a row for the Q4 file), and the pins of qwen4exp_meta, qwen4exp_mtp_meta and placement's qwen38_cards move with dated PIN lines. A plan that already holds every routed expert on the card (one GB10 at the default context) places the same experts with a smaller card need.
Contributor
There was a problem hiding this comment.
Verdict: CLEAN: the plan constant now equals the arena's measured growth per row, and every re-pinned value follows from the 27,008 B change.
Checked
- Duplicates: 3 new items (
UBATCH_ARENA_TOKEN_BYTES, the new test, the120_889term) checked; no second owner. dryer: 0 pairs. - Complexity: crapper flagged nothing.
- Silent failure: 0 new defaults or swallowed errors. The new test uses
expectandassert_eq, so a wrong count fails by name. - Arithmetic [derived]: 523,456 − 496,448 = 27,008 = (6,144 + 96 + 512) · 4. 496,448 + 120,889 = 617,337 and 644,345 − 523,456 = 120,889.
CARD_SCRATCH,CARD_ROUTE_SCRATCH, both max-context pins and the Q3 host bytes (−196,300,800) recompute from 4,096 · 27,008 = 110,624,768. - Tests: the test is
hw_-prefixed and#[ignore]d. Mutants: a new per-row buffer inArena38::allocor a changedUBATCH_ARENA_TOKEN_BYTESturnsassert_eq!(grown / rows, plan)red. A buffer that does not grow with rows is not checked, which is right, becauseUBATCH_FIXED_BYTEScovers it.bytes()lists every field of the arena, andselect_runand the router rows are equal at 2,048 and 4,096 rows at ctx 8,192. - Gates: seven pins moved, each with a dated
PIN(2026-10-28):, its reason and its derivation. The PR body shows the gate output on the contributor's card. - Hot path: none changed (planner constants and a test), so no performance term. Escape catalog: no match.
Card check: gpu-evidence. This pull request changes crates/gpu/src/arch/qwen3moe/scratch38.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)
Collaborator
Author
|
The review is done and the contribution check passed, so I'm merging this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Qwen3.8 ubatch 구간의 card 예약량을 실제 arena 할당량에 맞춰, planner가 position마다 27,008 B를 더 잡던 과예약을 바로잡습니다.
What and why
The planner reserved 644,345 B of card memory for each position of a Qwen3.8 ubatch walk. The walk's arena holds 496,448 B of that (124,100 f32 and 12 u32 per position), while the planner's derivation counted 523,456 B for it. The arena holds no query rows, no separate β and α rows and no one-row indexer queries, so the plan was 27,008 B per position too high. At the 4,096-position ubatch that is 110,624,768 B of card the planner kept empty, so placement put fewer experts on the card than it could.
UBATCH_ARENA_TOKEN_BYTESnow names the arena's share (496,448 B) andUBATCH_TOKEN_BYTESis that plus the walk's own buffers, 617,337 B per position. The model crate cannot depend on the gpu crate, so the number stays a constant in the model crate and a new GPU test ties it to the arena: it allocates the real arena at 2,048 and at 4,096 rows and requires the growth per row to equal the constant, so a count that is too high or too low is caught. Every pin that reads the planner (card plans, the Q3 host and need bytes, the two-slot boundary, the derived context limits) is re-pinned with aPIN(2026-10-28)line and its reason.Release notes: Fixed: the Qwen3.8 planner no longer over-reserves 27,008 B of card memory per ubatch position, so more experts stay on the card.
Code shape
The review reads these first. A box left unticked needs one line of why.
UBATCH_ARENA_TOKEN_BYTES, read byUBATCH_TOKEN_BYTESand by the GPU test that checks it against the arena's allocation.PIN(YYYY-MM-DD)lines are the re-pin form the template asks for.PIN(2026-10-28):and its reason.cargo fmtandcargo clippyare clean on what I touched.cargo fmt --checkandcheck-archwere clean on the head;cargo clippywas clean onbloomery-modelandbloomery-placementand was not run forbloomery-gpu, which needs CUDA.Duplication found or removed (
path:line):crates/placement/src/placement/qwen38_cards.rs:269keeps a hand-copied stage scratch value (scratch_bytes) that follows the model crate's derivation. It was already there; I re-pinned it and did not lift it, because that is a separate change.What I ran
The change is one commit on upstream main
e009acd4f93e930ae906572acbdcc0c92345d666, head6e2c57c370b5c9a41ee8046611cceb6297c45246. The GPU gates ran on the same change before upstream main moved to this base; the later main commits touch none of its files.On the RTX 5090 machine, the new arena test measures the arena's growth between 2,048 and 4,096 rows: 1,016,725,504 B over 2,048 rows, which is 496,448 B a row, equal to the plan's constant:
The Qwen3.8 reserve, meta, host and plan gates on the same machine, with the Q4 file
Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.ggufand the MTP filemtp-Qwen3.8-Flash-Next-Q8_0.gguf:The derived context limits that the MTP pins now carry were measured by that gate:
The recorded fixture budget for Qwen3.8 is lower under the new reservation, so a fixture written under the old one is refused as not the least. I regenerated the fixture with
fixture fetchasdocs/contrib/local-check.mddescribes, and the budget gate on this head then ran:Not run: a timed A/B, since no kernel or launch changed, and
cargo clippyforbloomery-gpu.Hardware
An RTX 5090 machine (this is a host-side planner change with a GPU allocation test):
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.