Skip to content

perf(fabric/tp): eager half-forwarding in 4-rank RoCE ring relay - #4798

Merged
ashhart merged 2 commits into
ashhart:mainfrom
GrgaPalcic:pr/roce-relay-eager
Nov 24, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
GrgaPalcic:pr/roce-relay-eager

Conversation

@GrgaPalcic

@GrgaPalcic GrgaPalcic commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Switches the 4-rank switchless RoCE ring relay (zig/src/fabric/tp/roce_relay.zig) from alternating completed half-forwards to eager half-forwarding: each half is forwarded as soon as its flag lands independently of the opposite direction, and initial sends post the longest-path halves (direction == d) first. Sequence s+1 still waits for wire.idle(), consumed of s-2, and every rank's s-1, preserving exact two-slot custody and identical reduction order.

  • Issue: n/a — bit-identical transport optimization on the existing opt-in TF_TP_ROCE_RELAY=1 4-rank ring path (Refs #4795); changes no model family, public API, or arithmetic order.
  • Stacked on: main (0300dfbfe2b3ed3c395fa511f53201f93303a72c), 1 commit (6e00fc784).
  • atc overlap --json: run on 2026-11-23T21:15Z against origin/main — 5 PR overlaps (#3041, #3075, #3076, #3102, #3103, all on README.md), every single one "conflict": "clean" (conflictFiles: 0; complete: false due to pullRequestsLimit / pullFilesUnavailable).

Checks on this head

  • Head commit: 6e00fc784
  • Lean checker, python3 tools/zig/lean_check.py, on the base and on this head: 165 on base (0300dfbfe), 165 on head (6e00fc784), 0 new findings (python3 tools/pr_check.py --base origin/main: 0 error(s), 1 warning(s) — advisory CHANGELOG.md Unreleased reminder).
  • Tests run, with the command and pass, fail and skip counts:
    • Before change: zig build test-roce-multi-host — 57 pass, 1 fail (58 total) (new relay eager: half 1 forwards immediately when half 0 has not landed yet fails as expected on origin/main).
    • After change: zig build test-roce-multi-host — 58 pass, 0 fail (58 total).
    • zig build test-roce-relay-controls-host — 9 pass, 0 fail (9 total).
    • zig build test-roce-integration-host — 5 pass, 0 fail (5 total).
    • zig build test-tp-suite-host — 1 pass, 0 fail (1 total).
    • zig fmt --check zig/src/fabric/tp/roce_relay.zig zig/src/fabric/tp/roce_relay_test.zig — pass (exit 0).
    • git diff --check — pass (exit 0).
  • CI: pending on PR open.
  • Not run, and why: Apple Silicon / Metal and HIP — Linux CUDA RoCE host proxy logic only (roce_relay.zig).

Receipt

  • Main against branch: alternated A/B/A/B tf-tp-test suite on the exact same 4× NVIDIA GB10 (sm_121) switchless ConnectX-7 ring (TF_TP_ROCE_RELAY=1, TF_TP_ROCE_FAST=1, TF_TP_MAILBOX_MAX_KB=1024), built from 0300dfbfe (origin/main) vs 6e00fc784 (PR head):
Op (world = 4, roce) origin/main 0300dfbfe (A1 / A2) PR 6e00fc784 (B1 / B2) Delta
all_gather 4 KB (graph_us) 20.64 / 20.72 us (0.60 GB/s) 14.11 / 14.10 us (0.87 GB/s) -31.8%
all_gather 8 KB (graph_us) 22.21 / 22.24 us (1.11 GB/s) 17.09 / 17.13 us (1.44 GB/s) -23.0%
all_gather 16 KB (graph_us) 24.95 / 24.99 us (1.97 GB/s) 20.42 / 20.47 us (2.41 GB/s) -18.1%
all_gather 64 KB (graph_us) 41.78 / 41.99 us (4.71 GB/s) 34.85 / 34.95 us (5.64 GB/s) -16.7%
decode_window (86 × 8 KB) 22.17 / 22.20 us (1906.7 / 1909.0 us) 17.42 / 17.04 us (1498.0 / 1465.7 us) -22.3%
SUMMARY (every run) 328 passed, 0 failed 328 passed, 0 failed 0 diffs
  • Boxes it reaches: TP=4 Linux CUDA hosts with TF_TP_ROCE_RELAY=1 (switchless 4-rank ConnectX-7 ring).
  • New switch? No new switches or defaults; TF_TP_ROCE_RELAY remains off by default.
  • Environment: base 0300dfbfe, head 6e00fc784, Zig 0.17.0, nvcc 13.0.88, 4× NVIDIA DGX Spark (GB10 sm_121, 128 GB unified memory each, dual-port ConnectX-7 200GbE ring), Linux aarch64.
  • Paths and platforms the change reaches: 4-rank TF_TP_ROCE_RELAY=1 proxy path only; 2-rank, 3-rank, and full-mesh paths are untouched. Ran host suites on Linux x86_64 and alternated A/B/A/B tf-tp-test suite on 4× GB10; did not run Metal, HIP, Windows, or app targets.
  • Exactness: tf-tp-test suite 328/328 byte-exact payload, graph-capture, and sequence/custody checks pass on all 4 runs (A1, B1, A2, B2).
  • Main against this branch: alternated A/B/A/B above on the same 4× GB10 ring; -16.7% to -31.8% lower all_gather latency from 4 KB to 64 KB, -22.3% on decode_window (-426 us per 86-exchange window), and all_reduce unchanged within noise (50.7 -> 51.0 us at 4 KB, 67.1 -> 66.2 us at 64 KB).
  • Decode speed before and after: saves ~4.8–5.1 us per 8 KB exchange (-426 us per 86-exchange decode_window on tf-tp-test).
  • Prompt speed before and after: n/a — roce_relay.zig handles messages up to TF_TP_ROCE_RELAY_MAX_KB (decode/draft windows); large prompt collectives stay on ring NCCL.
  • Licence of any new weights or drafter: n/a.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
  • No precision traded for speed. If the bits change, the description says which sums change and why.
  • Decode and prompt processing are no slower than main at one stream and the widest admitted; with --drafter, no slower than without it, greedy and sampled.

@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks, @GrgaPalcic. The eager forwarding and longest-path-first send order are confirmed in the source. The flag/payload ordering, per-segment completion accounting, two-slot custody and fixed reduction order preserve the existing byte contract, including when ranks progress at different speeds.

The alternated receipt also supports the reported fixed-size speedups; the averages match your table.

Before landing, please retain per-rank evidence that the relay stayed active without fallback in every alternated run. The remaining four-rank checks are payload verification for the timed graph window, variable-length gathers including zero and unequal lengths, and gathers through the raised 1 MiB relay ceiling with sustained graph and slot-reuse activity. The current suite's large operations otherwise use NCCL, and its timed window checks timing rather than payload bytes.

No source change is requested from this review. These are the remaining device qualification cells.

  • Synthena

@GrgaPalcic

Copy link
Copy Markdown
Contributor Author

Completed all requested 4-rank device qualification cells on exact PR head 6e00fc784 (no source changes) on 4× NVIDIA GB10 (sm_121, driver 615.71.09, CUDA 13.4, NCCL 2.30.7, switchless RoCE v2 ring with TF_COMM_BACKEND=roce TF_TP_ROCE_RELAY=1 TF_TP_ROCE_FALLBACK=error TF_TP_ROCE_FAST=1 TF_TP_MAILBOX_MAX_KB=1024, Zig 0.17.0, -Doptimize=ReleaseFast):

1. Per-rank no-fallback evidence across alternated A/B/A/B (0300dfbfe vs 6e00fc784, default 64 KiB ceiling)

TF_TP_ROCE_FALLBACK=error was enforced on every rank of all 4 runs (A1, B1, A2, B2). Every rank (0..3) reported backend roce, relay-active (four-rank relay has no opposite-rank link), 0 warnings/fallbacks, and 328 passed, 0 failed:

A1 (main 0300dfbfe): rank 0..3 -> INFO backend roce, SKIP four-rank relay active, SUMMARY 328 passed, 0 failed
B1 (PR   6e00fc784): rank 0..3 -> INFO backend roce, SKIP four-rank relay active, SUMMARY 328 passed, 0 failed
A2 (main 0300dfbfe): rank 0..3 -> INFO backend roce, SKIP four-rank relay active, SUMMARY 328 passed, 0 failed
B2 (PR   6e00fc784): rank 0..3 -> INFO backend roce, SKIP four-rank relay active, SUMMARY 328 passed, 0 failed
Case (graph_us / window_us) origin/main 0300dfbfe (A1 / A2) PR #4798 6e00fc784 (B1 / B2) Delta
all_gather 4 KiB 20.70 / 20.65 us (0.59 / 0.60 GB/s) 14.10 / 14.15 us (0.87 / 0.87 GB/s) -31.7%
all_gather 8 KiB 22.23 / 22.10 us (1.11 / 1.11 GB/s) 17.74 / 17.01 us (1.39 / 1.44 GB/s) -21.6%
all_gather 16 KiB 25.17 / 25.52 us (1.95 / 1.93 GB/s) 21.46 / 20.88 us (2.29 / 2.35 GB/s) -16.5%
all_gather 32 KiB 32.00 / 32.06 us (3.07 / 3.07 GB/s) 26.27 / 26.58 us (3.74 / 3.70 GB/s) -17.5%
all_gather 64 KiB 40.84 / 41.47 us (4.81 / 4.74 GB/s) 35.37 / 34.64 us (5.56 / 5.68 GB/s) -14.9%
decode_window (86 × 8 KiB) 22.46 / 22.25 us (1931.8 / 1913.1 us) 17.79 / 17.35 us (1530.0 / 1492.2 us) -21.3% (-411 us)

2. Raised 1 MiB relay ceiling (TF_TP_ROCE_RELAY_MAX_KB=1024) tf-tp-test suite on 6e00fc784

All 4 ranks (rank 0..3) reported backend roce, relay active, 0 fallbacks, and SUMMARY rank {0..3}: 328 passed, 0 failed (covering all_gather and captured graphs through 256 KiB, 256 KiB + 16 B, 512 KiB, and 1 MiB over the relay):

RESULT {"backend":"roce","world":4,"op":"all_gather","bytes":262144,"eager_us":86.43,"graph_us":82.48,"busbw_GBps":9.54}
RESULT {"backend":"roce","world":4,"op":"all_gather","bytes":524288,"eager_us":146.87,"graph_us":145.43,"busbw_GBps":10.82}
RESULT {"backend":"roce","world":4,"op":"all_gather","bytes":1048576,"eager_us":278.22,"graph_us":270.78,"busbw_GBps":11.62}

3. Dedicated 4-rank GPU qualification on unmodified 6e00fc784 (TF_TP_ROCE_RELAY_MAX_KB=1024, TF_TP_ROCE_FALLBACK=error)

Verified on all 4 ranks at startup (backend roce, relay=true, relay_max_bytes=1048576, slot_bytes=1048576, varFits(1 MiB)=true, seq_start=1; ring-only HCA pairs confirmed with empty opposite-rank pairs on every rank):

  • Timed 86 × 8 KiB graph window with byte-exact payload verification: 20 replays with 20 distinct per-rank payloads + 20 back-to-back timed replays (per_us=17.55–17.56, window_us=1509.7–1509.9), all 32,768 output bytes verified bit-for-bit against host reference on all 4 ranks after every replay (relay_ops=3440, 86 × 40, exact on all 4 ranks).
  • Variable-length GPU gathers (comm.allGatherV) — zero, unequal, unaligned, and 1 MiB ceiling: 12 eager cases ({0,0,0,0}, {0,17,0,4096}, {8192,0,33,0}, {0,0,0,65536}, {65536,0,0,0}, {1,15,16,17}, {65520,65535,65536,32768}, {16,4096,131072,262144}, {524288,0,262145,127}, {1048576,524288,0,12345}, {0,1048576,1048575,1}, {1048576,1048576,1048576,1048576}) + 8 CUDA-graphed 1 MiB replays with changing device lens vectors (including {0,0,0,0}, single-rank/mixed zero, unequal, ceiling) — every rank's lens[r] bytes verified bit-for-bit on all 4 ranks (relay_ops=20, exact on all 4 ranks).
  • Sustained 1 MiB graph & slot-reuse activity: 20 replays of a 16-op back-to-back 1 MiB allGather CUDA graph (320 consecutive 2-slot turnovers) interleaved with 20 eager 1 MiB allGather ops (340 1 MiB relay ops = 1.36 GiB gathered through the 2-slot relay), all 4,194,304 output bytes verified bit-for-bit on all 4 ranks after every replay and every eager op (relay_ops=340, exact on all 4 ranks).

Per-rank summaries and RDMA drain receipts (3801 total relay ops × 3 RDMA posts/op = 11,403 per HCA per rank, 0 dropped, 0 flushed):

QUAL_SUMMARY rank 0: 84 passed, 0 failed, total_relay_seq=3801 (HCA 0 posted/completed 11403/11403; HCA 1 11403/11403; still posted 0)
QUAL_SUMMARY rank 1: 84 passed, 0 failed, total_relay_seq=3801 (HCA 0 posted/completed 11403/11403; HCA 1 11403/11403; still posted 0)
QUAL_SUMMARY rank 2: 84 passed, 0 failed, total_relay_seq=3801 (HCA 0 posted/completed 11403/11403; HCA 1 11403/11403; still posted 0)
QUAL_SUMMARY rank 3: 84 passed, 0 failed, total_relay_seq=3801 (HCA 0 posted/completed 11403/11403; HCA 1 11403/11403; still posted 0)

@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks, @GrgaPalcic. The new receipt covers the requested relay-active, timed payload, variable-length and sustained 1 MiB checks. Together with the source review, this looks safe to land after CI.

Two small receipt clarifications: the listed cells add to 3,800 operations, while the counters imply 3,801; please identify the extra setup operation or counter convention. Also, 340 four-rank 1 MiB gathers total 1,360 MiB (1.328125 GiB) per gathered output. The speed results support transport latency improvements, rather than model tokens/s.

  • Synthena

@GrgaPalcic

Copy link
Copy Markdown
Contributor Author

Thanks — confirming both clarifications:

  1. Counter accounting (3,801 = 1 + 3,800): seq_start = 1 is the single load-time allGather probe in roce_multi_session.probe() (roce_multi_session.zig:83) that checks the relay against NCCL at 4 KiB during Session.open() (the probe's allReduce goes to NCCL since 4-rank relay only routes allGather/allGatherV). Adding the three qualification cells (3,440 decode_window + 20 allGatherV + 340 sustained 1 MiB = 3,800) gives total_relay_seq = 3,801 (3,801 × 3 = 11,403 RDMA posts/completions per HCA per rank).
  2. Data volume & scope: 340 four-rank 1 MiB gathers total 1,360 MiB (1.328125 GiB) of gathered output (the earlier 1.36 mixed decimal/binary units), and the measured speedups qualify transport collective latency/bandwidth rather than end-to-end model tokens/s.

@ashhart
ashhart force-pushed the pr/roce-relay-eager branch from 6e00fc7 to 4b40add Compare November 24, 2026 13:00
@ashhart
ashhart merged commit 539930b into ashhart:main Nov 24, 2026
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you @GrgaPalcic. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

ashhart added a commit to GrgaPalcic/TensorFold-hy4 that referenced this pull request Nov 24, 2026
ashhart added a commit that referenced this pull request Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants