Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/cli-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,11 @@ cannot honor the settings reports a capacity error in the section 6 form.
### Experimental RoCE ring configuration

`ignition export` and `ignition debug-serve` accept `--roce-ring` or `--roce-chain` with `--ranks N`;
`flare run` and `flare orbit run` accept it with a multi-host core. Rank
`flare run`, `flare orbit run`, and `flare orbit push` accept `--roce-ring`, `--roce-chain`, or
`--roce-hairpin` with a multi-host core (mutually exclusive). `--roce-hairpin` opens direct
all-to-all RoCEv2 queue pairs over a switchless physical ring configured with ConnectX-7 NIC-level
hardware hairpin (`skip_sw` `in_hw`), without native CPU proxy relaying, while keeping
neighbor-relayed TCP paths for core distribution. Rank
order defines the ring, including the cluster's node order when agents launch
ranks. The transport accepts 2..16
ranks, while recipe validation retains each model's supported TP sizes. This
Expand Down
55 changes: 53 additions & 2 deletions docs/roce-ring.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ authenticated agent sessions and signed grants. See
[core transfers](orbit.md#core-transfers-through-fabric-interfaces).

The ring can run over a switch or hosts cabled directly to their neighbors.
Forwarding runs on host CPUs; ConnectX hardware hairpin forwarding is not
implemented.
With `--roce-ring` or `--roce-chain`, forwarding runs on host CPUs through the
native proxy. With `--roce-hairpin`, every rank opens direct RoCEv2 queue pairs
to every peer without CPU proxy relaying, relying on ConnectX-7 NIC-level
hardware hairpin (`skip_sw` `in_hw`) configured on intermediate hosts to forward
non-neighbor RoCEv2 packets between physical ports.

## Rank order and routes

Expand Down Expand Up @@ -397,6 +400,54 @@ and reserves zero as the healthy error sentinel. It applies to mesh and ring
routing, independently of the number of model steps or requests. Sequence wrap
is unsupported; restarting the proxy thread alone does not reset the runtime.

## Hardware-hairpin ring (`--roce-hairpin`)

`--roce-hairpin` (mutually exclusive with `--roce-ring` and `--roce-chain`)
targets switchless physical rings whose intermediate ConnectX-7 NICs forward
non-neighbor RoCEv2 UDP/4791 packets directly in hardware (`tc flower skip_sw`
`in_hw`), bypassing host CPU and PCIe relay hops.

### Route planning and proxy behavior

- Every rank opens direct RC queue pairs to every peer (`Shape::HairpinRing`
with `relays() == false`), using the unmodified native RoCE proxy ABI and
existing exported cores without re-export.
- Direct ring neighbors (`(rank + 1) % N` and `(rank + N - 1) % N`) use their
physical point-to-point cable links, matching `--roce-ring`.
- Non-neighbor peers pair each rank's arc-entry device with the peer's arc-exit
device along the shorter arc around the cycle.
- On equal-length arcs (diagonals `0 <-> 2` and `1 <-> 3` in a 4-Spark ring),
a two-rail topology splits traffic across both arcs: Rail 0 crosses the
clockwise arc and Rail 1 crosses the counter-clockwise arc, choosing rail
slots that keep PCIe links and physical ports disjoint at both ends.
- Bulk TCP core distribution (`flare-cli/src/fabric.rs`) retains neighbor-relayed
ring paths so NIC hairpin rules need only offload RoCEv2 traffic.

### Host setup and verification

Flare does not modify host NIC switchdev mode, `tc` offload filters, static
routes, or ARP tables. Configure and verify hardware hairpin on each ring node
before launching `flare run --roce-hairpin` or `flare orbit run --roce-hairpin`.

[scripts/setup_cx7_hairpin_ring.sh](../scripts/setup_cx7_hairpin_ring.sh)
generates (dry-run by default), applies (`--apply`), verifies (`--verify`), or
removes (`--teardown`) the per-node 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.

Before running model traffic, confirm:

1. Every intermediate node's transit filter reports `in_hw` in
`tc -s filter show dev <if> ingress` (no software fallback).
2. Direct 2-hop RDMA latency (`ib_write_lat -d <local_hca> -x 3 <remote_ip>`)
succeeds across both diagonal pairs (`0 <-> 2` and `1 <-> 3`) on both arcs
with zero dropped or retransmitted packets.
3. Priority flow control (PFC) on TC 0 remains active on all ring ports.

Physical switchless 4-Spark hardware validation of `--roce-hairpin` is pending;
unit tests cover route symmetry, PCIe-link and physical-port separation, proxy
preflight, CLI forwarding, and Orbit grant validation.

## Failures

| Symptom | Check |
Expand Down
66 changes: 64 additions & 2 deletions flare-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,10 @@ pub struct OrbitPush {
#[arg(long, conflicts_with = "roce_ring")]
pub roce_chain: bool,

/// Stream core data through fabric interfaces in hardware-hairpin ring order.
#[arg(long, conflicts_with_all = ["roce_ring", "roce_chain"])]
pub roce_hairpin: bool,

/// Parallel TCP streams per destination file over the fabric [default: 8].
#[arg(long, value_name = "N", value_parser = clap::value_parser!(u8).range(1..=64))]
pub transfer_streams: Option<u8>,
Expand All @@ -535,6 +539,7 @@ impl OrbitPush {
no_advertise: false,
roce_ring: self.roce_ring,
roce_chain: self.roce_chain,
roce_hairpin: self.roce_hairpin,
rendezvous: None,
rank: None,
hosts: Vec::new(),
Expand Down Expand Up @@ -624,6 +629,16 @@ pub struct OrbitRun {
)]
pub roce_chain: bool,

/// Experimental hardware-hairpin ring in rank order: hosts cabled in a ring with ConnectX-7
/// NIC-level hardware hairpin (`skip_sw` `in_hw`); all ranks open direct RoCE QPs without CPU
/// proxy relaying.
#[arg(
long,
conflicts_with_all = ["roce_ring", "roce_chain"],
help_heading = "Multi-host options"
)]
pub roce_hairpin: bool,

/// IP address for rank zero's HTTP server [default: saved group or 127.0.0.1].
#[arg(long, value_name = "ADDR", help_heading = "Serving options")]
pub host: Option<IpAddr>,
Expand Down Expand Up @@ -724,6 +739,7 @@ impl OrbitRun {
no_advertise: self.no_advertise,
roce_ring: self.roce_ring,
roce_chain: self.roce_chain,
roce_hairpin: self.roce_hairpin,
rendezvous: None,
rank: None,
hosts: Vec::new(),
Expand Down Expand Up @@ -808,6 +824,16 @@ pub struct Run {
)]
pub roce_chain: bool,

/// Experimental hardware-hairpin ring in rank order: hosts cabled in a ring with ConnectX-7
/// NIC-level hardware hairpin (`skip_sw` `in_hw`); all ranks open direct RoCE QPs without CPU
/// proxy relaying.
#[arg(
long,
conflicts_with_all = ["roce_ring", "roce_chain"],
help_heading = "Multi-host options"
)]
pub roce_hairpin: bool,

/// Rank zero's rendezvous address: where rank zero listens, or on a peer, where it joins rank zero.
#[arg(long, value_name = "HOST:PORT", help_heading = "Multi-host options")]
pub rendezvous: Option<String>,
Expand Down Expand Up @@ -1125,8 +1151,11 @@ impl Run {
/// graphs and capacities on every host.
#[cfg(test)]
pub fn rank_options(&self) -> Vec<String> {
self.serving
.rank_options(Shape::from_flags(self.roce_ring, self.roce_chain))
self.serving.rank_options(Shape::from_flags(
self.roce_ring,
self.roce_chain,
self.roce_hairpin,
))
}

pub fn load_options(&self) -> LoadOptions {
Expand Down Expand Up @@ -1154,6 +1183,7 @@ impl ServingOptions {
Shape::Mesh => {}
Shape::Ring => options.push("--roce-ring".into()),
Shape::Chain => options.push("--roce-chain".into()),
Shape::HairpinRing => options.push("--roce-hairpin".into()),
}
if self.roce_switch_only {
options.push(ROCE_SWITCH_ONLY.into());
Expand Down Expand Up @@ -1865,6 +1895,38 @@ mod tests {
assert_eq!(args.rank_options(), vec!["--roce-ring"]);
}

#[test]
fn hairpin_flag_is_forwarded_and_excludes_ring_and_chain() {
let args = run(&["flare", "run", "model.safetensors", "--roce-hairpin"]);
assert!(args.roce_hairpin && !args.roce_ring && !args.roce_chain);
assert_eq!(args.rank_options(), vec!["--roce-hairpin"]);
assert!(
Cli::try_parse_from(["flare", "run", "m.safetensors", "--roce-hairpin", "--roce-ring"])
.is_err()
);
assert!(
Cli::try_parse_from([
"flare",
"run",
"m.safetensors",
"--roce-hairpin",
"--roce-chain",
])
.is_err()
);
assert!(
Cli::try_parse_from([
"flare",
"orbit",
"run",
"m.safetensors",
"--roce-hairpin",
"--roce-ring",
])
.is_err()
);
}

#[test]
fn switch_only_flag_is_forwarded_to_every_agent_started_rank() {
let args = run(&["flare", "run", "model.safetensors", "--roce-switch-only"]);
Expand Down
12 changes: 10 additions & 2 deletions flare-cli/src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ fn connected(transport: &RoceTransport) -> String {
Shape::Mesh => "peer",
Shape::Ring => "neighbor (experimental CPU relay ring)",
Shape::Chain => "neighbor (experimental CPU relay chain)",
Shape::HairpinRing => "peer (experimental hardware-hairpin ring)",
},
match topology.links {
Links::All => "",
Expand All @@ -110,8 +111,8 @@ fn connected(transport: &RoceTransport) -> String {
}

/// The transport shape a rank was started with and the links it may route over, as the ranks
/// exchange them before planning routes: `mesh`, `ring` or `chain`, followed by ` switch-only`
/// when direct cables are excluded.
/// exchange them before planning routes: `mesh`, `ring`, `chain`, or `hairpin-ring`, followed by
/// ` switch-only` when direct cables are excluded.
#[cfg(all(target_os = "linux", any(target_arch = "aarch64", feature = "roce")))]
fn shape_record(routing: Routing) -> Vec<u8> {
let links = match routing.links {
Expand Down Expand Up @@ -331,6 +332,13 @@ mod routing_tests {
};
assert_eq!(shape_record(mesh), b"mesh");
assert_eq!(shape_record(switched), b"mesh switch-only");
let hairpin = Routing {
shape: Shape::HairpinRing,
links: Links::All,
};
assert_eq!(shape_record(hairpin), b"hairpin-ring");
assert!(agree_shape(&vec![shape_record(hairpin); 4], hairpin).is_ok());
assert!(agree_shape(&[shape_record(hairpin), shape_record(mesh)], hairpin).is_err());
assert!(agree_shape(&vec![shape_record(switched); 2], switched).is_ok());
let error = agree_shape(&[shape_record(mesh), shape_record(switched)], mesh)
.unwrap_err()
Expand Down
5 changes: 5 additions & 0 deletions flare-cli/src/distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ pub fn root(
&endpoints.iter().map(|e| e.port).collect::<Vec<_>>(),
args.roce_ring,
args.roce_chain,
args.roce_hairpin,
args.serving.roce_switch_only,
)?;
let relay = Relay::start(0, streams, topology.clone(), network, source.port)?;
Expand Down Expand Up @@ -396,6 +397,9 @@ pub fn peer(args: &mut Run, progress: &mut StartupProgress) -> Result<Received,
if args.roce_chain && !plan.topology.chain {
return Err("rank zero did not select --roce-chain".into());
}
if args.roce_hairpin && !plan.topology.hairpin {
return Err("rank zero did not select --roce-hairpin".into());
}
if args.serving.roce_switch_only && !plan.topology.switch_only {
return Err("rank zero did not select --roce-switch-only".into());
}
Expand All @@ -404,6 +408,7 @@ pub fn peer(args: &mut Run, progress: &mut StartupProgress) -> Result<Received,
}
args.roce_ring = plan.topology.ring;
args.roce_chain = plan.topology.chain;
args.roce_hairpin = plan.topology.hairpin;
args.serving.roce_switch_only = plan.topology.switch_only;
args.stage_only = plan.stage_only;
select_plan_tensor_parallel(args, plan.tensor_parallel)?;
Expand Down
Loading
Loading