Repository navigation
Commit e80b1f2
authored
core,hub,heliopause,ignition: decouple signed bodies, single-pass export, slice synthesis, and HF LFS SHA-256 (#618)
Why:
Four packaging, export, and download defects block shipping and updating large
multi-rank model cores (such as TP8 and TP16 MoE models) and weaken download
integrity:
1. Unverified Hugging Face tree-API LFS downloads and unsafe blob adoption:
`fetch_tree_identities` in `flare/src/hub.rs` stores each Git-LFS entry's
bare 64-hex `lfs.oid` SHA-256 digest in `FileIdentity.etag` without a
`sha256:` prefix. Downstream verification (`content_digest`) requires a
`sha256:` prefix so opaque HTTP ETags are not assumed to be digests, causing
it to return `None` for every tree-API LFS entry and silently disabling
SHA-256 verification on downloaded and cached LFS blobs. Separately,
`Transport::adopt_complete` copies legacy blobs without locking `<key>.lock`,
falls back to renaming over an existing complete blob on `AlreadyExists`, and
writes `.adopt-*` temporary files that do not match the `.<key>.adopt-*`
pattern reclaimed by `flare::download_cache`.
2. Monolithic 128 MiB `ProtectedCore` envelope limit: `helios/src/core/schema.rs`
allows up to 1 GiB of reconstructed rank metadata across selected ranks
(`MAX_SELECTED_RANK_METADATA`), yet `ProtectedCore` inlines every
`SignedDeployment.body` and `SignedRank.body` into one `flare.manifest`
tensor capped at `MAX_ENVELOPE = 128 MiB`, blocking publication of large
multi-rank or multi-deployment cores.
3. Duplicate device-to-host weight reads, uncached staging collisions, and peak
capture host RAM: `resolve_weight_payload` in `heliopause/src/export/capture.rs`
reads every weight group from GPU memory twice (once in `scan_group_blocks`
and again through `Root::insert_payload`), even on cache hits and
`--no-weights` exports; `materialize_payload_spans` in
`heliopause/src/export/core.rs` opens `rank-{rank}-{base}.payload` with
`File::create`, truncating an already-pinned stable layer file in place when
the same layer also has a `:tuned` group; and `ForwardCache.prepare_many`
plus `capture_forwards` retain every compiled `BoundForward`, Dynamo guard
tree, `StorageBackend` descriptor set, and loaded CUDA module across the
entire catalog simultaneously.
4. Full weight re-downloads after minor layer-layout edits: removing, reordering,
or renaming a weight tensor inside a layer payload changes that layer's
`PayloadId` even when remaining tensor bytes are unchanged, causing
`flare download` to re-download every shifted weight file over HTTP despite
an earlier core for the same model being installed locally with its
`PreparedWeightCatalog`.
What changed:
- Hugging Face LFS SHA-256 verification and adoption (`flare/src/hub.rs`):
- Before: `FileIdentity` carried only `etag`; `content_digest` returned `None`
for bare `lfs.oid` strings; `adopt_complete` wrote `.adopt-*` temporaries
without locking `<key>.lock` and renamed over existing complete blobs.
- After: Added `sha256: Option<[u8; 32]>` to `FileIdentity`, populated from
`entry.lfs.oid` via `parse_sha256_hex` in `fetch_tree_identities` and from
`content_digest(&etag)` in HTTP probes (keeping opaque HTTP ETags unassumed).
Updated `pending_network_from_identities`, `fetch_file_with_identity_and_streams`,
and `transfer_blob_with_streams` to verify against `metadata.sha256()`.
Updated `Transport::adopt_complete` to take a non-blocking exclusive lock on
`<key>.lock` and call `publish_copy(..., replace = false)` so existing
complete blobs are never replaced, with collectible temporary names
`.<key>.adopt-<pid>-<n>`.
- External signed deployment and rank bodies (`helios/proto/core.proto`,
`helios/src/core/{protection,reader,export,cache,conversion}.rs`,
`helios/src/core/conversion/edit.rs`, `helios/src/runtime_core/{protection,metadata}.rs`,
`heliopause/src/export/weight_reuse.rs`, `flare/src/{cache_support,trust,hub}.rs`,
`flare-cli/src/orbit/controller.rs`, `docs/core-format-design.md`,
`docs/runtime-core-design.md`):
- Before: `SignedDeployment` and `SignedRank` always stored protobuf bytes
inline inside `flare.manifest` (`<= 128 MiB`), and `export.rs` buffered
`model.safetensors` in a single `Vec<u8>`.
- After: Added `ExternalBody { sha256, stored_nbytes, decoded_nbytes }`,
`SignedDeployment.external_body`, and `SignedRank.external_body` backed by
deduplicated `flare.body.<sha256>` U8 tensors in `model.safetensors`
(single-frame zstd level 3, window `<= 8 MiB`, stored and decoded lengths
each `<= 128 MiB`, mutually exclusive with inline `body`).
`EnvelopeBuilder::sign_envelope` keeps envelopes `<= 128 MiB` inline and
spills deployment/rank bodies when inline serialization would exceed 128 MiB,
preserving `flare-package-signature-v5` Ed25519 signatures and parent
commitments over exact decoded bytes. `verify_metadata` and
`verify_with_bodies` enforce the 1 GiB `MAX_SELECTED_RANK_METADATA` cap
before decompressing external bodies or compressed weight catalogs and check
compressed SHA-256 before decompression. `export.rs` streams
`model.safetensors` directly to disk. Updated cache, conversion, edit,
unverified inspection (enforcing the aggregate cap before decompressing
selected ranks), `--reuse-weights`, Hub/trust verification, and Orbit
`mirrored_ranges`.
- Compatibility: Inline v2 cores load and verify unchanged without re-export
or re-signing; cores whose inline envelope fits within 128 MiB continue to
be emitted inline.
- Single-pass weight capture, uncached staging fix, and streaming capture
(`helios/src/core/cache.rs`, `heliopause/src/export/{capture,core}.rs`,
`ignition/preparation/{aot,capture}.py`,
`tests/preparation/test_preparation_reclamation.py`):
- Before: Cached weight capture read GPU spans twice (`scan_group_blocks` plus
`insert_payload`); uncached export used `File::create` on
`rank-{rank}-{base}.payload`; `ForwardCache.prepare_many` and
`capture_forwards` held all live `BoundForward` objects and full
`StorageBackend` metadata simultaneously.
- After: Added `Root::verified_payload` and `Root::capture_streaming_payload`
(reserving a 4,096-byte prefix, hashing and streaming in one pass,
discarding staging on verified hits, or backfilling the deterministic
companion header at offset 0 on misses) and wired single-pass
`capture_group_into_cache` in `heliopause/src/export/capture.rs`. Named
uncached staging files `rank-{rank}-{stable|tuned}-{base}.payload` with
`create_new(true)`. Added `DeferredCompiledForward`,
`StorageBackend.retire_after_capture()` (stripping `_bound`, `inputs`,
`signature`, `invocations`, `_serialized_artifact`, `artifact`, and
`cubin_raw` while preserving `_cuda_allocation_sizes` and retaining loaded
`StaticallyLaunchedTritonKernel` and native library owners), and
`stream=True` in `ForwardCache.prepare_many` / `_prepare_many` /
`_prepare_ranks`; `capture_forwards` holds the publication lock and
materializes, captures, and retires one forward at a time when
`retain_forwards=False`.
- Local slice-level weight synthesis (`helios/src/core/synthesis.rs`,
`helios/src/core/{mod,cache}.rs`, `flare/src/hub.rs`):
- Before: `plan_acquisition_with` only reused exact cached `PayloadId`s and
in-core derivations.
- After: Added model-agnostic slice synthesis in `helios/src/core/synthesis.rs`,
invoked by `Root::plan_acquisition_for_model`. For missing remote weight or
tuned-weight payloads, planning leases installed donor entries for the same
model (skipping conflicting non-empty `checkpoint_revision`s and preferring
matching revisions and `(tensor_parallel, rank)`), matches target
`PreparedWeightCatalog` views by exact layout or declared checkpoint
`sources`, handles zero-elided donor subranges and bounded (`<= 64 KiB`)
alignment gaps, coalesces contiguous copy/zero segments, probes 3
representative payloads early when `> 8` candidates exist, and streams 8 MiB
chunks across up to 16 parallel workers with Linux `posix_fadvise` and
`AcquisitionProgress` accounting and cancellation. Synthesized blobs are
published and removed from `remote_files()` only on exact SHA-256 match
against the target's signed `PayloadId`; any gap or mismatch falls back to
HTTP download.
Claimed benefit and observed result:
- Expected impact on large-TP workflows: removes the 128 MiB envelope limit for
multi-rank/multi-deployment cores up to the 1 GiB aggregate rank budget, cuts
cached and `--no-weights` GPU weight D2H passes from two to one, bounds peak
unretired compiled forwards during capture to one per rank, and avoids
re-downloading shifted weight layers when a compatible prior core is installed
locally. End-to-end multi-GPU export memory and download throughput on live
checkpoints are not measured here.
- Observed in CPU tests: tree-API LFS blobs are verified by `lfs.oid` SHA-256
and `adopt_complete` locks `<key>.lock`, preserves existing blobs, and writes
reclaimable temp files; external-body envelopes spill and verify a 3-rank
~138 MiB core under the default 128 MiB limit while rejecting tampering, dual
bodies, trailing zstd bytes, and >1 GiB declarations before decompression;
`capture_group_into_cache` reads each source block once across cold misses,
warm hits, and `--no-weights` hits (with zero staging transactions under
`--no-weights`); mixed stable+tuned uncached groups publish distinct intact
companions; streamed `prepare_many` and `capture_forwards` collect each warmed
forward before loading the next and maintain peak live unretired forwards at 1;
and end-to-end Hub downloads synthesize shifted weight layers with zero HTTP
requests for the shifted layer and fall back to HTTP on weight mutations.
Evidence and limitations:
Validated on Linux x86_64 (CPU fixtures, `ulimit -l unlimited`):
- `helios --lib -- core:: runtime_core::`: 496 passed, 0 failed, 12 ignored.
- `helios --lib` (full): 1,724 passed, 45 ignored, 6 failed (all 6 require
`FLARE_TEST_TEMPLATE_DIR`).
- `helios --test unverified_empty`: 1 passed, 0 failed.
- `flare` (lib + `packed_canonical_download` + `reference_workflows`): 245
passed, 0 failed, 4 ignored.
- `heliopause --lib`: 213 passed, 0 failed, 6 ignored.
- `flare-cli` (`cache_commands`, `cli`, `inspect`, `unverified_payload`, release
build): 24 passed, 0 failed; release binary built cleanly.
- `flare-cli --bin flare`: 201 passed, 3 ignored, 1 failed (unrelated
pre-existing failure in untouched
`distribution::tests::source_waits_for_receiver_file_verification`).
- `eos` (2 passed), `selene` (548 passed), `selene-manager` (187 lib + 3 builder
+ 82 client passed; 3 unrelated pre-existing failures in untouched
`selene-manager/tests/client.rs` TCP/TLS loopback relay tests).
- Python: `tests/cli` (133 passed), `tests/test_design_review_hook.py` (18
passed), targeted `tests/preparation` (56 passed),
`tests/preparation/test_runtime_static_triton.py` standalone (28 passed), full
`tests/preparation` (1,148 passed, 74 CUDA-gated skipped; 2 environment
failures from shared-process CUDA init and preinstalled `.venv` wheel mismatch),
`tests/test_compilation.py` (43 CUDA-gated skipped).
Limitations: CUDA-gated GPU capture/export tests (`FLARE_RUN_CUDA_TESTS=1`,
`FLARE_RUN_TP_CUDA_TESTS=1`), `FLARE_TEST_TEMPLATE_DIR` frontend template tests,
rebuilt `flare_heliopause` wheel tests, and Windows builds were not run.
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Signed-off-by: Luke Alonso <lalonso@gmail.com>1 parent 968ca41 commit e80b1f2
23 files changed
Lines changed: 4784 additions & 399 deletions
File tree
- docs
- flare-cli/src/orbit
- flare/src
- heliopause/src/export
- helios
- proto
- src
- core
- conversion
- runtime_core
- ignition/preparation
- tests/preparation
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
| 182 | + | |
182 | 183 | | |
183 | 184 | | |
184 | 185 | | |
| |||
251 | 252 | | |
252 | 253 | | |
253 | 254 | | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
261 | 270 | | |
262 | 271 | | |
263 | 272 | | |
| |||
432 | 441 | | |
433 | 442 | | |
434 | 443 | | |
435 | | - | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
436 | 448 | | |
437 | 449 | | |
438 | 450 | | |
| |||
591 | 603 | | |
592 | 604 | | |
593 | 605 | | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
598 | 613 | | |
599 | 614 | | |
600 | 615 | | |
| |||
623 | 638 | | |
624 | 639 | | |
625 | 640 | | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
626 | 653 | | |
627 | 654 | | |
628 | 655 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
501 | 501 | | |
502 | 502 | | |
503 | 503 | | |
504 | | - | |
505 | | - | |
506 | | - | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
507 | 509 | | |
508 | 510 | | |
509 | 511 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2140 | 2140 | | |
2141 | 2141 | | |
2142 | 2142 | | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
2143 | 2162 | | |
2144 | 2163 | | |
2145 | 2164 | | |
| |||
3264 | 3283 | | |
3265 | 3284 | | |
3266 | 3285 | | |
| 3286 | + | |
| 3287 | + | |
| 3288 | + | |
| 3289 | + | |
3267 | 3290 | | |
3268 | 3291 | | |
3269 | 3292 | | |
3270 | | - | |
| 3293 | + | |
3271 | 3294 | | |
3272 | 3295 | | |
3273 | 3296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
170 | | - | |
| 169 | + | |
| 170 | + | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| |||
0 commit comments