Repository navigation
gpu: route_warp_gated's rescan walks a lane's entries four at a time, so a round's shared loads issue together - #35
Closed
juliankang4 wants to merge 0 commit into
Closed
juliankang4 wants to merge 0 commit into
juliankang4 wants to merge 0 commit into
Conversation
Owner
|
@juliankang4 Thank you. We are checking it now. It goes into our next landing train, after the current one with #27. The gates confirm that the ids, probabilities and weights keep their bits. |
Owner
|
Thank you. This is now in our next landing train (train0211i) with five other pieces. The fixture-tier batch runs next; I will post here when it lands or if a gate goes red. |
Owner
|
Thank you @juliankang4. This landed in main as 81355f2 with your authorship, in today's train after our fixture batch (137 gates, 0 red). It will be in the 0.3.0 release notes. |
midagedev
force-pushed
the
dgx-spark-router
branch
from
October 11, 2026 12:16
5baf333 to
81355f2
Compare
Owner
|
Sorry, GitHub shows this as Closed because of how I landed it. Your commit is in main as 81355f2 with your authorship, unchanged except for the rebase. It is in the 0.3.0 release notes. Thank you again. |
This was referenced Oct 11, 2026
Merged
Merged
juliankang4
added a commit
to juliankang4/bloomery
that referenced
this pull request
Oct 13, 2026
… locality was the term The opening says what the document is, where each lever stands and how to read it, and explains GEMV and PDL. The Verdict gains a Status column; it keeps the design's predictions, and where one was refuted it is struck with a pointer to section 10, which holds the measured values for each card. Section 4.4 opens with "Closed by section 10's measurement" and the rule's arithmetic with the measured c_node. In the text four predictions are struck with the corrected value and the measuring comment beside them: c_node 0.6 to 1.5 µs (now 0.553 µs), the row-locality form's −1.4 ms bound on GB10 (passed at stock clocks by −1.550 ms on public commits and −1.65 and −1.69 ms under a lease, and by −1.62 ms at a 1989 MHz cap), 0 ± ruler on the A6000 (0.9570 of main's decode tok/s), and section 4.3's 74 KB in flight (66 to 295 KB at the JIT's 4 blocks per SM). Section 10 adds the prefetch pair on public commits (fed530d against 4a89639 at stock clocks), the lease numbers from midagedev#27, the A6000 run and the router rescan that landed (midagedev#35). headpick-warmup.md and adaptive-picks.md cite sparkdec by section instead of line, and adaptive-picks.md 3.14 now cites lever 1d (section 4.3), whose model gives 0 on the A6000, instead of the router regrid's band.
juliankang4
added a commit
to juliankang4/bloomery
that referenced
this pull request
Oct 13, 2026
… locality was the term The opening says what the document is, where each lever stands and how to read it, and explains GEMV and PDL. The Verdict gains a Status column; it keeps the design's predictions, and where one was refuted it is struck with a pointer to section 10, which holds the measured values for each card. Section 4.4 opens with "Closed by section 10's measurement" and the rule's arithmetic with the measured c_node. In the text four predictions are struck with the corrected value and the measuring comment beside them: c_node 0.6 to 1.5 µs (now 0.553 µs), the row-locality form's −1.4 ms bound on GB10 (passed at stock clocks by −1.550 ms on public commits and −1.65 and −1.69 ms under a lease, and by −1.62 ms at a 1989 MHz cap), 0 ± ruler on the A6000 (0.9570 of main's decode tok/s), and section 4.3's 74 KB in flight (66 to 295 KB at the JIT's 4 blocks per SM). Section 10 adds the prefetch pair on public commits (fed530d against 4a89639 at stock clocks), the lease numbers from midagedev#27, the A6000 run and the router rescan that landed (midagedev#35). headpick-warmup.md and adaptive-picks.md cite sparkdec by section instead of line, and adaptive-picks.md 3.14 now cites lever 1d (section 4.3), whose model gives 0 on the A6000, instead of the router regrid's band.
juliankang4
added a commit
to juliankang4/bloomery
that referenced
this pull request
Oct 13, 2026
… locality was the term The opening says what the document is, where each lever stands and how to read it, and explains GEMV and PDL. The Verdict gains a Status column; it keeps the design's predictions, and where one was refuted it is struck with a pointer to section 10, which holds the measured values for each card. Section 4.4 opens with "Closed by section 10's measurement" and the rule's arithmetic with the measured c_node. In the text four predictions are struck with the corrected value and the measuring comment beside them: c_node 0.6 to 1.5 µs (now 0.553 µs), the row-locality form's −1.4 ms bound on GB10 (passed at stock clocks by −1.550 ms on public commits and −1.65 and −1.69 ms under a lease, and by −1.62 ms at a 1989 MHz cap), 0 ± ruler on the A6000 (0.9570 of main's decode tok/s), and section 4.3's 74 KB in flight (66 to 295 KB at the JIT's 4 blocks per SM). Section 10 adds the prefetch pair on public commits (fed530d against 4a89639 at stock clocks), the lease numbers from midagedev#27, the A6000 run and the router rescan that landed (midagedev#35). headpick-warmup.md and adaptive-picks.md cite sparkdec by section instead of line, and adaptive-picks.md 3.14 now cites lever 1d (section 4.3), whose model gives 0 on the A6000, instead of the router regrid's band.
juliankang4
added a commit
that referenced
this pull request
Oct 13, 2026
… locality was the term The opening says what the document is, where each lever stands and how to read it, and explains GEMV and PDL. The Verdict gains a Status column; it keeps the design's predictions, and where one was refuted it is struck with a pointer to section 10, which holds the measured values for each card. Section 4.4 opens with "Closed by section 10's measurement" and the rule's arithmetic with the measured c_node. In the text four predictions are struck with the corrected value and the measuring comment beside them: c_node 0.6 to 1.5 µs (now 0.553 µs), the row-locality form's −1.4 ms bound on GB10 (passed at stock clocks by −1.550 ms on public commits and −1.65 and −1.69 ms under a lease, and by −1.62 ms at a 1989 MHz cap), 0 ± ruler on the A6000 (0.9570 of main's decode tok/s), and section 4.3's 74 KB in flight (66 to 295 KB at the JIT's 4 blocks per SM). Section 10 adds the prefetch pair on public commits (fed530d against 4a89639 at stock clocks), the lease numbers from #27, the A6000 run and the router rescan that landed (#35). headpick-warmup.md and adaptive-picks.md cite sparkdec by section instead of line, and adaptive-picks.md 3.14 now cites lever 1d (section 4.3), whose model gives 0 on the A6000, instead of the router regrid's band.
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.
What and why
The router top-k change from #17 (#17 (comment)), as its own
pull request. Part of #13.
route_warp_gatedpicks a token'susedexperts inusedrounds. In each round every lane rescans itsPER_LANEprobabilities in shared memory for its best untaken one, and a five-step butterfly picks the warp's best. At 16 entries
a lane (512 experts, Qwen3.8) main's rescan compiles to a loop of 16 steps, each a test of the taken bit, a branch over
one shared load and a
take, so a round's loads wait one after another. At 8 entries a lane (256 experts, Qwen3.6) theloop is unrolled and its 8 loads are already predicated.
With this change the rescan reads a lane's entries four at a time into four running bests, one per entry
jmod 4, andmerges the four after the walk. A taken entry is read as −inf through a select instead of a branch, so a step's four
loads issue together, and each
takechain is a quarter as long. The butterfly, the taken mark and everything afterthem are main's.
The ids, probabilities and weights keep their bits.
take::<false>is a total order on (value, id), so the merge picksthe entry that one running best would pick. A −inf candidate never beats the seed (−inf, 0) or a probability, so a taken
entry is never picked, as before.
On a DGX Spark:
qwen35moe_router_fused_512launch takes 34.1 to 34.5 µs against main's 39.8 to39.9 µs in the same session (nsys, 2304 launches a run, two runs of each build). That is about 0.26 ms of a 33.7 ms
decode step
[derived: 5.5 µs × 48 layers].non-inferiority card (lower bound −0.23 %). Your model in
docs/research/sparkdec.md§4.2 put a routing rewritehere at 0.
Every build generates the same ids.
This is not the form I described on #17. There each lane kept its best untaken expert, so a round was two butterflies
and no rescan (the cards below call it the owner-refill form). It is as fast at 512 experts (34.0 to 34.5 µs), but at
256 experts it read 0.4 % slower than main in one lease, which the +0.17 % ± 0.19 % on #17 could not resolve. The form
here keeps main's round and shortens only the rescan's dependent chain. The numbers are under "What I ran into".
The diff is
route_warp_gated, its two helpers and the const assert inpub mod gated. It leaves the grid,norm_row_bodyand the launchers to yoursparkrouterround (§7.1). It merges without conflicts into current main andwith #27.
Code shape
#[inline(always)]helpers sit next toroute_warp_gated, and only its rescan callsthem:
keeptakes a candidate into a running best undertake::<false>, anduntakengives a probability, or−inf when its taken bit is set. The step
keepnames is also written out on main in three places (below). Ileft them as they are to keep the diff to the rescan. They can call
keepif you would rather have one form.PER_LANEconst generic, as before. No branch on the model.
PER_LANEto be a multiple of 4. The const assert ingatednow pins thatfor both widths, so a width that breaks the walk does not compile. The fault word still refuses a non-finite
logit (the
wide512fault cases below).reads a step's four entries under one SAFETY line, the way
crates/gpu/src/router.rs:232reads its pair.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none":crates/gpu/src/arch/qwen3moe/router.rs:297and:307(
route_warp's rescan and butterfly) and:713(this function's butterfly) write out the stepkeepnames. Left asthey are, as above.
What I ran
On a Mac with the pinned nightly:
tools/ptx-scan.sh --no-jit generate_qwen3moe(sm_86, the default build), main against this branch: the md5 moves forthe six entries that inline
route_warp_gated(qwen35moe_router_fused,_fused_512,_norm,_norm_m,_routeand
_route_512) and for none of the other 209. The table is the same on both, row for row, so these six keep main'sregisters, shared memory, spill (0) and blocks per SM. The
qwen3moe_router_*entries (128 experts,route_warp) donot move. At
--arch sm_121the md5s are the same as at sm_86, and ptxas givesqwen35moe_router_fused48 registersagainst main's 40 (6 → 5 blocks per SM),
_route36 against 39 and_route_51248 against 47, and_norm_mspills 32bytes against main's 64.
gate_qwen35moe_moeon a DGX Spark, built--arch sm_86, on main and on a tree with this branch's kernels (equal md5s):the
shape,wide512andpickscases print the same 38 lines, all PASS, on both. Among them are thewide512tiecases (ids and all eleven weights equal to the host rule), its fault cases, and
picksat k = 1, 3 and 32 for 256and 512 experts against the host rule. The per-layer cases read ik's Qwen3.6 reference sets, which I do not have, so I
ran these three cases with a local change that skips the missing sets at startup. That change is not in this pull
request (see "What I ran into").
The box gates need your workstation, so I did not run them there. On another DGX Spark I ran the 42 of the 98 selected
gate recipes that have a fixture-tier line, through
tools/box.sh's local mode in the dev container, once on main andonce on this branch (main's side is the run I reported on #27):
this machine does not have (
ref_qwen35moe,ref_qwen4exp,ref-synth,ref-mtp,ref-vision,glm5next/corpus-prose.ids), the Qwen3.6 file, which the fixture tier does not mount, andgate-gpu-qwen38-serve's--place gate, which asks for a 3090. 4 exit 64 on both: the two-card recipes, which localmode leaves to the box. 7 exit 66 on both: the V4.1 fixture set here does not hold the DSpark fixture draft.
gate-gpu-swapatits staging timing assertion ("flip made at 2, lands at 5") and
gate-gpu-libathost::nvtier::reader::tests::a_stop_names_an_open_ticket_and_refuses_later_fills. Both passed on a rerun of main.Qwen3.6, 256 experts: the A/B in one lease
tools/ref/depth-qwen3moe.shthroughtools/box.sh's local mode on a DGX Spark's host, in one lease withLC_ALL=C,six rounds with the order rotated each round, n = 96, depth 6. The arms were
6 bin:ab-base:6 bin:ab-router:6 6@BLOOMERY_AB_LOAD=arm: "ours" is this change,bin:ab-baseis main,bin:ab-routeris the owner-refill form from #17, and the last arm is the machine's A/A. I built every binary in the dev container
(CUDA 13.3.1, the pinned nightly) from main (
68609e1c) plus the two runner commits that section 3.5 needs on a Spark,as for #27 (local mode and the single-card timing mode). No kernel reads them. I built the ours binary before I added
the multiple-of-4 check to the const assert, which compiles to nothing; its kernels' md5s equal this branch's.
Decode, tok/s @ n=96, depth 6, GB10, Qwen3.6-35B-A3B Q4_K_M (the mean of the six rows):
clock-event mask was 0 in every block.
MemAvailablestayed between 102.3 and 125.3 GB, above the 21.2 GB modelfile. [cpu-busy] 0 of 24 rows, cold 0 of 24, failed arms 0.
local-appscarries[timing-card-busy]on the 12 "pre"witnesses of our own arms (ours and the A/A arm), as on gpu: on an integrated device, a decode gemv warp asks L2 for its whole row before the walk #27: that process is the arm itself, waiting under
--arm-sync.spark-router-chains2-q36.card (sha256 53eb2e2b…, as the lease printed it)
Qwen3.8, 512 experts: the router launch in nsys
The depth runner cannot resolve this on Qwen3.8 on a Spark (see below), so I read the launch with nsys directly:
nsys profile -t cuda --cuda-graph-trace=nodearoundgenerate_qwen3moe --prompt "The capital of France is" -n 48 --ctx 256 --timeon Qwen3.8-Flash-Next UD-Q4_K_XL, withBLOOMERY_DRAFT=off, at stock clocks with no other process on the card, each build twice in rotated order. This is adiagnostic outside a lease runner: the single-card mode I use on the Spark covers
depth-qwen3moe.shonly so far.qwen35moe_router_fused_512, µs a launch over the run's 2304 launches (48 tokens × 48 layers), mean (median):All six runs generated the same 48 ids. In an earlier session on the same machine, main read 39.52 and 39.50 µs and
the owner-refill form 34.47 and 33.99 µs.
What I ran into
None of these block this pull request. I'm writing them down because they cost me time, and you may want to change
some of them.
The owner-refill form loses at 256 experts. In one lease on Qwen3.6 it read 0.9957 ± 0.0021 against main at
depth 6, 0.9956 ± 0.0064 at 512 and 0.9967 ± 0.0057 at 4096, with the A/A arm at 1.0013 ± 0.0026. At 8 entries a
lane main's rescan is already 8 predicated loads, and that form trades it for a second butterfly: in the sm_121 SASS
that ptxas makes from the PTX, a round's dependent chain has 21 shuffles against main's 10. §4.2's sorted-heads form
also keeps a butterfly a round, so if you try it, the round's shuffle count is the term I would check first.
The branch the compiler kept. My first version of the four-chain walk kept main's
ifon the taken bit. ptxasput each of the four loads under its own branch, so at 512 experts the walk still waited on one load at a time, and
the launch read 38.4 and 38.8 µs against main's 39.5 in the same session. The select in
untakenis what lets thefour loads issue back to back (four
LDSwith no branch between them in the 512 entry's loop). The helper's doccomment says why.
The depth runner on Qwen3.8 on a Spark. With the owner-refill form, ten rounds at depth 6 on two Sparks read
1.0064 ± 0.0288 and 1.0242 ± 0.0389 against main, and the A/A arm 0.9912 ± 0.0402 and 1.0042 ± 0.0474 (Qwen3.6's A/A
arm reads 1.0009 ± 0.0019). A 0.8 % effect cannot be read through that. Some rows' early steps run slow: one main row
read a first-ten-steps p50 of 40.73 ms against 33.62 ms for its last ten. The rows' p50 step scatters less (A/A
1.0007 ± 0.0085 on one Spark) but still too much. I have not found the cause. The model is 83.3 GB resident on the
128 GB of unified memory, and
MemAvailablefell to 39.7 GB during the sitting. Separately, everybin:row thereis tagged cold (10 of 10 on each machine) and no ours row is. For a
bin:arm the runner counts major faults overthe whole process, the load included (its
[config] cold tagline), and for ours from theprompt_idsline, so thetag cannot say whether a
bin:row's measured window faulted. When abin:arm runsgenerate_qwen3moe, it printsthe same
prompt_idsline, so its window could be cut the same way.gate_qwen35moe_moeneeds ik's sets for every case. The gate opens its three reference sets at startup(
crates/gpu-gates/src/bin/gate_qwen35moe_moe.rs:2796), so without them it stops before any case withref_manifest: cannot read <data>/ref_qwen35moe/MANIFEST.tsv: No such file or directory. That includesshape,wide512andpicks, which read none of them and are the cases that pin this change's bits. The publishedbloomery-refsetsdataset has no qwen35moe set. If the sets opened only for the cases that read them, a contributorcould run those three anywhere.
Hardware
DGX Spark, three machines of the same build: NVIDIA GB10 (compute capability 12.1), driver 595.84, CPU Cortex-X925 and
Cortex-A725 (20 cores), 128 GB unified memory, Ubuntu 24.04.5 LTS, kernel 6.17.0-1032-nvidia. The dev container has
CUDA 13.3.1, LLVM 21.1.8 and the pinned nightly. The kernels are
sm_86PTX through the driver's JIT(
docs/contrib/dgx-spark.mdsection 5, answer 7). Clocks are stock: maximum SM clock 3003 MHz, 2411 to 2502 MHz readaround the Qwen3.6 arms, clock-event mask 0. The Qwen3.6 sitting ran on one machine, the nsys runs and
gate_qwen35moe_moeon a second, and the gate list pair on a third.Docs
I did not change the docs. The spots this moves, in
docs/research/sparkdec.md:route_warp_gatedatrouter.rs:565; it starts at:583with this change.used= 8 rounds of a branchy scan over the lane's 8 entries". At 8 entries the scan was alreadypredicated in the SASS, and with this change it is four select chains.
agrees: 1.0010 ± 0.0033.
Qwen3.8 numbers. This pull request carries the four-chain form instead, and the owner-refill form's own lease reading
on Qwen3.6 is 0.9957 ± 0.0021.