Repository navigation
gpu-gates: link_probe, the protocol probe of dgx-spark.md 8.9 step 2 (N nodes from the command line, one stage) - #44
Conversation
|
Thanks — the 29.76..30.27 µs p50 with no stale line answers 8.9 and 8.10 nicely. This is a bigger review (two new files, the unsafe ratchet), so it comes after the 0.3.0 tag tonight; I will post the review here. |
|
Review done. This can land after a few changes. The CI red is ours, not yours: the lease self-test failure was fixed on main in df872d5. A rebase onto main should clear it. Asks:
Keeping verbs.rs in gpu-gates behind dlopen is fine for now. It can move to its own crate when a second user appears. |
c062a2f to
c5ae528
Compare
|
Thanks for the review. All seven are in
On the questions: 1 is answered by your note on |
|
Thanks, all seven are fine. On your questions:
When CI is green after that, I will run the gates on our box and merge. |
…(N nodes from the command line, one stage) The stage's kernel writes a 16 KB image of generation-stamped 64-byte lines into a cuMemHostAlloc page registered with ibv_reg_mr without relaxed ordering, its stream raises the flag behind a system-scope barrier, and a pump thread posts one RDMA write a peer. Each peer's stream waits on its own page (WAIT_VALUE_32 GEQ), runs one kernel that counts the stale image lines and writes 64 KB of rows, and its pump writes them back; the stage's stream wait passes. A node writes its send region again only after its pump reaped that generation's write completions: the pump raises a sent word on the page, and the batch that raises the node's flag ends with a wait on it. The stage reads the round trip from %globaltimer and prints p50, p90, p99, p99.9, min, max and the stale lines of both directions, and fails on a stale line. --flag imm sends write-with-immediate and lets the receiving pump raise the flag. Every node sends its --flag mode with its endpoint, and setup refuses a mismatch on both ends by name. Every wait is bounded by --deadline-ms: a stall prints each flag and the sent word as the host reads them. Any failure, the card thread's (a panic included) or the pump's error, stops the pump, raises every word the stream waits on past the last generation enqueued and drains the stream within one more deadline, or ends the process without teardown when the stream is not seen to drain. No lease runner runs the probe, so its numbers are contributor evidence, not table numbers. libibverbs is loaded at run time (dlopen through libc, already a gpu dependency), so the workspace takes no new crate and builds without rdma-core; shared/verbs.rs mirrors the ABI structs it touches, with each size and the offset of every field it sets or reads pinned by a const assert, and reads the inline post_send, post_recv and poll_cq entries from the context's ops table. The unsafe pin of gpu-gates rises with its PIN line and the count's derivation (verbs, CUDA calls, kernel accesses), tools/spawn-allow.txt names the probe's one thread, and tools/recipes.py leaves link_probe out of the kernel carriers by name (CARRIER_SKIP: the probe's kernel is its own and no gate links it), so no scan set builds it; its self-test fails on a kernel bin no gate links that the table does not name, and on an entry that names a linked bin or none.
c5ae528 to
5466033
Compare
|
Both are in
The body's stall example used that mismatch, so it now uses different The body also closes three open points from the first round. The heavier tail in series 1 lines up with the DGX Dashboard's hourly firmware query, and repeating that query by hand reproduces it. N > 2 was only checked as a code path, since this ring has no switch. And the all_gather line now gives the real reason it did not run. Q2: I will open the common-entry pull request once this one lands. |
|
Thanks, both look right. I will run the box gates after our two landings that are in flight, then merge. If CI goes red in check-recipes again, it is our own self-test flake. The fix is in the second landing. |
|
Merged as de57867. Thanks. Its diff is the same patch as your branch (patch-id checked on top of our train). |
What and why
Part of #13. This adds
link_probe, the protocol probe that section 8.9 ofdocs/contrib/dgx-spark.mdasks acontributor to run first: it carries the host tier's word protocol between nodes over RDMA, times one round trip a
generation and counts the lines that are stale after their flag. On two DGX Sparks with one direct cable the round
trip p50 is 29.76..30.27 µs with no stale line, so 8.9's rule keeps option (a), and a stream wait on a host page that
the NIC writes works on GB10 (the 8.10 question); it adds no engine code and changes none.
How the probe works
One process a node; rank 0 is the stage, ranks 1.. are peers. Each node registers one
cuMemHostAllocpage(
PORTABLE | DEVICEMAP) withibv_reg_mrfor local and remote write, without relaxed ordering. The page holds the16 KB image (256 lines of 64 bytes), 64 KB of rows (1024 lines) for each peer, a flag line after each region, and a
last line for the node's sent word.
In generation g the stage's kernel writes the image as g; its stream raises the image flag to g behind a system-scope
barrier and waits (
CU_STREAM_MEM_OP_WAIT_VALUE_32, GEQ, throughcuStreamBatchMemOp_v2) for every rows flag to reachg. A pump thread on each node posts the RDMA writes, since the card cannot. A peer's stream waits for its image flag,
runs one kernel that counts the image lines not reading g and writes its rows as g, and raises its rows flag the same
way; its pump writes the rows back, and the stage's next kernel counts the stale rows lines. The pump raises the sent
word to g once it has reaped every write completion of generation g, and the batch that raises a node's own flag to g
ends with a wait for the sent word to reach g, so the next kernel writes the region only after the NIC is done with
it.
--flag write(default) sends a region and its flag line in one write, flag last;--flag immsends the regionas a write with immediate, and the receiving pump raises the flag from the completion. Each node sends its
--flagmode with its endpoint (the record's four spare bytes), and both ends refuse a mismatch by name before the first
generation.
The round trip of generation g runs from the end of the stage kernel that wrote image g to the start of the kernel the
rows wait released, read from
%globaltimer. The stage prints onelinkline (percentiles, min, max and mean over--itersafter--warmup, both stale counts over every generation, each side's kernel p50) and fails on a stale line.The card thread keeps at most 32 generations queued. With no progress for
--deadline-msit prints every flag wordand the sent word as the host reads them, which tells a wait that never passes from a write that never landed. Any
failure, the card thread's (a panic in its run included) or the pump's error, ends the same way: the pump stops, every word the stream waits on is raised
to the generation after the last one enqueued (the wait is cyclic, so
u32::MAXwould hold it, ascrates/gpu/src/host/lane.rs'srelease_waitsdocuments), and the stream drains within one more deadline; if it isnot seen to drain, the process exits without teardown, since the device buffers' drops would wait on it.
--itersplus--warmupabove 2^31 - 2 is refused, where that release would stop comparing as later than every wait.
libibverbsis loaded at run time (dlopenthroughlibc, already a dependency of thegpufeature), so theworkspace takes no new crate and the build needs no rdma-core.
crates/gpu-gates/src/bin/shared/verbs.rsmirrors thestructs the probe touches, with
constasserts on each size and on the offset of every field the probe sets or reads,which I checked against rdma-core 50.0's installed headers with a C program printing
sizeofandoffsetof.ibv_post_send,ibv_post_recvandibv_poll_cqare inline in the header, so the probe takes them from thecontext's ops table as the header does. Queue pairs are RC over RoCE v2 at the GID index given. The device is opened
by name: a negative count from
ibv_get_device_listand a name that is not listed are named errors (the second liststhe devices there are), and the first device with the name is the one opened. A write's kind carries its immediate
(
WriteKind::{Plain, Imm(u32)}), so no write with immediate goes out without one.tools/unsafe-ratchet.txtraises thegpu-gatespin from 61 to 120 blocks and from 5 to 26 fns with its PIN lineand a second one that derives the count on main's 61 5 1: 46 blocks for the verbs, 9 for CUDA calls and 4 for kernel
accesses; 19
unsafe extern "C" fnpointer types and two unsafe fns, the symbol lookup and the memory registration.tools/spawn-allow.txtnames the probe's one thread.tools/recipes.pyleaveslink_probeout ofthe kernel carriers by name (
CARRIER_SKIP, next toSCAN_PACKAGE): its kernel is its own and no gate links it, soscan-setdoes not list it andjust narrowdoes not build it.Code shape
Page(link_probe.rs:958) does whatMappedHost(crates/gpu/src/graph.rs:419)does, and its
op_zero,op_wait_geq,op_write,op_barrier_sysandmem_batch(link_probe.rs:1022-1083) aregraph.rs:555-632with the probe's error type: a second copy under R14. Opening them is the gpu crate owner'scall (both are
pub(crate), andMappedHost'sSyncargument covers the host tier's access pattern, not a pagethe NIC writes and a pump polls), so I left the engine crate alone here; the common entry follows in its own
pull request (question 2).
every completion. Every wait is bounded, and a stall fails with the flag words. Teardown cannot return an error:
Page's drop records a failed free on its context, and a failed verbs teardown call prints one line on stderr.PIN(2026-10-11):line. The narrowself-test keeps main's cases. The scan-set self-test gains two checks: every kernel bin of
gpu-gatesthat nogate links is named in
CARRIER_SKIP, and every name there is such a bin, with a reason.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line): found and copied, not removed:crates/gpu/src/graph.rs:419(MappedHost)and
crates/gpu/src/graph.rs:555-632(the batch memop builders andmem_batch), as above.Questions
libibverbsdependency (8.9, maintainers' item 5). Answered in review:verbs.rsstays ingpu-gatesbehind
dlopenuntil a second user appears.MappedHostand the memop builders (R14). Answered in review: a common entry inbloomery_gpu,in its own pull request right after this one lands.
link_probestays ingpu-gatesand is leftout of the narrow carriers by a named line in
recipes.py(above).What I ran
The commit is
54660338on upstream maine8e32a38. The Mac checks below ran on it. The tables are from this pullrequest's first posted build,
c062a2f8onaa6df234, with one local build setting (Hardware), the same sha256 onboth nodes. The review changes since then were checked on
54660338with shorter runs on the same pair (The finalcommit, below).
On a Mac:
Each
mac-staticline is cut after its time; lint and combos reused the ledger of an earlier run on the same tree.The lint step counts 41 warnings, the ratchet's 41.
just affectedselects 0 of 147 gate recipes and 0 of 7 weekly recipes for the 6 changed files and lists the two new files as read by
bin link_probe, which no gate builds.scan-setlists three bins (bloomery-serve-ds41,gate_kquant,gate_swap), as on main. With theCARRIER_SKIPentry taken out, the self-test fails withscan-set: bin link_probe has kernels and no gate links it, and CARRIER_SKIP does not name it; naminggate_swapthere, or a bin that doesnot exist, fails it as well.
On two DGX Sparks (hardware below). Before the timed runs I wrote prediction cards in
tools/ref/card.pyformat(
card.py check: ok, kind profile): λ_probe p50 in 29.5..32.5 µs and 0 stale lines. The λ band is the previous build'sp50 on this pair (29.82..29.98 µs) plus 0..2 µs for the sent-word wait, one satisfied memop a node
[derived]; 8.9'sown band is 18..40 µs.
Step 1, fabric. One RoCE device a node, one direct cable, GID index 3 (RoCE v2), MTU 4096, both directions, with
ib_write_bw -d <dev> -x 3 -F -s 65536 -n 500000 -q 1 --report_gbitsandib_write_lat -d <dev> -x 3 -F -s <size> -n 100000:ib_write_bw64 KB, Gb/s (3 runs)ib_write_lat16 KB, t_typical µs (2 runs)ib_write_lat64 KB, t_typical µs (2 runs)ib_write_bwran withPCIe relax order: ON, its default here, andib_write_latwithOFF, so the bandwidth row isnot protocol-mode bandwidth (8.6, item 4). The 99th percentiles were 4.96..5.01 µs at 16 KB and 9.42..9.76 µs at 64 KB.
all_gather_perfran on the same pair per the playbook: nccl-tests 2.19.7 built with MPI, NCCL 2.30.7 built fromsource, OpenMPI 4.1.6 in a user prefix, NCCL pinned to the cabled device on each node with GID index 3,
-b 8 -e 8G -f 2 -g 1three times and-b 16G -e 16G -f 2 -g 1once. At 8 GiB the busbw was 13.78..13.82 GB/s out of place and13.91..13.92 GB/s in place, and 13.88 GB/s at 16 GiB, with no wrong results. NCCL reported NET/IB over RoCE with relaxed
ordering and GDR 0, so the transfer is staged through host memory. 13.8 GB/s is 110.5 Gb/s, within 1 % of this cable's
ib_write_bwabove and about 0.1 GB/s over 8.9's 11.6..13.7 GB/s, whose top is 109.28 Gb/s divided by 8.Step 2, the probe. Run on each host with
LC_ALL=C,--gid 3, 100000 timed generations after 1000 warmup, eachrole assignment and both flag modes; the first run of each series adds
--deadline-ms 300000for the module's firstload. Two series of six runs, back to back:
One line, as the stage prints it:
Stale lines count every generation, warmup included: per run 25.9 M image lines and 103.4 M rows lines. Three write
runs of series 1 had a heavier tail (p99 45..66 µs), against 32.2..32.8 µs everywhere else. They overlapped the hourly update check of the DGX Dashboard, which runs
mstflint -d 0000:01:00.0 q(a read-onlyConnectX firmware query) every 1 to 3 s for about 40 s on each Spark. Repeating that query by hand during a run raised
p99 from 32.1..32.6 µs to 42.4..42.9 µs, from either node, with p50 unchanged and no stale line; a container start
right before a series and the check's CPU-bound apt steps left the tail at 32.2..32.5 µs.
The build before the sent word, six runs with the same flags on the same pair, had p50 29.82..29.98 µs and p99
32.1..40.2 µs, so the sent wait moves p50 by under 0.3 µs.
Before and after every run on both nodes: no Xid in the kernel log, no container and no GPU compute process; the SM
clock read 208 MHz idle and 2411..2502 MHz after runs (maximum 3003).
Against 8.9's rule: λ_probe p50 is 29.76..30.27 µs, at most 40 µs, so (a) holds as predicted, and by 8.9's arithmetic
the engine's λ is 37..60 µs
[derived]. Stale lines are 0, so write mode stands; the imm runs only exercise that codepath. On 8.10's question, the stream wait on a
cuMemHostAllocpage that the NIC writes works on GB10,issued as
CU_STREAM_MEM_OP_WAIT_VALUE_32throughcuStreamBatchMemOp_v2, the batch form ofcuStreamWaitValue32.The stale check has a floor: a receiving kernel starts only after its wait passed and its launch ran, so a data line
landing later than the flag by less than that gap reads as current. To see that it counts at all, I ran it once
against a local change, not committed, that skips line 0 of what the kernel writes at generation 500 on both nodes,
with the expectation written down first (one stale line each way, the stage failing):
The stage exited with rc 1 and the peer with rc 0.
The stall path. Two nodes with different
--itersgive a stall without any other fault: the side with moregenerations waits for one the other side never sends.
--flag write --deadline-ms 5000, on the final commit:The stalled side exits with rc 1 within a second after its deadline (the peer 5.6 s after its start; the stage 7.9 s,
having started 2 s earlier). In the first case the stage then fails on the closed connection with rc 1; in the second
the peer finishes its 2000 generations and exits with rc 0. No probe process is left. A pump failing first did not
come up on hardware.
The final commit.
54660338built as in Hardware, the same sha256 on both nodes, stage on A, 20000 timedgenerations after 1000 warmup. These are behavior checks, not measurements (no card):
A flag-mode mismatch is refused at setup on both ends, either way round, with rc 1, before any setup line (the peer
in 0.5 s, the stage 2.7 s after its earlier start):
The mode travels as 1 (write) or 2 (imm) in the endpoint record's last four bytes; any other word, 0 included, is
rank N sent flag mode M. With three or more nodes, the stage stops at the first peer whose mode differs, so a peerwhose mode matches ends on the closed connection instead.
--dev nosuchdevfails at setup withlink_probe: no RDMA device nosuchdev; devices: rocep1s0f0, rocep1s0f1, roceP2p1s0f0, roceP2p1s0f1.Scope: the final build ran on one pair, the twelve runs above plus the stall and stale checks. Over the 34 completed
timed runs of five builds on that pair, and 4 runs of an earlier build on a second pair, no wait stalled and no line
was stale. With two nodes each stream waits twice a generation, once on the other side's flag and once on its sent word.
N > 2 ran only as a code path check: three or four nodes cannot reach one stage port on a switchless ring, since
the probe opens one device a node and each port cables to one neighbour. With the stage on one node and two or three
peer processes on the other, over the same cable,
--nodes 3and4passed in both flag modes with no stale line;their round trip (p50 192 and 277 µs) is the peers sharing one GPU, not λ_fanout. 8.9's next step, the single-node
sustained BW term, is not run here. I could not run the gates;
just affectedselects none, and the gate batch is yours.What I ran into
and λ_probe p50 43.5..44.7 µs. Word by word across the block both ways gave 9.3..9.5 µs and a p50 of 40.8..41.5 µs
on this pair (33.2..33.6 µs in three runs and 41.5 µs in one on a second pair). The committed kernel reads whole
lines a thread (16 independent loads) and writes word by word: 2.3..2.5 µs. For the engine's copy nodes on GB10 this
suggests that reads of a mapped host page are latency bound unless a thread keeps several loads in flight
[derived from these runs; not measured on its own].ibv_post_recvfailed withEINVAL(rc 22)when the receives went in right after the queue pairs were created. They are now posted once the queue pair reaches
RTS, before the start signal.
[unverified]on a stream wait on a NIC-written page andits "a latency for a direct link" now have a reading here.
Hardware (if the change is for a machine)
Two DGX Sparks, one direct cable between one ConnectX-7 port on each, one rail. On both:
nvidia-smi --query-gpu=name,driver_versionprintsNVIDIA GB10, 595.84; CPU 20 cores (10 Cortex-X925 and 10 Cortex-A725);MemTotal127535276 kB and 127535272 kB; Ubuntu 24.04.5 LTS, kernel 6.17.0-1032-nvidia; ConnectX-7 firmware28.45.4028; Ubuntu's rdma-core and libibverbs 50.0-2ubuntu0.2 and perftest 24.01.0+0.38-1build2. RoCE v2, MTU 4096.
The probe was built in the project's dev container (CUDA 13.3.1) with
cargo oxide build --arch sm_86 -- -p bloomery-gpu-gates --features gpu --release --bin link_probe(the PTX JIT compiles on GB10) and run on the host. For thetables' build (
c062a2f8, before main's per-triple table) the tree's.cargo/cuda-oxide.tomlhadtarget-cpu=nativein place of
znver3, which crashes rustc on aarch64; that was its only local change.54660338was built with nolocal change, with
cargo-oxideinstalled from the pinned rev87bc9518, which takes theaarch64-unknown-linux-gnutable (
target-cpu=native), andCUDA_OXIDE_BACKENDpointing at a backend built from the same pin.