Final review report · NVIDIA/hyperflare-inference #698

Raw Markdown for agents: https://autobot.eidonix.com/p/ba81a07f-fdcd-4999-96d7-753ebf5c024d.md

Recommendation: Changes Requested

The core startup reorder—opening the host prefix store before RankExecutor::new() launches persistent GPU workers—directly fixes a verified cuModuleLoadData deadlock with a minimal, model-agnostic footprint (helios/src/server/runtime.rs, +52/−31). However, the PR cannot merge as-is because (1) the three new post-open error-cleanup blocks violate the HostStore::close ownership contract by swallowing close errors, dropping the store on failure/unwind, and reporting drained: true anyway (duplicating the existing Worker::close_store helper that already handles all of this safely), and (2) the cited validation run omits the server feature and therefore never compiled or tested a single line of the diff.

Merge Risk

Level: Medium

Walkthrough

Pre-merge Checks

Blockers

  1. Post-open error paths violate HostStore::close safety contract and duplicate Worker::close_store (helios/src/server/runtime.rs:697-706, :714-726, :784-796)

    • Verified behavior & impact: All three new cleanup branches run let _ = store.close(); and drop store on scope exit while keeping drained: true (hardcoded at :703; preserved from executor.close() at :717 and :787). This directly violates selene/src/store.rs:334-337 ("On failure the caller must retain the store: transfer jobs may still reference its registered host buffers and GPU destinations"), causes flare/src/controller.rs:2905-2910 to treat drain as confirmed and release the GPU/core lease while host slabs may still be in use, and drops Transfers on a failed close (whose Drop unconditionally calls thread.join(), helios/src/offload/transfer.rs:841-852). Furthermore, none of the three sites wraps store in ManuallyDrop before calling store.close(), so an unwind inside store.close() drops store—the exact hazard Worker::close_store (runtime.rs:1344-1364) and shutdown_retains_the_store_when_its_drain_panics (helios/src/server/runtime/phase_tests.rs:2340-2363) prevent. Because of this, the PR's claim that startup cleanup is exact LIFO-symmetric with Worker::close_store does not currently hold.
    • Concrete fix: Extract the body of Worker::close_store (runtime.rs:1344-1364, which only uses self to self.store.take()) into a shared helper fn close_store(store: Option<Box<dyn flare_selene::HostStore>>, shutdown: &mut Shutdown) and call it from Worker::close_store and all three startup failure paths:
      fn close_store(
          store: Option<Box<dyn flare_selene::HostStore>>,
          shutdown: &mut Shutdown,
      ) {
          let Some(store) = store else {
              return;
          };
          // Retain registered slabs if either drain fails, including an unwind
          // inside the store's close operation.
          let mut store = std::mem::ManuallyDrop::new(store);
          if !shutdown.drained {
              return;
          }
          shutdown.drained = false;
          match store.close() {
              Ok(()) => {
                  shutdown.drained = true;
                  drop(std::mem::ManuallyDrop::into_inner(store));
              }
              Err(error) => {
                  shutdown.error.get_or_insert(error.into());
              }
          }
      }
      
      Then on RankExecutor::new failure (:697-706):
      Err(error) => {
          let mut shutdown = Shutdown {
              drained: true,
              error: Some(error.clone()),
          };
          let _ = ready_tx.send(Err(error));
          close_store(store, &mut shutdown);
          return shutdown;
      }
      
      And on both scheduler failure paths (:714-726, :784-796):
      Err(error) => {
          let _ = ready_tx.send(Err(error.clone()));
          let mut shutdown = executor.close();
          close_store(store, &mut shutdown);
          shutdown.error = Some(error);
          return shutdown;
      }
      
      This fixes drain reporting, error preservation, unwind retention, and deletes ~25 lines plus both ad-hoc std::mem::forget(store) calls in one change.
  2. Mandatory server-feature test suite was never compiled or run (helios/src/lib.rs:30-31, helios/Cargo.toml:2,21,25)

    • Verified behavior & impact: helios/src/server/runtime.rs is gated behind #[cfg(feature = "server")] (helios/src/lib.rs:30-31), and runtime-core does not enable server (helios/Cargo.toml:21,25). The PR's Submission Validation (cargo test -p flare-helios --features runtime-core) therefore compiled zero lines of the diff, and the PR's Suggested test command (cargo test -p helios --features runtime-core) additionally names a nonexistent crate (helios/Cargo.toml:2 is flare-helios). Per docs/design-review.md:180-184,247-251 and .github/workflows/native-serving.yml:63 (not opened),68, leaving the applicable CPU crate test unrun blocks merge.
    • Concrete fix: Run and report the repo's standard Helios test command (with FLARE_TEST_TEMPLATE_DIR / ulimit -l per AGENTS.md:317-327):
      cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server
      
      and correct the suggested test command in the PR description.

Should Fix

None.

Subtract / Simplify

Nits

Dropped on verification