Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 40 additions & 13 deletions docs/core-format-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ writer fills the gaps with tensors whose names carry the reserved prefix

| File | Tensor | Contents |
| --- | --- | --- |
| `model.safetensors` | `flare.manifest` | U8-encoded core envelope, signed shared body, deployment bodies, and rank bodies. |
| `model.safetensors` | `flare.manifest` | U8-encoded core envelope (`ProtectedCore`), signed shared body, and inline or external references to deployment and rank bodies. |
| `model.safetensors` | `flare.body.<sha256>` | Optional single-frame zstd-compressed `DeploymentBody` or `RankBody` records spilled from `flare.manifest`, keyed by lowercase hex SHA-256 of the compressed frame. |
| `model.safetensors` | `flare.locations` | U8-encoded unsigned physical locations and locally available deployment selections. |
| `model.safetensors` | `flare.derivations` | Optional U8-encoded bounded byte-copy/fill recipes for reconstructing signed payloads. |
| `model.safetensors` | `frontend.tokenizer`, `frontend.chat-template` | Referenced frontend payloads; format and interpretation come from signed frontend metadata. |
Expand Down Expand Up @@ -251,13 +252,21 @@ form includes its decoded byte length; both forms together are invalid.
Exporters use compression when it reduces the encoded size. Readers accept
both forms. Rank signatures authenticate compressed bytes
before catalog decoding. Decoding requires an exact length, a window no larger
than 8 MiB, and one complete frame without trailing bytes. Reconstructing a
rank's inline metadata must fit within 128 MiB; selected ranks together must
fit within 1 GiB. The signed envelope limit is 128 MiB. Keyless
container conversion preserves compressed catalogs without decoding them.
Verification checks the size bounds for all selected ranks before decoding
any catalog. Consumers decode one catalog at a time; verified rank records
retain the compressed form.
than 8 MiB, and one complete frame without trailing bytes. Reconstructing a rank's inline metadata must fit within 128 MiB; selected ranks
together must fit within 1 GiB. The `flare.manifest` envelope limit is 128 MiB.
When inlining all deployment and rank bodies would exceed 128 MiB,
`SignedDeployment.external_body` and `SignedRank.external_body` store those
bodies in deduplicated `flare.body.<sha256>` tensors inside `model.safetensors`
as single zstd level-3 frames (window no larger than 8 MiB, stored and decoded
lengths each bounded by 128 MiB, no trailing bytes). Inline `body` and
`external_body` are mutually exclusive on a given record. Verification checks
the 1 GiB aggregate limit across selected ranks before decompressing external
bodies or compressed weight catalogs, verifies each external body's compressed
SHA-256 before decompression, and verifies the Ed25519 signature and parent
commitment over the exact decoded protobuf bytes. Keyless container conversion
preserves external bodies and compressed catalogs without decoding them.
Consumers decode one catalog at a time; verified rank records retain the
compressed form.

An unchanged checkpoint tensor may contribute several affine byte pieces to a
retained owner, including expert concatenation and scale swizzles:
Expand Down Expand Up @@ -432,7 +441,10 @@ not allocator placement. Elided bytes reconstruct as zero through allocation
initialization. Stable group ordering, overlap resolution, and elision rules are
part of the packing contract. State bytes and their elision are independent of
stable weight ordering. Disk payload grouping does not require separate GPU
allocations for each group.
allocations for each group. Cached weight capture reads each group's device
bytes in a single pass, streaming non-zero blocks directly into the cache's
deterministic 4,096-byte-prefixed companion wrapper (and validating installed
blobs on disk in a single scan without staging writes under `--no-weights`).

## Tensor-parallel deployments and materialization

Expand Down Expand Up @@ -591,10 +603,13 @@ content-addressed complete blobs, resumable `.part` files, quarantined suspect
bytes, transient adoption copies, per-content transfer locks, and repository
refs and snapshot hardlinks.
Blob content is scoped by endpoint and repository so Hub ETags are never shared
across repositories; revisions of one repository share content. An acquisition
lease excludes reclamation for the lifetime of every acquisition. The tree is
separate from the model cache and survives across acquisitions for
cross-revision reuse.
across repositories; revisions of one repository share content. Tree-API LFS
transfers carry each entry's `lfs.oid` SHA-256 digest explicitly so complete
cached and downloaded LFS blobs are verified by SHA-256; blob adoption locks
the content key exclusively, never replaces an existing complete blob, and uses
collectible temporary names. An acquisition lease excludes reclamation for the
lifetime of every acquisition. The tree is separate from the model cache and
survives across acquisitions for cross-revision reuse.
A successful installation reclaims its resolved commit's snapshot entries and
the consumed complete blobs whose last hardlink they held. Failed partials,
quarantined suspect bytes, and content referenced by another commit remain.
Expand Down Expand Up @@ -623,6 +638,18 @@ strides, not asserted by an untrusted flag. Only injective copied regions can be
inverted; fills cannot recover a source. Composed mappings must cover every
requested source byte and remain within the same operation and depth bounds.

When required weight or tuned-weight payloads are missing from the cache and
not satisfied by in-core derivations, acquisition planning also checks
installed cores for the same model whose `PreparedWeightCatalog` views match
the target payload's views (by exact view layout or declared checkpoint
`sources`, prioritizing matching `checkpoint_revision` and skipping conflicting
non-empty revisions). When installed donor views cover a target weight payload
completely, workers coalesce contiguous donor byte ranges and zero-elided
spans, stream them into a deterministic payload wrapper, and publish the
synthesized blob into `blobs/` only if its SHA-256 equals the target's signed
`PayloadId`. Incomplete coverage, probe failure on large batches, or any digest
mismatch falls back to normal remote download without failing acquisition.

Progress reports network bytes, local source reads, materialized bytes,
verification work, and elapsed acquisition time separately. Performance targets
apply to the complete acquire-and-ready path, including verification and writes.
Expand Down
8 changes: 5 additions & 3 deletions docs/runtime-core-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,11 @@ controllers must speak the same agent protocol version (`PROTOCOL_VERSION` in
before files are sent.
Resource classification follows actual consumers in the signed index. Missing,
overlapping, unclassified, or incorrectly classified spans fail loading. The
128 MiB metadata limit applies to the complete signed envelope and to each reconstructed rank body.
The verifier accepts up to 1 GiB of reconstructed metadata across the selected ranks and checks
the aggregate before decoding compressed weight catalogs. The core
128 MiB metadata limit applies to `flare.manifest`, to each spilled
`flare.body.<sha256>` external body record (stored and decoded), and to each
reconstructed rank body. The verifier accepts up to 1 GiB of reconstructed
metadata across the selected ranks and checks that aggregate bound before
decompressing external bodies or compressed weight catalogs. The core
contains the signing-key fingerprint, not the verification key. Keys come from
Helios's embedded publisher profiles or explicitly supplied profile files.

Expand Down
25 changes: 24 additions & 1 deletion flare-cli/src/orbit/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,25 @@ fn mirrored_ranges(header: &Value, size: u64, start: u64) -> Result<Vec<(u64, u6
if ranges.is_empty() {
return Err("not a Flare core".into());
}
if let Some(map) = header.as_object() {
let mut external_total = 0u64;
for name in map.keys() {
if name.starts_with(flare_helios::core::reader::EXTERNAL_BODY_PREFIX)
&& let Some(range) = bounded(name)?
{
if range.1 > flare_helios::core::schema::MAX_BODY as u64 {
return Err(format!("{name} external body exceeds its limit"));
}
external_total = external_total
.checked_add(range.1)
.ok_or("external metadata body length overflow")?;
if external_total > flare_helios::core::schema::MAX_SELECTED_RANK_METADATA {
return Err("external metadata bodies exceed budget".into());
}
ranges.push(range);
}
}
}
Ok(ranges)
}
_ => Err("not a Flare core".into()),
Expand Down Expand Up @@ -3264,10 +3283,14 @@ mod tests {
"flare.manifest": {"dtype": "U8", "shape": [10], "data_offsets": [0, 10]},
"flare.locations": {"dtype": "U8", "shape": [20], "data_offsets": [10, 30]},
"flare.derivations": {"dtype": "U8", "shape": [5], "data_offsets": [30, 35]},
"flare.body.0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef": {
"dtype": "U8", "shape": [15], "data_offsets": [35, 50]
},
"weights.layer-000": {"dtype": "U8", "shape": [100], "data_offsets": [50, 150]},
});
assert_eq!(
mirrored_ranges(&payload, 1000, 8).unwrap(),
vec![(8, 10), (18, 20), (38, 5)]
vec![(8, 10), (18, 20), (38, 5), (43, 15)]
);

let packed = json!({
Expand Down
4 changes: 2 additions & 2 deletions flare/src/cache_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ fn select_verified_deployments(
> {
use flare_helios::core::protection;

let catalog = protection::verify(
&metadata.envelope,
let catalog = protection::verify_metadata(
metadata,
publishers,
protection::Selection::Catalog,
)?;
Expand Down
Loading
Loading