libr4d: review fixes -- a tuned ar_ln_had_quant_i8 count under the ceiling; say which gathers it cannot cap

ar_ln_had_quant_i8 clamped a tuned block count to M only; it stays under R4D_AR_MAX_BLOCKS
now, as every other entry's. The MoE hyper-connection gathers keep the minimum their LDS table
needs, which may exceed the ceiling: the comment and GUIDE say so instead of "every
collective". r4d.h states that a refused IPC export leaves the handle zeroed, out_len 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mici81andClaude Opus 5.5 authored and StillDeadcode committed 2026-10-19 10:39:53 +02:00
1 parent 1d1cb21e02
commit d82c11644e
3 files changed
+7 -3

No files matched your search

+1 -1
View File
@@ -2651,7 +2651,7 @@ rad-kbench --home $RADIANCE_HOME --max-cases 1 # are the kernels correct?
| `ROCM_PATH` | where ROCm lives, if not `/opt/rocm` (build time) |
| `HF_TOKEN` | for `scripts/hfget.sh` and `--model <owner/name>` on a gated or private repo |
| `XDG_CACHE_HOME` | where `--model <owner/name>` fetches to without `--download-dir` (`$XDG_CACHE_HOME/radiance/hf`, else `~/.cache/radiance/hf`) |
| `R4D_AR_MAX_BLOCKS` | a ceiling on libr4d's collective block counts, for two tensor-parallel engines on one set of cards; set it in both (below). Unset, nothing changes |
| `R4D_AR_MAX_BLOCKS` | a ceiling on libr4d's collective block counts, for two tensor-parallel engines on one set of cards; set it in both (below). The MoE models' hyper-connection gathers keep the minimum their LDS table needs. Unset, nothing changes |
**Two engines on one set of cards.** Every block of a libr4d collective spins until its twin on the
peer card has pushed, and a prefill-sized fused all-reduce launches more blocks than a card holds at
+2 -1
View File
@@ -230,7 +230,8 @@ int r4d_gdn_recurrent_update_k128_v128_bf16_fp32state(
// zeroed words, a handshake and a slot-parity counter per block of capacity (r4d_ar_seq.h).
enum { R4D_AR_HANDLE_BYTES = 64 };
// IPC scratch helpers, startup-only: alloc returns the device pointer and writes the IPC handle
// (up to HANDLE_BYTES) into out_handle.
// (up to HANDLE_BYTES) into out_handle. A refused export (beside another engine on the same cards)
// leaves it zeroed with *out_len 0: libr4d's ranks are threads of one process and share the pointer.
long r4d_ar_ipc_alloc(long size, int finegrained, char* out_handle, int* out_len);
// Strided peer (or local) device-to-device copy through the copy engines; pitches and width in
// bytes, height in rows. Returns 0 or -100 - hipError_t.
+4 -1
View File
@@ -360,7 +360,9 @@ int build(ArInst* in, int rank, int world, long long max_numel, int dtype_code,
* R9700 holds. One engine survives that (both cards dispatch blocks in the same order, so the
* lowest unfinished block is resident on both); two engines do not: one engine's spinning blocks
* fill a card while their twins wait behind the other engine's kernel on the peer card, which
* waits for a slot on the full card. Two TP2 engines on two R9700s (Qwen3.8-27B and Gemma 3 27B)
* waits for a slot on the full card. Not capped: the hyper-connection gathers of the MoE paths
* (r4d_ar_gather_hc_write without its inverse scratch, r4d_ar_hc_write_wht6), whose LDS table
* needs a minimum block count, which may exceed the ceiling (dense models do not use them). Two TP2 engines on two R9700s (Qwen3.8-27B and Gemma 3 27B)
* hung within a minute of concurrent prefill; MES then failed to evict the queues and the
* failed reset froze the host. Capped in both engines so that their spinners together cannot
* fill a card, the cycle cannot close. The flag and counter arrays keep their full size (maxb);
@@ -1207,6 +1209,7 @@ extern "C" int r4d_rad_ar_ln_had_quant_i8(const RadArgs* a, RadStream s) {
* shim's count equal to the kernel's. */
int nblocks = cfgv.nblocks > 0 ? cfgv.nblocks : nb_for(M * K * 2 / 16, in->max_blocks);
if (nblocks > (int)M) nblocks = (int)M;
if (nblocks > in->max_blocks) nblocks = in->max_blocks; // a tuned count under R4D_AR_MAX_BLOCKS too
/* LDS floor on the block count. The compressed wire stages every row a block owns, so a count
* chosen for the push alone can exceed LDS (at K = 5120, more than two rows per block). Raise
* the count to the kernel's floor; refuse shapes no count within the flag capacity serves.