Skip to content

helios,flare-cli: add experimental ConnectX-7 hardware-hairpin ring mode (--roce-hairpin) - #712

Draft
original-el8 wants to merge 1 commit into
mainfrom
draft/roce-cx7-hairpin
Draft

original-el8 wants to merge 1 commit into
mainfrom
draft/roce-cx7-hairpin

Conversation

@original-el8

Copy link
Copy Markdown
Collaborator

Why

Switchless multi-host RoCEv2 rings using --roce-ring connect only neighbor queue pairs and forward non-neighbor transfers (such as 0 <-> 2 and 1 <-> 3 in a 4-Spark ring) through the native host CPU proxy (helios/native/roce_proxy.c) over 64 KiB software mailboxes. ConnectX-7 NICs support wire-speed hardware hairpin forwarding (tc flower skip_sw in_hw) between physical ports without crossing host PCIe or CPU.

Adding an explicit Shape::HairpinRing (--roce-hairpin) mode lets intermediate ConnectX-7 NICs forward non-neighbor RoCEv2 UDP/4791 packets in hardware while ranks open direct all-to-all RC queue pairs without CPU proxy relaying or changes to the native RoCE proxy ABI.

What Changed

  • helios/src/execution/roce_fabric.rs: Added Shape::HairpinRing (relays() == false, linked() == (peer != rank)), plan_hairpin_ring_routes, and hairpin_equal_arc_pair. Adjacent ring neighbors retain their direct physical cable links; non-neighbor peers pair arc-entry and arc-exit devices along the shorter arc; equal-length opposite pairs (0 <-> 2 and 1 <-> 3 in a 4-Spark ring) split Rail 0 clockwise and Rail 1 counter-clockwise while minimizing shared devices, PCIe links, and physical ports at both ends. Tightened direct_peers to require same_link(x, y) so multi-hop hairpin peers report direct = false.
  • helios/src/execution/roce.rs: Treated Shape::HairpinRing identically to Shape::Mesh in RoceTransport::open (enabled = 0, no roce_enable_ring), keeping the native C proxy and ABI 14 core layout unchanged.
  • flare-cli/src/{cli,cluster,distribution,fabric,fabric_transport,launch,main}.rs & flare-cli/src/orbit/{agent,controller,fabric,grant,store}.rs: Wired --roce-hairpin (mutually exclusive with --roce-ring and --roce-chain) across manual, --hosts, and Orbit launches with hairpin-ring rendezvous shape agreement, backward-compatible #[serde(default)] Orbit grant/store fields, and neighbor-relayed TCP core distribution so NIC hairpin rules need only offload RoCEv2 traffic.
  • scripts/setup_cx7_hairpin_ring.sh: Added a dry-run-by-default (--apply, --verify, --teardown) host setup and verification helper generating per-rank ConnectX-7 tc flower skip_sw L3 hairpin rules (pedit MAC rewrite plus mirred egress redirect) and static /32 routes and permanent neighbor entries for a 4-node switchless ring.
  • docs/roce-ring.md & docs/cli-design.md: Documented --roce-hairpin routing, host configuration, verification checks, and unverified hardware status.

Expected Benefit

On switchless 4-Spark rings configured with ConnectX-7 hardware hairpin:

  • Eliminates host CPU proxy relay hops and 64 KiB software mailbox copies for non-neighbor collective transfers.
  • Splits diagonal (0 <-> 2, 1 <-> 3) transfers across both ring arcs and both PCIe Gen5 x4 links per host.
  • Reuses existing ABI 14 exported cores without re-export.
  • Leaves existing mesh, --roce-ring, and --roce-chain paths unchanged.

No end-to-end serving speedup has been measured yet; this draft PR is published for testing on physical switchless ring hardware.

Evidence & Material Limitations

  • cargo test --locked --release --manifest-path helios/Cargo.toml --features roce,runtime-core,server --lib roce: 46 passed, 0 failed (including hairpin_ring_on_four_sparks_splits_diagonals_across_both_arcs_and_pcie_links and variable_size_hairpin_rings_route_all_peers_symmetrically).
  • cargo test --locked --release --manifest-path flare-cli/Cargo.toml: 225 unit tests and 7 integration tests passed, 0 failed (including hairpin_flag_is_forwarded_and_excludes_ring_and_chain, hairpin_ring_uses_neighbor_relays_for_tcp_distribution, cluster::routing_tests, and orbit::fabric::tests).
  • bash -n scripts/setup_cx7_hairpin_ring.sh and 4-rank dry-run verification checked symmetric endpoint routes and transit rules across all 8 unidirectional diagonal flows.
  • Material limitations (pending hardware test): Not yet tested on a physical switchless 4-Spark ring. Hardware testing is needed to confirm:
    1. ConnectX-7 dual-PF switchdev + tc flower skip_sw reports in_hw on all intermediate ring ports without software fallback.
    2. TC 0 PFC remains lossless under hairpin transit load.
    3. Direct 2-hop ib_write_lat succeeds across 0 <-> 2 and 1 <-> 3 on both arcs with zero drops/retransmits.
    4. Multi-host flare run --roce-hairpin completes collective warmup and serving replay cleanly.

Discord: el8

…ode (--roce-hairpin)

Switchless multi-host RoCEv2 rings running `--roce-ring` connect only neighbor
queue pairs and forward non-neighbor transfers (such as `0 <-> 2` and `1 <-> 3`
in a 4-Spark ring) through the native host CPU proxy over 64 KiB software
mailboxes. ConnectX-7 NICs support wire-speed hardware hairpin forwarding
(`tc flower skip_sw` `in_hw`) between physical ports without crossing host PCIe
or CPU. Adding a `Shape::HairpinRing` (`--roce-hairpin`) mode lets intermediate
ConnectX-7 NICs forward non-neighbor RoCEv2 UDP/4791 packets in hardware while
ranks open direct all-to-all RC queue pairs without CPU proxy relaying or
changes to the native RoCE proxy ABI.

Exact changes:
- `helios/src/execution/roce_fabric.rs`: add `Shape::HairpinRing`
  (`relays() == false`, `linked() == (peer != rank)`), `plan_hairpin_ring_routes`,
  and `hairpin_equal_arc_pair`. Adjacent ring neighbors keep their physical
  cable links, non-neighbors pair arc-entry and arc-exit devices along the
  shorter arc, and equal-arc opposite pairs (`0 <-> 2` and `1 <-> 3` on a
  4-Spark ring) split Rail 0 clockwise and Rail 1 counter-clockwise while
  avoiding shared devices, PCIe links, and physical ports at both ends. Tighten
  `direct_peers` to require `same_link(x, y)` so multi-hop hairpin peers report
  `direct = false`.
- `helios/src/execution/roce.rs`: treat `Shape::HairpinRing` identically to
  `Shape::Mesh` in `RoceTransport::open` (`enabled = 0`, no `roce_enable_ring`),
  leaving the native C proxy and ABI 14 core layout unchanged.
- `flare-cli/src/{cli,cluster,distribution,fabric,fabric_transport,launch,main}.rs`
  and `flare-cli/src/orbit/{agent,controller,fabric,grant,store}.rs`: wire
  `--roce-hairpin` (mutually exclusive with `--roce-ring` and `--roce-chain`)
  across manual, `--hosts`, and Orbit launches with `hairpin-ring` rendezvous
  shape agreement, backward-compatible `#[serde(default)]` Orbit grant/store
  fields, and neighbor-relayed TCP core distribution so NIC hairpin rules need
  only offload RoCEv2 traffic.
- `scripts/setup_cx7_hairpin_ring.sh`: add a dry-run-by-default (`--apply`,
  `--verify`, `--teardown`) host setup helper generating per-rank ConnectX-7
  `tc flower skip_sw` L3 hairpin rules (`pedit` MAC rewrite plus `mirred egress
  redirect`) and static `/32` routes and permanent neighbor entries for a
  4-node ring.
- `docs/roce-ring.md` and `docs/cli-design.md`: document `--roce-hairpin`
  routing, host configuration, verification checks, and unverified hardware
  status.

Expected benefit: on switchless 4-Spark rings configured with ConnectX-7
hardware hairpin, eliminates CPU proxy relay hops and software mailbox copies
for non-neighbor collectives, splits diagonal traffic across both ring arcs and
both PCIe Gen5 x4 links per host, and reuses existing exported cores without
re-export. Mesh, ring, and chain behavior remain unchanged. No end-to-end
hardware performance improvement has been measured yet.

Evidence and material limitations:
- `cargo test --locked --release --manifest-path helios/Cargo.toml --features roce,runtime-core,server --lib roce`:
  46 passed, 0 failed (covering 4-Spark diagonal split-arc PCIe/port
  separation, symmetric 2..16-rank hairpin routing, and proxy preflight).
- `cargo test --locked --release --manifest-path flare-cli/Cargo.toml`:
  225 unit tests and 7 integration tests passed, 0 failed (covering CLI mutual
  exclusivity and forwarding, rendezvous shape agreement, neighbor-relayed TCP
  distribution, and Orbit fabric/grant/store validation).
- `bash -n scripts/setup_cx7_hairpin_ring.sh` and 4-rank dry-run verification
  checked all 8 unidirectional diagonal transit flows.
- Limitation: not yet tested on a physical switchless 4-Spark ring; live
  hardware validation is required for ConnectX-7 dual-PF switchdev `in_hw`
  offload, TC 0 PFC stability, 2-hop `ib_write_lat`, and multi-host `flare run
  --roce-hairpin` collective replay.

Discord: el8

Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
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.

1 participant