Skip to content

host::costs: the expert stream and the split walk price from the detected device and this load - #1082

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-cmn-stream-costs
Nov 1, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-cmn-stream-costs

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

전문가 스트림과 분할 탐색의 비용을 한 카드의 상수 대신 감지한 장치와 이번 로드의 측정값으로 계산합니다.

What and why

The expert stream lane, the host union and the split walk priced their work from fitted rows and constants measured on one card. They now read the detected device and this load: the lane's rates, the union's costs and the enqueue cost are measured at load and kept under the device's key in a cost store, so a later load of the same key prices with the same values. The card's costs and the walk's front row come from the card's driver attributes (int8 MMA rate, DRAM rate) and the model's expert shape. The per-family fitted rows (Qwen3.8, Qwen3.6, Muse Spark, MiniMax, DeepSeek) and the lane and split constants are removed. Cache keys carry the actual staging slots, fill workers, pool width and probe part sizes, and a stored value outside its valid range is refused by name.

Release notes: Changed: the expert stream and the split walk price from the detected device and this load instead of one card's constants.

Code shape

  • No second copy. The key format, the range rule and the CPU identity reader each have one owner in crates/runtime/src/costs.rs, and the GPU callers use it.
  • Model code holds only architecture facts. The model files lose their fitted rows and constants; no model or device name branch was added.
  • Dead code is gone. The per-family cost rows, the lane and split constants and the inline key format are removed.
  • No silent failure. Malformed or colliding cache entries, non-finite union timings, out-of-range stored prices, negative driver attributes and missing CPU identity fields are named errors.
  • Comments state what is true now.
  • No relaxed gate. No band, tolerance or lint moved.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line), or "none": removed the per-family cost rows and constants in crates/gpu/src/arch/qwen3moe/, crates/gpu-minimaxm3/src/stream.rs, crates/gpu-deepseek41/src/prompt_walk.rs and crates/gpu/src/arch/musespark/body/stream.rs, which now call crates/gpu/src/host/costs.rs.

What I ran

Speed, RTX 5090 (NVIDIA GeForce RTX 5090, driver 595.99.02, compute capability 12.0). Base 996b23be30a2cd4332906bbd18af9c03d75e7452, head c10761f65125ee9d1deae233b150c6dde663dec1. Model: Qwen3.8-Flash-Next UD-Q4_K_XL split GGUF, revision 766911a6b7369840a91dbcd95f9f997acaab6cd6. Each side was built with cargo oxide build --arch <detected> -- -p bloomery-gpu-gates --features <shipped set> --release --bin bloomery-serve, and served with bloomery-serve -m <first shard> --host 127.0.0.1 --port 18731 --parallel 1 --ctx-size 16896 with BLOOMERY_DRAFT=off and BLOOMERY_HOST_ROOM=96G. The client sent 4096-token code prompts for 128 generated tokens at C=1 over eight fixed windows, after one warm-up and three rounds per side in base, head, head, base, base, head order.

Metric Base Head Difference Ranges overlap
prefill tok/s 1183.380 1276.033 +7.83% no
TTFT p95 ms 3464.537 3214.307 -7.22% no
decode tok/s 63.417 64.830 +2.23% no

The measured lane price was 10.92 GB/s where the base used a fixed 20.41 GB/s, so the head admits fewer experts per prompt call (median 1956 against 2199.5). Greedy tokens repeat within a side; they differ across sides because the residency decisions differ.

Speed, GB10 (NVIDIA GB10, driver 595.84, CUDA 13.3, compute capability 12.1). Same base and head. Model: Qwen3.8-Flash-Next-FP4-Local. P=4096, 128 generated tokens, C=1, eight windows, three rounds per side in base, head, head, base, base, head order.

Arm Metric Base Head Difference Ranges overlap
draft off, code prefill tok/s 2894.48 2884.53 -0.344% yes
draft off, code decode tok/s 31.7107 31.6682 -0.134% yes
MTP, code prefill tok/s 2697.63 2707.8 +0.377% yes
MTP, code decode tok/s 59.8547 60.2006 +0.578% yes

None of the GB10 differences is larger than the same-revision repeat spread, so the change claims no GB10 speed.

GPU gate and real binary on GB10, source 5ae9ea3bbc3b198266c9ff34d6923210043b0b20:

BLOOMERY_BOX_LOCAL=1 just gate-gpu-xstream
gate_xstream: PASS

The release bloomery-serve loaded the Qwen3.8 UD-Q4_K_XL model twice with --model qwen38 --place a --ctx-size 4096, BLOOMERY_CARD_BUDGET=60G, BLOOMERY_DRAFT=off and one 32-token greedy completion each, with the gate and both loads sharing one fresh BLOOMERY_COSTS directory:

SERVE PASS 1 prompt_n 3452 predicted_n 32
xstream_lane_gbs=23.21 xstream_priced_gbs=23.21 xstream_lane_source=measured xstream_union_source=measured
SERVE PASS 2 prompt_n 3452 predicted_n 32
xstream_lane_gbs=28.63 xstream_priced_gbs=23.21 xstream_lane_source=stored xstream_union_source=stored
two loads same greedy tokens: yes
lane cache geometry recorded: yes
CALIBRATION-CARD PASS

CPU tests and build on the head's patch:

cargo test -p bloomery-runtime --lib costs::
test costs::tests::prices_out_of_range_are_refused ... ok
test costs::tests::union_keys_keep_pool_widths_apart ... ok
test result: ok. 9 passed; 0 failed
cargo check -p bloomery-gpu --tests
Finished `dev` profile [unoptimized + debuginfo] target(s)

AI help

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

@github-actions github-actions Bot added gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja 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 Nov 1, 2026
github-actions[bot]
github-actions Bot previously approved these changes Nov 1, 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 behavior or quality defect was found.

Checked

Duplicates: 76 new named items checked. Both dryer pairs were read; they share enum-rendering shape, not the same facts.

Complexity: XStream::new 25→33 adds calibration and cache branches. Body38::stage_gemm 16→19 adds deferred initialization. Neither increase establishes a defect.

Silent failure: 15 default, clamp, parsing and discarded-result sites followed. Invalid cached prices produce named load errors; formatting into strings is infallible; discarded cleanup results are test-only.

Tests: static mutation review covered deferred-request consumption, rate units, expert parts, fit denominators, cache reads, key fields, range checks, locking, probe capacity, lane mixing and split cases. Assertions address those mutants. Probe-capacity arithmetic was independently checked at boundary sizes. Rust and GPU tests were not run.

Gates: no existing band was relaxed. The removed Muse Spark fitted-row test has a dated replacement reason. The unsafe and spawn ratchet changes have dated pins.

Escape catalog: no C1–C4 pattern matched.

Card check: needs-gpu. This pull request changes crates/gpu-deepseek41/src/prompt_walk.rs, crates/gpu-deepseek41/src/shared_routed.rs, crates/gpu-gates/src/bin/gate_minimaxm3_prefill.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)

@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: There were no earlier must-fix or non-blocking items. The interdiff only updates the unsafe ratchet for the new base.

Verdict: CLEAN: The rebased ratchet matches the source counts and preserves the justified three-block increase.

Checked

Duplicates: 0 new named items in the interdiff. Both dryer pairs concern unchanged patches; their prior shape-only assessment stands.

Complexity: The diagnostic increases in XStream::new, Body38::stage_gemm and Q38::open are outside the interdiff. No function changed.

Silent failure: 0 new sites in the interdiff.

Tests: No tests changed; no new mutation check applies. Independent source counting confirmed base 2951/404/10 and head 2954/404/10. Rust and GPU tests were not run.

Gates: tools/unsafe-ratchet.txt:763 retains its dated reason. Only the three documented blocks in host/costs.rs increase the counts. Function and impl counts remain exact; no unused allowance was added.

Escape catalog: No C1–C4 pattern matches the interdiff.

Notes

The reported GPU gate run uses source 5ae9ea3b; the supplied base/head evidence pair uses 996b23be/c10761f6. The PR body includes no nvidia-smi output.

Card check: needs-gpu. This pull request changes crates/gpu-deepseek41/src/prompt_walk.rs, crates/gpu-deepseek41/src/shared_routed.rs, crates/gpu-gates/src/bin/gate_minimaxm3_prefill.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)

…cted device and this load

The lane's rates, the host union's costs and the host's enqueue cost are
measured when first needed and kept under the device's key in the cost store, so a
later load of the key prices with the same bits. The store holds a key's
lock from the read to the write, so two loads that miss a key at once take
one measurement, and a load whose store cannot keep a value is refused.
The union probe fits the union the load prepared. The card's costs and the
split walk's front row are priced from the card's driver attributes (int8
MMA rate, DRAM rate) and the model's expert shape, glue bytes included in
the column cost; the walk's card tail a card pick is the stream's priced
card column. The families' fitted rows (Qwen3.8, Qwen3.6, Muse Spark,
MiniMax, DeepSeek) and the lane and split constants are removed; the gates
set their own costs through set_xstream_costs, and the walk's tail follows
the card column they set. bloomery-serve-qwen38 prints each prompt call's
xstream end record.

The common host tier owns deferred calibration requests. Its first consumer
loads and applies the costs, and consumes the request only after both succeed;
an absent host union consumes it without applying any prices. The split walk
requests its host costs and card front rate on its first multi-row Rule walk,
so loading, decoding, passes and a disabled walk need no split cost store.
Starting an expert stream still requests its own costs. Unsupported compute
capabilities and failed online-CPU counts are named errors, not guessed rates
or persistent invalid identities. Streams hold their validated union prices
directly rather than checking and later unwrapping an option.

Release notes: unused split pricing no longer requires a writable cost store;
actual stream or Rule use still refuses prices it cannot persist.

Removed 2026-11-01: a_load_starts_from_the_row_of_its_experts_widths; the
row it scaled no longer exists. The width ratio is now card_costs
(runtime/src/costs.rs, the_card_costs_are_the_rows_at_a6000), and
the_tail_is_the_rules_whole_set_with_nothing_admitted (host/xstream.rs)
holds the union floor's refusal.

Malformed or colliding cached entries are refused until deleted, before a
measurement can replace them. Negative driver attributes and a zero compute
capability major are named errors. CPU identification refuses read errors
and missing identity fields. The CPU identity reader and its x86/ARM tests
move together into runtime::costs. Lane cache keys include actual staging
slots, fill workers and the probe's part sizes, source kinds and count, so
a tiny test cannot seed a model's price.

Validation and timing evidence:
NVIDIA GeForce RTX 5090, 595.99.02, compute capability 12.0; power limit 400 W.
Base 996b23b,
measured head c10761f65125ee9d1deae233b150c6dde663dec1.
Qwen3.8-Flash-Next UD-Q4_K_XL split GGUF, model revision
766911a6b7369840a91dbcd95f9f997acaab6cd6, first shard
Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf.
Build each side with tools/box.sh and cargo oxide build --arch <detected>
-- -p bloomery-gpu-gates --features <tools/release/build.sh shipped set>
--release --bin bloomery-serve. Run bloomery-serve -m <first shard>
--host 127.0.0.1 --port 18731 --parallel 1 --ctx-size 16896 with
BLOOMERY_DRAFT=off and BLOOMERY_HOST_ROOM=96G. Submit 4096-token code-fn
prompts, 128 generated tokens, C=1, eight fixed windows, one warm-up,
then three rounds per side in base/head/head/base/base/head order.
Prefill base 1182.667,1189.268,1183.380 vs head 1278.140,1276.033,1275.457
tok/s (+7.83% median). TTFT p95 base 3466.874,3447.345,3464.537 vs head
3209.306,3214.307,3215.555 ms (-7.22%). Decode base 63.277,63.417,63.495
vs head 64.830,65.119,64.031 tok/s (+2.23%). Within-side greedy tokens
repeat; tokens differ across sides because the residency decisions differ.

The measured lane price was 10.92 GB/s instead of the base's fixed
20.41 GB/s (base probe 11.49). Timed requests' median admissions fell
from 2199.5 to 1956 experts and their copied bytes from 6888192000 to
6119577600. These are the residency call stream's moves. The separate
expert ring streamed zero experts. The A/B is the whole detected-price
path, not an isolation of the tail term; its source price formulas stand.

GPU correctness evidence: NVIDIA GB10, 595.84, compute capability 12.1.
BLOOMERY_BOX_LOCAL=1 just gate-gpu-xstream: gate_xstream: PASS.
The release bloomery-serve with the same model, --place a --ctx-size 4096,
BLOOMERY_CARD_BUDGET=60G, BLOOMERY_DRAFT=off, completed two loads and
32-token greedy completions: qwen38 two loads same tokens: yes.
A 64-column ubatch load also completed, and an unkept cost store was
refused by name. Saved card evidence is carried for unchanged formulas;
the cache namespace correction is checked separately on the final source.

Final cache-boundary validation on source
5ae9ea3bbc3b198266c9ff34d6923210043b0b20:
NVIDIA GB10, driver 595.84, compute capability 12.1.
BLOOMERY_BOX_LOCAL=1 just gate-gpu-xstream: gate_xstream: PASS.
Built the shipped bloomery-serve feature set from that source with cargo
oxide, then loaded the Qwen3.8 UD-Q4_K_XL revision above twice with
BLOOMERY_CARD_BUDGET=60G, BLOOMERY_DRAFT=off, --model qwen38 --place a
--ctx-size 4096, one greedy 32-token completion each. The gate and both
server loads used the same fresh BLOOMERY_COSTS directory.
SERVE PASS 1 prompt_n 3452 predicted_n 32; lane measured, union measured.
SERVE PASS 2 prompt_n 3452 predicted_n 32; lane stored, union stored.
Both loads priced at 23.21 GB/s; the second live probe read 28.63 GB/s
without changing the stored price. two loads same greedy tokens: yes.
lane cache geometry recorded: yes. CALIBRATION-CARD PASS.

CPU checks: cargo test -p bloomery-runtime --lib costs::tests::calibration_
(2 passed), cargo clippy -p bloomery-runtime --lib --tests -- -D warnings,
cargo fmt --all -- --check and check-comments.sh all passed. Executed
FAIL-first mutants: device-only lane key collides, CPU read-to-empty loses
the named read error, and missing CPU identity-to-unknown is accepted;
each test failed on its mutant and passed after restoring the source.
The earlier cache/attribute boundaries passed five tests and six executed
FAIL-first mutants. No kernel, price formula or timing probe was changed
by these follow-up fixes; the saved RTX 5090 A/B's first head load measured
its own rates and therefore did not reuse the tiny gate calibration.

Validation of the deferred-use boundary, source tree 498d12ae036f9e47a64477491ef47bed2e4dde87:
NVIDIA GB10, 595.84, compute capability 12.1; the same Qwen3.8 revision
and first shard named above. Build the shipped feature set with cargo oxide
for the detected architecture, --release --bin bloomery-serve
--bin generate_qwen3moe. The restored source builds successfully.
BLOOMERY_BOX_LOCAL=1 just gate-gpu-xstream: gate_xstream: PASS.
An eager-calibration mutant refuses startup without HOME or BLOOMERY_COSTS;
the corrected server, with BLOOMERY_XSTREAM=off, starts and generates four tokens.
With HOME absent and BLOOMERY_COSTS below a regular file,
BLOOMERY_SPLIT_WALK=off BLOOMERY_XSTREAM=off generate_qwen3moe --place a
--ctx 4096 --prefill gemm --prompt <long prose> -n 4 succeeds.
The server --model qwen38 --place a --ctx-size 4096, BLOOMERY_XSTREAM=off and the
same blocked cost path, starts and names the cost-store refusal when a
3,452-token prompt first needs Rule prices. With a writable cost path, two
independent loads complete the same prompt and four generated tokens; the
second leaves the cost files unchanged and emits the same greedy tokens.
CPU tests for deferred consumption, supported/unpriced capabilities and
CPU identities pass, with executed FAIL-first mutants for an early take,
an unknown capability default, a wildcard minor and an invalid CPU count.
Scoped x86_64 Linux clippy of bloomery-gpu's lib/tests and formatting pass.
No kernel, launch geometry, byte formula or gate tolerance changed.
@juliankang4
juliankang4 force-pushed the dgx-spark-q38-cmn-stream-costs branch from 23ac077 to 3f4f2e5 Compare November 1, 2026 14:47

@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: There were no earlier must-fix or non-blocking items. This interdiff rebases the existing cost changes onto shared staging ownership and the staging cap.

Verdict: CLEAN: The rebase preserves staging bounds, calibration geometry and gate failure propagation.

Checked

Duplicates: 0 new named items in the interdiff. Both dryer pairs were read; they share enum-to-string structure but represent different facts.

Complexity: The calibration branches in XStream::new and deferred calibration in Body38::stage_gemm belong to previously reviewed patches. The interdiff adds no branches.

Silent failure: 0 new sites. Insufficient ring space remains a named error. Calibration keys use actual staging slots, including zero for the pageable fallback.

Tests: No test logic changed in the interdiff. Mutation by inspection: removing the staging clamp fails the preserved cap check, whose accumulator reaches checks_failed(). Source assertions confirmed the cap precedes lane creation and cache-key construction. Rust and GPU tests were not run.

Gates: No pins moved or cases removed. The cap check retains its verdict accumulator and drops its stream before the next probe.

Performance: The interdiff changes load-time context; it introduces no work per token.

Escape catalog: No C1–C4 pattern matches the interdiff.

Notes

GPU evidence remains incomplete: the PR includes no nvidia-smi output. Its reported gate source is 5ae9ea3b; its timing pair is 996b23be/c10761f6, rather than the supplied review base and head.

Card check: needs-gpu. This pull request changes crates/gpu-deepseek41/src/prompt_walk.rs, crates/gpu-deepseek41/src/shared_routed.rs, crates/gpu-gates/src/bin/gate_minimaxm3_prefill.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.

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

Labels

gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja 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