Skip to content

Unify Orbit rank cache, fix GB10 page-cache KV sizing, consolidate NVML, and harden flare-agent - #646

Merged
lukealonso merged 2 commits into
mainfrom
unify-orbit-rank-cache-gb10-page-cac
Nov 30, 2026
Merged

lukealonso merged 2 commits into
mainfrom
unify-orbit-rank-cache-gb10-page-cac

Conversation

@lukealonso

@lukealonso lukealonso commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Why this change is needed

Four concrete operational defects affect multi-host Orbit clusters, unified-memory GPUs (such as DGX Spark GB10), and long-lived polling processes:

  1. Orbit rank-cache collision, eviction data loss, and duplicate staging (closes Orbit agent eviction removes flare download's default model store in ~/.cache/flare/packages #119, Store Orbit rank files in the shared model cache #361, orbit run ignores --core-cache and paths.core_cache for rank-core staging: peer rank cores duplicated into ~/.cache/flare/cores on the controller host #629, fix(orbit): preserve the prepared model cache during eviction #147):

    • flare-cli/src/main.rs hardcoded flare agent's cache root to orbit::cache::default_root() (~/.cache/flare) and ignored --core-cache and [paths].core_cache. agent::put and agent::transfer stored flat core directories inside ~/.cache/flare/cores—the exact default directory of helios::core::cache::Root—and ran core_cache::evict() over it, deleting Helios's managed blobs/, models/, refs/, sources/, origins/, staging/, and locks/ subdirectories without consulting Helios entry leases (Orbit agent eviction removes flare download's default model store in ~/.cache/flare/packages #119).
    • agent::run passed --core-cache ~/.cache/flare (instead of ~/.cache/flare/cores) to spawned flare run peers, so distribution::receive_rank opened a separate helios::core::cache::Root and could not see peer rank slices staged by orbit push, forcing duplicate transfers on orbit run (orbit run ignores --core-cache and paths.core_cache for rank-core staging: peer rank cores duplicated into ~/.cache/flare/cores on the controller host #629).
    • Controller-local PUT uploads to nodes[0] cleared .verified and skipped TRANSFER verification, leaving nodes[0] unverified in STATUS, flare orbit cores, and placement (plan::Pool::holds).
    • OrbitRun::rank_options and launch::Peers::start emitted --roce-ring / --roce-chain into spec.serving and Grant.serving while Grant also stored roce_ring / roce_chain booleans that agent::run appended again, breaking --roce-ring ↔ --roce-chain overrides on saved persistent groups.
    • flare run CORE --hosts built Grant.core directly from the managed cache entry directory rather than model.safetensors, failed peer core_cache::component_valid on + in multi-deployment entry names even when local_core == false, and did not infer tensor_parallel = hosts.len() + 1.
  2. GB10 KV collapse, input_window double-counting, integrated intake over-reservation, and metadata-only loading (Addresses GB10 unified memory: KV budget and cuCtxCreate respond to page-cache-polluted MemFree, not MemAvailable — same core+reserve gives 2.08M vs 3.43M KV tokens and spurious CUDA_ERROR_OUT_OF_MEMORY #630):

    • PayloadSource::release_page_cache() in helios/src/runtime_core/protection.rs was an empty no-op (unlike Archive::release_page_cache()), leaving tens of GiB of SHA-256-verified payload pages resident in Linux page cache through CUDA initialization and unified-memory KV sizing on GB10.
    • NativeModel::allocate_caches in helios/src/runtime_core/memory.rs added staging (input_window) into offload_host and then added input_window a second time into host_future whenever prefix-cache offload was enabled.
    • selene/src/offload.rs bounded integrated-GPU intake (target_intake_slots / sized_concurrency) to intake_slots(layout, 1) only when memory_bytes == 0 && disk_enabled(), allowing nonzero warm memory on integrated GPUs to reserve concurrency-scaled burst intake slots from unified RAM.
    • VerifiedCore::authorize_metadata returned the same AuthorizedCore type accepted by GPU loaders even though supporting payloads were not verified upfront.
    • Note: this PR addresses the page-cache, input_window, and Selene intake causes described in GB10 unified memory: KV budget and cuCtxCreate respond to page-cache-polluted MemFree, not MemAvailable — same core+reserve gives 2.08M vs 3.43M KV tokens and spurious CUDA_ERROR_OUT_OF_MEMORY #630; it does not add the optional low-KV-budget warning or cuCtxCreate MemFree/MemAvailable/Cached diagnostics also suggested there.
  3. flare-agent security, process-lifecycle, and LAN probe resilience gaps:

    • Agent::grant() verified controller signatures without calling grant.current(now()), allowing expired grants to remain valid indefinitely for TRANSFER, FETCH, and FETCH_FABRIC.
    • serve_on() spawned unbounded pre-auth OS threads, and Session::accept read 44 bytes before checking the 8-byte FLAREFLT magic and cleared read timeouts to None before HELLO or peer authorization.
    • Key::load_or_create, AgentDir::private_write, and Orbit::save wrote secret files under default umask before calling chmod 0600.
    • The rank reaper joined stdout/stderr forwarder threads before calling Group::finish(), allowing any grandchild holding stdio FDs open to lock GPUs and cache pins indefinitely and leaving a PID-reuse signal window in agent::stop; ranks lacked process-group isolation and Linux PR_SET_PDEATHSIG(SIGTERM); Controller::stop_group looped unboundedly waiting on rank zero.
    • Stray TCP connections (e.g., LAN scanners) aborted distribution::root rendezvous and fabric_transport::serve relays.
  4. Duplicate NVML FFI loaders, HardwareMonitor FD leak, and GPU ordinal visibility bug:

    • Five separate copies of libnvidia-ml.so.1 FFI bindings existed across helios, flare, heliopause, and flare-cli. flare/src/hardware_monitor.rs polled flare/src/hardware.rs::inventory() every 2 seconds, calling nvmlInit_v2() + nvmlShutdown() each cycle (~1,800 FDs/hr leak).
    • flare/src/hardware.rs::assign_visibility() matched numeric CUDA_VISIBLE_DEVICES entries against slice position instead of device.ordinal, mis-mapping GPUs when non-CUDA NVML devices were skipped.

What changed

  • Unified Orbit rank cache onto helios::core::cache::Root and fixed --hosts / RoCE flag bugs (helios/src/core/cache.rs, flare-cli/src/{cli,config,core_cache,distribution,launch,main,trust}.rs, flare-cli/src/orbit/{agent,controller}.rs, docs/orbit.md):

    • Before: Command::Agent ignored --core-cache and [paths].core_cache, stored flat directories under ~/.cache/flare/cores, ran core_cache::evict on cores/, passed --core-cache ~/.cache/flare to spawned ranks, skipped nodes[0] verification after PUT, duplicated RoCE flags into serving, and passed cached entry directories into --hosts Grant.core.
    • After: Command::Agent and AgentCommand::Install accept --core-cache (aliases --model-cache, --package-cache) and apply [paths].core_cache (default ~/.cache/flare/cores for serve; install propagates [paths].core_cache and top-level flare agent --core-cache with subcommand precedence and systemd-quotes --core-cache in ExecStart=). In-flight PUT/TRANSFER files assemble under <core-cache>/staging/orbit/cores/ on the same filesystem without ever calling core_cache::evict on published core caches (core_cache::evict also skips helios::core::cache::ROOT_DIRECTORIES as defense-in-depth). Abandoned unleased entries under staging/orbit/cores/ (and unreachable staging/orbit/blobs/ hardlinks) are reclaimed on agent startup, after core PUT/TRANSFER, and by helios::core::cache::Root::collect(), while live PUT->TRANSFER sessions, FETCH, and staging-backed RUN hold shared flock leases on the staged directory. Verified transfers—including nodes[0] after controller-local PUT uploads—commit into helios::core::cache::Root (models/<model>/<entry>/), write .verified and filename-sorted .flare-verified.json markers (propagating write failures and rolling back unpublished entries), and publish orbit:<dir>, <export>-rank<R>, and <export>-complete source refs discovered by distribution::receive_rank, Agent::cores(), and placement. distribution::verified_marker_matches matches marker files by filename instead of position. agent::run passes --core-cache <agent.core_cache>, holds flock Entry leases on active local cores for the lifetime of the Group, and skips cache::entry validation on peers (local_core == false). RoCE shape flags are stripped from serving and emitted once from Grant.roce_ring / Grant.roce_chain. --hosts resolves model.safetensors inside cached directories and infers tensor_parallel = hosts.len() + 1. Updated docs/orbit.md to document the unified layout, staging reclamation, and manual cleanup of legacy flat directories.
  • GB10 page-cache eviction, KV/host sizing, Selene intake cap, and metadata-only guard (helios/src/runtime_core/{protection,memory,mod,model}.rs, selene/src/offload.rs, selene/src/offload/tests.rs, docs/prefix-cache-offload.md):

    • Before: PayloadSource::release_page_cache() was an empty no-op; NativeModel::allocate_caches charged input_window in both offload_host and host_future; target_intake_slots and sized_concurrency capped integrated-GPU intake only when disk_only; and metadata-only AuthorizedCore values were accepted by GPU loaders.
    • After: PayloadSource::release_page_cache() calls crate::os::release_page_cache (POSIX_FADV_DONTNEED on Unix) once per deduplicated Arc<File> across primary and all opened payload containers. NativeModel::allocate_caches computes host_future via planned_host_future so input_window is charged once whether offload is enabled or disabled. target_intake_slots and sized_concurrency bound all integrated-GPU local offload tiers (memory_bytes == 0 or > 0) to intake_slots(layout, 1) (updated docs/prefix-cache-offload.md). AuthorizedCore tracks loadable: bool and NativeResources::load, NativeModel::load_agreeing, and PayloadAuthorizedCore::load reject metadata-only authorizations before touching CUDA.
  • flare-agent hardening and stray LAN probe handling (flare-cli/src/orbit/{agent,controller,identity,session,store}.rs, flare-cli/src/{distribution,fabric_transport}.rs):

    • Before: Agent::grant() did not check expiry; serve_on() had no session limits; Session::accept read 44 bytes before validating magic and cleared timeouts before authorization; secret files were written before chmod 0600; the reaper blocked finish() on forwarder joins with no PR_SET_PDEATHSIG or process-group isolation; stop_group looped unboundedly waiting on rank zero; and stray LAN probes aborted rendezvous and fabric relay listeners.
    • After: Agent::grant() enforces grant.current(now()) across TRANSFER, FETCH, FETCH_FABRIC, and RUN. serve_on() bounds concurrent sessions (1152) and pre-auth sessions (1024, accommodating 16-rank × 64-stream bursts) and logs shed connections; Session::accept validates the 8-byte FLAREFLT magic before reading the remaining handshake bytes and keeps read/write timeouts armed until peer authorization. atomic_write_private creates node/controller keys, controllers.toml, join-code, accept-first, and orbit.toml with O_CREAT | O_EXCL mode 0600, fsync, and atomic rename. Rank processes spawn in isolated process groups (setpgid(0, 0)) with Linux PR_SET_PDEATHSIG(SIGTERM) and parent-PID verification; on Linux, the reaper waits without reaping via waitid(P_PID, ..., WEXITED | WNOWAIT) and then sets exited and calls child.wait() under Group::reap, which agent::stop also holds while signaling -group.pid so kill() cannot target a reused PID; forwarder drain is bounded to 2s and finished.finish(code) always runs to release GPUs and leases; Controller::stop_group caps rank-zero drain wait at 120s; distribution::root drops malformed TCP probes while failing fast on valid version- or rank-mismatch Join frames; and fabric_transport::serve drops stray LAN probes without leaking relay worker slots.
  • Consolidated NVML OnceLock loader and ordinal fix (helios/src/{nvml,lib}.rs, helios/src/runtime_core/device_memory.rs, flare/src/hardware.rs, heliopause/src/export/capture.rs, flare-cli/src/{doctor.rs,orbit/gpu.rs}):

    • Before: 7 NVML FFI call sites across 5 files duplicated struct layouts and per-call nvmlInit_v2 / nvmlShutdown, and assign_visibility() compared numeric CUDA_VISIBLE_DEVICES entries to slice index.
    • After: added flare_helios::nvml::Nvml loaded once per process via OnceLock (libnvidia-ml.so.1 on Unix, nvml.dll with LOAD_LIBRARY_SEARCH_SYSTEM32 on Windows, never calling nvmlShutdown), migrated all 7 sites with zero Cargo.toml/Cargo.lock changes, and fixed assign_visibility() to match numeric entries against device.ordinal.

Claimed benefit

Supporting evidence and limitations

All Rust crate test suites ran with --locked --release on Linux x86_64:

  • eos (cargo test --locked --release --manifest-path eos/Cargo.toml --target-dir flare-cli/target): 2 passed, 0 failed.
  • selene (cargo test --locked --release --manifest-path selene/Cargo.toml --features test-support --target-dir flare-cli/target): 548 unit + 1 integration passed, 0 failed (updated integrated-GPU memory_bytes > 0 intake tests in selene/src/offload/tests.rs).
  • selene-manager (cargo test --locked --release --manifest-path selene-manager/Cargo.toml --features test-support --target-dir flare-cli/target): all passed, 0 failed.
  • helios (cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --target-dir flare-cli/target -- core:: runtime_core:: nvml): 505 passed, 0 failed, 12 ignored (GPU/checkpoint-gated), including authorize_metadata_is_not_loadable, payload_source_release_page_cache_deduplicates_unique_files, planned_host_future_counts_input_window_once, collect_reclaims_unleased_orbit_staging_and_preserves_leased, and updated integrated_offload_host_budget_matches_small_soc_scaling_and_explicit_limits.
  • flare (cargo test --locked --release --manifest-path flare/Cargo.toml --target-dir flare-cli/target): 238 unit + 8 integration tests passed (0 failed, 4 ignored), including gpu_inventory_visibility_matches_nvml_ordinal_when_non_cuda_devices_skipped.
  • flare-cli (cargo test --locked --release --manifest-path flare-cli/Cargo.toml): 212 unit tests passed (0 failed, 3 ignored) and 26 integration tests passed (cache_commands 9, cli 6, inspect 4, unverified_payload 7), including new tests for #119 managed-cache eviction protection, #361/#629 shared Root rank refs, abandoned staging reclamation (init_core_cache, PUT, and Root::collect()), multi-file .flare-verified.json order-independent matching, nodes[0] .verified after orbit push, expired-grant rejection across TRANSFER/FETCH/FETCH_FABRIC/RUN, RoCE flag deduplication, Command::Agent / AgentCommand::Install --core-cache and [paths].core_cache precedence + systemd ExecStart= quoting, atomic 0600 secret creation, immediate short-probe rejection in Session::accept, stray LAN probe tolerance on fabric_transport::serve, and reaper completion when a grandchild holds stdout/stderr open.
  • heliopause (cargo test --locked --release --manifest-path heliopause/Cargo.toml --target-dir flare-cli/target): 216 passed, 0 failed, 6 ignored (CUDA).

Unrun checks / limitations: Live GB10 KV token capacity measurement after PayloadSource::release_page_cache(), live 4-Spark orbit push + orbit run multi-host verification, Windows nvml.dll compilation, and FLARE_TEST_TEMPLATE_DIR chat-template tests were not run in this CPU-only Linux environment.

Discord: lukealonso

…ML, and harden flare-agent

Why this change is needed:
Four classes of operational defects affect multi-host Orbit clusters and
unified-memory GPUs (such as DGX Spark GB10):

1. Orbit rank-cache collision, eviction data loss, and duplicate staging
   (#119, #361, #629, #147): `flare agent` hardcoded its cache root to
   `~/.cache/flare` instead of honoring `--core-cache` / `[paths].core_cache`,
   stored flat core directories inside `~/.cache/flare/cores` (the default
   managed `helios::core::cache::Root` directory), and called
   `core_cache::evict` on that directory during `PUT` and `TRANSFER`. That
   eviction sweep deleted Helios's managed `blobs/`, `models/`, `refs/`,
   `sources/`, `origins/`, `staging/`, and `locks/` subdirectories without
   consulting Helios leases (#119). Meanwhile, `agent::run` passed
   `--core-cache ~/.cache/flare` to spawned `flare run` peers, so peer ranks
   opened a second model cache outside `~/.cache/flare/cores` and could not
   reuse peer rank shards staged by `orbit push` (#629). In addition,
   controller-local `PUT` uploads to `nodes[0]` skipped verification and left
   `.verified` absent; `OrbitRun::rank_options` and `launch::Peers::start`
   duplicated `--roce-ring` / `--roce-chain` into `spec.serving` and
   `Grant.serving` alongside `Grant`'s booleans (breaking overrides on saved
   persistent groups); and `flare run CORE --hosts` built `Grant.core` from
   the cached entry directory instead of `model.safetensors` while failing
   peer `core_cache::component_valid` on `+` in multi-deployment names and
   failing to infer `tensor_parallel = hosts.len() + 1`.
2. GB10 KV collapse and integrated-memory over-reservation (#630):
   `PayloadSource::release_page_cache()` was an empty no-op (unlike
   `Archive::release_page_cache()`), leaving tens of GiB of SHA-256-verified
   payload pages resident in Linux page cache through CUDA initialization and
   KV sizing. In `helios/src/runtime_core/memory.rs`, `NativeModel::allocate_caches`
   added `input_window` into both `offload_host` and `host_future`, charging
   it twice whenever prefix-cache offload was enabled. In `selene/src/offload.rs`,
   `target_intake_slots` bounded integrated-GPU intake to `intake_slots(layout, 1)`
   only when `memory_bytes == 0 && disk_enabled()`, allowing nonzero warm
   memory on unified-memory GPUs to reserve concurrency-scaled burst intake
   slots. Finally, `VerifiedCore::authorize_metadata` returned the same
   loadable `AuthorizedCore` type accepted by GPU loaders even though
   supporting payloads were not verified upfront.
3. `flare-agent` authentication, lifecycle, and LAN resilience gaps:
   `Agent::grant()` verified signatures without checking `grant.current(now())`,
   allowing expired grants to work indefinitely for `TRANSFER`, `FETCH`, and
   `FETCH_FABRIC`. `serve_on()` spawned unbounded pre-auth OS threads and
   `Session::accept` cleared read timeouts before `HELLO` or authorization
   while waiting for 44 bytes before checking the 8-byte `FLAREFLT` magic.
   `Key::load_or_create`, `AgentDir::private_write`, and `Orbit::save` wrote
   secret files with default umask before `chmod 0600`. The rank reaper joined
   stdout/stderr forwarders before calling `Group::finish()`, allowing a
   grandchild holding stdio open to lock GPUs and pins indefinitely and
   leaving a PID-reuse window in `agent::stop`; ranks were spawned without
   process-group isolation or `PR_SET_PDEATHSIG`; `Controller::stop_group`
   waited on rank zero without a timeout; and stray LAN probes on the
   rendezvous or wildcard fabric relay listeners aborted active launches.
4. Duplicated NVML loaders, FD leak, and ordinal visibility mismatch:
   Five files across `helios`, `flare`, `heliopause`, and `flare-cli`
   duplicated dynamic NVML loading, and six call sites invoked
   `nvmlInit_v2()` / `nvmlShutdown()` per query—causing `HardwareMonitor`'s
   2-second polling loop to leak ~1,800 NVML event file descriptors per hour.
   In `flare/src/hardware.rs`, `assign_visibility()` matched numeric
   `CUDA_VISIBLE_DEVICES` entries against the filtered vector slice index
   instead of `device.ordinal`, misbinding GPUs whenever a non-CUDA device
   was skipped.

What exactly changed:
- Orbit rank cache unification and CLI/Grant fixes (`flare-cli/src/{cli,config,core_cache,distribution,launch,main,trust}.rs`, `flare-cli/src/orbit/{agent,controller}.rs`, `helios/src/core/cache.rs`, `docs/orbit.md`):
  - Before: `flare agent` ignored `--core-cache` and `[paths].core_cache`,
    stored flat directories in `~/.cache/flare/cores`, evicted unpinned
    entries there, passed `--core-cache ~/.cache/flare` to ranks, left
    `nodes[0]` unverified after `PUT`, duplicated RoCE flags in `serving`,
    and wrote cached directory paths into `--hosts` `Grant.core`.
  - After: `Command::Agent` and `AgentCommand::Install` accept `--core-cache`
    and inherit `[paths].core_cache` (default `~/.cache/flare/cores`).
    In-flight `PUT`/`TRANSFER` files stage under `<core-cache>/staging/orbit`,
    never calling `core_cache::evict` on core caches (`evict` also skips
    Helios's seven managed directories as defense-in-depth). Verified
    transfers—including `nodes[0]` after controller `PUT`—commit into
    `helios::core::cache::Root` with `.verified` and `.flare-verified.json`
    markers and publish `orbit:<dir>`, `<export>-rank<R>`, and
    `<export>-complete` source refs shared with `distribution::receive_rank`,
    `Agent::cores()`, and placement. `agent::run` passes
    `--core-cache <agent.core_cache>`, holds `Entry` leases on active local
    cores, and skips `cache::entry` for remote-bootstrap peers. RoCE shape
    flags are stripped from `serving` and emitted once from `Grant`'s
    booleans. `--hosts` resolves `model.safetensors` inside cached entry
    directories and infers `tensor_parallel = hosts.len() + 1`.
- GB10 page-cache release, memory sizing, Selene intake, and metadata-only guard (`helios/src/runtime_core/{protection,memory,mod,model}.rs`, `selene/src/offload.rs`, `docs/prefix-cache-offload.md`):
  - Before: `PayloadSource::release_page_cache()` was empty; `memory.rs`
    counted `input_window` in both `offload_host` and `host_future`;
    `selene::offload::target_intake_slots` only capped integrated GPUs when
    `disk_only`; and metadata-only `AuthorizedCore` could enter GPU loaders.
  - After: `PayloadSource::release_page_cache()` invokes
    `crate::os::release_page_cache` once per unique `Arc<File>` across
    `primary` and all opened payload containers; `planned_host_future` counts
    `input_window` once; `target_intake_slots` and `sized_concurrency` bound
    all integrated-GPU local offload tiers to `intake_slots(layout, 1)`; and
    `AuthorizedCore` tracks `loadable` so `NativeResources::load`,
    `NativeModel::load_agreeing`, and `PayloadAuthorizedCore::load` reject
    metadata-only authorizations before touching CUDA.
- `flare-agent` hardening and stray LAN probe handling (`flare-cli/src/orbit/{agent,controller,identity,session,store}.rs`, `flare-cli/src/{distribution,fabric_transport}.rs`):
  - Before: `Agent::grant()` ignored expiry; `serve_on()` had no session or
    pre-auth cap; `Session::accept` read 44 bytes before checking magic and
    cleared timeouts before authorization; secret files were written before
    `chmod 0600`; the reaper blocked `finish()` on forwarder joins with no
    process-group isolation or `PR_SET_PDEATHSIG`; `stop_group` looped
    unboundedly on rank zero; and stray TCP connections aborted rendezvous
    and fabric relay listeners.
  - After: `Agent::grant()` rejects expired grants across all RPCs;
    `serve_on()` bounds concurrent sessions (`1024`) and pre-auth sessions
    (`256`); `Session::accept` checks the 8-byte `FLAREFLT` magic first and
    keeps read/write handshake timeouts armed until peer authorization;
    `atomic_write_private` creates secrets with `O_CREAT | O_EXCL` mode
    `0600` + `fsync` + `rename`; rank processes run in isolated process
    groups (`setpgid(0, 0)`) with Linux `PR_SET_PDEATHSIG(SIGTERM)`,
    PID-reuse-guarded process-group `SIGTERM`, and a 2-second bounded
    forwarder drain before `finished.finish(code)`; `stop_group` bounds rank
    zero drain to 120s; and `distribution::root` and `fabric_transport::serve`
    drop stray LAN probes without aborting active transfers.
- Consolidated NVML `OnceLock` loader and ordinal fix (`helios/src/{nvml,lib}.rs`, `helios/src/runtime_core/device_memory.rs`, `flare/src/hardware.rs`, `heliopause/src/export/capture.rs`, `flare-cli/src/{doctor.rs,orbit/gpu.rs}`):
  - Before: five crates duplicated NVML FFI structs and per-call
    `nvmlInit_v2` / `nvmlShutdown`, leaking ~1,800 FDs/hr in
    `HardwareMonitor`, and `assign_visibility()` compared numeric
    `CUDA_VISIBLE_DEVICES` entries to slice index instead of `device.ordinal`.
  - After: added `flare_helios::nvml::Nvml` backed by a process-wide
    `OnceLock` (using `LOAD_LIBRARY_SEARCH_SYSTEM32` on Windows and never
    calling `nvmlShutdown`), migrated all seven Rust call sites across five
    files with zero `Cargo.toml`/`Cargo.lock` changes, and matched numeric
    `CUDA_VISIBLE_DEVICES` entries against `device.ordinal`.

Claimed benefit or result:
- Expected on multi-host Orbit clusters: eliminates silent deletion of
  managed Helios cache trees during `PUT`/`TRANSFER` (#119), eliminates
  duplicate peer rank staging between `orbit push` and `orbit run` (#361,
  #629), preserves `.verified` status on `nodes[0]`, fixes persistent-group
  RoCE shape overrides and `--hosts` cached/multi-deployment launches, and
  hardens `flare-agent` against expired-grant replay, pre-auth thread
  exhaustion, secret permission races, stuck reapers, and stray LAN probes.
- Expected on GB10 and integrated-memory GPUs: reclaims verified weight page
  cache before CUDA init and KV sizing, stops double-charging `input_window`,
  and bounds local-tier offload intake when warm memory is nonzero (#630).
- Expected on long-lived polling processes (`HardwareMonitor`, `flare agent`):
  eliminates the ~1,800 FDs/hr NVML event-descriptor leak and fixes numeric
  `CUDA_VISIBLE_DEVICES` matching when non-CUDA NVML devices are skipped.
- These are CPU-verified behavioral guarantees; live GB10 KV token recovery
  and live 4-Spark transfer latency have not yet been measured on hardware.

Supporting evidence and limitations:
All Rust test suites ran with `--locked --release` in this worktree on Linux
x86_64:
- `eos`: 2 passed, 0 failed.
- `selene` (`--features test-support`): 548 unit + 1 integration passed, 0
  failed (updated integrated-GPU `memory_bytes > 0` intake assertions).
- `selene-manager` (`--features test-support`): all passed, 0 failed.
- `helios` (`--features runtime-core,server`, `core::`, `runtime_core::`,
  `nvml`): 504 passed, 0 failed, 12 ignored (GPU/checkpoint-gated), including
  `authorize_metadata_is_not_loadable`,
  `payload_source_release_page_cache_deduplicates_unique_files`,
  `planned_host_future_counts_input_window_once`, and
  `integrated_offload_host_budget_matches_small_soc_scaling_and_explicit_limits`.
- `flare`: all unit and integration tests passed, 0 failed, including
  `gpu_inventory_visibility_matches_nvml_ordinal_when_non_cuda_devices_skipped`.
- `flare-cli`: 208 unit tests passed (0 failed, 3 ignored) + 26 integration
  tests passed (`cache_commands` 9, `cli` 6, `inspect` 4,
  `unverified_payload` 7), including new tests for managed-cache eviction
  protection, shared `Root` rank refs, `nodes[0]` verification after `orbit
  push`, expired-grant rejection across all RPCs, RoCE deduplication,
  `Command::Agent` `--core-cache` precedence, atomic `0600` secret creation,
  immediate short-probe rejection, stray LAN probe tolerance on
  `fabric_transport`, and reaper completion with leaked grandchild stdio.
  (`actual_load_core_leases_managed_local_entries_and_releases_on_failure`
  exhibits a pre-existing parallel `fork`-vs-`flock` race in concurrent runs
  and passed standalone.)
- `heliopause`: 216 passed, 0 failed, 6 ignored (CUDA).
- Unrun checks: live GB10 KV capacity measurement, live multi-host 4-Spark
  `orbit push`/`orbit run`, Windows `nvml.dll` compilation, and
  `FLARE_TEST_TEMPLATE_DIR` chat-template tests.

Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 646.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot flare-autobot added area:caching Prefix/KV reuse, cache retention, and model or payload cache behavior. area:memory Memory budgets, allocation lifetimes, scratch sharing, and capacity. area:orbit Orbit host agents, orchestration, and package-cache management. area:selene Selene shared prefix-cache pool, protocol, manager, and transfers. bug Something isn't working performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness. labels Nov 30, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

Four real operational defects are addressed and the core fixes are clean and well-tested, but verification surfaced one blocker (permanently leaked Orbit staging cores with no reclamation path) plus several concrete correctness gaps, including a marker-ordering bug that defeats .flare-verified.json fast-path reuse after orbit push.

  • Blockers: 1 · Should fix: 6 · Subtract/Simplify: 4 · Nits: 3
Walkthrough
  • Orbit rank-cache unification & CLI/Grant fixes (flare-cli/src/{cli,config,core_cache,distribution,launch,main,trust}.rs, flare-cli/src/orbit/{agent,controller}.rs, helios/src/core/cache.rs, docs/orbit.md): Adds --core-cache to flare agent / flare agent install, stages PUT/TRANSFER under <core-cache>/staging/orbit/, publishes verified transfers into helios::core::cache::Root with orbit:<dir>, <export>-rank<R>, and <export>-complete source refs, passes --core-cache <agent.core_cache> and holds flock entry leases on launched ranks, deduplicates --roce-ring/--roce-chain from serving, resolves model.safetensors inside --hosts cached dirs, and infers tensor_parallel = hosts.len() + 1.
  • GB10 page-cache reclamation, host sizing, & metadata-only guard (helios/src/runtime_core/{protection,memory,mod,model}.rs, selene/src/offload.rs, selene/src/offload/tests.rs (not opened), docs/prefix-cache-offload.md (not opened)): Implements PayloadSource::release_page_cache() over deduplicated Arc<File>s before CUDA init/KV sizing, routes NativeModel::allocate_caches through planned_host_future so input_window is counted once, bounds all integrated-GPU local offload tiers to intake_slots(layout, 1), and rejects metadata-only AuthorizedCore values in NativeResources::load, NativeModel::load_agreeing, and PayloadAuthorizedCore::load.
  • flare-agent security, process lifecycle, & LAN probe resilience (flare-cli/src/orbit/{agent,controller,identity,session,store}.rs, flare-cli/src/{distribution,fabric_transport}.rs): Enforces grant.current(now()), bounds sessions (MAX_SESSIONS = 1024, MAX_PREAUTH_SESSIONS = 256), validates 8-byte FLAREFLT magic before reading the rest of the handshake, keeps timeouts armed until authorization, writes secret files via atomic_write_private, isolates ranks in process groups with PR_SET_PDEATHSIG(SIGTERM), bounds reaper stdio drain to 2s and rank-zero wait to 120s, and tolerates stray probes on rendezvous and fabric relay listeners.
  • Consolidated NVML loader & visibility ordinal fix (helios/src/{nvml,lib}.rs, helios/src/runtime_core/device_memory.rs, flare/src/hardware.rs, heliopause/src/export/capture.rs, flare-cli/src/{doctor.rs,orbit/gpu.rs}): Adds process-lifetime flare_helios::nvml::Nvml (OnceLock, no nvmlShutdown) across all 7 call sites with zero dependency changes, and fixes assign_visibility() to match numeric CUDA_VISIBLE_DEVICES entries against device.ordinal.
Merge Risk: High · up to ec1df84
  • Wide cross-crate blast radius in a single squashed commit: 29 files (+2,597/−1,217) spanning 5 crates (helios, selene, flare, heliopause, flare-cli) and 4 independent subsystems (on-disk cache layout, unified-memory KV/offload sizing, process/network supervision, and process-wide NVML FFI).
  • Disk-exhaustion and cluster-launch risk: Abandoned PUT / interrupted TRANSFER files in <core-cache>/staging/orbit/ have no GC path (Root::collect does not sweep staging/orbit), and MAX_PREAUTH_SESSIONS = 256 can silently drop legitimate multi-host FETCH_FABRIC streams at 5+ direct peers × 64 streams.
  • Active branch overlap and unrun hardware paths: Touches the hot selene/src/offload.rs budget path (overlaps open #625 and widens #497) and heliopause/src/export/capture.rs (overlaps open #647), while live GB10 KV capacity, live 4-Spark orbit push/run, and Windows nvml.dll builds are unrun.
Pre-merge checks: ✅ 1 passed · ⚠️ 3 warnings
  • ✅ Security / malicious screen: Verified atomic_write_private, grant.current(now()), magic-first handshake, async-signal-safe pre_exec syscalls, and Windows LOAD_LIBRARY_SEARCH_SYSTEM32; no malicious patterns.
  • ⚠️ Charter & value fit: Solves real Orbit/GB10/NVML defects from a priority contributor and area owner, but bundles 4 unrelated changesets in one commit, overclaims closes #630 (missing the requested KV-budget warning and cuCtxCreate MemFree/MemAvailable/Cached diagnostics), and omits the #361-required migration rule for pre-existing flat ~/.cache/flare/cores/ data.
  • ⚠️ Related / duplicate / conflict check: Supersedes open PR #147 (re-introducing a hardcoded directory skip list that #147's reviewer blocked) without notifying #147 or #497 authors; overlaps open #625 (selene/src/offload.rs) and #647 (heliopause/src/export/capture.rs).
  • ⚠️ Tests & verification evidence: Strong CPU test coverage across all crates, but misses tests for staging reclamation, multi-file .flare-verified.json (not opened) marker matching after orbit push, and [paths].core_cache on agent install; GB10 KV capacity, 4-Spark orbit push/run, NVML FD count, and Windows nvml.dll build remain unrun/unmeasured.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

…t reaper

Interrupted `PUT` or `TRANSFER` operations left unleased directories under
`<core-cache>/staging/orbit/cores/` (and companion hardlinks under
`staging/orbit/blobs/`) without reclamation. In addition, multi-file
`.flare-verified.json` matching zipped `Plan.files` positionally against
unsorted `read_dir` output from `move_staged_tree`, `agent::stop` raced
`child.wait()` before setting `exited`, `flare agent install` ignored
`[paths].core_cache` and top-level `--core-cache` and wrote unquoted
systemd `ExecStart=` arguments, `distribution::root` swallowed valid
version/rank-mismatch `Join` frames, and `publish_orbit_entry` ignored
marker-write failures.

Changes:
- Reclaim unleased `<core-cache>/staging/orbit/cores/` entries on agent
  startup, after core `PUT` and `TRANSFER`, and in
  `helios::core::cache::Root::collect()` (along with unreachable
  `staging/orbit/blobs/` files); hold shared `flock` leases on staged
  directories across live controller sessions (`PUT` -> `TRANSFER`),
  `FETCH`, and staging-backed `RUN` so concurrent GC preserves active
  staging.
- Sort `move_staged_tree` and `write_verified_marker_for` file lists and
  match `verified_marker_matches` by filename instead of position.
- Coordinate Linux child reaping with `stop()` via `waitid(P_PID, ...,
  WEXITED | WNOWAIT)` and `Group::reap` so `kill()` never targets a
  reused PID.
- Propagate `[paths].core_cache` and top-level `flare agent --core-cache`
  into `flare agent install` (preserving subcommand precedence) and quote
  `--core-cache` for systemd `ExecStart=`.
- Raise `MAX_PREAUTH_SESSIONS` to 1024 and `MAX_SESSIONS` to 1152 for
  16-rank × 64-stream bursts and log when connections are shed; avoid
  redundant pre-`read_header` controller checks once authorized.
- Fail fast in `distribution::root` on valid `Join` frames with an
  incompatible version or invalid/duplicate rank while still ignoring
  malformed TCP probes; propagate `.verified`/`.flare-verified.json` write
  errors in `publish_orbit_entry` and roll back the unpublished entry.
- Share `helios::core::cache::ROOT_DIRECTORIES` with `core_cache::evict`,
  remove redundant `AuthorizedCore::is_loadable` and NVML `check(..)`
  wrappers, and document manual cleanup of legacy flat rank directories in
  `docs/orbit.md`.

Verified with `--locked --release` tests: `helios` `core::`/`runtime_core::`/
`nvml` (505 passed, 12 ignored), `flare` (238 unit + 8 integration passed,
4 ignored), `flare-cli` (212 unit + 26 integration passed, 3 ignored), and
`heliopause` (216 passed, 6 ignored).

Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
@lukealonso
lukealonso merged commit bf7562a into main Nov 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:caching Prefix/KV reuse, cache retention, and model or payload cache behavior. area:memory Memory budgets, allocation lifetimes, scratch sharing, and capacity. area:orbit Orbit host agents, orchestration, and package-cache management. area:selene Selene shared prefix-cache pool, protocol, manager, and transfers. bug Something isn't working performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

2 participants