Repository navigation
perf(helios): sync vendored roce_proxy.c to FlashInfer 2a07747b8 (2-step ring2) - #643
Conversation
|
A case file has been opened for 643. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedThe 2-step neighbor-only ring allreduce mechanics in
Walkthrough
Merge Risk: High · up to
|
|
Validated cleanly on our 4x DGX Spark switched dual-rail RoCE cluster ( One cross-repo deployment note with |
…tep ring2) Why: On 4-rank switchless dual-port RoCE rings (DGX Spark / NVIDIA GB10, SM121), small-message BF16 allreduce previously used the oneshot protocol, which relays across opposite ranks over CPU mailbox hops. FlashInfer's merged `local-inference-lab/flashinfer#192` (`2a07747b8e12e54ec8e8e4bbef34de8586618e68`) adds a 2-step neighbor-only ring allreduce (`KIND_RING2_STEP1` / `KIND_RING2_STEP2`) plus small-message inline WR and ring-relay improvements in `_roce_proxy.c`. Per `docs/roce-ring.md`, Helios's vendored `helios/native/roce_proxy.c` must remain byte-identical to FlashInfer's `_roce_proxy.c` after its provenance header so preparation and serving share the transport protocol. What changed: Re-vendored `helios/native/roce_proxy.c` byte-for-byte (after the 9-line provenance header) from `local-inference-lab/flashinfer` commit `2a07747b8e12e54ec8e8e4bbef34de8586618e68` (`#192`). Relative to Flare `main`, this brings in: - `KIND_RING2_STEP1` (5) and `KIND_RING2_STEP2` (6) direct-neighbor RDMA write handling (`post_direct_striped_batched`, `post_ring2_step`) with batched completion signaling (`RING2_SIGNAL_STRIDE = 16`, `RING2_MAX_OUTSTANDING = 6`, statically verified against `ROCE_SEND_DEPTH` with queue slack for relay ops and ring ACKs). - Small-message and ring-relay transport improvements from FlashInfer `#192`: QP `max_inline_data` raised from 16 to 256 (with fallback to 16 and per-HCA `max_inline` tracking) to enable `IBV_SEND_INLINE` on relay mailbox and `post_striped` payloads `<= max_inline`; `ring_next_from` and precomputed `ring_relays_origin[]` so `ring_service` skips non-relayed origins; `post_op` posting relayed peers before direct peers on rings; and idle-loop polling (`ring_service` every spin when `!ring2_active`, every 16th when `ring2_active`; `drain_cqs` every 16th). - High-capacity CPU pinning (`pin_high_capacity_cpus`, `"flare-roce"` thread name) already merged upstream in `flashinfer#156` (overlaps open `#576`). - Existing control opcodes (0..4) and `ROCE_ABI_VERSION = 14` remain unchanged, preserving full compatibility with existing ABI-14 cores. Claimed benefit and result: Enables native Rust serving (`flare run`) to drive b12x's 2-step RoCE ring allreduce on 4-rank switchless rings without opposite-rank CPU relay hops. Note that an isolated `#643`-only run on a `main`-exported core does not emit kinds 5/6; paired with `local-inference-lab/flashinfer#192` (`2a07747b8`), `local-inference-lab/flashinfer#193`, `local-inference-lab/hyperflare-recipes#112`, and `#644` on 4x DGX Spark TP4 DeepSeek-V4.1-Flash serving (`max_tokens = 256`, 5-prompt suite): - In node-level nsys P=4 traces, `RoceRing2AllReduceLaunch` averages 31.8-33.0 us/call across 88 calls/round (eliminating opposite-rank CPU relay hops on small BF16 allreduces). - Combined-stack matched-depth GPU round times dropped 1.5-2.2 ms across P=1..6 versus pre-existing non-ring2 baseline core `gb10-tp4-202611291503` (P=1: 22.3 -> 20.8 ms, P~4: 34.59 -> 32.36 ms, P~5: 35.92 -> 34.16 ms; 5-prompt mean 74.02 -> 76.11 tok/s under `balanced`, `greedy_code` 74.39 -> 80.89 tok/s). Supporting evidence and limitations: - Byte-parity check: `diff` between `tail -n +10 helios/native/roce_proxy.c` and `flashinfer@2a07747b8:flashinfer/experimental/b12x/comm/roce/_roce_proxy.c` returned 0 bytes diff. - Native RoCE proxy unit tests (`cargo test --locked --release --manifest-path helios/Cargo.toml --features roce --lib --target-dir flare-cli/target execution::roce`): **30 passed, 0 failed** (6 `execution::roce::tests` + 24 `execution::roce_fabric::tests`). - Full crate tests (`cargo test --locked --release` on `helios` with `--features runtime-core,server`, `flare`, `flare-cli`): all passed. - Live 4-rank multi-GPU collective execution verified on 4x DGX Spark dual-port switchless RoCE rings serving both ring2-enabled cores (`gb10-tp4-202611301141`, `gb10-tp4-202611301553`, 57 graphs each) and legacy non-ring2 ABI-14 core (`gb10-tp4-202611291503`). - Limitations / unrun checks: - Keeping `ROCE_ABI_VERSION = 14` preserves compatibility with existing ABI-14 cores, but an older Flare binary without `#643` loading a newer ring2-exported core will connect and fail on replay op 1 with `unknown op kind 5` rather than rejecting at startup. - Collides on `roce_proxy.c` with open `#576` (`pin_high_capacity_cpus` from merged `flashinfer#156`) and `#577` (`RING_WINDOW` / `reserve`); whichever lands second will rebase cleanly against the vendored file. - Non-4-rank ring topologies and non-SM121 RoCE NICs were not benchmarked. Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
9c3ea69 to
3736fef
Compare
|
Addressed all review items:
|
…ap, and deferred shared expert (#112) * perf(deepseek41): wire RoCE ring2 collectives, DSpark main_proj overlap, and deferred shared expert Why: During TP4 speculative decode on 4x DGX Spark (SM121), four recipe-level execution overheads left GPU time on the table: 1. `PreparedAllReduce` and `PreparedAllGather` in `components/collectives.py` did not expose b12x's fused-addend 2-step RoCE ring allreduce or device-gated RoCE allgather when available. 2. `PreparedPackedSpeculativeRound` still broadcast vocabulary-parallel distribution confidence from rank 0 even though every rank reduces the identical confidence vector locally from gathered softmax records. 3. `PreparedContext` in `components/dspark.py` could not overlap its output-sharded `mtp.0.main_proj` projection on the auxiliary stream when `compact` was off and RoCE collectives handled the gather. 4. `ConcurrentSharedExpert` in `recipes/deepseek41/decoder.py` set `defer_launch = (M > 4)`, causing `shared_up` to contend with `router_projection` at `M <= 4` instead of filling the `route_topk` + route-coalesce memory bubble before `FC1`. What changed: - `hyperflare_recipes/components/collectives.py`: Added capability-checked fused-addend support (`_roce_supports_addend`) for RoCE `PreparedAllReduce` and device-side `gate` forwarding for RoCE `PreparedAllGather` (preserving compatibility with current `uv.lock` FlashInfer until `flashinfer#192` merges). - `hyperflare_recipes/components/packed_speculation.py`: Skipped the redundant confidence broadcast when `confidence_head is None` (vocabulary-parallel distribution confidence is identical on every rank). - `hyperflare_recipes/components/dspark.py` & `parallel_draft.py`: Added `flare::start_dspark_main_proj` / `flare::join_dspark_main_proj` and `overlap_context_main` to overlap sharded `mtp.0.main_proj` on the auxiliary stream with target completion and synchronize before commit. - `hyperflare_recipes/recipes/deepseek41/decoder.py`: Enabled `defer_launch=True` for `ConcurrentSharedExpert` across all decode sizes. - Added/updated component unit tests in `test_collective_plan_choice.py`, `test_dspark_context_shard.py`, and `test_packed_speculation.py`. Claimed benefit and result: Reduces per-round collective, confidence-broadcast, draft-context, and shared-expert contention overhead in TP4 speculative decode. Combined with `local-inference-lab/flashinfer#192`, `local-inference-lab/flashinfer#193`, and `NVIDIA/hyperflare-inference#643`/`#644` on 4x DGX Spark TP4 DeepSeek-V4.1-Flash serving (`gb10-tp4-202611301553`), node-level nsys P=4 median round dropped 33.72 -> 32.52 ms (-1.20 ms), non-MoE time across 39 target layers dropped 17.01 -> 15.68 ms (-1.33 ms) with `sh_dn` completing before `FC1` starts, and matched-depth GPU round latency dropped 1.5-2.2 ms across P=1..6. Supporting evidence and limitations: - Component unit tests on tachyon (`TRITON_INTERPRET=1 pytest tests/components/test_collective_plan_choice.py tests/components/test_dspark_context_shard.py tests/components/test_packed_speculation.py -q`): all passed (48/48 including `test_vocabulary_completion_abi.py`). - Full 4x DGX Spark TP4 export (57 graphs) and 5-prompt live serving verified on SM121. - Limitations: `uv.lock` is not bumped in this PR and should be updated once `local-inference-lab/flashinfer#192` and `#193` merge; SM120 / non-SM121 GPUs were not benchmarked in this pass. Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=6fcc * fix(deepseek41,collectives): align RoCE addend capability check and medium-batch shared-expert overlap - In `_roce_supports_addend` (`hyperflare_recipes/components/collectives.py`), check `getattr(runtime, "supports_all_peer_auxiliary", False)` before the `_uses_ring2` fallback so runtimes implementing one-shot and two-shot fused addends keep fused reductions across switched RoCE, two-shot, and 16-byte payloads while preserving ring2-only gating when absent. - In `hyperflare_recipes/recipes/deepseek41/decoder.py`, set `ConcurrentSharedExpert(..., defer_launch=(rows <= 4) or (rows > 64))` so `M <= 4` avoids `router_projection` bandwidth contention and `M > 64` avoids SM starvation, while `5 <= M <= 64` keeps shared-expert projections overlapped with routed-expert execution. - Update `tests/recipes/test_deepseek41_expert_overlap.py` for the `(rows <= 4) or (rows > 64)` policy and add precedence coverage plus a capability skip guard in `tests/components/test_collective_plan_choice.py`. Verified: `pytest tests/recipes/test_deepseek41_expert_overlap.py tests/components/test_collective_plan_choice.py tests/components/test_dspark_context_shard.py tests/components/test_packed_speculation.py` (184 passed, 8 skipped live-ring2 cases on pre-ring2 FlashInfer). Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=6fcc
Why
On 4-rank switchless dual-port RoCE rings (DGX Spark / NVIDIA GB10, SM121), small-message BF16 allreduce previously routed through the oneshot protocol, which relays traffic across opposite ranks through CPU mailbox hops. Merged upstream
local-inference-lab/flashinfer#192(2a07747b8e12e54ec8e8e4bbef34de8586618e68) adds a 2-step neighbor-only ring allreduce (KIND_RING2_STEP1/KIND_RING2_STEP2) along with small-message inline WR and ring-relay optimizations in_roce_proxy.c. Perdocs/roce-ring.md, Helios's vendoredhelios/native/roce_proxy.cmust remain byte-identical to FlashInfer's_roce_proxy.cafter its provenance header so preparation and serving share the transport protocol.What Changed
Re-vendored
helios/native/roce_proxy.cbyte-for-byte (after the 9-line provenance header) from mergedlocal-inference-lab/flashinfercommit2a07747b8e12e54ec8e8e4bbef34de8586618e68(#192). Relative to Flaremain, this brings in:KIND_RING2_STEP1 = 5,KIND_RING2_STEP2 = 6):post_direct_striped_batched,post_ring2_step) with batched completion signaling (RING2_SIGNAL_STRIDE = 16,RING2_MAX_OUTSTANDING = 6, statically verified againstROCE_SEND_DEPTHwith queue slack for relay ops and ring ACKs).flashinfer#192:max_inline_datafrom16to256(with fallback to16and per-HCAmax_inlinetracking) to enableIBV_SEND_INLINEon relay mailbox andpost_stripedpayloads<= max_inline.ring_next_fromand precomputedring_relays_origin[]inroce_connectsoring_serviceskips non-relayed origins.post_opto post relayed peers before direct peers on rings.ring_serviceevery spin when!ring2_active(every 16th spin whenring2_active) anddrain_cqsevery 16th spin.flashinfer#156:pin_high_capacity_cpus()and"flare-roce"thread naming already present on FlashInfermain(overlaps open#576).0..4: oneshot, varlen, reduce-scatter, gather-shards) andROCE_ABI_VERSION = 14are unchanged. Existing ABI-14 cores without ring2 opcodes load and serve unchanged.Claimed Benefit and Result
flare run) to driveb12x's 2-step RoCE ring allreduce on 4-rank switchless rings without opposite-rank CPU relay hops.#643-only run against amain-exported core does not emit op kinds5/6; evaluating ring2 requires a core exported withlocal-inference-lab/flashinfer#192(2a07747b8) andlocal-inference-lab/hyperflare-recipes#112.max_tokens = 256, 5-prompt suite):nsysP = 4traces,RoceRing2AllReduceLaunchaverages 31.8–33.0 µs/call across 88 calls/round.flashinfer#192+flashinfer#193+flare#643+flare#644+hyperflare-recipes#111/#112, coregb10-tp4-202611301553) vs pre-existing non-ring2 baseline core (gb10-tp4-202611291503,flare-trackA): matched-depth GPU round time dropped 1.5–2.2 ms (P = 1:22.3 → 20.8 ms,P ≈ 4:34.59 → 32.36 ms,P ≈ 5:35.92 → 34.16 ms), 5-prompt mean rose74.02 → 76.11 tok/sunderbalanced, andgreedy_coderose74.39 → 80.89 tok/s(+8.7%).Supporting Evidence and Limitations
diffbetweentail -n +10 helios/native/roce_proxy.candlocal-inference-lab/flashinfer@2a07747b8e12e54ec8e8e4bbef34de8586618e68:flashinfer/experimental/b12x/comm/roce/_roce_proxy.creturned 0 bytes diff.cargo test --locked --release --manifest-path helios/Cargo.toml --features roce --lib --target-dir flare-cli/target execution::roce): 30 passed, 0 failed (6execution::roce::tests+ 24execution::roce_fabric::tests).cargo test --locked --release): Passed onhelios(--features runtime-core,server),flare, andflare-cli.gb10-tp4-202611301141,gb10-tp4-202611301553, 57 graphs each) and legacy non-ring2 ABI-14 core (gb10-tp4-202611291503).local-inference-lab/flashinfer#192(merged at2a07747b8e12e54ec8e8e4bbef34de8586618e68), recipe wiringlocal-inference-lab/hyperflare-recipes#112.ROCE_ABI_VERSION = 14preserves compatibility with existing ABI-14 cores, but an older Flare binary without#643loading a newer ring2-exported core will connect and fail on replay op 1 withunknown op kind 5rather than rejecting at startup.helios/native/roce_proxy.cwith open#576(pin_high_capacity_cpusfrom already-mergedflashinfer#156) and#577(RING_WINDOW/reserve); whichever merges second will rebase against the vendored file.Discord: lukealonso