From 879dc0171a09a619c9621dc75dd09f5f76d466ae Mon Sep 17 00:00:00 2001 From: Joshua Cartu Date: Wed, 2 Dec 2026 20:45:22 +0100 Subject: [PATCH] fix(helios): align proposal_confidence manifest messages with submission-row layout ExecutionManifest::validate in helios/src/execution/manifest.rs checks proposal_confidence and graph confidence_width against shape [2, request_capacity(), draft_capacity], where request_capacity() is Execution.max_active.next_power_of_two() and draft_capacity is in 1..=completion_token_capacity - 1. Both transport decoding (helios/src/execution/transport.rs) and runtime completion (helios/src/server/runtime.rs) index proposal_confidence by submission row (0..batch_capacity, padded to request_capacity()), not by physical request slot. The two manifest validation error strings contradicted this layout by stating "indexed by request slot" and naming the row extent "request_slots", and the Helios and top-level design documents also referred to the row extent as "request_slots" or omitted the submission-row layout. Updated the two validation error strings in helios/src/execution/manifest.rs, aligned the Helios and top-level design documentation, and added unit coverage in helios/src/execution/tests.rs: - Before: the buffer check returned "proposal confidence requires two float32 frames indexed by request slot and draft prefix"; the graph confidence check returned "confidence output requires [2, request_slots, draft_capacity] float32 frames"; helios/manifest.md and docs/runtime-core-design.md omitted the submission-row shape; and helios/model-contract.md, helios/README.md, docs/core-design.md, docs/runtime-core-design.md, and docs/scheduling-runtime-design.md wrote "[2, request_slots, draft_capacity]". - After: the buffer check states "[2, request_capacity, draft_capacity] float32 frames indexed by submission row (sized to max_active.next_power_of_two()) and draft depth 1..=completion_token_capacity - 1"; the graph confidence check states "a speculative graph whose confidence_width equals draft_tokens and [2, request_capacity, draft_capacity] float32 submission-row frames covering confidence_width within draft depth 1..=completion_token_capacity - 1"; and helios/manifest.md, helios/model-contract.md, helios/README.md, docs/core-design.md, docs/runtime-core-design.md, and docs/scheduling-runtime-design.md all document "[2, request_capacity, draft_capacity]" indexed by completion frame, submission row (sized to Execution.max_active.next_power_of_two()), and draft depth 1..=completion_token_capacity - 1 (with helios/manifest.md using the locally defined token capacity T). - Added proposal_confidence_validation_describes_submission_row_layout in helios/src/execution/tests.rs exercising max_active = 3 (request_capacity = 4) across accepted and rejected buffer shapes, dtypes, and graph confidence configurations, verifying the updated layout wording and asserting that neither "request slot" nor "request_slots" appears in either error. Accepted manifest shapes, buffer layouts, wire formats, and core compatibility are unchanged. Manifest validation diagnostics and repository specifications now accurately describe the [2, request_capacity, draft_capacity] submission-row layout enforced for proposal_confidence while preserving full compatibility with existing prepared cores. Ran cargo test --locked --release on Linux with prepared chat templates and a 512 MiB locked-memory limit across all affected crates: - helios (--features runtime-core,server): 1879 passed (1817 unit tests including proposal_confidence_validation_describes_submission_row_layout, eight_token_completions_accept_shorter_proposal_confidence, and confidence_output_requires_two_frames_and_covers_declared_prefixes, plus 62 integration tests), 0 failed, 84 GPU/snapshot/core-gated tests ignored. - flare: 254 passed, 0 failed, 4 ignored. - flare-cli: 245 passed, 0 failed, 3 ignored. GPU, model-checkpoint snapshot, and exported-core tests were not run because validation predicates and runtime execution paths are unchanged. Signed-off-by: Joshua Cartu Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b --- docs/core-design.md | 5 ++- docs/runtime-core-design.md | 14 +++++-- docs/scheduling-runtime-design.md | 7 +++- helios/README.md | 4 +- helios/manifest.md | 7 +++- helios/model-contract.md | 8 ++-- helios/src/execution/manifest.rs | 4 +- helios/src/execution/tests.rs | 66 +++++++++++++++++++++++++++++++ 8 files changed, 100 insertions(+), 15 deletions(-) diff --git a/docs/core-design.md b/docs/core-design.md index 09826a289..7ee671cfc 100644 --- a/docs/core-design.md +++ b/docs/core-design.md @@ -1225,7 +1225,10 @@ frames. Exact host `QueryLength` bindings select lengths before proposal draws; GPU `SpeculativePrefixLimit` bindings freeze per-lane ceilings while the captured program allocates within P. Both paths reserve cache against their full submitted lane limits. Confidence producers declare `confidence_width` and write -FP32 `[2, request_slots, draft_capacity]` completion frames. +FP32 `[2, request_capacity, draft_capacity]` completion frames indexed by +completion frame, submission row (sized to +`request_capacity = Execution.max_active.next_power_of_two()`), and draft depth +`1..=completion_token_capacity - 1`. Host pending-token, grammar, history, cost-discovery, and phase-transition dependencies serialize the affected program. Prefill, terminal prefill, scored diff --git a/docs/runtime-core-design.md b/docs/runtime-core-design.md index 97145ddb2..fcaaa8ef0 100644 --- a/docs/runtime-core-design.md +++ b/docs/runtime-core-design.md @@ -694,9 +694,12 @@ maximum prefill chunk; intermediate prefill capacities are optional. tokens per completion. Zero or omission resolves to eight; positive values are literal. ABI6 records contain 16 metadata fields followed by that many token fields. Logprob storage uses the same token capacity. Optional survival storage -uses one fewer position. Proposal-confidence buffers may have one through T−1 -positions and must cover every graph’s confidence width, where T is the completion -token capacity. Capacity one omits these zero-depth outputs. All ranks must agree on the resolved capacity. Graph widths +uses one fewer position. Proposal-confidence buffers (`proposal_confidence`) +are contiguous FP32 storage with shape `[2, request_capacity, draft_capacity]`, +indexed by completion frame, submission row (sized to +`request_capacity = Execution.max_active.next_power_of_two()`), and draft depth +`1..=completion_token_capacity - 1`, covering every graph’s confidence width. +Capacity one omits these zero-depth outputs. All ranks must agree on the resolved capacity. Graph widths fit this capacity; continuation-state storage has independently declared geometry. Execution metadata identifies complete speculative programs by B/D/W/P: request @@ -712,7 +715,10 @@ reads. Graph names do not select semantics. inputs bind immutable ceilings and leave actual lengths to a captured GPU causal allocator. Fixed prefix selection supports host-allocated ragged programs; GPU allocation requires adaptive selection. A confidence output declares -`confidence_width` and uses FP32 `[2, request_slots, draft_capacity]` frames. +`confidence_width` and uses FP32 `[2, request_capacity, draft_capacity]` +submission-row frames (where +`request_capacity = Execution.max_active.next_power_of_two()` and +`draft_capacity` is in `1..=completion_token_capacity - 1`). `flare run` accepts `--max-concurrency`, `--mtp-draft-tokens`, and adaptive/fixed selection flags. Unspecified values retain core defaults. A concurrency limit diff --git a/docs/scheduling-runtime-design.md b/docs/scheduling-runtime-design.md index 2822195e1..e260dcf58 100644 --- a/docs/scheduling-runtime-design.md +++ b/docs/scheduling-runtime-design.md @@ -79,8 +79,11 @@ prefixes. Termination censors the remaining suffix. Width-one rounds measure cost without supplying acceptance observations. A confidence-producing program declares `confidence_width`, equal to its actual -D. Its FP32 sidecar has shape `[2, request_slots, draft_capacity]`, covering every -produced prefix. Only completed rounds update host forecasts. Rank zero's +D. Its FP32 sidecar (`proposal_confidence`) has shape +`[2, request_capacity, draft_capacity]`, indexed by completion frame, submission +row (sized to `request_capacity = Execution.max_active.next_power_of_two()`), +and draft depth `1..=completion_token_capacity - 1`, covering every produced +prefix. Only completed rounds update host forecasts. Rank zero's confidence drives host decisions; peer estimates must be valid probabilities but need not agree bitwise. Exact request identities, consumption, emitted prefixes, and committed state agree across ranks. diff --git a/helios/README.md b/helios/README.md index b96e10e4e..953d342cb 100644 --- a/helios/README.md +++ b/helios/README.md @@ -299,7 +299,9 @@ Speculative descriptors carry actual request/proposal/target geometry B/D/W/P, including explicit P for rectangular programs. Exact `QueryLength` inputs select host allocation; `SpeculativePrefixLimit` inputs select captured GPU allocation. A produced confidence sidecar declares `confidence_width` and uses two FP32 -frames shaped `[2, request_slots, draft_capacity]`. Host dependencies are derived +frames shaped `[2, request_capacity, draft_capacity]` indexed by submission row +(sized to `Execution.max_active.next_power_of_two()`) and draft depth +`1..=completion_token_capacity - 1`. Host dependencies are derived per selected program. Planning projects queued expected service and output age at submission; observed delivery age changes only when tokens are published. diff --git a/helios/manifest.md b/helios/manifest.md index 9ed32fc39..38bff6150 100644 --- a/helios/manifest.md +++ b/helios/manifest.md @@ -161,8 +161,11 @@ runtime validates graph operations, buffer geometry, and storage dependencies. zero value resolves to eight tokens; a positive value is the token capacity T. All ranks use the same resolved value. Completion records have 16 metadata fields and T token fields. Generation logprobs have T token positions, and optional -survival outputs have T−1 positions. Proposal-confidence buffers may have -one through T−1 positions and must cover each graph’s confidence width. Cores +survival outputs have T−1 positions. Proposal-confidence buffers +(`proposal_confidence`) are contiguous `float32` storage with shape +`[2, request_capacity, draft_capacity]`, indexed by completion frame, submission +row (sized to `request_capacity = Execution.max_active.next_power_of_two()`), +and draft depth `1..=T−1`, covering each graph’s confidence width. Cores with T=1 omit these zero-depth outputs. Graph verification widths cannot exceed T; model and operator limits may be smaller. Continuation-state geometry is independent of completion token capacity. diff --git a/helios/model-contract.md b/helios/model-contract.md index 3722a9e6d..13d2f353a 100644 --- a/helios/model-contract.md +++ b/helios/model-contract.md @@ -226,9 +226,11 @@ and target programs retain their declared RNG reservations. A program producing confidence declares `confidence_width`, equal to its actual D. `proposal_confidence` is contiguous FP32 storage with shape -`[2, request_slots, draft_capacity]`; the capacity covers every declared output -width. Frame index selects the completion frame, and submitted rows retain their -lane order. There is no unframed confidence layout. +`[2, request_capacity, draft_capacity]`, where +`request_capacity = Execution.max_active.next_power_of_two()` and +`draft_capacity` is in draft depth `1..=completion_token_capacity - 1` covering +every declared output width. Frame index selects the completion frame, and +submitted rows retain their lane order. There is no unframed confidence layout. The single terminal completion reports actual offers, accepted drafts, and emitted tokens. Helios validates each offer against its reserved lane ceiling diff --git a/helios/src/execution/manifest.rs b/helios/src/execution/manifest.rs index b540202ee..24565b74e 100644 --- a/helios/src/execution/manifest.rs +++ b/helios/src/execution/manifest.rs @@ -827,7 +827,7 @@ impl ExecutionManifest { if buffer.dtype != Dtype::Float32 || buffer.shape.len() != 3 || buffer.shape[0] != 2 || buffer.shape[1] != self.request_capacity() || !(1..self.completion_token_capacity).contains(&buffer.shape[2]) { - return Err("proposal confidence requires two float32 frames indexed by request slot and draft prefix".into()); + return Err("proposal confidence requires [2, request_capacity, draft_capacity] float32 frames indexed by submission row (sized to max_active.next_power_of_two()) and draft depth 1..=completion_token_capacity - 1".into()); } } if let Some(buffer) = self.buffers.iter().find(|buffer| buffer.name == "readiness_timestamps") { @@ -868,7 +868,7 @@ impl ExecutionManifest { || confidence.shape[1] != self.request_capacity() || confidence.shape[2] < graph.confidence_width || confidence.shape[2] > self.completion_token_capacity - 1 { - return Err("confidence output requires [2, request_slots, draft_capacity] float32 frames".into()); + return Err("confidence output requires a speculative graph whose confidence_width equals draft_tokens and [2, request_capacity, draft_capacity] float32 submission-row frames covering confidence_width within draft depth 1..=completion_token_capacity - 1".into()); } } if graph.name.is_empty() || !names.insert(&graph.name) { diff --git a/helios/src/execution/tests.rs b/helios/src/execution/tests.rs index cf9bcb772..7fe2cef9c 100644 --- a/helios/src/execution/tests.rs +++ b/helios/src/execution/tests.rs @@ -1331,6 +1331,72 @@ fn eight_token_completions_accept_shorter_proposal_confidence() { assert!(value.validate().is_err()); } +#[test] +fn proposal_confidence_validation_describes_submission_row_layout() { + let mut value = manifest(); + value.max_active = 3; + assert_eq!(value.request_capacity(), 4); + value.graphs[0].kind = GraphKind::Speculative; + value.graphs[0].token_capacity = 6; + value.graphs[0].draft_tokens = 5; + value.graphs[0].packed_token_capacity = 24; + value.graphs[0].confidence_width = 5; + value.buffers.push(BufferDescriptor { + name: "proposal_confidence".into(), + address: 0x20000, + nbytes: 2 * 4 * 5 * 4, + dtype: Dtype::Float32, + shape: vec![2, 4, 5], + strides: vec![20, 5, 1], + }); + value.validate().unwrap(); + + for (shape, strides, nbytes, dtype) in [ + (vec![2, 3, 5], vec![15, 5, 1], 2 * 3 * 5 * 4, Dtype::Float32), + (vec![1, 4, 5], vec![20, 5, 1], 4 * 5 * 4, Dtype::Float32), + (vec![2, 4, 16], vec![64, 16, 1], 2 * 4 * 16 * 4, Dtype::Float32), + (vec![2, 4, 5], vec![20, 5, 1], 2 * 4 * 5 * 4, Dtype::Int32), + ] { + let mut invalid = value.clone(); + let buffer = invalid.buffers.last_mut().unwrap(); + buffer.shape = shape; + buffer.strides = strides; + buffer.nbytes = nbytes; + buffer.dtype = dtype; + let error = invalid.validate().unwrap_err().to_string(); + assert!(error.contains("submission row"), "{error}"); + assert!(error.contains("request_capacity"), "{error}"); + assert!(error.contains("draft depth 1..=completion_token_capacity - 1"), "{error}"); + assert!(!error.contains("request slot"), "{error}"); + assert!(!error.contains("request_slots"), "{error}"); + } + + let mut width_exceeds = value.clone(); + width_exceeds.graphs[0].confidence_width = 6; + width_exceeds.graphs[0].draft_tokens = 6; + width_exceeds.graphs[0].token_capacity = 7; + + let mut width_mismatch = value.clone(); + width_mismatch.graphs[0].confidence_width = 4; + + let mut non_speculative = value.clone(); + non_speculative.graphs[0].kind = GraphKind::Decode; + non_speculative.graphs[0].token_capacity = 1; + non_speculative.graphs[0].draft_tokens = 0; + non_speculative.graphs[0].packed_token_capacity = 0; + non_speculative.graphs[0].confidence_width = 1; + + for invalid in [width_exceeds, width_mismatch, non_speculative] { + let error = invalid.validate().unwrap_err().to_string(); + assert!(error.contains("speculative graph whose confidence_width equals draft_tokens"), "{error}"); + assert!(error.contains("request_capacity"), "{error}"); + assert!(error.contains("submission-row"), "{error}"); + assert!(error.contains("draft depth 1..=completion_token_capacity - 1"), "{error}"); + assert!(!error.contains("request slot"), "{error}"); + assert!(!error.contains("request_slots"), "{error}"); + } +} + #[test] fn persistent_worker_manifest_validation_enforces_handles_alignment_and_cardinality() { let mut value = manifest();