Archived
libr4d: check that a peer's push has landed before reducing it (2-rank family)
A two-rank all-reduce or gather pushes its bytes into the peer's slot over PCIe P2P, drains its stores and then publishes a release flag; the peer reads the slot once it sees the flag. On 2x R9700 the bytes do not always land before the flag. With reads streaming beside the all-reduce (prefetch), a greedy reply differed from one server start to the next. A probe in ar_rmsnorm_quant_fp8 compared, right after the handshake, a plain load of the slot with a system-scope load and with the same word 100 us later: in about 1 launch in 1000 the reader saw the slot's previous contents, and the new bytes arrived about 1 us later, sometimes more. Pushed bytes wait in the writer's L2 until a system-scope release writes them back: with the flag sent before the push (a test mode) and nothing after it, they stayed invisible for the whole kernel (49 ms). The flag's release does write them back, but the writeback and the flag store reach the peer by different paths, so the flag can arrive first. A stronger drain on the writer (drain=1), PCIe relaxed ordering off on both cards and an HDP flush on the reader did not change that; acq=1 hides it only by delaying the reads (and costs 12-33 % of decode). The writer now sums a per-dword hash (MurmurHash3's finalizer over value and index) over what it pushes and stores the block's sum, salted with its handshake value, into the peer's check word for (slot, block): two parity slots of fine-grained words after the flags. The flag's release that follows writes the pushed bytes back. The reader reads the check word, sums the same over the bytes it is about to read and, until the two agree, takes an acquire fence, sleeps briefly and reads again; a push that never lands traps after 2 s. A stale element and a stale check word both disagree, so the order in which the two land does not matter. No value changes. Kernels: ar_rmsnorm_quant_fp8 (exact and 6-bit wire), r4d_ar_oneshot_2rank_exact, r4d_ar_hc_write, r4d_ar_gather_hc_write, r4d_ar_gather_2rank, r4d_ar_oneshot_2rank_wht6, r4d_ar_hc_write_wht6, ar_rmsnorm_quant_i8, r4d_ar_ln_had_quant_i8. Also: the link gate is released after the check, the exact and gather launchers round their width to whole waves (the check's wave sum reads all 32 lanes), and ln_had's dynamic LDS ceiling leaves room for the check's static words. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
2721f7c951
commit
0044d8d201
9 files changed
+317
-24
No files matched your search
@@ -343,10 +343,10 @@ int build(ArInst* in, int rank, int world, long long max_numel, int dtype_code,
|
||||
if (hipGetDevice(&dev) != hipSuccess) return RAD_E_DEVICE;
|
||||
if (host) {
|
||||
sc = r4d_ar_host_alloc((long)nslots * in->slot_bytes);
|
||||
fl = r4d_ar_host_alloc(flag_words * 4);
|
||||
fl = r4d_ar_host_alloc((flag_words + 2L * maxb) * 4);
|
||||
} else {
|
||||
sc = r4d_ar_ipc_alloc((long)nslots * in->slot_bytes, 1, handle, &hlen);
|
||||
fl = r4d_ar_ipc_alloc(flag_words * 4, 1, handle, &hlen);
|
||||
fl = r4d_ar_ipc_alloc((flag_words + 2L * maxb) * 4, 1, handle, &hlen);
|
||||
}
|
||||
sq = r4d_ar_ipc_alloc(kSeqWords(maxb) * 4, 0, handle, &hlen));
|
||||
|
||||
|
||||
Reference in new issue
Block a user