Skip to content

Engine patches 0107/0108: the RoCE all-gather at any world and the drafter MLP split, MESH_ROCE for TP=4 on a switch (round 36.4 -> 33.0 ms) - #5

Closed
shanedertrain wants to merge 9 commits into
MiaAI-Lab:mainfrom
shanedertrain:tp4-mesh-roce-engine
Closed

shanedertrain wants to merge 9 commits into
MiaAI-Lab:mainfrom
shanedertrain:tp4-mesh-roce-engine

Conversation

@shanedertrain

Copy link
Copy Markdown

Depends on #4 (this branch is #4 plus four commits). Four DGX Sparks behind one switch, TP=4.

What

Two engine patches and one launcher switch, so the decode-sized all-gathers go over RoCE at four as they do on the pair:

  • 0107 cuda/roce: the one-shot RoCE all-gather at any world. zig/src/cuda/roce.zig and roce_gather.cu generalised from two ranks: one RC queue pair per peer per HCA, a receive region [slot][world-1] with a flag per peer per HCA, the shard written to every peer, the kernel waiting for (world-1) × n_hca flags and copying each peer's stripes into rank-ordered slots (the same slots hcPost sums, so the bytes are NCCL's). A connect-time probe writes a token to every peer and refuses (PeerUnreachable) when one cannot be written to, so a ring never opens the path. World 2 keeps the old layout bit for bit (a test pins it). tf-cuda-test roce-gather <rank> [world] compares every size with ncclAllGather and times a call.
  • 0108 glm/cuda: the DFlash2 drafter MLP split across every rank (ff = FF / world when 256-aligned; rank-ordered fp32 df_sumn, world 2 bit-identical to df_sum2). Exact; on its own it does not move the round (its block overlaps other work) and is kept as lighter.
  • start-tp4.sh: MESH_ROCE=auto|on|off — on a switch, TF_ROCE=1 when 0107 is in the image, TF_ROCE_HCA per rank; a ring stays on NCCL. README "4 Sparks", CHANGELOG and RESULTS.md ("Engine patches 0107 and 0108") updated.

Evidence (four GB10s, CRS804, one 200G cable each, image d46e73d4e405 = f350cd3e + 108 patches; compiled first try)

  • Microbench, one container a Spark, all four ranks: every size 16 B – 512 KiB × 3 seeds byte-equal to NCCL; 3,000 mixed 16/32/64 KiB calls, 0 mismatches. µs a call RoCE / NCCL: 4 KiB 14.9 / 28.9, 16 KiB 18.2 / 32.9, 32 KiB 22.0 / 39.4, 64 KiB 28.7 / 57.3.
  • Model (Ablit, split, 768k × 8, greedy, your acc.py): the per-layer gathers 2.58 + 2.19 → 1.76 + 1.55 ms a verify call (TF_GLM_PROF), drafter block 5.5 → 3.5 ms a round, decode round 36.4 → 33.0 ms. One stream 53.8 / 83.0 → 59.4 / 90.8 tok/s (prose / code), four streams 118 → 131.5. Greedy hashes unchanged in every boot (fab1d3b6894b / e71492bf766b), with RoCE on and off, acceptance unchanged (53% / 72%).
  • Every rank logs RoCE all-gather: 4 ranks, 2 HCA(s), shards up to 4096 KiB by RDMA writes.

Not verified

The host spin proxy's CPU at eight streams; TF_ROCE_MAX_KB stays 4096 (prefill-sized exchanges stay on NCCL); the engine change has not been ported to TensorFold main (1,125 commits past the pin) — that is a separate upstream PR we are preparing.

…les or NCCL_ALGO=Ring, PREFILL_REDUCE auto (split on a switch, gather on a ring)
…ts, the ring's hashes reproduced, prefill +30% with split)
…ompt cache / retention trade at 1M vs 768k windows
…rompt cache is under 8 GiB; README memory and incast notes for four Sparks
…d, mesh only) and 0108 (DFlash2 drafter MLP split across every rank); notes with the microbench and gates (unbuilt, untested)
… 0107 is in the image (MESH_ROCE=auto|on|off); TF_ROCE_HCA per rank
…LTS: microbench and model boots, hashes unchanged, round 36.4 -> 33.0 ms)
…/33/33 registers on sm_80/86/89/120/121), not df_sum2's carried figures
@shanedertrain

Copy link
Copy Markdown
Author

Pushed one more commit: 0108's df_sumn launch record is now the RECORD line from tf-cuda-test kernel-contract-limits over five-SM fatbins (32/40/40/33/33 registers on sm_80/86/89/120/121; cuobjdump -res-usage agrees) instead of df_sum2's carried figures. The same two engine changes, ported onto TensorFold main, are ashhart/TensorFold#2205 (compiles, zig build test +5 tests vs a pristine-main control, the world-4 microbench reproduces 18.1 / 22.0 µs there).

@MiaAI-Lab

Copy link
Copy Markdown
Owner

Thank you for the work and the measured evidence. This PR cannot merge into main as it stands: the four-Spark recipe was removed from this repository on 2026-11-05 by 94b72f5 (start-tp4.sh, scripts/tp4.sh, the TP=4 settings in scripts/config.sh and scripts/prepare.sh, the README section and docs/speed/tp4), so every file this PR changes for TP=4 is gone and GitHub reports the branch as conflicting; this repository is the two-Spark recipe only. By the PR descriptions, patches 0107 and 0108 are bit-identical to the pin's two-rank paths at world 2, so they bring nothing to the pair this repository serves. The one part with a pair-side effect is patch 0109 (TF_GLM_CHUNK_SOLO, PR #6: the CHUNK_SOLO/CHUNK_BUSY settings in scripts/config.sh and the start.sh:158-159 plumbing); if you want it considered here, a pair-only PR on top of main's 105-patch pin, with the patch renumbered to follow 0105 and a pair A/B (greedy hashes and the harness rows in docs/speed/RESULTS.md), is what could be reviewed. The shell changes were scanned for secrets, privilege and network exposure and nothing was found; the engine patches were not reviewed in depth since they are not being ported. Left open for you to re-scope. (Review notes prepared with Claude Code on behalf of the maintainer.)

@shanedertrain

Copy link
Copy Markdown
Author

Closing: patches 0107/0108 are not needed at world 2, and the engine changes continue upstream as ashhart/TensorFold#2205 (RoCE gather at any world, now opt-in at 3+ ranks, and the drafter MLP split). Thanks for the review.

shanedertrain added a commit to shanedertrain/GLM-5.3-Flash-DGX-Sparks-1104 that referenced this pull request Nov 8, 2026
…on this tree

Owner asked to pull the prompt-cache-starvation fix from MiaAI-Lab/GLM-5.3-Flash-DGX-Sparks-1104
main (605c6a1, issue 7): CACHE_FIRST=1 (TF_PROMPT_CACHE_FIRST) sets PROMPT_CACHE_GIB aside before
the page pool is sized in whole windows, instead of only capping the remainder. Upstream measured a
380k-token conversation resuming 99% cached (3.0s vs 234s) with eight ~31k ones also resuming, at
PARALLEL=8 / 1M window / PROMPT_CACHE_GIB=12.

Real collision found and resolved: upstream main independently reused the number 0108 for this patch,
which on this tree already names our own DFlash2 drafter MLP split (part of PR MiaAI-Lab#5/MiaAI-Lab#10). Two
files both prefixed 0108- would have landed in patches/engine/ (upstream issue 15 tracks this exact
numbering mess across main, MiaAI-Lab#10 and MiaAI-Lab#11). Renumbered the pulled patch file and every
reference to it (start.sh, scripts/config.sh, README, CHANGELOG) to 0110, the next free slot on this
branch. Also wrote an accurate patch-count line and table row for this tree (110 patches, 0001-0110) --
neither sides prose was correct for our actual history, which already includes 0106-0109 unconflicted.

Scope: cache-first only. Did NOT pull TOOL_CALL_GUARD (0107 upstream), WITH_VIDEO, LEARN_GIB (disk
persistence) or KV_SHARD from the same upstream range -- out of scope for this ask, and pulling them
would have meant documenting features this tree does not have. docker/Dockerfile and scripts/config.sh
and scripts/prepare.sh wiring for CACHE_FIRST are real (auto-merged clean, no conflict). Not built, not
run, not served -- this is a docs+scripts+patch-file change on the tp4-mesh-roce-engine branch only;
production is unaffected (still the separate GLM-5.3-Flash-TensorFold-tp4-main Python recipe).
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