Repository navigation
Harden Orbit payload integrity, multi-deployment TP seams, GB10 page-cache release, Unix flock drop, and multi-host peer exports - #667
Conversation
…cache release, Unix flock drop, and multi-host peer exports Why this change is needed: Five operational defects remain in Orbit core distribution, integrated-GPU memory reclamation (#630), Unix file locking across `fork()`, and multi-host peer export caching: 1. Silent stale-weights execution on single-host Payload cores: `orbit/controller.rs` derived single-host `Core.export` from the primary filename stem (`model.safetensors` -> `"model"`), `Grant.core` omitted the signed envelope digest, and `orbit/agent.rs` (`have`, `transfer`, `run`) keyed and reused cached entries solely by directory name (`model-<len>`) and file byte length. Two different single-host checkpoints sharing the same architecture and fixed-width manifest/layer byte lengths collided on `model-<len>`, causing `have` and `transfer` to report cache hits and launch stale weights without transferring or verifying the updated checkpoint. 2. Broken Orbit seams on multi-deployment Payload cores (e.g., TP1+TP2+TP4): `VerifiedCore::open(..., None)` rejects cores with more than one deployment, causing `orbit/agent.rs` `verify_core` to fail and delete staged transfers, `publish_orbit_entry` to swallow metadata errors via `.ok()` and record a zeroed `[0u8; 32]` envelope without `.flare-verified.json`, `ServingOptions::rank_options` to omit `--tensor-parallel`, and rank zero launches under `agent::run` to start without `--tensor-parallel` (where `trust::load_with` cannot infer TP size because `args.hosts` is empty and `args.rank` is `Some(0)`). 3. Residual page-cache pressure on unified-memory GPUs such as GB10 (#630): `distribution.rs` never released Linux page cache after hashing primaries in `sha256_file` or streaming peer shard files (~95 GiB/peer) in `serve_source`. Because rank zero's model loader never opens peer shard files, `model.rs` could not evict those pages before CUDA context creation and KV sizing. Buffered writes in `core_cache.rs`, `agent::fetch`, and payload hashing in `protection.rs` likewise left verified bytes in page cache, and `model.rs` did not re-release page cache immediately after `load_payload` on integrated GPUs. 4. Unix `flock` retention across `fork()`: `helios::core::cache::Lock`, `helios::core::conversion::CoreLock`, and raw locked `File` guards in `flare` (`hub.rs`, `download_cache.rs`, `trust.rs`) had no `Drop` implementation calling `flock(LOCK_UN)`. When another thread forked a child process (`agent::run`) before `execve` closed `O_CLOEXEC` descriptors, the inherited open file description kept the advisory lock held after the parent dropped its guard. 5. Multi-host `--no-weights` peer failure and orphan peer blob leaks: Remote peers running `ignition join` (`host_ranks.py`) captured into their local `~/.cache/flare/cores` even though only rank zero commits a model entry. Normal multi-host exports leaked 40-100+ GiB of unreferenced blobs into each peer's cache, while `--no-weights` failed on cold or GC'd peers because `capture_group_into_cache` required cached weight blobs locally on the peer rather than deferring verification to rank zero's coordinator cache. What changed: - Orbit envelope binding and multi-deployment TP selection (`flare-cli/src/orbit/{grant,controller,agent}.rs`, `flare-cli/src/cli.rs`, `flare-cli/src/launch.rs`): - Before: `Grant.core` carried only `export`, `length`, `files`, and `source`; single-host `describe()` set `export` to the sanitized primary stem; `verify_core` and `publish_orbit_entry` called `VerifiedCore::open(..., None)`; `ServingOptions::rank_options` and `agent::run` omitted `--tensor-parallel`. - After: Added `#[serde(default)] envelope_digest: [u8; 32]` and `#[serde(default)] tensor_parallel: Option<u32>` to `Grant.core` (backward compatible with earlier grants). Single-host `describe()` appends the first 8 bytes (16 hex chars) of `authorized.envelope_digest()` to `export`. Controller `HAVE` sends `envelope_digest`; `agent.rs` checks `SourceRef::expected_envelope()` in `have()`, `transfer()`, `fetch()`, and `run()`, ignores unverified staging hits in `have()` when an envelope is bound, and verifies metadata envelopes before spawning `flare run`. `open_verified_core` dispatches Payload cores with `tensor_parallel` to `VerifiedCore::open_tensor_parallel`; `verify_core` returns `VerifiedCoreMeta` directly to `publish_orbit_entry`; `rank_options` forwards `--tensor-parallel`; `Controller::run` deduplicates saved vs. CLI `--tensor-parallel`; and `agent::run` emits `--tensor-parallel <tp>` once. - Page-cache release (`eos/src/{unix,windows}.rs`, `helios/src/lib.rs`, `helios/src/runtime_core/{model,protection}.rs`, `flare-cli/src/{distribution,core_cache}.rs`, `flare-cli/src/orbit/agent.rs`): - Before: `sha256_file`, `serve_source`, `Source` teardown, `store_parallel`, `store_partial`, `agent::fetch`, and `hash_payload` left buffered I/O in Linux page cache; `model.rs` released page cache at lines 618 and 917 only. - After: Added `release_page_cache_range` in `eos` (re-exported with `release_page_cache` from `helios`). Called `release_page_cache` / `release_page_cache_range` in `sha256_file`, `serve_source`, `Source` worker teardown (deduplicated across all peer file handles), `store_parallel` and `store_partial` after `sync_all()`, `agent::fetch`, `hash_payload`, and immediately after `load_payload` on integrated GPUs in `model.rs`. - Explicit Unix `flock(LOCK_UN)` on drop (`helios/src/core/{cache,conversion}.rs`, `flare/src/{file_lock,lib,hub,download_cache,trust}.rs`): - Before: `Lock`, `CoreLock`, and raw `File` locks in `flare` relied solely on descriptor close. - After: Added Unix `Drop` calling `libc::flock(fd, libc::LOCK_UN)` on `helios::core::cache::Lock` and `CoreLock`, and introduced shared RAII `flare::file_lock::FileLock` used across `hub.rs`, `download_cache.rs`, and `trust.rs`. - Multi-host peer export caching (`heliopause/src/export/{mod,capture,transfer}.rs`, `ignition/preparation/{core_snapshot,runtime_core,host_ranks}.py`): - Before: `host_ranks.py` exported peers into their persistent `core_cache` with local `--no-weights` cache checks. - After: Added `ExportOptions.remote_cache` (default `false`). Remote peers in `host_ranks.py` capture into a transient `peer-cache` inside `NativeExportStage` with `remote_cache=True` and drop `core` before `native_stage.close()`, reclaiming all transient peer blobs after transfer. Under `no_weights && remote_cache`, `capture_group_into_cache` hashes weight groups in a single pass and places them in `WeightPayloadSources.cached` without local cache lookup; rank zero's `receive_rank` checks existence and length in the coordinator cache while keeping zero payload reads. Claimed benefit and result: - Distinct single-host Payload cores with identical filenames and sizes no longer collide or launch stale weights in Orbit. - Multi-deployment Payload cores verify, publish with real envelope digests and `.flare-verified.json` markers, and launch rank zero with the selected `--tensor-parallel` size across Orbit and `--hosts`. - Peer shard distribution, verification hashing, and integrated-GPU weight loading are expected to keep Linux page cache reclaimed on unified-memory GPUs such as GB10 so KV cache sizing retains full available memory (#630). - Dropping cache/trust/hub locks releases Unix `flock` immediately even across concurrent `fork()` calls. - Multi-host `--no-weights` exports succeed on cold or GC'd peers, and normal multi-host exports leave zero orphan weight blobs on peer hosts. Supporting evidence and limitations: - Release CPU unit and integration tests (`--locked --release`): - `eos`: 12 passed, 0 failed. - `helios` (`--features runtime-core,server --lib -- core:: runtime_core::`): 507 passed, 0 failed, 12 ignored (GPU/hardware-gated), including `lock_drop_releases_flock_even_with_duplicate_descriptor`. - `flare`: 246 unit + 8 integration passed, 0 failed, 4 ignored, including `file_lock::tests::drop_releases_flock_even_when_duplicate_descriptor_stays_open`. - `flare-cli`: 219 unit + 26 integration passed, 0 failed, 3 ignored (4 consecutive full runs), including `rank_options_forward_tensor_parallel`, `single_host_describe_derives_distinct_exports_from_envelope_digest`, `envelope_digest_blocks_stale_single_host_cache_hits_and_wrong_weights`, and `multi_deployment_payload_core_verifies_publishes_and_launches_rank_zero_with_tp`. - `heliopause`: 229 passed, 0 failed, 6 ignored (CUDA-gated), including `capture_group_into_cache_reads_source_once_for_miss_hit_and_no_weights` and `remote_no_weights_peer_reuses_coordinator_cache_and_rejects_missing_or_corrupt`. - Python tests: `tests/cli` and `tests/preparation/test_core_boundary.py` (140 passed); `tests/preparation -k "host_ranks or core_snapshot or export"` (94 passed, 8 CUDA-gated skipped). - Limitations: Live multi-host GB10 KV sizing (#630), multi-host CUDA/RoCE exports (`FLARE_RUN_CUDA_TESTS=1` / `FLARE_RUN_TP_CUDA_TESTS=1`), and `helios` chat-template tests (`FLARE_TEST_TEMPLATE_DIR`) were not run on this host. Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b Signed-off-by: Luke Alonso <lalonso@gmail.com>
31eec32 to
7908ac3
Compare
|
A case file has been opened for 667. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedAll five fixes are sound — envelope binding closes the single-host cache collision, multi-deployment TP routing,
Walkthrough
Merge Risk: Medium · up to
|
Why this change is needed
Five defects affect Orbit core distribution, integrated-GPU KV cache sizing (#630), Unix file locking across
fork(), and multi-host peer exports:orbit/controller.rsderived single-hostCore.exportfrom the primary filename stem (model.safetensors->"model"),Grant.coreomitted the signed core envelope digest, andorbit/agent.rs(have,transfer,run) resolved and reused cached entries solely by directory name (model-<len>) and file byte length. Two different single-host checkpoints sharing the same architecture and fixed-width manifest/layer byte lengths collided onmodel-<len>, causinghave()andtransfer()to return cache hits (received: 0, verified: false) and launch stale weights without transferring or verifying the updated checkpoint.VerifiedCore::open(..., None)rejects cores containing more than one deployment (helios/src/runtime_core/protection.rs). That broke four Orbit paths:agent.rsverify_corefailed and deleted staged transfers after copying;publish_orbit_entryswallowedVerifiedCore::openerrors via.ok(), recording[0u8; 32]envelopes without.flare-verified.json;ServingOptions::rank_optionsdropped--tensor-parallel; andagent::runstarted rank zero without--tensor-parallel(wheretrust::load_withcannot infer TP size becauseargs.hostsis empty andargs.rankisSome(0)).flare-cli/src/distribution.rsnever calledrelease_page_cacheafter hashing primaries insha256_fileor streaming peer shards (~95 GiB/peer) inserve_source. Because rank zero's model loader never opens peer shard files,model.rs'sFiles::release_page_cachecould not evict those peer pages before CUDA initialization and KV sizing. Buffered writes incore_cache.rs,agent::fetch, and payload hashing inprotection.rsalso left verified bytes in Linux page cache, andmodel.rsdid not re-release page cache immediately afterload_payloadon integrated GPUs.flockretention acrossfork():helios::core::cache::Lock,helios::core::conversion::CoreLock, and raw lockedFileguards inflare(hub.rs,download_cache.rs,trust.rs) relied solely on closing the file descriptor without callingflock(LOCK_UN)inDrop. When another thread forked a child process (agent::run) beforeexecveclosedO_CLOEXECdescriptors, the inherited open file description kept the advisory lock held after the parent dropped its guard.--no-weightscold/GC'd peer failure and orphan peer blob leaks: Remote peers runningignition join(ignition/preparation/host_ranks.py) captured into their local~/.cache/flare/coreseven though only rank zero commits a model entry. Normal multi-host exports leaked 40-100+ GiB of unreferenced blobs into each peer's cache, and--no-weightsfailed on cold or GC'd peers becausecapture_group_into_cacherequired cached weight blobs locally on the peer instead of deferring cache validation to rank zero's coordinator cache.What changed
flare-cli/src/orbit/{grant,controller,agent}.rs,flare-cli/src/cli.rs,flare-cli/src/launch.rs):Grant.corecarried onlyexport,length,files, andsource; single-hostdescribe()setexportto the sanitized primary stem;verify_coreandpublish_orbit_entrycalledVerifiedCore::open(..., None);ServingOptions::rank_optionsandagent::runomitted--tensor-parallel.#[serde(default)] envelope_digest: [u8; 32]and#[serde(default)] tensor_parallel: Option<u32>toGrant.core(preserving compatibility with existing grants lacking these fields). Single-hostdescribe()appends the first 8 bytes (16 hex chars) ofauthorized.envelope_digest()toexport. ControllerHAVErequests carryenvelope_digest;agent.rschecksSourceRef::expected_envelope()acrosshave(),transfer(),fetch(), andrun(), refuses unverified staging hits inhave()when an envelope is bound, and verifies signed core metadata envelopes before spawningflare run. Addedopen_verified_coreto dispatch Payload cores withtensor_paralleltoVerifiedCore::open_tensor_parallel, returnedVerifiedCoreMetadirectly fromverify_coretopublish_orbit_entry, forwarded--tensor-parallelinServingOptions::rank_options, deduplicated saved vs. CLI--tensor-parallelinController::run(feeding saved values toresolve_core), and emitted--tensor-parallel <tp>once inagent::run.eos/src/{unix,windows}.rs,helios/src/lib.rs,helios/src/runtime_core/{model,protection}.rs,flare-cli/src/{distribution,core_cache}.rs,flare-cli/src/orbit/agent.rs):sha256_file,serve_source,Sourceteardown,store_parallel,store_partial,agent::fetch, andhash_payloaddid not release Linux page cache;model.rsreleased page cache only before GPU init and beforeallocate_caches.release_page_cache_rangeineosand re-exportedrelease_page_cacheandrelease_page_cache_rangefromhelios. Added page-cache release insha256_file, per transferred range inserve_source, across all deduplicated peerArc<File>handles duringSourceteardown, aftersync_all()instore_parallelandstore_partial, after range reads inagent::fetch, after each hashed payload inprotection.rs, and immediately afterload_payloadon integrated GPUs inmodel.rs.flock(LOCK_UN)on drop (helios/src/core/{cache,conversion}.rs,flare/src/{file_lock,lib,hub,download_cache,trust}.rs):helios::core::cache::Lock,CoreLock, and rawFilelocks inflarehad no UnixDropunlock.Dropcallinglibc::flock(fd, libc::LOCK_UN)onLockandCoreLock, and added a shared cross-platform RAIIflare::file_lock::FileLockreplacing rawFilelocks inhub.rs,download_cache.rs, andtrust.rs.heliopause/src/export/{mod,capture,transfer}.rs,ignition/preparation/{core_snapshot,runtime_core,host_ranks}.py):host_ranks.pyexported remote peers into their localcore_cacheand enforced--no-weightslocally on the peer.ExportOptions.remote_cache(defaultfalse). Remote peers inhost_ranks.pynow capture into a transientpeer-cacheinsideNativeExportStagewithremote_cache=Trueand releasecorebeforenative_stage.close(), reclaiming all transient peer blobs immediately after transfer. Underno_weights && remote_cache,capture_group_into_cachehashes weight groups in one pass and records them inWeightPayloadSources.cachedwithout local cache lookup; rank zero'sreceive_rankvalidates their presence and length in the coordinator cache while keeping zero payload reads.envelope_digestortensor_parallelcontinue to deserialize cleanly.Claimed benefit and result
model.safetensorsand identical file lengths can no longer collide in Orbit caches or silently launch stale weights..flare-verified.jsonmarkers, and launch rank zero with--tensor-parallelacross Orbit and--hosts.flockimmediately even while a concurrently forked child holds an inherited descriptor pre-execve.--no-weightsexports work on cold or GC'd peers, and normal multi-host exports leave zero orphan weight blobs on peer hosts.Supporting evidence and limitations
All Rust suites were run with
--locked --release:cargo test --locked --release --manifest-path eos/Cargo.toml --target-dir flare-cli/target: 12 passed, 0 failed.cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --target-dir flare-cli/target --lib -- core:: runtime_core::: 507 passed, 0 failed, 12 ignored (GPU/hardware-gated), includinglock_drop_releases_flock_even_with_duplicate_descriptor.cargo test --locked --release --manifest-path flare/Cargo.toml --target-dir flare-cli/target: 246 unit + 8 integration passed, 0 failed, 4 ignored, includingfile_lock::tests::drop_releases_flock_even_when_duplicate_descriptor_stays_open.cargo test --locked --release --manifest-path flare-cli/Cargo.toml: 219 unit + 26 integration passed, 0 failed, 3 ignored (4 consecutive full runs), including:cli::cache_cli_tests::rank_options_forward_tensor_parallelorbit::controller::tests::single_host_describe_derives_distinct_exports_from_envelope_digestorbit::agent::tests::envelope_digest_blocks_stale_single_host_cache_hits_and_wrong_weightsorbit::agent::tests::multi_deployment_payload_core_verifies_publishes_and_launches_rank_zero_with_tpcargo test --locked --release --manifest-path heliopause/Cargo.toml --target-dir flare-cli/target: 229 passed, 0 failed, 6 ignored (CUDA-gated), includingcapture_group_into_cache_reads_source_once_for_miss_hit_and_no_weights(with cold-peerremote_cache=truecoverage) andremote_no_weights_peer_reuses_coordinator_cache_and_rejects_missing_or_corrupt.pytest tests/cli tests/preparation/test_core_boundary.py -q: 140 passed.pytest tests/preparation -q -k "host_ranks or core_snapshot or export": 94 passed, 8 skipped (CUDA-gated).Limitations and unrun checks:
FLARE_RUN_CUDA_TESTS=1/FLARE_RUN_TP_CUDA_TESTS=1) were not run on this host.helioschat-template tests requiringFLARE_TEST_TEMPLATE_DIRwere not run.Related: #630
Discord: lukealonso