Skip to content
Open
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
8 changes: 8 additions & 0 deletions docs/TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
buffered and streamed, including max_tokens and max_output_tokens truncation.
Close when a served TMLv0 core passes those checks and the result is recorded.

[ ] Qualify core-declared FP32 `core_parameters` on GPU: export and serve a
core that declares `core_parameters` through `flare run` (including
mixed-parameter batches and speculative decoding), verify loading and
serving a pre-existing declaration-free core on the same runtime, and
verify `--direct` GPU execution with a recipe that declares
`core_parameters`. Close when those GPU runs pass and the qualification
notes in docs/api.md and docs/direct-execution.md are updated.

[ ] Make test_explicit_worker_budget_compiles_and_replays_a_catalog account for
host memory admission. Its nine-worker assertion requires 296 GiB available
under the 32 GiB worker allowance and 8 GiB headroom; smaller hosts admit fewer.
Expand Down
6 changes: 5 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,11 @@ independently of the six-column sampling layout. Prefix-cache identity hashes
every declared effective parameter in declaration order (length-prefixed name
and canonical FP32 bits) into the prefix root, so requests with different
resolved values cannot share checkpoints. For cores without declared core
parameters, the prefix root hashes only the domain tag and core identity.
parameters, the prefix root hashes only the domain tag and core identity. CPU
tests cover the wire contract, request decoding, prefix-cache identity, and
packing paths, and Kani harnesses cover declaration validation and resolution.
Live GPU export and serving with a core that declares `core_parameters` remain
pending qualification.

The recipes use these default-mode settings. Parameters without an interval in
the table are fixed at their defaults. Bounds span the minimum and maximum values
Expand Down
5 changes: 4 additions & 1 deletion docs/direct-execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ tokens, speculative rounds and outcome.
`/v1/models` reports the core's declared `core_parameters` under `flare`. Chat
requests accept the same top-level `core_parameters` object as native serving;
omitting it or passing `null` uses declared defaults, and the direct scheduler
resolves defaults and ranges before prefix lookup.
resolves defaults and ranges before prefix lookup. Direct core-parameter
resolution, packing, and checkpoint isolation are verified by CPU tests; live
GPU direct execution with a recipe that declares `core_parameters` remains
pending qualification.

## Design

Expand Down
16 changes: 9 additions & 7 deletions docs/prefix-cache-offload.md
Original file line number Diff line number Diff line change
Expand Up @@ -833,13 +833,15 @@ both transports.
`helios/src/scheduler.rs` and `helios/src/scheduler/sharing.rs` provide:

- `RequestPhase::Inbound`, which `RequestScheduler::plan` never selects.
- Admission in two steps. `plan_admission(&spec)` validates the request,
builds its history, performs the GPU lookup, and returns an `AdmissionPlan`
with the history and the lookup without reserving anything. `admit_planned(
spec, plan, inbound)` reserves and creates the request; `admit(spec)` is the
composition with no inbound. With an inbound hit at consumed count `c` and
`n` chain pages under GPU ancestor `A`, the request reserves pages and
snapshots as if its prefix depth were `c`, and the scheduler creates or joins
- Admission in two steps. For a core with declared parameters, the caller
passes the request's resolved values to `plan_admission_with_core_parameters`.
For a core without declarations, it can call `plan_admission(&spec)`. Both
return the prefix history and GPU lookup in an `AdmissionPlan` without
reserving resources. `admit_planned(spec, plan, inbound)` reserves resources
and creates the request. `admit(spec)` combines these steps for a core
without declarations and no inbound hit. With an inbound hit at consumed
count `c` and `n` chain pages under GPU ancestor `A`, the request reserves
pages and snapshots as if its prefix depth were `c`, and the scheduler creates or joins
an inbound ticket for the key: `n` pages and one snapshot popped from the
free lists through `ensure_resources`, a pin on `A`, the plan's history, and
the waiting request handles. The request starts in `Inbound` with no prefix,
Expand Down
2 changes: 1 addition & 1 deletion heliopause/src/export/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ pub(crate) fn serving_metadata(
.or_insert("mtp".into());
let contract: super::wire::ServingContract = message("ServingContract", &server.into())?;
if let Some(model_contract) = contract.model_contract.as_ref() {
helios_core::runtime_core::validate_core_parameters(model_contract)?;
helios_core::runtime_core::validate_core_parameter_declarations(model_contract)?;
}
index.contract = Some(contract);
Ok(assets.clone())
Expand Down
7 changes: 4 additions & 3 deletions helios/model-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ each active lane's resolved value rather than reading stale slot contents.
Inactive rows of a `SUBMISSION_ROW` core-parameter binding receive `0.0`. Shared
admission fills omitted names from declared defaults, clamps finite FP32 request
values to declared inclusive ranges, accepts any finite FP32 value when `range`
is omitted, canonicalizes `-0.0` to `+0.0`, and rejects unknown names or
out-of-range numeric encodings. The six-column `SAMPLING_PARAMETERS` layout
remains unchanged.
is omitted, canonicalizes `-0.0` to `+0.0`, and rejects unknown names and values
outside the finite FP32 range (non-finite numbers, magnitude above `f32::MAX`,
or nonzero values underflowing to FP32 zero). The six-column
`SAMPLING_PARAMETERS` layout remains unchanged.

The execution transport owns frame index and submission sequence.

Expand Down
6 changes: 5 additions & 1 deletion helios/src/execution/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,19 @@ impl GraphKind {
}

pub fn samples(self) -> bool {
self.is_text_forward()
}

pub(crate) fn is_text_forward(self) -> bool {
matches!(
self,
Self::Prefill
| Self::TerminalPrefill
| Self::ScoredPrefill
| Self::Resume
| Self::Decode
| Self::Speculative
| Self::Mixed
| Self::Resume
)
}
}
Expand Down
1 change: 1 addition & 0 deletions helios/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ pub fn scheduler_capabilities(config: &ModelConfig) -> SchedulerCapabilities {
.max()
.unwrap_or(1),
),
core_parameters: config.contract.core_parameters.clone(),
}
}

Expand Down
15 changes: 1 addition & 14 deletions helios/src/model/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,19 +425,6 @@ pub fn canonical_core_parameter(value: f32) -> f32 {
if value == 0. { 0. } else { value }
}

pub(crate) fn is_text_forward_graph(kind: GraphKind) -> bool {
matches!(
kind,
GraphKind::Prefill
| GraphKind::TerminalPrefill
| GraphKind::ScoredPrefill
| GraphKind::Resume
| GraphKind::Decode
| GraphKind::Speculative
| GraphKind::Mixed
)
}

impl CoreParameter {
pub fn validate(&self) -> Result<()> {
if self.name.is_empty()
Expand Down Expand Up @@ -666,7 +653,7 @@ impl PreparedContract {
return Err("prompt lookahead requires paired packed lookahead_token_ids and int32 submission-row lookahead_query_lengths bindings".into());
}
}
let text_forward = is_text_forward_graph(descriptor.kind);
let text_forward = descriptor.kind.is_text_forward();
saw_text_forward |= text_forward;
let mut graph_parameters = std::collections::HashSet::new();
let mut destinations = std::collections::HashSet::new();
Expand Down
2 changes: 1 addition & 1 deletion helios/src/model/packing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Inputs {
binding.indexing == Scalar
}
CoreParameter => {
is_text_forward_graph(graph.kind)
graph.kind.is_text_forward()
&& matches!(
binding.indexing,
SubmissionRow | RequestRow | ActiveRow
Expand Down
18 changes: 10 additions & 8 deletions helios/src/model/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,30 @@ fn generic_core_parameters_resolve_pack_and_enforce_text_forward_contracts() {
growable_output: false,
preserve_message_anchor: false,
};
// Parameterless plan_admission/admit reject declaring cores at admission time
// rather than building plans without core-parameter prefix identity.
assert!(scheduler.plan_admission(&spec).is_err());
assert!(scheduler.admit(spec.clone()).is_err());
assert_eq!(scheduler.free_slot_count(), 4);

// Unified validation rejects out-of-range and non-canonical -0.0 values in plan_admission_with_core_parameters.
let out_of_range =
std::collections::BTreeMap::from([("gain".into(), 2.), ("offset".into(), 0.25)]);
assert!(
scheduler
.plan_admission_with_core_parameters(&spec, &config.contract.core_parameters, &out_of_range)
.plan_admission_with_core_parameters(&spec, &out_of_range)
.is_err()
);
let neg_zero =
std::collections::BTreeMap::from([("gain".into(), -0.0f32), ("offset".into(), 0.25)]);
assert!(
scheduler
.plan_admission_with_core_parameters(&spec, &config.contract.core_parameters, &neg_zero)
.plan_admission_with_core_parameters(&spec, &neg_zero)
.is_err()
);

let plan = scheduler
.plan_admission_with_core_parameters(&spec, &config.contract.core_parameters, &resolved)
.plan_admission_with_core_parameters(&spec, &resolved)
.unwrap();
let handle = scheduler.admit_planned(spec, plan, None).unwrap().handle;
let mut admissions: [Option<Admission>; 4] = std::array::from_fn(|_| None);
Expand Down Expand Up @@ -386,11 +392,7 @@ fn core_parameters_pack_sparse_permuted_rows_and_preserve_prefix_values() {
.map(|gain| {
let parameters = std::collections::BTreeMap::from([("gain".into(), gain)]);
let plan = scheduler
.plan_admission_with_core_parameters(
&spec,
&config.contract.core_parameters,
&parameters,
)
.plan_admission_with_core_parameters(&spec, &parameters)
.unwrap();
let handle = scheduler
.admit_planned(spec.clone(), plan, None)
Expand Down
4 changes: 2 additions & 2 deletions helios/src/runtime_core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ pub use preparation::{
pub fn validate_sampling_defaults(value: &wire::DefaultSamplingParameters) -> crate::Result<()> {
protobuf::sampling_defaults(value.clone()).map(|_| ())
}
pub fn validate_core_parameters(value: &wire::ModelContract) -> crate::Result<()> {
protobuf::validate_core_parameters(value)
pub fn validate_core_parameter_declarations(value: &wire::ModelContract) -> crate::Result<()> {
protobuf::validate_core_parameter_declarations(value)
}
pub const WIRE_DESCRIPTOR: &[u8] =
include_bytes!(concat!(env!("OUT_DIR"), "/runtime_core_descriptor.bin"));
Expand Down
10 changes: 5 additions & 5 deletions helios/src/runtime_core/protobuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub(super) fn size(value: u64) -> Result<usize> {
usize::try_from(value).map_err(|_| invalid("resource size exceeds host address space"))
}

pub(super) fn validate_core_parameters(contract: &wire::ModelContract) -> Result<()> {
pub(super) fn validate_core_parameter_declarations(contract: &wire::ModelContract) -> Result<()> {
let mut parsed = Vec::with_capacity(contract.core_parameters.len());
for parameter in &contract.core_parameters {
let default_value = required(parameter.default_value, "core parameter default_value")?;
Expand Down Expand Up @@ -82,7 +82,7 @@ pub(super) fn serving_contract(
if !(1..=3).contains(&contract.version) {
return Err(invalid("unsupported prepared model contract version; re-export the model core"));
}
validate_core_parameters(contract)?;
validate_core_parameter_declarations(contract)?;
let mut value = serde_json::to_value(value).map_err(|e| invalid(e.to_string()))?;
value.as_object_mut().unwrap().retain(|_, v| !v.is_null());
Ok(value)
Expand Down Expand Up @@ -949,7 +949,7 @@ mod tests {
};
let restored = wire::ModelContract::decode(contract.encode_to_vec().as_slice()).unwrap();
assert_eq!(restored, contract);
validate_core_parameters(&restored).unwrap();
validate_core_parameter_declarations(&restored).unwrap();
let binding: crate::model::contract::ValueBinding = serde_json::from_value(
serde_json::to_value(&restored.graphs[0].inputs[0]).unwrap(),
)
Expand All @@ -963,7 +963,7 @@ mod tests {
let previous = wire::ModelContract::decode(b"\x08\x03".as_slice()).unwrap();
assert_eq!(previous.version, 3);
assert!(previous.core_parameters.is_empty());
validate_core_parameters(&previous).unwrap();
validate_core_parameter_declarations(&previous).unwrap();

for invalid_contract in [
wire::ModelContract {
Expand Down Expand Up @@ -1009,7 +1009,7 @@ mod tests {
..Default::default()
},
] {
assert!(validate_core_parameters(&invalid_contract).is_err());
assert!(validate_core_parameter_declarations(&invalid_contract).is_err());
}
}

Expand Down
16 changes: 11 additions & 5 deletions helios/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ pub struct SchedulerCapabilities {
pub speculative_allocations: Vec<(usize, usize, usize, usize, crate::execution::PrefixAllocation)>,
/// Execution state rows each active request holds; None, the widest speculative graph's width.
pub state_rows_per_request: Option<usize>,
/// Core-declared FP32 forward parameters validated and hashed into every admission plan.
pub core_parameters: Vec<crate::model::contract::CoreParameter>,
}

#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
Expand Down Expand Up @@ -704,6 +706,7 @@ impl RequestScheduler {
) -> Result<Self> {
limits.validate_prefill()?;
capabilities.vision.validate()?;
crate::model::contract::validate_core_parameter_declarations(&capabilities.core_parameters)?;
if capabilities.completion_token_capacity == 0
|| capabilities.draft_pages_per_request > limits.pages as usize
|| capabilities.vocabulary == 0
Expand Down Expand Up @@ -1590,25 +1593,28 @@ impl RequestScheduler {
+ self.draft_pages()
}

/// Admits a request with no inbound host restore. Rejects cores that
/// declare `core_parameters`.
pub fn admit(&mut self, spec: RequestSpec) -> Result<RequestHandle> {
let plan = self.plan_admission(&spec)?;
Ok(self.admit_planned(spec, plan, None)?.handle)
}

/// Validates the request, builds its prefix history, and looks up the GPU
/// cache without reserving anything.
/// cache without reserving anything. Rejects cores that declare core parameters.
pub fn plan_admission(&mut self, spec: &RequestSpec) -> Result<AdmissionPlan> {
self.plan_admission_with_core_parameters(spec, &[], &Default::default())
self.plan_admission_with_core_parameters(spec, &Default::default())
}

/// Validates the request and its resolved core parameters, builds its
/// salted prefix history, and looks up the GPU cache without reserving anything.
/// Validates the request and its resolved core parameters against the
/// scheduler's declared core parameters, builds its salted prefix history,
/// and looks up the GPU cache without reserving anything.
pub fn plan_admission_with_core_parameters(
&mut self,
spec: &RequestSpec,
parameters: &[crate::model::contract::CoreParameter],
core_parameters: &crate::model::CoreParameters,
) -> Result<AdmissionPlan> {
let parameters = &self.capabilities.core_parameters;
if spec.prompt.is_empty()
|| spec.message_boundaries.first() == Some(&0)
|| spec.message_boundaries.last().is_some_and(|n| *n > spec.prompt.len())
Expand Down
1 change: 1 addition & 0 deletions helios/src/scheduler/boundary_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ fn scheduler_with_concurrency(snapshots: u32, mtp: bool, page_tokens: usize, act
completion_inputs: vec![],
speculative_allocations: vec![],
state_rows_per_request: None,
core_parameters: vec![],
},
)
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions helios/src/scheduler/cache_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1886,6 +1886,7 @@ mod tests {
completion_inputs: vec![],
speculative_allocations: vec![],
state_rows_per_request: None,
core_parameters: vec![],
},
)
.unwrap();
Expand Down
Loading