Repository navigation
gpu, qwen38: the card route's down form is read from the whole slot map, so a load with an expert tier rounds its down rows to BF16 as its union's one-card load does, and the tier join reads the tier's rows rounded with them - #1126
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: the new load-policy API exposes three declarations that have no caller outside the GPU crate, contrary to R13.
Must fix
1. Keep the load-policy API crate-private (kind B, R13)
crates/gpu/src/card_slots.rs:714 and crates/gpu/src/host/slots.rs:391: DownStore, DownStore::of_load, and SlotMap::all_on_cards are public. A repository-wide search finds only callers inside bloomery-gpu; the policy test is also inside that crate. R13 permits pub only for cross-crate callers.
Restricting these declarations now avoids adding external API commitments for internal storage policy. Keep the existing attributes and surrounding documentation. Replace the enum, the of_load method, and the all_on_cards method with these definitions:
pub(crate) enum DownStore {
F32,
/// BF16 bits, each product rounded to nearest even;
/// tier rows are read with the same rounding.
Bf16,
}pub(crate) fn of_load(map: &SlotMap, keep_host: bool) -> DownStore {
if !keep_host && map.all_on_cards() {
DownStore::Bf16
} else {
DownStore::F32
}
}pub(crate) fn all_on_cards(&self) -> bool {
self.slots.iter().all(|&e| e != HOST)
}Non-blocking
⚠ Precision-change evidence: crates/gpu/src/q38.rs:731 adds rounding and widening in the BF16 join for each selected tier slot × 2,560 values per prefill token per tier layer [derived]. Attach the error model, applicable end-to-end count-pin result, and one timed A/B required by AGENTS.md's “float sum order or precision” row. The attached join and spill results do not establish the runtime effect.
Checked
Duplicates: 10 new functions/types checked; no duplicate owner found. dryer reported 0 pairs; GPU code was searched manually. Existing tier sums use different row layouts and weight pitches.
Complexity: check_tier_join is new at 29; its separable jobs are input setup, kernel execution, and result comparison. check_q38_card rises 48→49 with one gate clause; harmless growth.
Silent failure: 5 sites followed: the HOST skip, three invalid-place/rank branches, and BF16 non-finites. Invalid values reach named faults through the join and combine.
Tests: static mutation review: flipping !keep_host at card_slots.rs:731 fails the policy assertions; dropping TierRowsRne at q38.rs:731 fails the join's bit comparison. GPU tests were not rerun here.
Gates: no tolerance or band moved; the unsafe-count increase has a dated reason. The new clause carries FAIL-first output.
Escape catalog: no C1–C4 pattern matched.
Notes
dryer did not scan crates/gpu or crates/gpu-gates; those searches were manual.
The attached runs name base d76d5fb and head 9be1235; this review covers base 97902d2 and head 1229ef1.
Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/gate_kquant.rs, crates/gpu-gates/src/bin/shared/q38_combine.rs, crates/gpu/src/arch/qwen3moe/card38.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)
| /// sum over them reads ([`DownRows`]), decided once a load from its whole | ||
| /// slot map ([`DownStore::of_load`]). | ||
| #[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
| pub enum DownStore { |
There was a problem hiding this comment.
R13: this storage-policy type has no caller outside bloomery-gpu.
| pub enum DownStore { | |
| pub(crate) enum DownStore { |
| /// card's share, so a load with a tier and the one-card load of its | ||
| /// union round the same rows. | ||
| #[must_use] | ||
| pub fn of_load(map: &SlotMap, keep_host: bool) -> DownStore { |
There was a problem hiding this comment.
R13: all callers of this load-policy method are inside bloomery-gpu.
| pub fn of_load(map: &SlotMap, keep_host: bool) -> DownStore { | |
| pub(crate) fn of_load(map: &SlotMap, keep_host: bool) -> DownStore { |
| /// card: no entry is [`HOST`]. A map with a tier and the map of its union | ||
| /// (every tier set joined to the stage card's) hold it alike. | ||
| #[must_use] | ||
| pub fn all_on_cards(&self) -> bool { |
There was a problem hiding this comment.
R13: this map query is only called inside bloomery-gpu.
| pub fn all_on_cards(&self) -> bool { | |
| pub(crate) fn all_on_cards(&self) -> bool { |
…ap, so a load with an expert tier rounds its down rows to BF16 as its union's one-card load does, and the tier join reads the tier's rows rounded with them
1229ef1 to
d922862
Compare
There was a problem hiding this comment.
Since the last review:
- Fixed: R13 visibility.
DownStoreandof_loadare crate-private at card_slots.rs:714 and card_slots.rs:730;all_on_cardsis crate-private at host/slots.rs:391. All callers remain inside the GPU crate. - Still open: precision-change evidence at q38.rs:731, detailed below.
Verdict: CLEAN: The previous must-fix is resolved, and the three visibility edits introduce no blocking defect.
Non-blocking
⚠ Precision-change evidence: crates/gpu/src/q38.rs:731 rounds and widens each selected tier slot × 2,560 values per prefill token per tier layer [derived]. Attach the precision error model, applicable end-to-end count-pin result, and timed A/B required by AGENTS.md's “float sum order or precision” row. The added one-card whole-program gate and server outputs cover execution but do not establish the runtime effect.
Checked
Duplicates: 0 new items in the interdiff; callers of all three edited declarations checked. dryer reports 0 pairs.
Complexity: previously flagged check_tier_join (new→29, setup/execution/comparison) and check_q38_card (48→49, one gate clause) are unchanged in the interdiff.
Silent failure: 0 added sites; the edits change visibility only.
Tests: none changed. Static mutation review: flipping !keep_host fails the policy assertions; dropping TierRowsRne fails the join's bit comparison. GPU gates were not rerun here.
Gates: none changed since the previous review; no pins moved.
Escape catalog: no C1–C4 pattern matched.
Notes
dryer did not scan crates/gpu or crates/gpu-gates; relevant searches were manual. Attached gate evidence now names this review's base and head hashes.
Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/gate_kquant.rs, crates/gpu-gates/src/bin/shared/q38_combine.rs, crates/gpu/src/arch/qwen3moe/card38.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. |
두 장 카드 load가 한 장 union load와 같은 BF16 down 형식을 쓰도록 맞춰, 두 장 prompt 결과가 union reference와 어긋나던 문제(#1120)를 고칩니다.
Fixes #1120. On Qwen3.8, a two-card load with an expert tier sums its down rows in F32, while the one-card load of the same experts rounds each down row to BF16 first. The two sums differ in the last bits, so the two-card prompt call no longer matches its union reference.
What and why
The down-row storage form was decided from
!tiered && card.all_hostless(), so any load with a tier took F32. This change makes one owner,card_slots::DownStore::of_load, decide it from the whole slot map: when every expert sits on a card (stage or tier) and no host leg is kept, down rows are BF16, otherwise F32. A two-card load and its union as a one-card load see the same map fact (SlotMap::all_on_cards), so they get the same form. The stage down store, the block join and the tier join all read this one value. In the BF16 form the tier join reads the tier's F32 rows rounded to nearest-even, the same rounding the card rows get.The tier join needs its own kernel entry,
q38_card_tier_acc_bf16, because a kernel entry's argument types are fixed and the stage rows areu16in this form. It shares its body withq38_card_tier_accthroughcard_tier_acc_at. The one-card path keeps its form: without a tier,all_on_cardsholds under the same conditions as before.Release notes: Fixed: a two-card Qwen3.8 load with an expert tier now rounds its down rows to BF16 like the one-card load of the same experts, so its prompt output matches the one-card reference.
Code shape
wide38.rs); it now lives only inDownStore::of_load, andq38_card_tier_accand its_bf16entry share one body.card_slotsowner;wide38.rsandcard38.rsread it.all_hostlessis still read by the PLE path.enqueue_card_tier_acccovers both forms.wide38,tier38,q38,card38andplace.rsnow state the BF16 condition.q38_card_tier_acc_bf16 0 0, and the unsafe ratchet moves with the new blocks.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line): the old!tiered && card.all_hostless()rule incrates/gpu/src/arch/qwen3moe/wide38.rswas the only copy and is replaced byDownStore::of_load(crates/gpu/src/card_slots.rs). The body ofq38_card_tier_accmoved tocard_tier_acc_atincrates/gpu/src/q38.rs, shared by two entries.What I ran
Upstream base
97902d2be794e22bf03675fabba987a2681bf543, PR headd9228627ee32505b8dbdb3f88cb0c32ce0698732.The new gate clause
q38_card_tier_joinreproduces the two-card join on one card and compares it with the union's BF16 card sum. On the code before this change:After the change, on a DGX Spark (GB10):
The same clause on an RTX 5090 machine:
The real binary on Qwen3.8 FP4-Local, where every routed expert is on the card (the BF16 down form). Model:
nvidia/Qwen3.8-Flash-Next-FP4-Local, revisionb9ce18a6887e18c089fdea8509a33e63429a3300,$Mis its folder. SHA-256 of its files:The one-card whole-program gate in the fixture tier covers both forms (a card plan with a host leg takes F32, a whole plan without it takes BF16):
The PTX comparison against the base shows one added entry and an unchanged resource row for the moved one, and the spill check pins all three card-tier entries:
Hardware (if the change is for a machine)
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.