Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/native-serving.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,5 @@ jobs:
cargo check --locked --manifest-path selene/Cargo.toml --tests --features rdma
cargo check --locked --manifest-path selene-manager/Cargo.toml --tests --features rdma
cargo check --locked --manifest-path flare-cli/Cargo.toml --tests --features roce,rdma
- name: Test native RoCE transport
run: cargo test --locked --release --manifest-path helios/Cargo.toml --features roce --lib execution::roce
2 changes: 1 addition & 1 deletion docs/cli-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,7 @@ on these hosts and are unverified when no GPU is selected or detected.
- PCI identifies the ConnectX-7 physical function (`15b3:1021`) even if its
RDMA driver has not bound. The fabric check is not applicable when the
adapter is absent.
- The report uses serving's RoCEv2 GID index and lists the selected
- The report uses serving's per-device RoCEv2 GID indices and lists the selected
ConnectX-7 devices, interface names, IPv4 prefixes, and observed MTUs.
One active device with an assigned IPv4 address and RoCEv2 GID is
sufficient. The report identifies active devices skipped by discovery.
Expand Down
27 changes: 14 additions & 13 deletions docs/roce-ring.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ that receiving kernels wait for. The proxy performs transport work, not the
model's reductions.

Ring mode also allocates registered host memory on each rank at startup, sized
for the group: about 1.004 MiB per rank in the group, so 4.02 MiB on each rank
of a four-rank group and 16.06 MiB at sixteen ranks. This region contains
eight relay mailboxes, acknowledgment words, and outgoing descriptors for every
for the group: about 2.008 MiB per rank in the group, so 8.03 MiB on each rank
of a four-rank group and 32.13 MiB at sixteen ranks. This region contains
sixteen relay mailboxes, acknowledgment words, and outgoing descriptors for every
origin rank and each of two rails. It is
separate from captured graph storage and the core's collective region.
Relay payloads occupy at most 64 KiB per packet.
Expand All @@ -126,7 +126,7 @@ A transfer from rank 0 to rank 2 through rank 1 proceeds as follows:
The last relay waits for its send completion, then acknowledges the packet
to the preceding hop. Longer paths pass acknowledgments back through each
relay to the origin.
4. Rank 0 keeps at most eight packets in flight on a rail: it reuses a mailbox
4. Rank 0 keeps at most sixteen packets in flight on a rail: it reuses a mailbox
slot only after the acknowledgment of the packet that last used that slot
returns. Relay buffers and outgoing descriptors remain live until
downstream acknowledgment permits reuse.
Expand Down Expand Up @@ -158,13 +158,14 @@ uv sync --locked --extra prepare --extra test
cargo build --release --manifest-path flare-cli/Cargo.toml
```

Preparation and serving use proxy ABI 14. Its proxy holds eight packets in flight per sender and
rail in ring mailboxes that the runtime allocates at startup, serves the pipelined reduce-scatter
and shard-gather operations, connects four queue-pair lanes per rail, and exchanges start-of-op
credits between proxies. Cores recording proxy ABI 9, 10 or 11 have the same captured region
layout, so the runtime loads cores that record ABI 9, 10, 11 or 14. Serving does not enable
FlashInfer's all-gather relay. The chain topology is a mode of this layout, and startup rejects
any other proxy ABI before replay.
Preparation and serving use proxy ABI 14. Its proxy holds sixteen packets in flight per sender and
rail in ring mailboxes that the runtime allocates at startup (validated across ranks during
connect), serves the pipelined reduce-scatter, shard-gather, and closed-ring 1-hop bidirectional
reduce-scatter and shard-gather operations, connects four queue-pair lanes per rail, and exchanges
start-of-op credits between proxies. Cores recording proxy ABI 9, 10 or 11 have the same captured
region layout, so the runtime loads cores that record ABI 9, 10, 11 or 14. Serving does not enable
FlashInfer's all-gather relay. The chain topology is a mode of this layout, and startup rejects any
other proxy ABI before replay.

### Prepare across four hosts

Expand Down Expand Up @@ -415,9 +416,9 @@ failed collective as a completed model step.

| Component | Responsibility |
| --- | --- |
| [Fabric discovery and route planning](../helios/src/execution/roce_fabric.rs) | Finds host devices and builds symmetric neighbor routes. |
| [Fabric discovery and route planning](../helios/src/execution/roce_fabric.rs) | Finds host devices with per-HCA GIDs and builds symmetric neighbor routes. |
| [Native transport owner](../helios/src/execution/roce.rs) | Validates the core ABI and layout, registers its region, enables the ring, and retains transport resources. |
| [RDMA proxy](../helios/native/roce_proxy.c) | Posts direct and relayed writes, progresses mailboxes and acknowledgments, and releases two-shot send buffers. |
| [RDMA proxy](../helios/native/roce_proxy.c) | Posts direct, 1-hop closed-ring, and relayed writes, progresses mailboxes and acknowledgments, and releases two-shot send buffers. |
| [Serving distribution](../flare-cli/src/distribution.rs) | Receives and verifies rank cores before handing rendezvous sockets to serving. |
| [Cluster startup](../flare-cli/src/cluster.rs) | Exchanges endpoints and connection records before native replay. |
| [Collective preparation](../ignition/preparation/collectives.py) | Passes the routing choice to b12x and retains the transport through export. |
Expand Down
117 changes: 107 additions & 10 deletions flare-cli/src/doctor/spark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ fn inspect(
));
}

// Use the same GID index and assigned-address verification as serving.
// Use the same per-device GID indices and assigned-address verification as serving.
let fabric = discover();
let mut ready = Vec::new();
if let Ok(fabric) = &fabric {
let mut unresolved = Vec::new();
for endpoint in &fabric.endpoints {
for (idx, endpoint) in fabric.endpoints.iter().enumerate() {
// Serving discovers every RDMA adapter. This check covers ConnectX-7 devices.
if !active.contains(&endpoint.name) {
continue;
Expand All @@ -158,9 +158,13 @@ fn inspect(
unresolved.push(endpoint.name.as_str());
continue;
};
let Some(gid_index) = fabric.gid_index_for(idx) else {
unresolved.push(endpoint.name.as_str());
continue;
};
let netdev = root
.join(&endpoint.name)
.join(format!("ports/1/gid_attrs/ndevs/{}", fabric.gid_index));
.join(format!("ports/1/gid_attrs/ndevs/{gid_index}"));
let Some(interface) = read(&netdev) else {
unresolved.push(endpoint.name.as_str());
continue;
Expand All @@ -170,22 +174,24 @@ fn inspect(
ready.push(Interface {
device: &endpoint.name,
interface,
gid_index,
address,
prefix,
mtu,
});
}
if !ready.is_empty() {
if let Some((first_ready, rest_ready)) = ready.split_first() {
let listed = ready
.iter()
.map(Interface::describe)
.collect::<Vec<_>>()
.join(", ");
let rest_gids: Vec<u32> = rest_ready.iter().map(|port| port.gid_index).collect();
let gid_label = format_gid_indices(first_ready.gid_index, &rest_gids);
let mut detail = format!(
"{} of {} active CX7 devices supply IPv4 endpoints for serving at RoCEv2 GID index {}: {listed}.",
"{} of {} active CX7 devices supply IPv4 endpoints for serving at RoCEv2 GID {gid_label}: {listed}.",
ready.len(),
active.len(),
fabric.gid_index
);
let mut warnings = configuration_warnings(&ready);
if ready.iter().any(Interface::is_link_local) {
Expand Down Expand Up @@ -235,10 +241,15 @@ fn inspect(

let reason = match fabric {
Err(error) => error.to_string(),
Ok(fabric) => format!(
"discovery could not verify a local IPv4 address and prefix on a ConnectX-7 device at RoCEv2 GID index {}",
fabric.gid_index
),
Ok(fabric) => {
let gid_label = match fabric.gid_indices.split_first() {
Some((&first, rest)) => format_gid_indices(first, rest),
None => format!("index {}", fabric.gid_index()),
};
format!(
"discovery could not verify a local IPv4 address and prefix on a ConnectX-7 device at RoCEv2 GID {gid_label}"
)
}
};
Ok(result(
CheckStatus::Warn,
Expand All @@ -250,9 +261,25 @@ fn inspect(
))
}

fn format_gid_indices(first: u32, rest: &[u32]) -> String {
if rest.iter().all(|&g| g == first) {
format!("index {first}")
} else {
format!(
"indices [{}]",
std::iter::once(first)
.chain(rest.iter().copied())
.map(|g| g.to_string())
.collect::<Vec<_>>()
.join(", ")
)
}
}

struct Interface<'a> {
device: &'a str,
interface: String,
gid_index: u32,
address: Ipv4Addr,
prefix: u8,
mtu: Option<u32>,
Expand Down Expand Up @@ -491,13 +518,15 @@ mod tests {
Interface {
device: "roce0",
interface: "enp1s0f0np0".into(),
gid_index: 3,
address: Ipv4Addr::new(192, 168, 0, 0),
prefix: 31,
mtu: Some(9000),
},
Interface {
device: "roce1",
interface: "enp1s0f1np1".into(),
gid_index: 3,
address: Ipv4Addr::new(192, 168, 1, 15),
prefix: 24,
mtu: Some(9000),
Expand All @@ -521,4 +550,72 @@ mod tests {
interfaces.iter_mut().for_each(|port| port.prefix = 16);
assert!(configuration_warnings(&interfaces).is_empty());
}

#[test]
fn cx7_readiness_handles_distinct_per_hca_gid_indices() {
let dir = tempfile::tempdir().unwrap();
let sysfs = dir.path();
add_spark(sysfs);
let root = sysfs.join("class/infiniband");
for (dev, net, gid_idx, gid_hex) in [
("roce0", "enP2p1s0f0np0", 3, "c0a8:650a"),
("roce1", "enp1s0f0np0", 5, "c0a8:640a"),
] {
write(&root, &format!("{dev}/device/vendor"), "0x15b3\n");
write(&root, &format!("{dev}/device/device"), "0x1021\n");
let port = root.join(dev).join("ports/1");
write(&port, "state", "4: ACTIVE\n");
write(
&port,
&format!("gid_attrs/ndevs/{gid_idx}"),
&format!("{net}\n"),
);
write(&port, &format!("gid_attrs/types/{gid_idx}"), "RoCE v2\n");
write(
&port,
&format!("gids/{gid_idx}"),
&format!("0000:0000:0000:0000:0000:ffff:{gid_hex}\n"),
);
write(sysfs, &format!("class/net/{net}/mtu"), "9000\n");
}
// Decoy IPv6 RoCEv2 entry at index 3 on roce1 so reading a uniform ndevs/3 would fail.
let roce1_port = root.join("roce1/ports/1");
write(&roce1_port, "gid_attrs/ndevs/3", "decoy0\n");
write(&roce1_port, "gid_attrs/types/3", "RoCE v2\n");
write(
&roce1_port,
"gids/3",
"fe80:0000:0000:0000:0200:00ff:fe00:0001\n",
);

let rep = report(sysfs, |netdev, _| {
matches!(netdev, "enP2p1s0f0np0" | "enp1s0f0np0").then_some(24)
});
let check = cx7(&rep);
assert!(rep.ok);
assert_eq!(check.status, CheckStatus::Pass, "{}", check.detail);
assert!(
check.detail.contains("2 of 2 active CX7 devices"),
"{}",
check.detail
);
assert!(check.detail.contains("indices [3, 5]"), "{}", check.detail);
assert!(check.detail.contains("enp1s0f0np0"), "{}", check.detail);
assert!(!check.detail.contains("decoy0"), "{}", check.detail);

// When no local IPv4 prefix resolves, the Warn fallback also reports all selected indices.
let warn_rep = report(sysfs, |_, _| None);
let warn_check = cx7(&warn_rep);
assert_eq!(
warn_check.status,
CheckStatus::Warn,
"{}",
warn_check.detail
);
assert!(
warn_check.detail.contains("indices [3, 5]"),
"{}",
warn_check.detail
);
}
}
29 changes: 26 additions & 3 deletions heliopause/src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ fn flare_heliopause(module: &Bound<'_, PyModule>) -> PyResult<()> {
module.add_class::<NativeServer>()?;
module.add_function(wrap_pyfunction!(current_context, module)?)?;
module.add_function(wrap_pyfunction!(memory_inventory, module)?)?;
module.add_function(wrap_pyfunction!(roce_devices, module)?)?;
module.add_function(wrap_pyfunction!(roce_gid_index, module)?)?;
module.add_function(wrap_pyfunction!(serve_tensor_parallel_rank, module)?)?;
#[cfg(target_os = "linux")]
Expand All @@ -689,14 +690,36 @@ fn memory_inventory(py: Python<'_>) -> PyResult<Bound<'_, pyo3::types::PyDict>>
Ok(result)
}

/// This host's RoCE GID index by the rule native serving uses: 3 when every active device has a
/// RoCEv2 IPv4 GID there, otherwise the lowest index at which one does.
/// The first selected RoCE device's GID index by the rule native serving uses: each active device
/// prefers index 3 when it has a RoCEv2 IPv4 GID there, otherwise its own lowest RoCEv2 IPv4 GID
/// index. Prefer `roce_devices` when HCAs on the host may have distinct GID indices.
#[pyfunction]
fn roce_gid_index() -> PyResult<u32> {
#[cfg(target_os = "linux")]
{
crate::execution::roce_fabric::discover()
.map(|fabric| fabric.gid_index)
.map(|fabric| fabric.gid_index())
.map_err(|error| PyRuntimeError::new_err(error.to_string()))
}
#[cfg(not(target_os = "linux"))]
Err(PyRuntimeError::new_err("RoCE preparation requires Linux"))
}

/// This host's discovered RoCE devices and their per-device RoCEv2 IPv4 GID indices, in the same
/// name-sorted order as native serving discovery.
#[pyfunction]
fn roce_devices() -> PyResult<Vec<(String, u32)>> {
#[cfg(target_os = "linux")]
{
crate::execution::roce_fabric::discover()
.map(|fabric| {
fabric
.endpoints
.into_iter()
.zip(fabric.gid_indices)
.map(|(endpoint, gid_index)| (endpoint.name, gid_index))
.collect()
})
.map_err(|error| PyRuntimeError::new_err(error.to_string()))
}
#[cfg(not(target_os = "linux"))]
Expand Down
Loading
Loading