Skip to content

Commit 87cc8c1

Browse files
committed
Load signed format-4 model packages
Restore AES-GCM executable decoding with format-4 signatures and publisher acceptance. Accept prepared contracts 1 through 3 and resolve omitted speculative row capacity to the checked rectangular layout. Preserve signature, resource, geometry, and format-6 validation without changing package bytes. Validation: 123 runtime-package tests and seven contract tests passed; seven GPU tests were ignored. The published Flash Next GB10 package served 11 native requests, including eight concurrent requests and a 5,437-token cached prefix, without --verify-weights. Separate proposal/verification graph families remain unsupported and are tracked in docs/TODO.txt. Design-Signed-Off-By: Codex (GPT-6); design-review=a38f
1 parent 5e356e6 commit 87cc8c1

12 files changed

Lines changed: 693 additions & 53 deletions

File tree

‎docs/TODO.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
[ ] Expose the selected deployment's rebuild metadata in flare inspect --json.
22
Payload packages report rebuild: null even when DeploymentBody.rebuild is present.
33

4+
[ ] Restore loading and serving for packages with separate proposal and verification
5+
graphs, whose operation identifiers 10, 11, and 13 are reserved in
6+
helios/proto/runtime_package.proto. Validate their original captured graphs
7+
through native serving without re-export or re-signing.
8+
49
[ ] After merging dev/qwen27b in Flare and FlashInfer, evaluate combined MXFP8
510
GDN QKV/Z/B/A projections for Qwen3.8 Flash Next through shared loading and
611
execution components. Preserve TP partitioning and compare complete graph

‎docs/runtime-package-design.md‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ pool holds only graph-local intermediates and is also cleared, as are unused
148148
bytes in the preparation allocator. Weight tensors, MTP weights, rotary
149149
tables, pointer tables, and required initialized metadata retain their contents.
150150

151-
Serving accepts payload format 2 and signed format-6 logical-resource containers,
152-
with structural contract validation in both carriers. Execution ABI numbers
151+
Serving accepts payload format 2 and signed format-4 and format-6 logical-resource
152+
containers, with structural contract validation in every carrier. Execution ABI numbers
153153
do not gate loading. Engine upgrades must preserve previously supported models. Unsigned rank staging cannot load.
154154
The canonical format uses signed content IDs, payload-relative initializers,
155155
and unsigned physical locations; see [payload packages](package-format-design.md).
@@ -395,14 +395,22 @@ by 4 TiB. The decoder accepts one bounded zstd frame, caps its window at 8 MiB,
395395
and rejects truncated or extra frames, trailing bytes, and decoded length
396396
mismatch.
397397

398-
Signatures authenticate the stored frame and its signed decoded length. Helios
399-
authenticates each compressed chunk against its signed commitment before feeding
398+
For payload format 2 and signed format 6, signatures authenticate the stored frame
399+
and its signed decoded length. Helios authenticates each compressed chunk against
400+
its signed commitment before feeding
400401
it to the decoder; it does not require hashing the entire combined executable
401402
payload first. Acceptance is a trust and license decision: the value passed to
402403
`authorize` equals the signed publisher namespace exactly. It is not key
403404
material. Weights and tables stay uncompressed and retain direct-I/O compatibility
404405
and storage deduplication.
405406

407+
Signed format 4 uses the `flare-package-signature-v4` signature domain and
408+
AES-256-GCM executable encoding. Each encrypted chunk contains up to 4 MiB of plaintext and a 16-byte
409+
authentication tag. The reader validates the signed ciphertext hashes, derives the key
410+
from the publisher key, package ID, accepted namespace, and resource offset, and
411+
authenticates each chunk before exposing its plaintext. Loading these packages
412+
does not modify their signatures, weights, or captured graphs.
413+
406414
`PackageClaim::read` returns what a package claims before verification: signer
407415
fingerprint, namespace, official source, and development marker, syntax-checked
408416
so a caller can resolve the signer's identity from them. `VerifiedPackage::open`
@@ -412,8 +420,9 @@ license. `VerifiedPackage::authorize` requires the acceptance string to equal th
412420
signed publisher namespace exactly, records it, and optionally checks the
413421
stored-data contents. Only its `AuthorizedPackage` result can enter
414422
`NativeModel::load` or `NativeResources::load`. Executable resources are
415-
hash-checked, decompressed, and length-checked before CUDA receives them. Frontend assets retain
416-
signed digest checks. Open package descriptors remain alive through native
423+
hash-checked, decoded according to their signed format, and length-checked before
424+
CUDA receives them. Frontend assets retain signed digest checks. Open package
425+
descriptors remain alive through native
417426
use, including deferred frontend and embedding-table reads; replacing the
418427
pathname cannot redirect those reads. Package files must remain immutable while
419428
loaded. Signatures authenticate bytes and do not sandbox executable code.

‎helios/manifest.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ verification, and commit work. It declares B/D/W/P explicitly: request capacity,
113113
captured proposal depth, per-request target capacity, and aggregate target rows.
114114
W is from 1 through T, the resolved completion token capacity; P is from B
115115
through B × W, including rectangular P = B × W.
116+
An omitted or zero packed token capacity resolves to B × W for speculative
117+
graphs, preserving packages exported before that field was added.
116118
Width-one speculative graphs have D = 0 and maintain draft context. No standalone
117119
proposal, verification, or packed-speculative graph kind exists.
118120
Prefill has batch capacity 1. Token capacities are 1, 16, or a multiple of 64

‎helios/model-contract.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ version domains. Execution ABI labels do not gate loading; the runtime validates
4141
the declared layouts and operations. Engine upgrades must preserve support for
4242
previously supported models without re-export.
4343

44-
Executable resources are one mandatory zstd level-3 frame per resource. The
45-
signed `ExecutableResource` binds its stored frame, signed decoded length,
44+
Payload format 2 and signed format 6 encode each executable resource as one
45+
mandatory zstd level-3 frame. Signed format 4 retains its authenticated AES-GCM
46+
chunk reader. In payload packages, the signed `ExecutableResource` binds its
47+
stored frame, signed decoded length,
4648
resource id and kind. `chunk_nbytes` is 4 MiB and `chunk_sha256` covers
4749
compressed bytes with count `ceil(stored.nbytes / 4 MiB)`. The decoder window is
4850
capped at 8 MiB and rejects truncated or extra frames, trailing bytes, and
@@ -70,7 +72,7 @@ serving contract and replay path unchanged.
7072

7173
| Field | Meaning |
7274
|---|---|
73-
| `version` | Semantic contract version, 3 |
75+
| `version` | Semantic contract version, 1, 2, or 3; exporters write 3 |
7476
| `vocabulary` | Valid sampled token range and histogram/mask geometry |
7577
| `input_vocabulary` | Valid input range, including declared nonsampled image sentinels |
7678
| `vision` | Feature-slot and per-window feature capacities, patch-to-feature ratio, and captured patch capacities |

‎helios/proto/runtime_package.proto‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,8 @@ message ExecutionGraph {
728728
optional bool speculation_enabled = 10;
729729
uint64 estimated_duration_ns = 11; // Zero denotes an indeterminate duration.
730730
uint64 prefill_capacity = 12; // Prompt capacity of a mixed graph; zero otherwise.
731-
// Physical target rows of a complete speculative operation, including rectangular layouts.
731+
// Physical target rows of a complete speculative operation. Zero retains the rectangular
732+
// batch_capacity * token_capacity layout.
732733
uint64 packed_token_capacity = 13;
733734
// Number of confidence prefixes produced per request in the selected completion frame.
734735
uint32 confidence_width = 14;

‎helios/src/model/contract.rs‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl PreparedContract {
348348
}
349349

350350
pub fn validate(&self, manifest: &ExecutionManifest) -> Result<()> {
351-
if self.version != 3 {
351+
if !(1..=3).contains(&self.version) {
352352
return Err("unsupported prepared model contract version; re-export the model package".into());
353353
}
354354
if self.vocabulary == 0
@@ -682,6 +682,24 @@ impl FrontendContract {
682682
mod tests {
683683
use super::*;
684684

685+
#[test]
686+
fn supported_contract_versions_validate_declared_state_storage() {
687+
let config = crate::model::tests::config();
688+
let manifest = crate::model::testing::manifest(&config);
689+
for version in [1, 2, 3] {
690+
let mut contract = config.contract.clone();
691+
contract.version = version;
692+
contract.validate(&manifest).unwrap();
693+
contract.graphs[0].state[0].view.buffer = "missing_state".into();
694+
assert!(contract.validate(&manifest).is_err());
695+
}
696+
for version in [0, 4, u32::MAX] {
697+
let mut contract = config.contract.clone();
698+
contract.version = version;
699+
assert!(contract.validate(&manifest).is_err());
700+
}
701+
}
702+
685703
#[test]
686704
fn state_view_validation_resolves_buffers_and_preserves_storage_errors() {
687705
use crate::{Error, ExecutionError, execution::Dtype};

‎helios/src/runtime_package/archive.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ pub fn package_companions(path: &Path) -> Result<Vec<String>> {
333333
}
334334
let envelope =
335335
wire::ProtectedIndex::decode(bytes.as_slice()).map_err(|e| invalid(e.to_string()))?;
336-
if envelope.version != 6
337-
|| envelope.groups.len() != 3
336+
super::protection::ExecutableEncoding::from_version(envelope.version)?;
337+
if envelope.groups.len() != 3
338338
|| envelope.groups[0].kind != 1
339339
|| envelope.ranks.is_empty()
340340
{

‎helios/src/runtime_package/metadata.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ pub fn unverified_metadata_selected(
5757
let (file, _, payload_bytes, bytes) = Archive::envelope(path)?;
5858
let envelope = wire::ProtectedIndex::decode(bytes.as_slice())
5959
.map_err(|e| invalid(format!("invalid signed envelope: {e}")))?;
60-
if envelope.version != 6
61-
|| envelope.groups.len() != 3
60+
super::protection::ExecutableEncoding::from_version(envelope.version)?;
61+
if envelope.groups.len() != 3
6262
|| envelope
6363
.groups
6464
.iter()

‎helios/src/runtime_package/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl ModelPackage {
156156
/// On-disk prepared-package formats.
157157
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
158158
pub enum PackageFormat {
159-
/// Signed format-6 logical-resource packages read through the archive.
159+
/// Signed format-4 and format-6 logical-resource packages read through the archive.
160160
Legacy,
161161
/// Payload-identity packages read through pinned payload containers.
162162
Payload,

0 commit comments

Comments
 (0)