diff --git a/.github/workflows/native-serving.yml b/.github/workflows/native-serving.yml index 9cb3e8b55..68b94b47b 100644 --- a/.github/workflows/native-serving.yml +++ b/.github/workflows/native-serving.yml @@ -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: | diff --git a/.github/workflows/python-cpu.yml b/.github/workflows/python-cpu.yml new file mode 100644 index 000000000..62f10c988 --- /dev/null +++ b/.github/workflows/python-cpu.yml @@ -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 diff --git a/helios/src/model/catalog.rs b/helios/src/model/catalog.rs index 2cd92bfa9..7e99c338f 100644 --- a/helios/src/model/catalog.rs +++ b/helios/src/model/catalog.rs @@ -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 = 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 = 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 = + 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( @@ -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(()) diff --git a/helios/src/runtime_core/selection.rs b/helios/src/runtime_core/selection.rs index 083614bf9..fa9ba88f5 100644 --- a/helios/src/runtime_core/selection.rs +++ b/helios/src/runtime_core/selection.rs @@ -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)) @@ -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}"); + } + } diff --git a/helios/src/scheduler/cost.rs b/helios/src/scheduler/cost.rs index de2596054..9060e84c3 100644 --- a/helios/src/scheduler/cost.rs +++ b/helios/src/scheduler/cost.rs @@ -262,7 +262,8 @@ impl ActionCosts { } pub fn fresh_duration(&self, kind: GraphKind, tokens: usize) -> Option { - 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) } @@ -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)); + } } diff --git a/ignition/direct/scheduler.py b/ignition/direct/scheduler.py index 5211fabbe..2c17bf0ee 100644 --- a/ignition/direct/scheduler.py +++ b/ignition/direct/scheduler.py @@ -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] diff --git a/pyproject.toml b/pyproject.toml index 2ef86c070..d8717dbbd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] diff --git a/tests/components/test_draft_block_broadcast_cuda.py b/tests/components/test_draft_block_broadcast_cuda.py deleted file mode 100644 index 3b0e7963c..000000000 --- a/tests/components/test_draft_block_broadcast_cuda.py +++ /dev/null @@ -1,22 +0,0 @@ -# SPDX-FileCopyrightText: Copyright (c) 2026 Flare community contributors -# SPDX-License-Identifier: Apache-2.0 - -"""Root proposal blocks replace divergent peer chains before native consumers.""" - -import json -import os - -import pytest -import torch -import torch.multiprocessing as mp - -from tests.components.draft_block_broadcast_support import rank_main - - -@pytest.mark.skipif(os.environ.get("FLARE_RUN_CUDA_TESTS") != "1" or torch.cuda.device_count() < 2, - reason="requires two explicitly assigned CUDA devices") -def test_canonical_block_under_native_tp2_replay(tmp_path): - output = tmp_path / "results.json" - mp.spawn(rank_main, args=((tmp_path / "rendezvous").as_uri(), output), nprocs=2, join=True) - result = json.loads(output.read_text()) - assert set(result["summary"]) == {"1", "8", "32"} diff --git a/tests/components/test_vocabulary_commit_cuda.py b/tests/components/test_vocabulary_commit_cuda.py deleted file mode 100644 index 3d265e705..000000000 --- a/tests/components/test_vocabulary_commit_cuda.py +++ /dev/null @@ -1,244 +0,0 @@ -# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -"""Committed conditional sequences exercise request state, RNG and raw logprobs.""" - -import itertools -import json -import math -import os - -import pytest -import torch -import triton -import triton.language as tl - -from ignition.components.sampling import FINISHED -from tests.components.causal_prefix_oracle import allocate -from tests.components.test_generation_logprobs_cuda import _assert_entry -from tests.components.vocabulary_commit_support import ToyCommittedModel - -pytestmark = pytest.mark.skipif(os.environ.get("FLARE_RUN_CUDA_TESTS") != "1", - reason="requires an explicitly assigned CUDA device") - - -def start(model, *, generation=1, budget=20, eos=(), rows=None): - model.stage(generation=generation, max_new_tokens=budget, eos=eos, rows=rows) - model.replay("admit") - model.replay("prefill") - - -def assert_committed(model, checkpoint): - before = {id(tensor): value for tensor, value in checkpoint} - state = model.requests - slots = model.slots.cpu().tolist() - for row, slot in enumerate(slots): - count = int(model.committed.emitted_count[row]) - if row >= int(model.live_rows) or int(model.epochs[row]) != int(state.generation[slot]): - assert count == 0 - continue - assert int(state.consumed_tokens[slot]) == int(before[id(state.consumed_tokens)][slot]) + count - assert int(state.generated_tokens[slot]) == int(before[id(state.generated_tokens)][slot]) + count - assert int(state.rng_counter[slot]) == int(before[id(state.rng_counter)][slot]) + count - previous_generation = int(before[id(model.rng.generation)][slot]) - base = int(before[id(model.rng.target_offset)][slot]) if previous_generation == int(state.generation[slot]) else 0 - assert int(model.rng.target_offset[slot]) == (base + model.verify.draw_reservation if count else - int(before[id(model.rng.target_offset)][slot])) - if count: - inputs = model.candidates[row, :count] - history = torch.cat((before[id(state.ple_history)][slot], inputs))[-2:] - torch.testing.assert_close(state.ple_history[slot], history) - assert state.pending_token[slot] == model.committed.emitted_ids[row, count - 1] - expected_histogram = before[id(state.histogram)][slot] + torch.bincount( - model.committed.emitted_ids[row, :count], minlength=model.vocabulary).to(torch.int32) - torch.testing.assert_close(state.histogram[slot], expected_histogram) - record = model.completion.records[int(model.frame), slot] - assert int(record[8]) == count - torch.testing.assert_close(record[16:16 + count], model.committed.emitted_ids[row, :count]) - if int(model.completion.requested[slot]): - queried = model.completion.token_ids[slot, :int(model.completion.token_id_counts[slot])].tolist() - for col in range(count): - _assert_entry(model.completion.logprobs[int(model.frame), slot, col], model.logits[row, col], - int(model.committed.emitted_ids[row, col]), ids=queried or None) - - -def test_causal_prefix_commit_offsets_rollback_stale_rows_and_slot_reuse(): - model = ToyCommittedModel(token_capacity=5) - try: - model.completion.requested.fill_(1) - model.completion.token_id_counts[0] = 21 - model.completion.token_ids[0, :21] = torch.arange(21, device="cuda", dtype=torch.int32) - model.capture() - start(model) - before = model.checkpoint() - model.replay("round") - assert_committed(model, before) - expected_lengths, expected_valid = allocate(model.confidence.cpu().tolist(), model.slots.cpu().tolist(), - [True] * 4, [True] * 4, [3] * 4, 5, 4) - assert model.limits.tolist() == expected_lengths - assert model.admitted.tolist() == expected_valid - assert (model.owner.offset == 8).all() - assert (model.rng.target_offset == model.verify.draw_reservation).all() - previous = model.candidates[:, 0] - for step in range(model.width - 1): - scores = model.proposal_base[:, step].double() + model.embedding[previous].double() @ model.head.double().T - torch.testing.assert_close(model.q[:, step].double(), scores.softmax(-1), rtol=3e-6, atol=1e-9) - previous = model.drafts[:, step] - first_tokens = model.committed.emitted_ids.clone() - first_q = model.q.clone() - first_logprobs = model.completion.logprobs.clone() - # The complete checkpoint includes all physical RNG domains and consumed - # predecessor state. Rejected suffixes and dead graph scratch are absent. - model.restore(before) - model.q.fill_(float("nan")) - model.p.fill_(float("nan")) - model.replay("round") - assert_committed(model, before) - torch.testing.assert_close(model.committed.emitted_ids, first_tokens) - torch.testing.assert_close(model.q, first_q) - torch.testing.assert_close(model.completion.logprobs, first_logprobs) - model.live_rows.fill_(1) - before = model.checkpoint() - model.replay("round") - assert_committed(model, before) - inactive = [slot for slot in range(4) if slot != int(model.slots[0])] - for value, saved in before: - actual_bits = value.view(torch.int64) if value.dtype == torch.uint64 else value - saved_bits = saved.view(torch.int64) if saved.dtype == torch.uint64 else saved - torch.testing.assert_close(actual_bits[inactive], saved_bits[inactive]) - # A stale graph lane cannot advance request state or either RNG domain. - model.epochs[0] += 1 - before = model.checkpoint() - model.replay("round") - for value, saved in before: - torch.testing.assert_close(value, saved) - model.prefix_limits[0] = expected_lengths[0] - model.stage(generation=2, rows=[0]) - model.replay("admit") - model.replay("prefill") - before = model.checkpoint() - model.replay("round") - assert_committed(model, before) - reused = int(model.slots[0]) - assert int(model.owner.generation[reused]) == 2 - assert int(model.owner.offset[reused]) == 8 - assert int(model.rng.generation[reused]) == 2 - assert int(model.rng.target_offset[reused]) == model.verify.draw_reservation - # Reusing the seed and complete initial state restarts both streams. - torch.testing.assert_close(model.committed.emitted_ids[0], first_tokens[0]) - finally: - model.close() - - -@pytest.mark.parametrize("stop", ["budget", "eos"]) -def test_budget_and_natural_stop_clip_commit_and_leave_rng_terminal(stop): - model = ToyCommittedModel() - try: - model.completion.requested.fill_(1) - if stop == "eos": - model.target_table.fill_(-float("inf")) - model.target_table[:, 2] = 0. - else: - model.prefix_limits.fill_(1) - model.capture() - start(model, budget=2 if stop == "budget" else 20, eos=(2,) if stop == "eos" else ()) - before = model.checkpoint() - model.replay("round") - assert_committed(model, before) - assert (model.committed.emitted_count == 1).all() - assert (model.requests.status == FINISHED).all() - assert (model.requests.generated_tokens == 2).all() - if stop == "eos": - assert (model.requests.pending_token == 2).all() - before = model.checkpoint() - model.replay("round") - for value, saved in before: - torch.testing.assert_close(value, saved) - assert (model.committed.emitted_count == 0).all() - finally: - model.close() - - -@triton.jit -def _observe(Emitted, Lengths, Sequence, Counts, Rounds, B: tl.constexpr): - row = tl.program_id(0) - count = tl.load(Counts + row) - emitted = tl.load(Lengths + row) - col = tl.arange(0, 4) - value = tl.load(Emitted + row * 3 + col, col < 3, other=-1) - tl.store(Sequence + row * 3 + count + col, value, (col < emitted) & (count + col < 3)) - tl.store(Counts + row, count + emitted) - tl.store(Rounds + row, tl.load(Rounds + row) + (emitted > 0).to(tl.int32)) - - -class ConditionalTrial: - """Generate exactly three tokens through admission and actual commits.""" - - def __init__(self, model): - from ignition.preparation.triton import prepare_triton - self.model = model - self.sequence = torch.full((model.batch, 3), -1, device="cuda", dtype=torch.int64) - self.counts = torch.zeros(model.batch, device="cuda", dtype=torch.int32) - self.rounds = torch.zeros_like(self.counts) - self.observe = prepare_triton(_observe, (model.committed.emitted_ids, model.committed.emitted_count, - self.sequence, self.counts, self.rounds), (model.batch, 1, 1), B=model.batch, num_warps=4) - - def __call__(self): - m = self.model - m.admission_buffers.admission_generations.add_(1) - m.admission_buffers.admission_seed_bits.add_(m.batch) - m.epochs.copy_(m.admission_buffers.admission_generations) - m.initialize() - m.prefill() - self.sequence.fill_(-1) - self.counts.zero_() - self.rounds.zero_() - safe = m.slots.long() - for _ in range(3): - m.prefix_limits.copy_((m.requests.max_new_tokens[safe] - m.requests.generated_tokens[safe]).clamp(1, 3).int()) - m() - self.observe() - - -def test_fixed_length_conditional_law_through_admission_prefix_allocation_and_commit(): - model = ToyCommittedModel(batch=64) - try: - model.stage(generation=1, max_new_tokens=4) - trial = ConditionalTrial(model) - model.capture(extra={"trial": trial}) - sequences = [] - for _ in range(2048): - model.replay("trial") - sequences.append(trial.sequence.clone()) - observed_sequences = torch.cat(sequences) - assert (observed_sequences >= 0).all() and (observed_sequences < 3).all() - assert (trial.counts == 3).all() - assert (model.requests.generated_tokens == 4).all() - assert (model.requests.consumed_tokens == 4).all() - assert (model.requests.rng_counter == 4).all() - assert (model.requests.histogram.sum(-1) == 5).all() - safe = model.slots.long() - torch.testing.assert_close(model.requests.pending_token[safe], trial.sequence[:, -1]) - torch.testing.assert_close(model.requests.ple_history[safe], trial.sequence[:, :2]) - torch.testing.assert_close(model.owner.offset[safe], trial.rounds.long() * 8) - torch.testing.assert_close(model.rng.target_offset[safe], trial.rounds.long() * model.verify.draw_reservation) - matrix = model.target_table[:3, :3].double().softmax(-1).cpu() - measurements = [] - for width in (2, 3): - codes = (observed_sequences[:, :width] * 3 ** torch.arange(width - 1, -1, -1, device="cuda")).sum(-1) - observed = codes.bincount(minlength=3**width).cpu().double() / codes.numel() - expected = [] - for ids in itertools.product(range(3), repeat=width): - probability, previous = 1., 0 - for token in ids: - probability *= float(matrix[previous, token]) - previous = token - expected.append(probability) - error = float((observed - torch.tensor(expected, dtype=torch.float64)).abs().max()) - bound = math.sqrt(math.log(2 * (9 + 27) / 1e-7) / (2 * codes.numel())) - assert error < bound - measurements.append(dict(width=width, sequences=codes.numel(), max_joint_error=error, - simultaneous_hoeffding_bound=bound)) - print(json.dumps(dict(committed_conditional_joint_law=measurements))) - finally: - model.close() diff --git a/tests/preparation/test_capture_roce_wait.py b/tests/preparation/test_capture_roce_wait.py index 905fc3764..1c044a2c0 100644 --- a/tests/preparation/test_capture_roce_wait.py +++ b/tests/preparation/test_capture_roce_wait.py @@ -24,6 +24,8 @@ def capture_scope(*, stream): runtime.capture = capture_scope forward = lambda: None forward.prepare_capture = lambda: 0 + forward.capture_allocation_sizes = () + forward.retire_after_capture = lambda: None class Cache: def __init__(self, **kwargs): @@ -33,8 +35,9 @@ def prepare_many(self, functions, signatures, **kwargs): waits.append(("warm", runtime.spin_limit)) return functions - coordinator = SimpleNamespace(spans_hosts=True, ranks=(0, 1), barrier=lambda name, ranks: None) + coordinator = SimpleNamespace(spans_hosts=True, ranks=(0, 1), group=None, barrier=lambda name, ranks: None) monkeypatch.setattr(capture, "ForwardCache", Cache) + monkeypatch.setattr(capture.torch.distributed, "all_gather_object", lambda out, obj, group=None: out.__setitem__(slice(None), [obj] * len(out))) monkeypatch.setattr(capture.torch.cuda, "current_stream", lambda device: stream) monkeypatch.setattr(capture, "_warmup_stream", lambda device: stream) monkeypatch.setattr(capture, "_seed_warmup_workspaces", lambda stream, device: None) diff --git a/tests/preparation/test_core_protection.py b/tests/preparation/test_core_protection.py index 53308e8db..cb9120740 100644 --- a/tests/preparation/test_core_protection.py +++ b/tests/preparation/test_core_protection.py @@ -449,8 +449,8 @@ def test_stamped_profiles_verify_signatures_without_conferring_identity(flare, t stamp(flare, executable, json.loads(profile.read_text())) store = tmp_path / 'trust.toml' unknown = launch(flare, path, None, store, *approval(signer)) - assert unknown.returncode != 0 and 'publish the key in publisher.json' in unknown.stderr - assert 'https://huggingface.co/flare-tests/fixture' in unknown.stderr and not store.exists() + assert unknown.returncode != 0 and 'unknown core publisher' in unknown.stderr + assert not store.exists() known = launch(executable, path, None, store, *approval(signer)) assert 'Publisher: Example publisher fixture' in known.stderr assert 'Identity: Unverified' in known.stderr and 'Verified via' not in known.stderr @@ -730,7 +730,7 @@ def test_linked_companions_validate_targets_and_stored_data(native, tmp_path, re assert read(native, path, weights=False).returncode == 0 assert 'stored-data content verification failed' in read(native, path, weights=True).stderr target.write_bytes(target.read_bytes()[:-1]) - assert 'payload length' in read(native, path, weights=False).stderr + assert 'safetensors data length differs from model core' in read(native, path, weights=False).stderr with pytest.raises(ValueError, match='data length'): assert_shard_contents(path, expected) diff --git a/tests/preparation/test_packaging.py b/tests/preparation/test_packaging.py index 6b3fc41ae..4f4e9765a 100644 --- a/tests/preparation/test_packaging.py +++ b/tests/preparation/test_packaging.py @@ -22,7 +22,7 @@ def test_pyproject_declares_preparation_entrypoint_and_cores(): assert "ignition*" in includes assert not any(name.startswith(("flare", "serve")) for name in includes) assert pyproject["project"]["dependencies"] == [] - assert pyproject["project"]["scripts"] == {"ignition": "ignition.__main__:main"} + assert pyproject["project"]["scripts"] == {"ignition-core": "ignition.__main__:main"} def test_core_import_has_no_runtime_or_cuda_side_effects(): diff --git a/tests/preparation/test_transient_retention.py b/tests/preparation/test_transient_retention.py index 27db26a46..e83fea29b 100644 --- a/tests/preparation/test_transient_retention.py +++ b/tests/preparation/test_transient_retention.py @@ -116,6 +116,7 @@ def retention(): def forward(): events.append('run') forward.prepare_capture = lambda: events.append('prepare_capture') or 0 + forward.capture_allocation_sizes = () forward.retire_after_capture = lambda: None class Cache: def __init__(self, **kwargs):