libr4d: RADIANCE_AR8_FORM -- the eight-rank two-shot's steps in ring order, or with a flag after each half instead of a handshake a step

The eight-rank two-shot reaches 56% of its link time at 16 MiB (1316 to 1340 us against 763), and
measured(K) = f x link time(K) + h x (K + 1) fits f of about 1.45 and h of about 20 us a step:
both the transfers and the step boundaries lose time. Two schedules of the same work go after
them, each a new form beside the existing one, chosen by RADIANCE_AR8_FORM (unset or lockstep:
as before) or per launch by the `form` parameter:

- ring: the first hop goes to the peers in ring order from rank + 1 instead of ascending. In the
  lockstep order every card but rank 0 starts by writing rank 0's shard, then rank 1's, so the
  seven senders can converge on one receiver while the other links idle; in ring order each card
  receives from one peer at a time.
- split: ring, and the one handshake a step, which waits until every peer has finished the
  whole step (next piece's first hop, this piece's reduce, the previous piece's assemble), becomes
  a flag after each half, awaited only before its data is read: before reducing piece j the
  peers' first hop of j, before assembling j their reduce of j. A card whose half is done goes on
  with the next piece's first hop while a slower card still reduces, so each link runs at its own
  pace instead of the slowest card's per step. The flags stay one monotone word per (block,
  source): the first hop of piece 0 at v0, of piece j + 1 at v0 + 2j + 1, the reduce of piece j
  at v0 + 2j + 2; the launch reserves pieces + 1 steps for its 2 pieces + 1 values, so it mixes
  with every other kernel on the instance. A launch still ends only after every peer has
  published its last reduce inside it, so the slot parity argument holds unchanged.
  r4d_ar_publish and r4d_ar_await (r4d_ar_wide.h) are the two halves of r4d_ar_handshake.

Neither changes which rank folds a word or in what order, so all forms give the bits of the
lockstep form, which compiles to the code it was. Ring and split are eight-rank only; the
three- and four-rank launches stay lockstep and refuse another form. Every rank must read the
same form; init compares it with the other eight-rank settings.

--perfar8 numel iters dtype forms (comma-separated) times the forms side by side; the timeline
prints a pair a synchronisation (K + 1 handshakes, or 2K awaits split, up to 8 pieces).
r4d_selftest's weighted eight-rank runs repeat for ring and split at 1, 4 and 8 pieces over even,
uneven, single-owner and zero-weight tables and with the piece count changing launch to launch,
and the box's own weights run auto, duplex and off. On one card (R4D_SELFTEST_ONE_CARD) all three
forms give the fold on every rank at 65536 to 8388608 elements, even and weighted, bf16 and fp32.
Which form is fastest on the board is for the TP8 window to measure.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
NunzeandClaude Fable 5.1 authored and StillDeadcode committed 2026-10-22 11:54:56 +02:00
1 parent 5b9bc13e5f
commit c25bca83d5
7 files changed
+306 -69

No files matched your search

+13 -2
View File
@@ -1166,6 +1166,12 @@ checked against the fold (warm, the slowest rank):
With the two Gen4 links retrained to Gen5 x8 the weights read 4,1,1,4,1,1,4,4 and the 16 MiB
message takes 1360 µs.
That is 56% of the time the x8 cards' links need for its bytes (763 µs). `--perfar8 N iters bf16
lockstep,ring,split` times the forms below side by side, and `--timeline` adds every rank's first
push, each step's work and wait and the final assemble, which in one piece are the reduce-scatter
and the all-gather apart; `R4D_SELFTEST_ONE_CARD=1` runs the eight ranks on one card, for their
bits only.
The links are read once, at startup: a link that drops to a lower speed while the server runs
keeps its weight until the next start. `RADIANCE_AR8_SHARD_WEIGHTS` overrides them: `off` keeps
the shards even, eight comma-separated integers set them, unset or `auto` reads the links.
@@ -1173,8 +1179,13 @@ the shards even, eight comma-separated integers set them, unset or `auto` reads
same time's bytes when both directions run at once (`r4d_ar_weights_duplex`): x16 64 and x8 8 on
the repaired board, whose link time it puts 10% under the `auto` weights', a Gen4 x8 card nothing.
`RADIANCE_AR8_PIECES` (1 to 16) fixes the piece count, and `RADIANCE_AR8_SHARD_WEIGHTS_MIN_ELEMS`
and `RADIANCE_AR8_PIECES_MIN_ELEMS` move the two sizes they start at. Every rank must read the
same values; where they differ, every rank stops at startup.
and `RADIANCE_AR8_PIECES_MIN_ELEMS` move the two sizes they start at. `RADIANCE_AR8_FORM` chooses
how the steps run, with the same bits: `lockstep` (unset) as above; `ring` sends the first hop to
the other cards in ring order from the next rank, so no card receives from all seven at once;
`split` does that and replaces each step's handshake, which waits for every card to finish the
whole step, by a flag after each half of it, awaited only where its data is read, so a card whose
half is done goes on with the next piece while a slower one still reduces. Every rank must read
the same values; where they differ, every rank stops at startup.
### 4.8 Host tier for finished conversations