#1 [high] S1: c->gid_index in roce_ctx_t is now write-only dead state
helios/native/roce_proxy.c:268 int gid_index; inside the roce_ctx_t typedef (fields 262-300). Written once at :558 c->gid_index = gid_indices[0];. Grep of the whole file for gid_index returns only: 259 (roce_hca_t field, needed), 461 (hca read in open_hca, needed), 558 (ctx write), 577 (hca write, needed), 587/597 (roce_create wrapper), 680 (hca read in connect_qp, the actual fix). So ctx->gid_index is write-only: connect_qp was changed from c->gid_index to hca->gid_index (:680). roce_ctx_t is opaque to Rust (FFI holds a *mut context; roce_blob_t at :240-243 carries only mtu/qp_num/lanes), so deleting the field changes no ABI.
Simplification: delete line 268 from the typedef and delete line 558. Two fewer lines of fork from the vendored FlashInfer source (header at roce_proxy.c:6-8 demands the body stay identical), and removes a second, divergent source of truth for the GID index (ctx value = gid_indices[0] while QPs use per-HCA values -> a latent trap = pure subtraction.
#2 [high] S2: roce_create wrapper is dead code with duplicated validation
helios/native/roce_proxy.c:587-601 is the whole roce_create wrapper: it re-checks n_hca < 1 || n_hca > ROCE_MAX_HCAS (needed only so the gids[] fill cannot overflow), fills int gids[ROCE_MAX_HCAS] with the single index, and tail-calls roce_create_with_gids.
Callers: grep roce_create across the repo = roce_proxy.c:531 (with_gids def), :587 (wrapper def), :599 (its tail call), helios/src/execution/roce.rs:46 (FFI decl of with_gids), roce.rs:205 (single call site). Nothing declares or calls roce_create any more; the Rust FFI was switched wholesale to roce_create_with_gids. roce_proxy_dlopen.c:236 #include "roce_proxy.c" compiles it into the same object, so there is no dynamic-symbol indirection either.
Simplification: delete lines 587-601 (and with them the duplicate bounds check and the ROCE_MAX_HCAS stack array). If it is meant for out-of-tree FlashInfer callers, that is exactly the vendored-parity claim in docs/roce-ring.md:360-364 which the file header (roce_proxy.c:6-8) asserts and nothing tests.
#3 [high] S3: gid_index duplicated alongside gid_indices, plus 3 redundant fallbacks
One fact (the GID index per device) is stored twice and recovered by three fallbacks, all of which exist only for test fixtures.
(a) helios/src/execution/roce_fabric.rs:430-431
let gid_index = devices[0].1;
let gid_indices: Vec<u32> = devices.iter().map(|(_, gid, _)| *gid).collect();
gid_index is, by construction, gid_indices[0] — derived state stored separately.
(b) roce_fabric.rs:1027-1031 in Fabric::topology:
let gid_indices = if self.gid_indices.len() == self.endpoints.len() {
self.gid_indices.clone()
} else {
vec![self.gid_index; self.endpoints.len()]
};
In discover_in (the only producer) gid_indices.len() == endpoints.len() always, because both are built from the same devices vector. The else branch is reachable only from the three hand-built test fixtures that set gid_indices: Vec::new() (roce_fabric.rs:1567, :1682, :1834; roce.rs:397).
(c) roce_fabric.rs:1006-1011 gid_index_for repeats the same fallback:
pub fn gid_index_for(&self, index: usize) -> u32 {
self.gid_indices.get(index).copied().unwrap_or(self.gid_index)
}
Because gid_indices is exactly parallel to endpoints, self.gid_indices[index] is the honest expression; the .get(..).unwrap_or(..) masks a producer bug rather than covering a real case.
(d) helios/src/execution/roce.rs:199-203 a third copy of the same fallback:
let gid_indices: Vec<c_int> = if topology.gid_indices.len() == pointers.len() {
topology.gid_indices.iter().map(|&g| g as c_int).collect()
} else {
vec![topology.gid_index as c_int; pointers.len()]
};
pointers.len() is topology.hcas.len(), and Topology::gid_indices is produced with self.endpoints.len() == hcas.len() in that same function. So all three branches are dead in production and none has a test (roce.rs is #[cfg(feature = "roce")], so CI only compiles it).
Simplification: keep gid_indices: Vec<u32> as the single stored fact on Fabric and Topology; expose pub fn gid_index(&self) -> u32 { self.gid_indices[0] } for the one outside consumer (heliopause/src/python.rs:698-699 fabric.gid_index, prep path) and for the doctor's warn text (spark.rs:254); make gid_index_for a plain index; delete the two if len == len { clone } else { vec![..] } blocks and the .unwrap_or. Fix the four fixtures to carry real indices (gid_indices: vec![3; 2]) instead of Vec::new(). Net: ~20 lines gone, one invariant expressed once instead of four times.
#5 [high] Research summary
Subtraction/simplicity review of #672 complete. The Rust discovery fix itself is lean and idiomatic (the pick_gid_index closure and the filter_map/take/is_empty restructure are strictly simpler than main's two-pass global-index selection); the removable code is concentrated in the native proxy and in the redundant plumbing of the new per-HCA index.
Four findings, all in the scratchpad with verbatim quotes and line numbers:
roce_ctx_t.gid_indexis now write-only (helios/native/roce_proxy.c:268, written at:558). Sinceconnect_qpswitched tohca->gid_index(:680), nothing reads the ctx-level copy.roce_ctx_tis opaque to the Rust FFI and absent fromroce_blob_t, so deleting the field and its assignment is ABI-neutral — two fewer lines of fork from the vendored source, and one fewer divergent source of truth.roce_create(roce_proxy.c:587-601) is dead code with a duplicated bounds check. Every in-tree caller now goes toroce_create_with_gids; the 15-line wrapper exists only to fill aROCE_MAX_HCASarray and re-validaten_hca. Delete it (or keep it only if an out-of-tree FlashInfer caller is demonstrated — which is exactly the untested parity claim indocs/roce-ring.md:360-364).- The per-HCA index is stored twice and recovered by three fallback branches, all dead in production and none tested.
gid_indexis by constructiongid_indices[0](roce_fabric.rs:430-431);Fabric::topologyre-derives a same-length vec with anelsebranch reachable only fromVec::new()test fixtures (:1027-1031);gid_index_forrepeats the fallback (:1006-1011);roce.rs:199-203repeats it a third time. Collapse to one storedVec<u32>plus agid_index()accessor and fix the four fixtures; ~20 lines gone. - (Low)
flare-cli/src/doctor/spark.rs:150/179/181-198builds a parallelready_gidsvec only to format a mixed/single label; folding the index intoInterfaceor always printingindices [...]removes the array and the branch, and also removes the inconsistency with the terminalWarntext at:250-256, which still uses singularfabric.gid_index.
Also noted: doc updates that AGENTS.md:234 requires for transport changes (docs/multi-host.md (not opened), docs/roce-ring.md) are absent, and the header of the edited vendored file still claims byte parity with FlashInfer — both are convention-level rather than code-shape issues.
#6 [medium] S0: what is already lean in this diff (no action needed)
Verified by reading helios/src/execution/roce_fabric.rs:404-476 at head: the new shape is strictly simpler than main's rule, not more convoluted.
- main computed a host-wide index with two passes (an
all()over names at PREFERRED_GID_INDEX, else(0..GID_TABLE).find(any)), then filtered the device list by that index, then mapped. Head collapses it to one closure + onefilter_map(pick_gid_indexat :407-413, used at :414-426) and replaces main's.ok_or_else(...)with a plainif devices.is_empty() { return Err(...) }at :427-429 — clearer, same behaviour. - No new flag, env var, config key, trait, or generic parameter is introduced.
MAX_DEVICES/PREFERRED_GID_INDEX/GID_TABLEare unchanged constants (:62-65); PREFERRED_GID_INDEX stays the single pinned default rather than growing a configurable cousin. - The
.take(MAX_DEVICES)move from before the map to afterfilter_map(:425) is required by the new per-device selection and does not add a branch. - The doctor's per-endpoint
gid_index_for(idx)(:162) correctly replaces a single global index; enumerating with.iter().enumerate()(:153) is the minimum needed. - The two new tests (roce_fabric.rs:1181-1219, spark.rs:539-576) are focused single-behaviour unit tests, not scaffolding; nothing to trim there.
- No speculative generality: the PR introduces no abstraction layer, no new module, no trait object. The removable code is the four items in notes #1-#4, not the design.
Conclusion for the report: the Rust half of the diff is lean and idiomatic; the subtraction findings are (a) dead/duplicated state in the vendored C and (b) triple-redundant fallbacks around a single invariant.
#7 [medium] S5: convention items — stale docs and vendored-parity header (not code shape)
These are structural-convention issues, adjacent to the subtraction lens; keep them short in the report.
VERIFIED BY ME at head:
- helios/native/roce_proxy.c:6-8 header, verbatim: "// Vendored from FlashInfer's pinned preparation dependency / (flashinfer/experimental/b12x/comm/roce/_roce_proxy.c, proxy ABI 14). / Keep the source below identical so preparation and serving share the transport ABI." The PR edits the source below it (
roce_hca_t:256-260,open_hca:461,connect_qp:680,roce_create_with_gids:531-585, wrapper :587-601) with no upstream FlashInfer revision cited in the diff or description, so the header is now false as written. - helios/native/roce_proxy_dlopen.c:7-9, verbatim: "// ... while / keeping the vendored roce_proxy.c byte-for-byte identical to FlashInfer." Also now false; note dlopen.c:236
#include "roce_proxy.c"pulls the fork into the built object silently. - docs/roce-ring.md:360-364, verbatim: "Flare vendors the serving proxy in
helios/native/roce_proxy.c; preparation uses the pinned FlashInfer dependency. When changing the protocol, keep the vendored source identical to the dependency after its provenance header and verify their ABI and collective-region layouts together." This is the repo's own stated rule; #672 breaks it and does not amend it. Since docs/roce-ring.md:161 declares proxy ABI 14 and PROXY_ABI is still 14 (helios/src/execution/roce.rs:23), the ABI number need not change — the parity statement does. - AGENTS.md:234 table row, verbatim: "| Change Orbit, host agents, or multi-host preparation, serving, or transport | Orbit, multi-host serving, and the RoCE ring |". A transport change is in scope for all three; the diff touches only Rust, C and a CLI test. docs/orbit.md not opened.
- AGENTS.md:188-193, verbatim: "Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement." This is the charter backing for findings #1-#3 (the fallback layers with no concrete requirement, the speculative-compatibility wrapper).
FROM THE DOSSIER, NOT RE-VERIFIED BY ME (phrase as "reported", not "verified"): docs/multi-host.md:42-43 ("Active RoCEv2 ports with IPv4 GIDs"), docs/multi-host.md:102-130, docs/roce-ring.md:405, docs/cli-design.md:1695-1698 (doctor wording, singular index) and :1707-1714 ("RoCEv2 GID index 3") all still describe the old single host-wide index rule.
Also from my own read: the doctor's terminal Warn fallback at flare-cli/src/doctor/spark.rs:250-256 still formats the singular "at RoCEv2 GID index {}" from fabric.gid_index, inconsistent with the new "indices [a, b]" wording at :187-198 — folded into note #4.
#4 [low] S4: doctor ready_gids parallel vec + mixed-label branch
flare-cli/src/doctor/spark.rs:150 introduces let mut ready_gids = Vec::new(); — a second vector parallel to ready (built at :149) and pushed in lockstep at :179 ready_gids.push(gid_index);. Then :181-198 spends 12 lines minting a label:
let gid_label = if ready_gids.iter().all(|&g| g == ready_gids[0]) {
format!("index {}", ready_gids[0])
} else {
format!(
"indices [{}]",
ready_gids
.iter()
.map(u32::to_string)
.collect::<Vec<_>>()
.join(", ")
)
};
Two cheaper options, both removing a parallel array and the branch:
- Add
gid_index: u32toInterface(spark.rs:267-273) next todevice/interface; the label becomesready.iter().map(|i| i.gid_index).collect::<Vec<_>>()rendered once, andconfiguration_warningsdoes not care about the extra field. - Or drop the special case and always print
indices [3, 3]/indices [3, 5](one format!, no branch), which also fixes the inconsistency that the terminalWarnpath at :250-256 still says "at RoCEv2 GID index {}" singular fromfabric.gid_index. Either way ~10 lines go.
Low importance: this is the least of the four; the duplicate-array pattern is the structural point, and the single-vs-mixed wording is presentation.