Repository navigation
gpu, gpu-gates: the link's all-gather of f32 row spans among N ranks, and link_probe --gather - #501
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: the new test bypasses capture synchronization, and a permitted output alias corrupts the gather sum.
Must fix
1. Create the test's first stream through capsync
crates/gpu/src/tensor.rs:842 The normal gate-gpu-lib pass (justfile:1756) runs this test alongside graph-capture tests, including graph.rs:1481. Between fresh_context returning and new_stream, another thread can start a capture. The first stream then runs an unguarded context-wide synchronize and invalidates that capture, as documented in capsync.rs:124–130. capsync::fresh_stream holds the exclusive lock across both operations.
This is a one-call fix before the hardware gate gains an intermittent failure. Replace the two initialization lines with:
let (ctx, stream) = crate::capsync::fresh_stream(0).expect("CUDA device 0 with a stream");2. Reject output windows that overlap gather storage
crates/gpu/src/host/link/gather.rs:337 The safety contract at lines 303–306 requires a live mapped page but permits y to overlap its parts. With three ranks, one value per part [1, 4, 8], and all accesses ordered on the same stream, a WindowMut::from_raw output over part 2 satisfies the contracts. The first add overwrites 8 with 5; the next add reads that overwritten part and returns 10 instead of 13.
Reject overlap in this owner to prevent silent wrong sums. After let n = rows * s.shape.width;, insert:
let out = y.cu_deviceptr();
let out_end = out + (n * 4) as u64;
let first = dev + self.slots[0].parts as u64;
let end = dev + self.page_bytes() as u64;
if out < end && first < out_end {
return Err(GpuError::shape(
"Gathers::enqueue_sum",
"output overlaps gather parts, counters or link tail",
));
}This preserves output in the page's reserved prefix. Extend the existing device test to assert that an output window over a part is refused.
Checked
Duplicates: diagnostics report 0 dryer pairs in gpu; gpu-gates was excluded.
Complexity: diagnostics report gather_run new at 47 and opts rising 31→35.
Silent failure: enqueue_sum rejects empty/excess rows and short outputs, but accepts the overlapping output above.
Tests: the device sum test uses separate output buffers and misses overlap. The window test asserts context-handle release; its stream creation bypasses capture synchronization.
Gates: unsafe ratchet increases have dated PIN reasons. The PR body reports FAIL-first results for layout overflow, one-set reuse and window release.
Escape catalog: no shell-script changes match C1–C4.
Notes
CUDA tests were not rerun. The reported hardware runs use one test thread, which excludes finding 1's interleaving.
Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/link_probe.rs, crates/gpu-gates/src/record.rs, crates/gpu/src/host/link.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)
| let ctx = crate::capsync::fresh_context(0).expect("CUDA device 0"); | ||
| let stream = ctx.new_stream().expect("a stream"); |
There was a problem hiding this comment.
Create the fresh handle and its first stream under capsync's exclusive lock so this test cannot invalidate another thread's capture.
| let ctx = crate::capsync::fresh_context(0).expect("CUDA device 0"); | |
| let stream = ctx.new_stream().expect("a stream"); | |
| let (ctx, stream) = crate::capsync::fresh_stream(0).expect("CUDA device 0 with a stream"); |
…pages Gathers lays out every rank's page alike: past the page's own bytes, each gather slot holds two span sets of one part per rank and one counter per set and rank, then the link's tail with a block of lines for every pair of ranks. A part crosses each pair's link as a done of the tier protocol does, through the existing ends and pump: the writer posts its part with one more generation, the reader's end adds one to the part's counter on its page, and the card's captured wait takes it back. post and wait give the stream memory operations of a gather and enqueue_sum adds every rank's part in rank order, so every rank holds the same bits. Its windows over the page come from WindowMut::from_raw, which drops their context handle with them. Between two uses of one set the ranks run another gather, so stream order alone keeps a part until every rank has added it. No slot leaves the page and the tier link as they were; nothing else opens a gather yet. Tests at 2, 3 and 4 ranks: host cards over the loopback add the host's rank-order sum, a late rank still adds its own gather's parts while the next gather lands, every rank lays out the same page, and on a card captured chains of four gathers replayed 200 times sum bit-equal to the host.
… nodes Each node holds an end to every other node; the stage passes the peers' endpoints between them, and the ready barrier now waits for every peer before any starts. One replay is a captured chain of 45 layers' two gathers of ROWS rows of 4096 f32 and the head's gather of two words a row. Each node counts stale words in the parts it waited for, checks its last replay's sums against the host's rank-order sum and prints lambda_g per gather and summed over a chain as a link_gather record; the stage fails on a stale word, a host disagreement or a digest of the sums that differs between nodes. The stall report, the bounded wait and the release on failure move to one Node both modes use, and both modes enqueue at most AHEAD steps ahead of the host through one replays loop.
a6de7dc to
6476ccd
Compare
There was a problem hiding this comment.
Since the last review:
- Fixed 1: tensor.rs:842 creates the context and first stream under the capture lock.
- Fixed 2: gather.rs:334 rejects output overlapping any slot, counter or tail before launching.
Verdict: CLEAN: Both previous must-fix items are fixed, and the interdiff adds no blocking defect.
Checked
Duplicates: 0 new definitions in the interdiff; dryer reports 0 candidate pairs in gpu.
Complexity: crapper flags new orchestration gather_run at 47 and option branches in opts at 31→35; both are unchanged in this interdiff.
Silent failure: 1 added rejection followed; overlapping output returns a named shape error before any launch.
Tests: removing the guard at gather.rs:334 makes the assertion at gather.rs:625 fail. Replacing the raw window with the old constructor fails the context-count assertion at tensor.rs:850. The PR supplies FAIL-first output for both.
Gates: the unsafe ratchet increase covers two added test blocks with a dated PIN and reason; no tolerance changed.
Bounds: output ending at the first part stays allowed; partial overlap, later slots and the tail are rejected. Constructor checks bound the byte products.
Escape catalog: no changes match C1–C4.
Notes
CUDA tests were not rerun during this review. Dryer excluded gpu-gates; that crate is unchanged in the interdiff.
Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/link_probe.rs, crates/gpu-gates/src/record.rs, crates/gpu/src/host/link.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. |
TP=2를 위해 두 개의 노드가 층마다 계산 결과를 서로 주고받는 통신(all-gather)을 기존 RDMA 링크 위에 더하는 작업입니다.
What and why
Part of #494, the "The exchange of partial rows between the two nodes over the existing link" item.
Under TP=2, each GLM-5.3-Flash layer ends its attention and its feed-forward block with a partial row on each node, and both nodes need the same sum before the next layer starts. This PR adds that exchange to the existing link as an all-gather among N ranks. Each rank's card writes its part into its own page, the link's ends carry the part to every other rank's page, and each card waits for the other parts and adds all of them in rank order. Every rank adds the same values in the same order, so every rank holds the same bits. Nothing in the engine opens a gather yet; the TP=2 placement and decode are later items of #458.
What the PR adds:
bloomery_gpu::host::Gathers(crates/gpu/src/host/link/gather.rs) lays out the gather slots alike on every rank's page. A slot holds two span sets, each with one part per rank, and one counter per set and rank. The link's tail follows, with a block of lines for every pair of ranks. Each pair of ranks is one link of the existingRdmaEndand pump, and a part crosses it the way a tier's done does.Gathers::postandGathers::waitreturn a gather's stream memory operations. A post is a system-scope barrier and one more generation on the rank's own counter. A wait is, on each other rank's counter, a wait for at least one and the take back of one. A captured CUDA graph therefore waits on one fixed target on every replay.Gathers::enqueue_sumadds the parts in rank order through the existingElemKernels::enqueue_add. Its windows over the page come fromWindowMut::from_raw(crates/gpu/src/tensor.rs), a non-owning window over caller-owned memory that releases its context handle when it drops, asWindow's drop already does.link_probe --gather ROWSruns the gather on N nodes. Each node holds an end to every other node, and the stage passes the peers' endpoints between them. One replay is a captured chain of a token's 91 gathers: two a layer for 45 layers, eachROWSrows of 4096 f32, then the output head's gather of two words a row. Each node counts the stale words in the parts it waited for, checks its last replay's sums against the host's rank-order sum, and prints the gather latency lambda_g, per gather and summed over a chain, as alink_gatherrecord thatlink_probe --records-schemalists. lambda_g runs from a stamp after the rank's part is written to a stamp once its wait has released, one kernel launch included. The stage fails on a stale word, a sum the host disagrees with, or a digest of the sums (Fnv1a64over the per-value digests) that differs between nodes. The round-trip and--sizeruns keep their star layout, and setup refuses--gathertogether with--size.Existing paths: a page with no gather slot has the layout
link_tailgives on main, and no tier page, crossing or message changes. Inlink/pump.rsonly the test module and itsMemtest page become visible to the gather's tests,link.rsgains only thegathermodule and its re-export, andtensor.rsgains onlyWindowMut::from_rawand its test.Release notes: Under the hood: the link carries an all-gather of f32 row spans among N ranks that a captured CUDA graph waits on, and
link_probe --gatherruns a token's 91 gathers across N nodes.Code shape
The review reads these first. A box left unticked needs one line of why.
RdmaEnd, pump andlink_tail, the graph'sop_wait_geq,op_addandop_barrier_sys, andElemKernels::enqueue_addfor the sum. It adds no kernel tobloomery-gpu; the only new kernels arelink_probe's own test kernels.Gathers::newrefuses fewer than two ranks, a rank past them, an empty slot and a slot or rank count whose page passesusizeby name, checking every product before it can wrap, andGathers::enqueue_sumrefuses more rows than the slot holds, a short output or an output over the page's parts, counters or tail by name.tools/unsafe-ratchet.txtmoves thegpuandgpu-gatescounts up for the new blocks only, each count with itsPIN(2026-10-19):line, and every newunsafeblock has its SAFETY line.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none": inlink_probe, both modes now open their ends through oneopen_ends(crates/gpu-gates/src/bin/link_probe.rs:592), share oneNodefor the stall report, the bounded wait and the release on failure (crates/gpu-gates/src/bin/link_probe.rs:719), and enqueue through one boundedreplaysloop (crates/gpu-gates/src/bin/link_probe.rs:1320). The digest reusesFnv1a64, the line goes throughrecord.rs, and the gather's loopback tests reusepump'sMemtest page.What I ran
Head
960eb44c6059aec7c250497bdf31b6c7e6443881, baseb36f8e916360005ce070b35e6e2308fef83fc18d. The RTX 5090 machine (NVIDIA GeForce RTX 5090, 595.99.02, 12.0) ran the gather, link and window tests ata6de7dcb; the head adds the output overlap check and makes the window test's stream throughcapsync::fresh_stream, and a DGX Spark ran the changed tests at it. The DGX Spark runs (NVIDIA GB10, 595.84, 12.1) were made at earlier commits named in each line: since then the gather's wire layout, posts and waits are unchanged, and the head adds the overflow checks, the window release, the shared submission loop and the record. Thelink_probedigests quoted below come from those commits, before the digest moved toFnv1a64, so this head prints other digest values for the same sums.The reference for every sum is the host's rank-order sum of the same parts, compared bit for bit:
test host::link::gather::tests::every_rank_adds_every_part_in_rank_order ... ok46cee04f), 2, 3 and 4 ranks, a captured chain of four gathers replayed 200 timestest host::link::gather::tests::hw_held_every_rank_adds_the_parts_in_rank_order_on_the_card ... oklink_probe --gather 4, two ranks on one DGX Spark, 200 replays (at88c48909)stale_words=0 host_wrong=0 digest=0xcbfe869afdd52ac0link_probe --gather 1, two DGX Spark nodes on a direct 200 Gb/s link, 10,000 replays (at88c48909)stale_words=0 host_wrong=0 digest=0x0ffeadeb885668c8link_probe --gather 4, two DGX Spark nodes on a direct 200 Gb/s link, 10,000 replays (at88c48909)stale_words=0 host_wrong=0 digest=0xf7ba6934cf33e11elink_probe --gather 512, two DGX Spark nodes on a direct 200 Gb/s link, 10,000 replays (at88c48909)stale_words=0 host_wrong=0 digest=0x9b447b0f6b87afc6Difference from the reference: in every
link_proberun above, every rank has 0 stale words and 0 host disagreements, and the ranks' digests are equal.RUST_TEST_THREADS=1 bash tools/gate.sh --oxide -p bloomery-gpu --release --lib -- --include-ignored host::link::ran the gather and link tests, the card test among them:test result: ok. 18 passed; 0 failed; 0 ignored; 0 measured; 278 filtered out.test tensor::tests::hw_a_raw_window_releases_its_context_handle ... ok, and thelink_probebuild after them endedrc tests=0 probe=0.NVIDIA GB10),bash tools/gate.sh --oxide -p bloomery-gpu --release --lib -- --include-ignored --test-threads 1 hw_held_every_rank_adds_the_parts hw_a_raw_window_releases every_rank_lays_outat the head's tree:test result: ok. 3 passed; 0 failed. Output overlap, with the test's assertion andenqueue_sumunchanged:2 ranks: a sum into a part is refused, thentest result: FAILED. 1 passed; 1 failed.Gathers::new's products unchecked as before the fix (at46e30f60, whose constructor is the head's):pages past usize taken, (bytes, ranks): [(0, 9223372036854775808), (0, 4294967297), (64, 9223372036854775808), (64, 4294967297)], thentest result: FAILED. 0 passed; 1 failed. With the checks, the layout test passes in the 18 above.windowas before the fix:assertionleft == rightfailed: the window's context handle releasedwithleft: 4andright: 3. WithWindowMut::from_rawthe test passes, as above.Gathers::SETSset to 1 (pub const SETS: usize = 1;), on an RTX 5090 machine at3c7051dd:2 ranks, the last one late: wrong values per rank [Ok(0), Ok(4536)], thentest result: FAILED. 0 passed; 1 failed. With the PR's two sets,test host::link::gather::tests::a_late_rank_adds_the_parts_of_its_own_gather ... ok.BLOOMERY_ARCH=sm_121(at46cee04f),RUST_TEST_THREADS=1 bash tools/gate.sh --oxide -p bloomery-gpu --release --lib -- --include-ignored link::gatherran the four gather tests (both loopback tests, the page layout test and the card test):test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 290 filtered out. The layout test also checks that a page with no slot islink_tail(bytes, 0). Thelink_probebuild forsm_121after it endedrc gather=0 probe=0.link_probeat88c48909, both ranks as two processes on one DGX Spark over one RDMA port (commands below). The--size 4096 --iters 2000 --warmup 100run printedPASS: link_probe stale lines after the counter 0, and the--gather 4 --iters 200 --warmup 10run printedPASS: link_probe gather stale words and host disagreements 0, digests equal on every node true, withrc0=0 rc1=0for each. The two ranks shared one card, so this run's times are not quoted.88c48909,link_probe --gather ROWS --iters 10000 --warmup 100at 1, 4 and 512 rows. Rank 0 printedPASS: link_probe gather stale words and host disagreements 0, digests equal on every node trueafter each run, and both ranks endedrc=0. Each node's line carries its stale words, its host check, its digest and lambda_g at p50 and p99:link gather rank=0 nodes=2 rows=1 gathers=91 iters=10000 lambda_us_p50=16.45 lambda_us_p90=18.11 lambda_us_p99=28.51 lambda_us_max=269.79 chain_us_p50=1489.57 chain_us_p90=1501.47 chain_us_p99=1548.29 stale_words=0 host_wrong=0 digest=0x0ffeadeb885668c8andlink gather rank=1 nodes=2 rows=1 gathers=91 iters=10000 lambda_us_p50=16.58 lambda_us_p90=18.21 lambda_us_p99=28.61 lambda_us_max=265.50 chain_us_p50=1498.37 chain_us_p90=1510.43 chain_us_p99=1555.90 stale_words=0 host_wrong=0 digest=0x0ffeadeb885668c8link gather rank=0 nodes=2 rows=4 gathers=91 iters=10000 lambda_us_p50=17.54 lambda_us_p90=17.86 lambda_us_p99=28.22 lambda_us_max=275.42 chain_us_p50=1562.30 chain_us_p90=1606.66 chain_us_p99=1720.67 stale_words=0 host_wrong=0 digest=0xf7ba6934cf33e11eandlink gather rank=1 nodes=2 rows=4 gathers=91 iters=10000 lambda_us_p50=17.79 lambda_us_p90=17.98 lambda_us_p99=28.35 lambda_us_max=273.82 chain_us_p50=1576.99 chain_us_p90=1621.86 chain_us_p99=1737.25 stale_words=0 host_wrong=0 digest=0xf7ba6934cf33e11elink gather rank=0 nodes=2 rows=512 gathers=91 iters=10000 lambda_us_p50=643.62 lambda_us_p90=644.83 lambda_us_p99=651.07 lambda_us_max=1151.68 chain_us_p50=57764.29 chain_us_p90=57827.90 chain_us_p99=58770.43 stale_words=0 host_wrong=0 digest=0x9b447b0f6b87afc6andlink gather rank=1 nodes=2 rows=512 gathers=91 iters=10000 lambda_us_p50=657.28 lambda_us_p90=669.06 lambda_us_p99=680.67 lambda_us_max=1123.65 chain_us_p50=59446.53 chain_us_p90=59537.86 chain_us_p99=60391.14 stale_words=0 host_wrong=0 digest=0x9b447b0f6b87afc6link_probe --size 4096 --iters 2000 --warmup 100printedPASS: link_probe stale lines after the counter 0, with a one way p50 of 6.78 µs (one_way_us_p50=6.78). The nodes ran no other job during these runs. The times come from the probe itself, with no separate timing run.gate_glm5next_nodes) for this PR. The PR does not change that path's code: the diff touches onlylink_probe.rs,record.rs,gather.rs,link.rs,host/mod.rs,tensor.rs, the test module's visibility inpump.rs,tools/spawn-allow.txtandtools/unsafe-ratchet.txt, and leavesgate_glm5next_nodes.rs,tier_server.rsandrdma.rsas they are on main.just contrib-check --tier t0on this head, on a Linux x86_64 machine:DONE tier=t0 total=94 red=0.The one-machine
link_proberun, on a DGX Spark with an RDMA portrocep1s0f0and GID index 3:On two nodes, rank 1 takes
--stage <rank 0's address>:<port>and rank 0 takes--listenon that address, each with its own--dev.What I ran into
None of this blocks the PR. Nothing outside the change came up in these runs.
Hardware (if the change is for a machine)
The change is for two or more DGX Sparks joined by their direct link. The GB10 runs were on a DGX Spark in the CUDA 13.3.1 container with
BLOOMERY_ARCH=sm_121. The late-reader and card tests also ran on an RTX 5090 machine.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.