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
2 changes: 1 addition & 1 deletion .github/workflows/native-serving.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Prepare external frontend test fixtures
run: |
python -m pip install huggingface-hub==1.33.0
python tests/frontend/prepare_templates.py --output "${{ runner.temp }}/flare-test-templates" --recipe gemma4 --recipe glm53 --recipe mimo_v2 --recipe nemotron_h --recipe qwen38 --recipe step5
python tests/frontend/prepare_templates.py --output "${{ runner.temp }}/flare-test-templates" --recipe gemma4 --recipe glm53 --recipe mimo_v2 --recipe minimax_m3 --recipe nemotron_h --recipe qwen38 --recipe step5
- name: Install Linux build dependencies
if: runner.os == 'Linux'
run: |
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/python-cpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Python CPU tests

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
pytest:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: astral-sh/setup-uv@v6
- name: Install Linux build dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake ninja-build nasm protobuf-compiler libssl-dev liburing-dev
- name: Sync preparation and test environment
env:
BUILD_NVEP: "0"
FLASHINFER_BUILD_NO_PIP: "1"
run: uv sync --extra prepare --extra test
- name: Run CPU pytest suite
env:
CUDA_VISIBLE_DEVICES: ""
run: .venv/bin/python -m pytest tests/ -q
110 changes: 81 additions & 29 deletions helios/src/model/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,66 @@ fn validate_inner(config: &ModelConfig, manifest: &ExecutionManifest) -> Result<
graph.sampling_mode,
)?;
}
for kind in [
GraphKind::Init,
GraphKind::Restore,
GraphKind::Snapshot,
GraphKind::Resume,
GraphKind::Decode,
] {
if kind == GraphKind::Decode && !config.speculative_widths.is_empty() {
continue;
let lifecycle_batches: std::collections::BTreeSet<usize> = manifest
.graphs
.iter()
.filter(|graph| {
matches!(
graph.kind,
GraphKind::Init | GraphKind::Restore | GraphKind::Snapshot | GraphKind::Resume
) && graph.token_capacity == 1
&& graph.prefill_capacity == 0
&& graph.sampling_mode == SamplingMode::General
})
.map(|graph| graph.batch_capacity)
.collect();
if lifecycle_batches.is_empty() {
return Err("prepared model lacks lifecycle graphs".into());
}
let generation_batches: std::collections::BTreeSet<usize> = manifest
.graphs
.iter()
.filter(|graph| {
if config.speculative_widths.is_empty() {
graph.kind == GraphKind::Decode
&& graph.token_capacity == 1
&& graph.prefill_capacity == 0
&& graph.sampling_mode == SamplingMode::General
} else {
graph.kind == GraphKind::Speculative
}
})
.map(|graph| graph.batch_capacity)
.collect();
if generation_batches.is_empty() {
let missing = if config.speculative_widths.is_empty() {
"Decode"
} else {
"speculative"
};
return Err(format!("prepared model lacks {missing} graph").into());
}
let required_batches: std::collections::BTreeSet<usize> =
lifecycle_batches.union(&generation_batches).copied().collect();
for &batch in &required_batches {
for kind in [
GraphKind::Init,
GraphKind::Restore,
GraphKind::Snapshot,
GraphKind::Resume,
] {
select(config, manifest, kind, batch, 1, 0, SamplingMode::General)?;
}
if !manifest
.graphs
.iter()
.any(|graph| graph.kind == kind && graph.token_capacity == 1 && graph.prefill_capacity == 0 && graph.sampling_mode == SamplingMode::General)
{
return Err(format!("prepared model lacks {kind:?} graph").into());
if config.speculative_widths.is_empty() {
select(
config,
manifest,
GraphKind::Decode,
batch,
1,
0,
SamplingMode::General,
)?;
}
}
select(
Expand All @@ -166,22 +210,30 @@ fn validate_inner(config: &ModelConfig, manifest: &ExecutionManifest) -> Result<
)?;
}
if !config.speculative_widths.is_empty() {
if !manifest.graphs.iter().any(|graph| {
graph.kind == GraphKind::Speculative && graph.token_capacity == 1
}) {
return Err("prepared model lacks width-one speculative graph".into());
}
if config.speculative_widths.iter().any(|&width| width > 1)
&& manifest.graphs.iter().any(|graph| {
let has_wider_width = config.speculative_widths.iter().any(|&width| width > 1);
for &batch in &required_batches {
if !manifest.graphs.iter().any(|graph| {
graph.kind == GraphKind::Speculative
&& graph.batch_capacity == batch
&& graph.token_capacity == 1
&& graph.batch_capacity * 2 <= config.speculative_token_capacity
})
&& !manifest.graphs.iter().any(|graph| {
graph.kind == GraphKind::Speculative && graph.token_capacity > 1
})
{
return Err("prepared model lacks wider speculative graph".into());
}) {
return Err(format!(
"prepared model lacks width-one speculative graph for batch {batch}"
)
.into());
}
if has_wider_width
&& batch * 2 <= config.speculative_token_capacity
&& !manifest.graphs.iter().any(|graph| {
graph.kind == GraphKind::Speculative
&& graph.batch_capacity == batch
&& graph.token_capacity > 1
})
{
return Err(
format!("prepared model lacks speculative graph for batch {batch}").into(),
);
}
}
}
Ok(())
Expand Down
55 changes: 54 additions & 1 deletion helios/src/runtime_core/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,15 @@ impl LoadOptions {
_ => return Err(invalid("unknown speculative proposal source")),
};
let adaptive = self.adaptive_verification.unwrap_or(captured_fixed.is_none());
let speculative_max_batch = execution
.graphs
.iter()
.filter(|g| g.kind == "speculative" && g.batch_capacity >= active as u64)
.map(|g| g.batch_capacity)
.min()
.unwrap_or(active as u64);
let eligible_widths: BTreeSet<_> = execution.graphs.iter().filter(|graph|
graph.kind == "speculative" && graph.batch_capacity <= active.next_power_of_two() as u64
graph.kind == "speculative" && graph.batch_capacity <= speculative_max_batch
&& graph.draft_source == source && graph.draft_tokens.is_some_and(|depth| depth <= drafts as u32)
&& widths.contains(&(graph.token_capacity as usize))
&& (graph.token_capacity == 1 || graph.packed_token_capacity <= token_capacity))
Expand Down Expand Up @@ -1889,6 +1896,52 @@ mod tests {
}
}

#[test]
fn eligible_widths_follow_covering_max_batch_instead_of_next_power_of_two() {
// Core declares intermediate bucket 6 alongside 8; selecting max_concurrency=5 retains
// batches <= 6 and drops batch 8, so a width present only on batch 8 must not be eligible.
let mut core = host_wide_round_core();
core.execution.as_mut().unwrap().max_active = 8;
let graphs = &mut core.execution.as_mut().unwrap().graphs;
let template_spec_w1 = graphs.iter().find(|g| g.kind == "speculative" && g.batch_capacity == 1 && g.token_capacity == 1).unwrap().clone();
let template_spec_w8 = graphs.iter().find(|g| g.kind == "speculative" && g.batch_capacity == 1 && g.token_capacity == 8).unwrap().clone();
for batch in [6u64, 8] {
for kind in ["init", "restore", "snapshot", "resume"] {
let mut g = graphs.iter().find(|g| g.kind == kind && g.batch_capacity == 1).unwrap().clone();
g.name = format!("{kind}-b{batch}");
g.batch_capacity = batch;
graphs.push(g);
}
let mut spec_w1 = template_spec_w1.clone();
spec_w1.name = format!("spec-b{batch}-w1");
spec_w1.batch_capacity = batch;
spec_w1.packed_token_capacity = batch;
graphs.push(spec_w1);
}
// Place wider speculative width 8 ONLY on batch 8 (above max_batch=6 for active=5).
graphs.retain(|g| g.kind != "speculative" || g.token_capacity == 1);
let mut spec_b8_w8 = template_spec_w8;
spec_b8_w8.name = "spec-b8-w8".into();
spec_b8_w8.batch_capacity = 8;
spec_b8_w8.packed_token_capacity = 64;
graphs.push(spec_b8_w8);
refresh_graph_resources(&mut core);
let mut configuration = serde_json::json!({
"speculative_widths": [1, 8],
"speculative_token_capacity": 64
});
let error = LoadOptions {
max_concurrency: Some(5),
mtp_draft_tokens: Some(5),
adaptive_verification: Some(false),
..Default::default()
}
.select(&mut [core], &mut configuration)
.unwrap_err()
.to_string();
assert!(error.contains("no captured speculative width fits"), "{error}");
}

}


Expand Down
36 changes: 35 additions & 1 deletion helios/src/scheduler/cost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ impl ActionCosts {
}

pub fn fresh_duration(&self, kind: GraphKind, tokens: usize) -> Option<u64> {
let key = Key { drafts: 0, kind, batch: 1, tokens, prefill: 0, packed: 0 };
let batch = self.batches(kind).first().copied()?;
let key = Key { drafts: 0, kind, batch, tokens, prefill: 0, packed: 0 };
self.entry(key).filter(|estimate| estimate.fresh(self.now_ns, self.ttl_ns))
.map(|estimate| estimate.nanos)
}
Expand Down Expand Up @@ -411,4 +412,37 @@ mod tests {
assert_eq!(reversed.packed_round_duration(16, 4), Some(18_000_000));
assert_eq!(reversed.packed_round_duration(16, 6), Some(18_000_000));
}

#[test]
fn fresh_duration_uses_smallest_declared_batch_when_batch_one_is_absent() {
let graphs = vec![GraphDescriptor {
name: "snapshot-b2".into(),
kind: GraphKind::Snapshot,
sampling_mode: SamplingMode::General,
confidence_width: 0,
draft_tokens: 0,
handle: 1,
batch_capacity: 2,
token_capacity: 1,
packed_token_capacity: 0,
prefill_capacity: 0,
estimated_duration_ns: 0,
input_bindings: vec![],
tuned_bindings: vec![],
}];
let mut costs = ActionCosts::prepared(&graphs, 1).unwrap();
let step = ScheduledStep {
draft_tokens: 0,
kind: GraphKind::Snapshot,
batch_capacity: 2,
token_capacity: 1,
packed_token_capacity: 0,
mixed: None,
lanes: vec![],
requires_feedback: false,
};
assert_eq!(costs.fresh_duration(GraphKind::Snapshot, 1), None);
costs.set_measured(&step, 750_000);
assert_eq!(costs.fresh_duration(GraphKind::Snapshot, 1), Some(750_000));
}
}
12 changes: 12 additions & 0 deletions ignition/direct/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,18 @@ def __init__(self, ident, prompt, max_new_tokens, sampling, *, ignore_eos=False,
def core_parameters(self):
return self._core_parameters

def __deepcopy__(self, memo):
from copy import deepcopy

copied = object.__new__(type(self))
memo[id(self)] = copied
for key, value in self.__dict__.items():
if isinstance(value, MappingProxyType):
setattr(copied, key, MappingProxyType(deepcopy(dict(value), memo)))
else:
setattr(copied, key, deepcopy(value, memo))
return copied

@property
def pending_token(self):
return (self.prompt + self.generated)[self.consumed]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ requires-python = ">=3.12,<3.13"
dependencies = []

[project.scripts]
ignition = "ignition.__main__:main"
ignition-core = "ignition.__main__:main"

[project.optional-dependencies]
test = ["pytest>=9,<10", "tiktoken>=0.12,<1"]
Expand Down
22 changes: 0 additions & 22 deletions tests/components/test_draft_block_broadcast_cuda.py

This file was deleted.

Loading
Loading