Skip to content

Accelerate multi-host rank export transfer and check disk space up front - #588

Draft
FujitsuPolycom wants to merge 2 commits into
NVIDIA:mainfrom
FujitsuPolycom:perf/multihost-rank-export-transfer
Draft

FujitsuPolycom wants to merge 2 commits into
NVIDIA:mainfrom
FujitsuPolycom:perf/multihost-rank-export-transfer

Conversation

@FujitsuPolycom

Copy link
Copy Markdown
Contributor

Why

Multi-host ignition export can discover insufficient disk space after preparing weights and graphs. Peer transfers also wait behind rank zero's local export, and cache installation re-reads companion files that transfer framing already verified.

What changed

Before: Ignition started preparation without checking host storage, rank zero finished its local export before receiving peer payloads, and cache installation re-read verified companion files.

After: Ignition checks cache and staging capacity before preparation, deducting reusable bytes only from verified planned checkpoint blobs ((sha256_hex, nbytes) in core_cache/blobs/) or signed CoreEnvelope Weights payloads verified via flare_heliopause.export_verified_reusable_weight_bytes (matching recipe, checkpoint repository, exact checkpoint_revision, weight-scoped parameters, TP width, and architecture). Hard UsageError rejection applies strictly when free_bytes <= 0 or free_bytes < net_weights; heuristic executable/staging margins emit UserWarning advisories. Rank zero receives peer payloads concurrently with local export, transfer aborts wake blocked peers and release descriptors, and Linux cache adoption links verified companions after inode/header checks.

Claimed benefit and result

Predictably infeasible weight exports fail before GPU preparation without crediting unrelated cached revisions or rejecting tight margins on heuristic floors, while peer transfer overlaps with rank-zero export.

Supporting evidence and limitations

Candidate 1c0d47b711a9131923f82b2095037128df7ba066 stacked on #585 (perf/native-capture-and-streaming-publish at 3805fcf9cbf8a5ba938f4909779bdfff31569909, atop main 167f22c88076c1da801fe0ceca35f846d7295b24). Verified in WSL2:

  • python -m pytest -q -rs tests/preparation/test_core_boundary.py tests/test_design_review_hook.py: 22 passed.
  • python -m pytest -q -rs tests/cli/test_export_disk_preflight.py tests/preparation/test_host_ranks.py tests/preparation/test_checkpoint_source.py: 60 passed. Covers rejecting unverified or mismatched-revision cache files, deducting verified planned digests and signed weight-reuse cores, and emitting warnings rather than hard errors when net_weights <= free_bytes < recommended_bytes.
  • cargo test --locked --release --manifest-path heliopause/Cargo.toml --lib -- --test-threads=1: 218 passed, 5 ignored, 0 failed.
  • cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib core::cache -- --test-threads=1 and core::export: passed, 0 failed.
  • Broad helios unit runs reproduce two pre-existing base failures on 167f22c88076c1da801fe0ceca35f846d7295b24 (model::tests::packed_combined_budget_keeps_width_one_batches_without_a_useful_packed_shape and server::runtime::phase_tests::worker_observes_prefill_decode_and_prerequisite_timings).
  • Multi-host GPU export, Windows transfer paths, and signed-core serving remain unverified on this candidate.

Stack and merge order

Merge #585 (3805fcf9cbf8a5ba938f4909779bdfff31569909) into main first, then rebase and mark this PR ready. While this Draft PR targets main, Files changed includes #585; see the incremental diff for this commit alone.

Discord: Dooner

Why:
Native export repeats CUDA driver symbol and kernel parameter queries across graphs, scans captured weight blocks serially, and serializes executable resource compression during publication.

What:
Before: Heliopause repeated CUDA symbol and kernel parameter lookups per graph, scanned weight blocks sequentially, and compressed executable resources one at a time.
After: Heliopause caches resolved driver symbols and kernel parameter layouts per recording session (invalidating on module unload or context teardown), scans weight blocks in parallel, streams large weight groups into verified cache companions, and compresses executable resources in memory-bounded batches (`IN_MEMORY_BATCH_BYTES = 64 MiB` cumulative plaintext per batch, scaled down by `/proc/meminfo` `MemAvailable` and falling back to zero-batch streaming below `512 MiB` headroom) while writing in capture order.

Result:
Native export reduces repeated driver queries and overlaps executable compression with archive writes while bounding transient batch plaintext memory to at most two 64 MiB batches (`128 MiB`).

Evidence:
- `cargo test --locked --release --manifest-path heliopause/Cargo.toml --lib -- --test-threads=1`: 216 passed, 5 ignored, 0 failed.
- `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib core::export -- --test-threads=1`: 36 passed, 1 ignored, 0 failed.
- `python -m pytest -q -rs tests/preparation/test_core_boundary.py tests/test_design_review_hook.py`: 22 passed.
- Live CUDA recording, signed-core serving, and isolated export throughput remain unverified on this revision.

Discord: Dooner

Design-Signed-Off-By: Antigravity (Gemini 4); design-review=c3a9
Signed-off-by: FujitsuPolycom <[email protected]>
Why:
Multi-host `ignition export` can exhaust disk space after GPU preparation, stalls peer transfers behind rank zero's local export, and re-reads verified companion files during cache adoption.

What:
Before: Ignition ran preparation without checking host disk space, rank zero finished local export before receiving peer payloads, and companion installation re-hashed verified files.
After: Ignition checks free staging and cache bytes up front, deducting only verified planned checkpoint blobs (`sha256_hex` and byte length) or signed `CoreEnvelope` weight payloads matching model identity, TP width, `i32` compute-capability architecture, and exact `checkpoint_revision`, reserving hard `UsageError` failures for `free_bytes < net_weights` while warning on heuristic executable margins. Rank zero overlaps peer reception with local export, aborts wake blocked peers and release descriptors, and Linux cache adoption links verified companions by inode/header.

Result:
Defensible weight-capacity shortfalls fail before GPU preparation without false deductions from unrelated revisions, while rank transfer overlaps with local export and avoids redundant companion reads.

Evidence:
- `python -m pytest -q -rs tests/preparation/test_core_boundary.py tests/test_design_review_hook.py tests/cli/test_export_disk_preflight.py tests/preparation/test_host_ranks.py tests/preparation/test_checkpoint_source.py`: 82 passed.
- `cargo test --locked --release --manifest-path heliopause/Cargo.toml --lib -- --test-threads=1`: passed, 0 failed.
- `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib core::cache -- --test-threads=1`: 101 passed, 1 ignored, 0 failed.

Discord: Dooner

Design-Signed-Off-By: Antigravity (Gemini 4 Carbon); design-review=c3a9
Signed-off-by: FujitsuPolycom <[email protected]>

@voipmonitor voipmonitor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Draft Review & Build/Test Report (commit 1c0d47b7, stacked on #585)

Verdict: Do not merge — fails to compile flare-heliopause (E0277), stacked on #585, and introduces a cache verification bypass plus disk-preflight and concurrency bugs.

Build & Automated Test Results

  • Python pytest -q tests/cli/test_export_disk_preflight.py tests/preparation/test_host_ranks.py — 23 passed, 0 failed (note: test_export_disk_preflight.py:313 monkeypatches out the Rust helper).
  • cargo test --locked --release --manifest-path heliopause/Cargo.toml --lib — FAILS TO COMPILE (E0277):
    error[E0277]: can't compare `i32` with `u32`
       --> src/export/weight_reuse.rs:163:63
        |
    163 | ...y.architecture != architecture)
        |                   ^^ no implementation for `i32 == u32`
    
    body.architecture is Vec<i32> while verified_reusable_weight_bytes takes architecture: &[u32].

Blockers

  1. [Blocker] flare-heliopause does not compile (heliopause/src/export/weight_reuse.rs:163).
  2. [Blocker] pub fn Root::adopt_verified_companion bypasses payload SHA-256 verification for external paths (helios/src/core/cache.rs:1975-2080, heliopause/src/export/transfer.rs:1303-1325):
    Unlike #585's private publish_verified_payload (confined to Root's own private staging transaction), #588 exposes a public method taking an external path + (dev, ino) after transfer.rs calls drop(file), verifies only (dev, ino), size, and the 4 KiB header (not readonly, nlink == 1, or continuous fd ownership), hard-links via /proc/self/fd, and skips payload SHA-256 verification. Any concurrent writer holding a writable fd can mutate bytes after drop(file) and poison the immutable content-addressed cache. Fix by streaming received companions directly into a Root-owned private staging transaction, or keep adopt_companion's post-link verification.
  3. [Blocker] 140 LOC of untested Rust verification code masked by except Exception: return 0 (weight_reuse.rs:93-220, ignition/planning.py:151-185):
    Zero Rust or Python tests invoke verified_reusable_weight_bytes / export_verified_reusable_weight_bytes (which is why E0277 went undetected). planning.py:184 catches bare except Exception: return 0, silently masking real errors, and planning.py:170 constructs SimpleNamespace(directory=None, ...) breaking local-checkpoint reuse accounting.

Major Issues

  1. Disk preflight false positives blocking valid exports (serve.py:203-214, planning.py:56-70, 188-201, 365-384, weight_reuse.rs:136):
    • Pre-rendezvous check breaks cached re-exports: _export_hosts runs check_export_disk_space(None, ..., profiles=None) before rendezvous, so verified_reusable == 0 always — hard-failing valid 300+ GiB cached re-exports with UsageError before reaching the post-rendezvous call that actually supplies plan and profiles.
    • weight_reuse.rs:136 only inspects refs/default (blocks TP4 re-export if TP1 is default), and peer hosts receive 0 reuse credit.
    • probe_filesystem (planning.py:56-70) walks up past dangling symlinks (e.g. ~/.cache/flare/cores -> /mnt/nvme/cores before target creation), probing / instead of /mnt/nvme.
    • Hard lower bound ignores TP replicated-weight content dedup and unused checkpoint tensors (e.g. vision weights under --language-model-only) with no override flag.
  2. Disk preflight false negatives (weight_reuse.rs:173-215, planning.py:271-296, serve.py:329): Over-credits draft_bytes on --no-mtp against a target+draft core; only checks free_bytes <= 0 on split staging filesystems (missing 188.8 GiB Engram staging); single-host _prepare runs preflight before fetch(model, hub_cache).
  3. Doubled IoBudget during concurrent capture + receive & teardown gaps (host_ranks.py:544-575, 643-658, transfer.rs:1392-1393):
    Rank 0 runs export_model (IoBudget::for_capture(1)) concurrently with receive_ranks (IoBudget::for_ranks(1)), doubling native transfer RAM (~2 GiB + pinned rings) while the full model is GPU/unified-DRAM resident (contradicting docs/runtime-core-design.md:299-306). Early peer receive failures do not cancel rank-0 capture; HostRankGroup.close() drops the drain-failure guard and skips socket/dist teardown if model.close() raises; dual StartupProgress::stderr_rows() instances race on stderr.
  4. Concurrency & portability bugs in heliopause/src/export/transfer.rs:
    • Condvar lost-wakeup race (transfer.rs:86-93, 104-142): AbortScope::trigger() calls FILE_TRANSACTIONS.1.notify_all() without locking FILE_TRANSACTIONS.0.
    • FD capacity inflation (transfer.rs:145-160): saturating_sub paired with saturating_add inflates capacity above RLIMIT_NOFILE headroom after saturation.
    • POLLRDHUP ordering & portability (transfer.rs:299-325): Calls libc::send() after poll() already returned POLLRDHUP, and uses Linux-only libc::POLLRDHUP inside #[cfg(unix)].

Stacking note: Commit 1 (3805fcf9) is verbatim #585; rebase once #585 is split/resolved and add real Rust+Python unit tests for weight_reuse.rs plus live multi-host RSS validation.

@FujitsuPolycom
FujitsuPolycom force-pushed the perf/multihost-rank-export-transfer branch from 1c0d47b to 7aa9346 Compare November 28, 2026 22:18
@flare-autobot flare-autobot added area:caching Prefix/KV reuse, cache retention, and model or payload cache behavior. area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. performance Performance, latency, throughput, or memory-efficiency investigation or improvement. labels Nov 29, 2026
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:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. performance Performance, latency, throughput, or memory-efficiency investigation or improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants