bd255419e1
CI / Sync project version with tag (push) Has been skipped
CI / Lint (ruff check) (push) Successful in 1m45s
CI / Format (ruff format) (push) Successful in 3m0s
CI / Type check (ty) (push) Successful in 3m16s
CI / Tests (push) Successful in 3m30s
CI / Bump version, tag, and update changelog on merge to master (push) Has been skipped
giant predict/rollout rebuilt models straight from ckpt["model_config"] with no way to change sampling-only keys (e.g. stage2_model.n_sec.stop_sampling) without retraining. Adds config_overrides to load_for_inference, validated against giant.config.INFERENCE_OVERRIDES so a typo or shape-bearing key raises CheckpointCompatibilityError up front instead of an opaque load_state_dict mismatch. Wired as a repeatable --set dotted.path=value on both CLI commands, recorded in the rollout YAML sidecar, and surfaced in `giant model summary`'s output. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
"""Thin CLI smoke coverage for `giant rollout` (issues.md Issue 5) — confirms
|
|
the CheckpointCompatibilityError raised by giant.checkpoint_io.load_for_inference
|
|
surfaces as a clean typer.Exit(1) with the expected message, end-to-end
|
|
through the CLI, not just at the giant.checkpoint_io unit level."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import torch
|
|
from typer.testing import CliRunner
|
|
|
|
from giant.cli import app
|
|
|
|
runner = CliRunner()
|
|
|
|
|
|
def test_rollout_exits_1_on_checkpoint_missing_model_config(tmp_path):
|
|
checkpoint = tmp_path / "bad.pt"
|
|
torch.save({"sec_decoder": {}, "normalizer": {"sec_phys": {}}}, checkpoint)
|
|
|
|
result = runner.invoke(
|
|
app,
|
|
[
|
|
"rollout",
|
|
"dummy.parquet",
|
|
"--checkpoint",
|
|
str(checkpoint),
|
|
"--geometry",
|
|
"dummy_geometry.pkl",
|
|
],
|
|
)
|
|
|
|
assert result.exit_code == 1
|
|
assert "checkpoint has no model_config" in result.output
|
|
|
|
|
|
def test_rollout_set_flag_disallowed_path_surfaces_compat_error(tmp_path):
|
|
checkpoint = tmp_path / "ckpt.pt"
|
|
torch.save(
|
|
{"model_config": {"stage1_model": {}, "stage2_model": {}}, "sec_decoder": {}, "normalizer": {"sec_phys": {}}},
|
|
checkpoint,
|
|
)
|
|
|
|
result = runner.invoke(
|
|
app,
|
|
[
|
|
"rollout",
|
|
"dummy.parquet",
|
|
"--checkpoint",
|
|
str(checkpoint),
|
|
"--geometry",
|
|
"dummy_geometry.pkl",
|
|
"--set",
|
|
"stage2_model.n_sec.typo=sample",
|
|
],
|
|
)
|
|
|
|
assert result.exit_code == 1
|
|
assert "not an inference-safe override" in result.output
|