Final review report · NVIDIA/hyperflare-inference #640

Raw Markdown for agents: https://autobot.eidonix.com/p/3aa75c41-4f25-418f-8818-e4893af1dbe3.md

Recommendation: Changes Requested

The predicate relaxations in model.rs, selection.rs, and threaded.rs are narrow, model-agnostic, and cleanly scoped to rank 0 of local multi-rank cores, while preserving peer-rank and multi-host cluster rejections. However, the PR lifts a maintainer-imposed safety gate from PR #430 without exercising or hardening the multi-rank initialization, partial-startup-failure, and failure-abandonment paths that #430 explicitly required before enabling multi-rank persistent workers, leaves helios/manifest.md contradicting the code, and exposes unvalidated cooperative-collective SM-partition asymmetry across ranks. Add real threaded lifecycle coverage (and address startup/abandonment handling), update helios/manifest.md, address/verify the cooperative SM-partition asymmetry, and run the full --release crate test gates before merging.

Merge Risk

Level: Medium

Walkthrough

Pre-merge Checks

Blockers

  1. Unmet PR #430 multi-rank lifecycle condition and untested initialization/teardown paths (helios/src/execution/threaded.rs:632-636, 766-822, 1004-1012, 1631-1651; helios/src/execution/transport.rs:793-808, 979-990; helios/src/server/session.rs:96-101, 125-133):
    • Verified behavior/impact: In PR #430, @lukealonso required rejecting cores.len() > 1 explicitly until multi-rank coordination and failure-abandonment (GraphExecutor::abandon, partial finish_startup failures) are implemented and tested, or multi-rank startup and teardown are validated directly. This PR lifts the gate while adding zero tests that construct ThreadedExecutor::new with a rank-0 worker (the new test at threaded.rs:1631-1651 only calls same_layout, and helios/src/execution/tests.rs:1371-1373 only asserts peer rejection), leaving the PR's claim that local multi-rank cores can initialize rank-0 persistent workers unverified (docs/design-review.md:187-189). Furthermore, two concrete lifecycle hazards remain on the newly reachable multi-rank paths:
      1. Startup ordering (threaded.rs:766-775): result.local.finish_startup()? launches rank 0's persistent worker before confirming peers' Reply::Started. Because peer ranks cannot have persistent workers, peer finish_startup() does no CUDA work; if a peer fails startup, rank 0 has already launched the worker and peer-join cleanup (threaded.rs:802-810) calls std::process::abort() before result.local.close() at :813 runs.
      2. Failure abandonment (threaded.rs:1009-1012 -> transport.rs:979-990): When a poisoned multi-rank session or failed peer drain takes self.local.abandon(error), GraphExecutor::abandon forgets self.resources and returns Shutdown { drained: false, .. } without signaling the worker's stop_flag. DrainGuard (session.rs:125-133) then forgets NativeModel, so NativeResources::release_execution_resources() never runs either, leaving rank 0's persistent worker spinning on its SM partition until process exit (including in in-process Rust SDK consumers).
    • Concrete fix:
      • Receive Reply::Started from all peers before calling result.local.finish_startup()? in threaded.rs:766-775 so rank 0's worker never starts on a failed peer startup.
      • Decide and implement explicit abandonment semantics for a running rank-0 worker in GraphExecutor::abandon (e.g., best-effort control.stop() or non-blocking stop_flag = 1 write before forgetting resources, or document explicitly why it is intentionally left running).
      • Add a threaded CPU test (or test double via PersistentWorkerControl) exercising ThreadedExecutor::new with a rank-0 worker + plain peer(s), verifying start-once after peers are ready, clean stop on close(), and partial finish_startup / abandonment behavior; obtain maintainer sign-off from @lukealonso that #430's multi-rank condition is satisfied.

Should Fix

  1. Unvalidated SM-partition asymmetry for cooperative TP collectives (helios/src/runtime_core/mod.rs:369-402, 763-781, 893-911, 1002-1017, 1335-1374; docs/same-process-tp.md:30-34):
    • Verified behavior/impact: NativeResources creates a primary context + GreenContextPartition only when a rank declares a persistent worker (now rank 0 only), setting partition_sms = Some(partition.compute_sm_count) (mod.rs:906), while peer ranks use cuCtxCreate_v2 with partition_sms = None (mod.rs:397-401, 910). At mod.rs:1002-1006, status == 0 && partition_sms.is_some() triggers clamp_cooperative_launch on rank 0 even when the cooperative attribute restored cleanly, clamping rank 0's grid to blocks_per_sm * compute_sm_count while peers keep their captured full-device grid. While single-GPU cooperative kernels tolerate largest-axis reduction (docs/runtime-core-design.md:906-915) and collectives whose grids already fit compute_sm_count are unaffected (mod.rs:144), any full-device cooperative collective expecting symmetric CTA counts across ranks will silently receive fewer CTAs on rank 0 than on peers — risking a barrier hang under docs/same-process-tp.md:32-33. Because no live multi-GPU test ran, neither cooperative grid symmetry nor VMM peer access (peer_access.rs:38-57) alongside a rank-0 Green Context has been verified.
    • Concrete fix: Either reject multi-rank loads when rank 0's cooperative clamp actually shrinks a grid relative to its peers (or require preparation validation that multi-rank cooperative collectives fit compute_sm_count without clamping and document that invariant in docs/same-process-tp.md:30-34 and docs/runtime-core-design.md:906-915), and validate with a live two-GPU run.
  2. Contradictory specification in helios/manifest.md (helios/manifest.md:89-95):
    • Verified behavior/impact: helios/manifest.md:92-95 still states: "Helios currently supports at most one persistent worker entry on single-rank cores; cores declaring more than one entry, multi-rank cores, and multi-host cluster cores declaring a persistent worker fail validation before execution." This directly contradicts both the code and docs/runtime-core-design.md:642-644.
    • Concrete fix: Reword helios/manifest.md:92-95 to match docs/runtime-core-design.md:642-644 (at most one entry on rank 0 of a local core; peer ranks and multi-host cluster cores fail validation).
  3. Run required --release verification gates and confirm green CI (docs/design-review.md:180-185; .github/workflows/native-serving.yml:56-77 (not opened)):
    • Verified behavior/impact: The PR body reports only CPU debug --lib runs on flare-helios, omitting --release, integration tests, and downstream crates (flare, flare-cli, heliopause) required by docs/design-review.md:180-185.
    • Concrete fix: Run cargo test --locked --release on helios --features runtime-core,server, flare, flare-cli, and heliopause, and ensure CI workflows pass on the updated head.

Subtract / Simplify

  1. Delete the redundant worker check in same_layout (helios/src/execution/threaded.rs:1292-1294): ThreadedExecutor::new (threaded.rs:632-636) is the only non-test caller of same_layout (threaded.rs:639) and already rejects any peer rank with non-empty persistent_workers with the precise topology error before same_layout is called. Removing :1292-1294 eliminates unreachable production code and frees rank_layout_permits_persistent_worker_only_on_rank_zero (threaded.rs:1631-1651) to be replaced with a real ThreadedExecutor::new test.
  2. Delete the unreachable peer-rank worker check in LoadOptions::select (helios/src/runtime_core/selection.rs:285-289): select is pub(super) (selection.rs:76) with one production caller (helios/src/runtime_core/model.rs:441), which always runs after validate_persistent_worker_topology (model.rs:386). Deleting :285-289 removes both an unreachable production branch and the third divergent error string ("persistent workers are only supported on rank 0"). (If standalone defense-in-depth in select is explicitly desired, also check self.cluster_rank.is_some()—already present on LoadOptions at selection.rs:79—and unify the error message with model.rs:130.)
  3. Collapse the duplicated closure in validate_persistent_worker_topology (helios/src/runtime_core/model.rs:118-128): Replace the two identical 5-line closures (has_rank0_worker and has_peer_worker) with a single pass:
    let unsupported = cores.iter().enumerate().any(|(rank, core)| {
        core.execution
            .as_ref()
            .is_some_and(|execution| !execution.persistent_workers.is_empty())
            && (rank > 0 || cluster.is_some())
    });
    if unsupported { ... }
    

Nits

Dropped on verification