Skip to content

helios,heliopause,ignition: unify RankBody and RankOutput payload visitors for external_extents and align config.toml schema - #720

Merged
lukealonso merged 1 commit into
mainfrom
exhaustive-rankbody-payload-visitor
Dec 4, 2026
Merged

lukealonso merged 1 commit into
mainfrom
exhaustive-rankbody-payload-visitor

Conversation

@lukealonso

Copy link
Copy Markdown
Collaborator

Why

Payload-format prepared cores store authenticated Execution.async_transfers extent tables in RankBody.external_extents (a packed 24-byte-entry directory payload plus backing segment payloads), while preparation represents them in RankOutput.external_extents (ExternalExtentInput directory and segment file paths). Six independent hand-written walkers across Helios and Heliopause enumerated initializers, modules[].globals, and resources (or RankOutput.payload) without visiting external_extents, causing concrete failures across export, conversion, verification, and serving:

  1. Multi-host export transfer (heliopause/src/export/transfer.rs): send_rank and receive_rank hashed, validated, transferred, and rewrote only RankOutput.payload source paths, dropping external_extents files and leaving sender-local paths in the coordinator's staged rank output.
  2. Keyless pack/unpack and combine (helios/src/core/conversion.rs): rank_consumers omitted external_extents (dropping their LocationSet entries during Verified::open in pack and unpack), and publish_rank cloned rank.external_extents without adding the directory or segment payloads to PublishRank.payloads, failing schema::validate_rank.
  3. Cryptographic verification and multi-host serving bootstrap (helios/src/runtime_core/protection.rs): PayloadSource::supporting_payload_ids omitted external_extents directories and verification_payloads(true) omitted external_extents segments. Once authorize sets supporting_verified = true, PayloadSource::read skips per-read hashing, so prepare_async_transfers read unverified extent directories and --verify-weights never hashed offloaded extent segments. In addition, PayloadAuthorizedCore::rank_ranges omitted external_extents companions from per-rank transfer closures during multi-host serving bootstrap.
  4. Weight reuse and export planning (heliopause/src/export/weight_reuse.rs, heliopause/src/export/core.rs): open_source ignored external_extents when checking cached weight payloads for --reuse-weights; estimated_export_fds omitted pinned or leased external_extents file descriptors; and rank_plan pinned raw extent files directly instead of deduplicating against core-cache leases (forcing duplicate hashing in resolve_cache_object).
  5. Container alignment mismatch at capture (heliopause/src/export/capture.rs, ignition/preparation/execution.py): Core safetensors containers align payload bases to container::ALIGNMENT (4 KiB), placing companion tensors at offset 4096. Capture validated external_extents at seg_base_offset = 0 for any channel.alignment >= 4096, allowing channels with alignment > 4096 to export cleanly and fail at load time in decode_extent_directory (helios/src/async_transfer/ring.rs).
  6. Shared config.toml drift (ignition/cli/config.py): flare/src/configuration.rs accepts [memory] pool_vram and [memory] pool_ram, whereas ignition/cli/config.py restricted [memory] to {"reserve"}, causing every Ignition command to fail with UsageError when either key is configured in ~/.config/flare/config.toml.
  7. Broken helios test compilation (helios/src/runtime_core/cache_memory.rs, .github/workflows/helios-lifecycle.yml): cuda_sentinel_row_with_exact_granule_stride_maps_without_tail omitted external_extents: vec![] in a runtime_core::format::Core literal, breaking cargo test --manifest-path helios/Cargo.toml --features runtime-core,server on main while the Helios lifecycle workflow only built --features server.

Centralizing rank payload traversal in exhaustively destructured visitors (RankBody::visit_payload_uses and RankOutput::visit_source_paths) removes duplicated field walks and turns future payload-bearing field additions into compile-time errors across every consumer.

What changed

  • Exhaustive RankBody visitor and schema validation (helios/src/core/schema.rs):
    • Added RankPayloadUse (Initializer, ModuleGlobal, ExternalExtentDirectory, ExternalExtentSegment, ExecutableResource) and wire::RankBody::{visit_payload_uses, try_visit_payload_uses}, destructuring all fields of RankBody and its payload-bearing records without ...
    • Changed validate_external_extents from checking the whole payload length returned by catalog.check_use to checking directory.slice.nbytes, matching ModuleGlobal slice validation.
  • Unified Helios payload consumers (helios/src/core/reader.rs, helios/src/core/conversion.rs, helios/src/runtime_core/protection.rs, helios/src/runtime_core/format.rs, flare-cli/src/distribution/cache_tests.rs):
    • Replaced manual loops in reader::required_payloads, conversion::rank_consumers, conversion::publish_rank, PayloadSource::supporting_payload_ids, PayloadSource::verification_payloads, PayloadAuthorizedCore::rank_ranges, and cache_tests with visit_payload_uses / try_visit_payload_uses.
    • Before: supporting_payload_ids, verification_payloads(true), rank_ranges, rank_consumers, and publish_rank skipped external_extents. After: supporting_payload_ids unconditionally includes ExternalExtentDirectory (independent of PayloadRole, preserving compatibility with existing cores whose directories carry PayloadRole::Weights) plus any InitialState ExternalExtentSegment; verification_payloads(true) includes all ExternalExtentSegment payloads; and rank_ranges, rank_consumers, and publish_rank include all external_extents directories and segments.
    • Core::validate in helios/src/runtime_core/format.rs now rejects nonempty external_extents when execution is absent.
  • Test compilation fix and CI coverage (helios/src/runtime_core/cache_memory.rs, .github/workflows/helios-lifecycle.yml):
  • Exhaustive RankOutput visitor and Heliopause export (heliopause/src/export/{mod,transfer,weight_reuse,core,capture}.rs, ignition/preparation/execution.py):
    • Added RankSourcePath and exhaustively destructured RankOutput::{visit_source_paths, try_visit_source_paths, visit_source_paths_mut}.
    • Updated send_rank and receive_rank to hash, validate, transfer, and rewrite external_extents directory and segment paths alongside RankOutput.payload.
    • Updated weight_reuse::open_source to validate cached weight payloads via RankBody::try_visit_payload_uses.
    • Updated estimated_export_fds to count external_extents files (2 FDs per cache lease when cached, 1 pinned FD when uncached) and updated rank_plan to pin extent files before hashing via Slice::digest() and reuse matching core-cache leases.
    • Extracted validate_external_extents in capture.rs to validate directories at seg_base_offset = container::ALIGNMENT (4 KiB), reject channel.alignment > container::ALIGNMENT, reject invalid alignments (< 4096 or non-power-of-two) before modulo arithmetic, and reject empty directory files; added the matching alignment > 4096 check when extent_directory is set on AsyncTransferChannel in ignition/preparation/execution.py.
  • Configuration parity (ignition/cli/config.py, docs/cli-design.md, tests/cli/test_config.py, flare-cli/src/config.rs):
    • Added [memory] pool_vram and [memory] pool_ram to _SECTIONS and _BUILT_IN with validation matching flare_helios::runtime_core::PoolMemoryLimit::from_str.
    • Documented [memory] pool_vram and pool_ram in docs/cli-design.md.
    • Added test_python_config_schema_matches_rust_configuration in tests/cli/test_config.py, which parses flare/src/configuration.rs structs and serde aliases and loads a generated TOML file containing every Rust key through Configuration.load, plus unit tests for [memory] pool_vram/pool_ram precedence in flare-cli/src/config.rs.

Claimed benefit

  • Restores flare-helios --features runtime-core,server test compilation and keeps it gated in Helios lifecycle CI.
  • Fixes RankBody.external_extents end-to-end across multi-host export (send_rank/receive_rank), keyless pack/unpack, combine, multi-host serving bootstrap (rank_ranges), --reuse-weights, export FD preflight, cache-lease deduplication, and startup cryptographic verification (directories always verified; weight segments verified under verify_weights = true).
  • Prevents exporting unloadable external_extents channels whose alignment exceeds the 4 KiB core container alignment.
  • Eliminates UsageError failures in Ignition when [memory] pool_vram or [memory] pool_ram is set in shared ~/.config/flare/config.toml, with an automated Rust-vs-Python schema parity check.
  • Ensures future payload-bearing fields added to RankBody or RankOutput fail compilation until handled in every visitor consumer.

Supporting evidence and limitations

Executed on Linux x86_64 against origin/main (17961ccd):

  • Helios compilation (lifecycle CI check): cargo test --locked --manifest-path helios/Cargo.toml --features runtime-core,server --lib --no-run passed with 0 warnings (baseline on origin/main failed with E0063: missing field external_extents at helios/src/runtime_core/cache_memory.rs:1659).
  • Helios unit tests: FLARE_TEST_TEMPLATE_DIR=/tmp/flare-test-templates cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib: 1899 passed, 6 failed, 49 ignored.
    • Passing targeted coverage includes new tests core::schema::tests::visit_payload_uses_covers_all_rank_payload_categories, core::schema::tests::validate_external_extents_checks_directory_slice_length, core::conversion::tests::pack_unpack_and_combine_preserve_external_extents_payloads, runtime_core::protection::payload_core_tests::external_extents_verification_and_rank_ranges_cover_directory_and_segments, and all 52 non-GPU cache_memory::tests (4 GPU/benchmark tests ignored).
    • The 6 failures (frontend::jinja::tests::*, frontend::templates::tests::compatibility_requires_exact_legacy_bytes, server::protocol::decode::native_prompt_tests::messages_image_hints_end_after_expansion_for_text_and_segmented_templates) occurred because the local /tmp/flare-test-templates cache lacked external template fixtures for nemotron_h, qwen38, and step5.
  • Helios runtime-core integration tests: cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --test unverified_empty --test actual_qwen38_tp2 --test actual_w4a16: 3 passed, 0 failed, 2 ignored.
  • Heliopause unit tests: cargo test --locked --release --manifest-path heliopause/Cargo.toml --lib: 234 passed, 0 failed, 6 ignored, including new tests export::capture::tests::validate_external_extents_enforces_container_alignment_and_nonempty_directory, export::transfer::tests::rank_transfer_roundtrips_external_extents_and_rewrites_paths, and export::core::payload_export_tests::external_extents_fd_preflight_cache_dedup_and_weight_reuse_open_source.
  • Flare and Flare CLI tests:
    • cargo test --locked --release --manifest-path flare/Cargo.toml --tests: 255 passed, 0 failed, 4 ignored (247 lib, 7 packed_canonical_download, 1 reference_workflows).
    • cargo test --locked --release --manifest-path flare-cli/Cargo.toml --tests: 249 passed, 0 failed, 3 ignored (223 bin including config::tests::pool_memory_configuration_and_flag_precedence, 9 cache_commands, 6 cli, 4 inspect, 7 unverified_payload).
  • Python CPU tests:
    • CUDA_VISIBLE_DEVICES="" pytest tests/cli tests/preparation/test_execution.py -q: 260 passed, 0 failed, including [memory] pool_vram/pool_ram validation, test_python_config_schema_matches_rust_configuration, and test_async_transfer_channel_rejects_external_extents_alignment_above_container_alignment.
    • CUDA_VISIBLE_DEVICES="" pytest tests/preparation/test_runtime_core.py tests/preparation/test_core_boundary.py -q: 26 passed, 14 skipped (CUDA/optional fixtures).
  • Limitations / unrun checks: GPU-only tests (#[ignore] / FLARE_RUN_CUDA_TESTS), live multi-host GPU export and serving with external_extents, and the 6 external-template frontend tests were not run locally; GitHub Actions workflows will run the full template-populated Linux/Windows native-serving, Python CPU, and Helios lifecycle suites.

Discord: lukealonso

…itors for external_extents and align config.toml schema

Independent payload walkers across Helios and Heliopause omitted
RankBody.external_extents (the authenticated extent directories and
backing segments for Execution.async_transfers), creating six defects:
multi-host rank export dropped external_extents files and left
sender-local paths unrewritten; keyless pack/unpack and combine dropped
external_extents from location closures and PublishRank.payloads;
runtime-core verification omitted external_extents directories from
supporting_payload_ids (leaving directories unhashed once
supporting_verified is set), omitted segments from
verification_payloads(true), and omitted external_extents companions
from multi-host serving bootstrap (rank_ranges); weight reuse and export
planning omitted external_extents from cached-weight checks, file
descriptor preflight accounting, and cache-lease deduplication; capture
validation checked external_extents at seg_base_offset=0, allowing
alignments above the 4 KiB core container alignment to pass export and
fail at load; and Ignition's config.toml validator rejected [memory]
pool_vram and pool_ram that Flare already accepts. Separately, a test
Core literal in helios/src/runtime_core/cache_memory.rs omitted
external_extents, breaking cargo test --features runtime-core,server
compilation while the Helios lifecycle workflow only built --features
server. Unifying rank traversal through exhaustively destructured
visitors ensures future payload-bearing fields on RankBody or RankOutput
fail compilation until every consumer classifies them.

Changes:
- helios/src/core/schema.rs: add RankPayloadUse and exhaustively
  destructured wire::RankBody::{visit_payload_uses,
  try_visit_payload_uses}; fix validate_external_extents to validate
  directory.slice.nbytes rather than the enclosing payload length.
- helios/src/core/reader.rs, helios/src/core/conversion.rs,
  helios/src/runtime_core/protection.rs,
  flare-cli/src/distribution/cache_tests.rs: replace manual rank payload
  loops with RankBody::visit_payload_uses / try_visit_payload_uses.
  supporting_payload_ids now always includes ExternalExtentDirectory
  (independent of PayloadRole, preserving compatibility with cores whose
  directories use PayloadRole::Weights) plus any InitialState
  ExternalExtentSegment; verification_payloads(true) includes all
  ExternalExtentSegment payloads; rank_ranges includes all rank
  external_extents companions.
- helios/src/runtime_core/format.rs,
  helios/src/runtime_core/cache_memory.rs,
  .github/workflows/helios-lifecycle.yml: reject nonempty
  Core.external_extents without an execution manifest, add missing
  external_extents: vec![] to the cache_memory test Core literal, and
  add runtime-core,server test compilation to the Helios lifecycle
  workflow.
- heliopause/src/export/{mod,transfer,weight_reuse,core,capture}.rs and
  ignition/preparation/execution.py: add RankSourcePath and exhaustively
  destructured RankOutput::{visit_source_paths, try_visit_source_paths,
  visit_source_paths_mut}; transfer and rewrite external_extents paths
  in send_rank/receive_rank; route weight_reuse::open_source through
  RankBody::try_visit_payload_uses; account for external_extents file
  descriptors in estimated_export_fds and deduplicate them against
  core-cache leases in rank_plan; extract and enforce 4 KiB
  container::ALIGNMENT (validating at seg_base_offset=4096 and rejecting
  empty directories) in capture.rs and AsyncTransferChannel.
- ignition/cli/config.py, docs/cli-design.md, tests/cli/test_config.py,
  flare-cli/src/config.rs: accept and validate [memory] pool_vram and
  pool_ram matching flare_helios::runtime_core::PoolMemoryLimit, update
  the configuration specification, and add a Rust-vs-Python schema
  parity test that parses flare/src/configuration.rs and loads every
  Rust configuration key through Configuration.load.

Result:
Restores flare-helios --features runtime-core,server test compilation,
closes multi-host export transfer, keyless pack/unpack, combine,
multi-host serving rank_ranges, --reuse-weights, and cryptographic
verification coverage for RankBody.external_extents, prevents exporting
unloadable external_extents channels above 4 KiB container alignment,
unblocks Ignition commands sharing config.toml files with [memory]
pool_vram or pool_ram, and turns future omitted payload fields on
RankBody or RankOutput into compile-time errors.

Validation (CPU suites on Linux x86_64):
- cargo test --locked --manifest-path helios/Cargo.toml --features
  runtime-core,server --lib --no-run: compiled cleanly (0 warnings).
- cargo test --locked --release --manifest-path helios/Cargo.toml
  --features runtime-core,server --lib (with
  FLARE_TEST_TEMPLATE_DIR=/tmp/flare-test-templates): 1899 passed,
  49 ignored, 6 failed solely in external chat-template tests due to
  missing nemotron_h/qwen38/step5 fixtures in /tmp/flare-test-templates;
  all new schema, conversion, combine, and protection external_extents
  tests and all 52 cache_memory unit tests passed.
- cargo test --locked --release --manifest-path helios/Cargo.toml
  --features runtime-core,server --test unverified_empty
  --test actual_qwen38_tp2 --test actual_w4a16: 3 passed, 0 failed,
  2 ignored.
- cargo test --locked --release --manifest-path heliopause/Cargo.toml
  --lib: 234 passed, 0 failed, 6 ignored (including new capture
  alignment, transfer roundtrip, FD preflight, cache dedup, and
  weight_reuse::open_source tests).
- cargo test --locked --release --manifest-path flare/Cargo.toml
  --tests: 255 passed, 0 failed, 4 ignored.
- cargo test --locked --release --manifest-path flare-cli/Cargo.toml
  --tests: 249 passed, 0 failed, 3 ignored (including new pool_vram and
  pool_ram config precedence tests).
- pytest tests/cli tests/preparation/test_execution.py: 260 passed,
  0 failed (including pool_vram/pool_ram validation, Rust-vs-Python
  config parity, and AsyncTransferChannel alignment tests);
  tests/preparation/test_runtime_core.py and test_core_boundary.py:
  26 passed, 14 skipped (CUDA/optional fixtures).
Limitations: live CUDA execution, GPU-only tests, multi-host live fabric
serving with external_extents, and the 6 missing-template frontend tests
were not executed here.

Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
Signed-off-by: Luke Alonso <lalonso@gmail.com>
@lukealonso
lukealonso merged commit f705086 into main Dec 4, 2026
3 checks passed
jcartu added a commit to jcartu/hyperflare-inference that referenced this pull request Dec 4, 2026
… inherit orbit memory reserve, and log integrated MemInfo

Why

- On Linux unified-memory GPUs (such as GB10), CUDA allocations and context
  creation can respond to Linux `MemFree` rather than `MemAvailable` when
  tens of gigabytes of clean page cache accumulate from core distribution
  and buffered cache I/O (NVIDIA#630).
- `flare-cli`'s peer-serving path (`distribution::serve_source`) streamed
  core shards via buffered `RangeReader` before dropping page cache,
  leaving multi-GiB bursts in the page cache during transfer, and four
  buffered I/O sites across `flare-cli` and `helios` omitted
  `release_page_cache`.
- `flare orbit run` did not inherit `[memory] reserve` from host
  configuration (`config.rs`), unlike `flare run`, while persistent
  groups still needed their stored `--memory-limit` preserved unless
  overridden on the command line and must not freeze config defaults into
  saved `GroupSpec.serving` definitions.
- When integrated-GPU cache planning was memory-limited or
  `cuDevicePrimaryCtxRetain` / `cuCtxCreate_v2` returned
  `CUDA_ERROR_OUT_OF_MEMORY`, diagnostics did not surface Linux
  `MemFree / MemAvailable / Cached` or hint when reclaimable page cache
  was likely blocking allocation.

What changed

- Direct peer serving and missed `release_page_cache` sites:
  - Re-exported `eos` direct-I/O helpers (`FileReadAt`, `allocate_aligned`,
    `direct_reopen`, `free_aligned`) from `helios/src/lib.rs`.
  - Updated `flare-cli/src/distribution.rs::serve_source` to reopen files
    with `direct_reopen` on Unix and stream 4 MiB aligned chunks from a
    zero-initialized `AlignedBuffer` (handling arbitrary unaligned offsets,
    multi-range requests, and unaligned EOF byte-for-byte identically to
    `cache::RangeReader`), falling back cleanly to buffered `RangeReader`
    when `O_DIRECT` is unsupported or returns `EINVAL`, and executing one
    unconditional post-branch `release_page_cache_range` loop in
    `copy_source_ranges` for every served range (including on error).
  - Added `release_page_cache` / `release_page_cache_range` at the four
    missed buffered I/O sites: `flare-cli/src/orbit/controller.rs`,
    `flare-cli/src/core_cache.rs`, `flare-cli/src/orbit/agent.rs::get`,
    and `helios/src/core/cache.rs` (`write_stream`, `verify_file`,
    `hash_file`, `import_legacy_into`, and non-Windows `copy_file`).
    Collapsed `verify_file` onto `hash_file(path, release: bool)` so
    `import_legacy_into` hashes with `release = false` (avoiding double
    storage reads before `insert_legacy_container`) and releases the
    source file unconditionally after `insert_legacy_container` returns.
- Orbit `[memory] reserve` propagation:
  - Added `#[arg(skip)] pub config_memory_limit: Option<MemoryLimit>` to
    `OrbitRun` (`flare-cli/src/cli.rs`) and `RunOptions`
    (`flare-cli/src/orbit/controller.rs`), populated from `[memory] reserve`
    in `flare-cli/src/config.rs` only when `--memory-limit` is unset on
    the command line.
  - Kept config-derived `--memory-limit` out of `OrbitRun::rank_options`
    and `GroupSpec.serving` so persistent groups never freeze config
    defaults; applied it only at launch via `apply_config_memory_limit`
    when neither the saved group nor the CLI specifies `--memory-limit`.
  - Added a persistent-group round-trip unit test through `save_group` /
    `Orbit::save` / `Orbit::load` verifying config reserve edits take
    effect on reload while explicit saved and CLI `--memory-limit` values
    retain precedence.
- Linux integrated-GPU `/proc/meminfo` diagnostics:
  - Added `LinuxMemInfo { free, available, cached }` parser and
    `CUDA_ERROR_OUT_OF_MEMORY` constant in `helios/src/runtime_core/`.
  - Appended `MemFree / MemAvailable / Cached` to the `Plan cache`
    summary on Linux integrated GPUs and emitted a concise stderr warning
    when `MemAvailable - MemFree > 10 GiB` and KV sizing is limited by
    memory (without repeating the triple already logged in `Plan cache`).
  - Enriched `cuDevicePrimaryCtxRetain` and `cuCtxCreate_v2`
    `CUDA_ERROR_OUT_OF_MEMORY` failures on Linux integrated GPUs via
    `enrich_integrated_ctx_oom(error, meminfo: Option<LinuxMemInfo>)` with
    `MemFree / MemAvailable / Cached` (and a `drop_caches` hint when
    `MemAvailable - MemFree > 4 GiB`) while preserving the structured
    `ExecutionError::Driver(CudaError { code: 2, .. })` error.
- Documentation:
  - Documented `orbit run` `[memory] reserve` inheritance, non-persistence,
    and saved/CLI `--memory-limit` precedence in `docs/orbit.md` and
    `docs/cli-design.md`, and integrated-GPU `Plan cache` / context-OOM
    `/proc/meminfo` diagnostics in `docs/cli-design.md`.

Verification

- Rebased onto `origin/main` (`f705086b`, including `NVIDIA#720` and `NVIDIA#721`).
- CPU-only verification on Linux x86_64 (no live GB10 run yet):
  - Verified `.githooks/commit-msg` passes on the staged diff and message.
  - `cargo test --locked --release --manifest-path flare-cli/Cargo.toml`:
    254 passed (228 bin + 9 cache_commands + 6 cli + 4 inspect + 7 unverified_payload), 0 failed, 3 ignored.
  - `cargo test --locked --release --manifest-path flare/Cargo.toml`:
    255 passed (247 lib + 7 packed_canonical_download + 1 reference_workflows), 0 failed, 4 ignored.
  - `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib`:
    `core::cache` 106 passed, 0 failed, 2 ignored; `runtime_core::` 206 passed (including `runtime_core::memory` 30 passed), 0 failed, 13 ignored.
  - `rustfmt --edition 2024`: clean on all touched lines across all 12
    Rust files.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
Signed-off-by: Joshua Cartu <jcartu@users.noreply.github.com>
fakoli added a commit to fakoli/hyperflare-inference that referenced this pull request Dec 4, 2026
Why:
Under --prefix-cache-pool with --prefix-cache-memory 0 (pool_only()), the host
capture slab and runtime_core::memory headroom planning previously sized
buffers for full multi-sequence GPU KV capacity (~33 GiB on an RTX PRO 6000
96 GiB card for 1M-context cores), even though any single sequence chain
cannot exceed max_sequence_tokens.

What changed:
- selene/src/offload.rs: Added PrepareInputs::max_sequence_pages: Option<u64>
  and capped pool_only() chain capture slots to local_pages.min(limit) +
  row_slots when limit > 0, keeping unbounded local_pages for None / Some(0).
- helios/src/runtime_core/{memory,model}.rs: Computed max_sequence_pages =
  max_sequence_tokens.div_ceil(page_tokens), passed it to PrepareInputs, and
  clamped minimum_pages, capture_growth, and planned_offload_host in memory.rs.
- docs/prefix-cache-offload.md & tests: Documented prepared max-sequence page
  capping and power-of-two --staging (Arena) sizing behavior for NoWindows
  avoidance on >8 GiB exports, and added
  pool_only_caps_capture_buffer_to_max_sequence_pages.

Claimed benefit:
Bounds pool_only() host capture allocation on a 1M-context JMNI-Labs/Inkling-2-Mini-FLARE
RTX PRO 6000 96 GiB prefill rank to one sequence chain plus one row (9.1 GiB /
8,293 slots), reducing combined committed RSS across selene, prefill, and decode
from 46.02 GiB to 41.77 GiB. Multi-sequence simultaneous capture still requires
explicit --prefix-cache-memory.

Evidence:
- 6-crate RUSTFLAGS="-D warnings" cargo check and release test suite (3,514
  passed, 0 failed, 94 ignored) on 45e1c1a baseline, plus focused re-verification
  of flare-helios, flare-selene, and flare-selene-manager tests after rebase
  onto f705086 (NVIDIA#720) including pool_only_caps_capture_buffer_to_max_sequence_pages.
- verification/helios-lifecycle/check.py --mutations passed all TLA+ models and
  observed Rust transitions on 45e1c1a.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
Signed-off-by: fakoli <fakoli@users.noreply.github.com>
lukealonso pushed a commit that referenced this pull request Dec 4, 2026
… inherit orbit memory reserve, and log integrated MemInfo (#713)

Why

- On Linux unified-memory GPUs (such as GB10), CUDA allocations and context
  creation can respond to Linux `MemFree` rather than `MemAvailable` when
  tens of gigabytes of clean page cache accumulate from core distribution
  and buffered cache I/O (#630).
- `flare-cli`'s peer-serving path (`distribution::serve_source`) streamed
  core shards via buffered `RangeReader` before dropping page cache,
  leaving multi-GiB bursts in the page cache during transfer, and four
  buffered I/O sites across `flare-cli` and `helios` omitted
  `release_page_cache`.
- `flare orbit run` did not inherit `[memory] reserve` from host
  configuration (`config.rs`), unlike `flare run`, while persistent
  groups still needed their stored `--memory-limit` preserved unless
  overridden on the command line and must not freeze config defaults into
  saved `GroupSpec.serving` definitions.
- When integrated-GPU cache planning was memory-limited or
  `cuDevicePrimaryCtxRetain` / `cuCtxCreate_v2` returned
  `CUDA_ERROR_OUT_OF_MEMORY`, diagnostics did not surface Linux
  `MemFree / MemAvailable / Cached` or hint when reclaimable page cache
  was likely blocking allocation.

What changed

- Direct peer serving and missed `release_page_cache` sites:
  - Re-exported `eos` direct-I/O helpers (`FileReadAt`, `allocate_aligned`,
    `direct_reopen`, `free_aligned`) from `helios/src/lib.rs`.
  - Updated `flare-cli/src/distribution.rs::serve_source` to reopen files
    with `direct_reopen` on Unix and stream 4 MiB aligned chunks from a
    zero-initialized `AlignedBuffer` (handling arbitrary unaligned offsets,
    multi-range requests, and unaligned EOF byte-for-byte identically to
    `cache::RangeReader`), falling back cleanly to buffered `RangeReader`
    when `O_DIRECT` is unsupported or returns `EINVAL`, and executing one
    unconditional post-branch `release_page_cache_range` loop in
    `copy_source_ranges` for every served range (including on error).
  - Added `release_page_cache` / `release_page_cache_range` at the four
    missed buffered I/O sites: `flare-cli/src/orbit/controller.rs`,
    `flare-cli/src/core_cache.rs`, `flare-cli/src/orbit/agent.rs::get`,
    and `helios/src/core/cache.rs` (`write_stream`, `verify_file`,
    `hash_file`, `import_legacy_into`, and non-Windows `copy_file`).
    Collapsed `verify_file` onto `hash_file(path, release: bool)` so
    `import_legacy_into` hashes with `release = false` (avoiding double
    storage reads before `insert_legacy_container`) and releases the
    source file unconditionally after `insert_legacy_container` returns.
- Orbit `[memory] reserve` propagation:
  - Added `#[arg(skip)] pub config_memory_limit: Option<MemoryLimit>` to
    `OrbitRun` (`flare-cli/src/cli.rs`) and `RunOptions`
    (`flare-cli/src/orbit/controller.rs`), populated from `[memory] reserve`
    in `flare-cli/src/config.rs` only when `--memory-limit` is unset on
    the command line.
  - Kept config-derived `--memory-limit` out of `OrbitRun::rank_options`
    and `GroupSpec.serving` so persistent groups never freeze config
    defaults; applied it only at launch via `apply_config_memory_limit`
    when neither the saved group nor the CLI specifies `--memory-limit`.
  - Added a persistent-group round-trip unit test through `save_group` /
    `Orbit::save` / `Orbit::load` verifying config reserve edits take
    effect on reload while explicit saved and CLI `--memory-limit` values
    retain precedence.
- Linux integrated-GPU `/proc/meminfo` diagnostics:
  - Added `LinuxMemInfo { free, available, cached }` parser and
    `CUDA_ERROR_OUT_OF_MEMORY` constant in `helios/src/runtime_core/`.
  - Appended `MemFree / MemAvailable / Cached` to the `Plan cache`
    summary on Linux integrated GPUs and emitted a concise stderr warning
    when `MemAvailable - MemFree > 10 GiB` and KV sizing is limited by
    memory (without repeating the triple already logged in `Plan cache`).
  - Enriched `cuDevicePrimaryCtxRetain` and `cuCtxCreate_v2`
    `CUDA_ERROR_OUT_OF_MEMORY` failures on Linux integrated GPUs via
    `enrich_integrated_ctx_oom(error, meminfo: Option<LinuxMemInfo>)` with
    `MemFree / MemAvailable / Cached` (and a `drop_caches` hint when
    `MemAvailable - MemFree > 4 GiB`) while preserving the structured
    `ExecutionError::Driver(CudaError { code: 2, .. })` error.
- Documentation:
  - Documented `orbit run` `[memory] reserve` inheritance, non-persistence,
    and saved/CLI `--memory-limit` precedence in `docs/orbit.md` and
    `docs/cli-design.md`, and integrated-GPU `Plan cache` / context-OOM
    `/proc/meminfo` diagnostics in `docs/cli-design.md`.

Verification

- Rebased onto `origin/main` (`f705086b`, including `#720` and `#721`).
- CPU-only verification on Linux x86_64 (no live GB10 run yet):
  - Verified `.githooks/commit-msg` passes on the staged diff and message.
  - `cargo test --locked --release --manifest-path flare-cli/Cargo.toml`:
    254 passed (228 bin + 9 cache_commands + 6 cli + 4 inspect + 7 unverified_payload), 0 failed, 3 ignored.
  - `cargo test --locked --release --manifest-path flare/Cargo.toml`:
    255 passed (247 lib + 7 packed_canonical_download + 1 reference_workflows), 0 failed, 4 ignored.
  - `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib`:
    `core::cache` 106 passed, 0 failed, 2 ignored; `runtime_core::` 206 passed (including `runtime_core::memory` 30 passed), 0 failed, 13 ignored.
  - `rustfmt --edition 2024`: clean on all touched lines across all 12
    Rust files.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b

Signed-off-by: Joshua Cartu <jcartu@users.noreply.github.com>
Co-authored-by: Joshua Cartu <jcartu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant