From f54928b995b8aaa30f19843b5e13175561fdc270 Mon Sep 17 00:00:00 2001 From: Jonathan Gutierrez Date: Tue, 24 Nov 2026 17:27:43 -0800 Subject: [PATCH] Add recipe-declared --target-head-quantization preparation flag Bandwidth-limited GPUs such as DGX Spark GB10 (273 GB/s LPDDR5X) spend a measurable share of each single-user decode step reading a full-precision BF16 vocabulary projection (`lm_head`, e.g. 1.21 GiB for a 248,320 x 2,560 head) and reserve that weight memory out of the unified KV cache budget. Checkpoint precision must remain the default, and Flare forbids environment-variable behavior switches, so opting into a quantized target vocabulary head requires an explicit recipe-declared preparation flag carried through `Plan` and `PreparationManifest` without adding model-specific logic to core `ignition`. Changes: - Add `Recipe.target_head_quantizations: tuple[str, ...] = ()` in `ignition/declaration.py`, validated in `Recipe.__post_init__` to accept supported target head formats (`"mxfp8"`). - Add the default-None, model-agnostic `--target-head-quantization {mxfp8}` advanced preparation flag in `ignition/cli/__init__.py` across `export`, `debug-serve`, and `bench`, forwarded through `ignition/cli/preparation.py::derive`, `ignition/cli/serve.py` (`_export_hosts`, `_prepare` including startup status summary, and `debug_serve`), and `ignition/cli/bench.py` (`run` and `_measure`). - Add `Plan.target_head_quantization: str | None = None` in `ignition/planning.py`, validate against `self.recipe.target_head_quantizations` in `Plan.__post_init__` (raising `UsageError` naming `self.checkpoint.alias` when unsupported), and record it in `Plan.to_dict()` when set. - Record `--target-head-quantization ` in `ignition/preparation/rebuild_manifest.py::reproduction_arguments` and emit `target_head_quantization` under `SCOPE_TARGET_WEIGHT` in `PreparationManifest` (`from_plan`) when set (omitted when `None` so existing default-precision cores remain compatible across `combine` and `--reuse-weights` with zero Protobuf or Rust changes). - Document `--target-head-quantization {mxfp8}` in `docs/cli-design.md`. - Add recipe-free unit tests in `tests/cli/test_commands.py` and `tests/cli/test_planning.py` verifying model-agnostic CLI help, `derive` forwarding and rejection, `Recipe` / `Plan` validation, `Plan.to_dict()`, and `PreparationManifest` (`SCOPE_TARGET_WEIGHT` + `reproduction_args`) Protobuf round-trip. Result: - Core `ignition` remains strictly recipe-free (`ignition/components/` keeps its 13 Helios-ABI modules), Helios runtime policy and `PreparedContract` are unchanged, and omitting `--target-head-quantization` preserves existing plans, exports, and checkpoint precision identically. - Enables downstream recipes declaring `target_head_quantizations=("mxfp8",)` (such as Qwen3.8-Flash-Next in `local-inference-lab/hyperflare-recipes`) to prepare opt-in MXFP8 target `lm_head` weights with full `PreparationManifest` `TARGET_WEIGHT` scope tracking for `flare combine` and `--reuse-weights`. Measured serving gains on GB10 (+7.5-9.0% C1 decode, ~600 MiB memory saved on TP1, 44/44 quality checks PASS) belong to the paired core + recipe change, not this core flag alone. Evidence and limitations: - Rebased onto `origin/main` `2771618` (`PreparationManifest`) and verified unit tests covering core boundary invariants, commit-msg design-review hook, model-agnostic CLI flag parsing, `derive` forwarding and rejection, `Recipe`/`Plan` validation, and deterministic `PreparationManifest` `SCOPE_TARGET_WEIGHT` Protobuf round-trip. - End-to-end TP1 and TP2 RoCE Qwen3.8-Flash-Next exports with `--target-head-quantization mxfp8` were qualified on DGX Spark GB10 (SM121) with the companion `hyperflare-recipes` PR via `flare run`. - Limitations: Rust `cargo test` was not run because no Rust or Protobuf files were modified. Design-Signed-Off-By: Antigravity (Gemini); design-review=eb2f Signed-off-by: Jonathan Gutierrez --- docs/cli-design.md | 1 + ignition/cli/__init__.py | 3 ++ ignition/cli/bench.py | 17 ++++++--- ignition/cli/preparation.py | 4 +- ignition/cli/serve.py | 4 ++ ignition/declaration.py | 5 ++- ignition/planning.py | 8 ++++ ignition/preparation/rebuild_manifest.py | 4 ++ tests/cli/test_commands.py | 43 +++++++++++++++++++++- tests/cli/test_planning.py | 47 +++++++++++++++++++++++- 10 files changed, 126 insertions(+), 10 deletions(-) diff --git a/docs/cli-design.md b/docs/cli-design.md index 07ee1cc94..50e66a0c3 100644 --- a/docs/cli-design.md +++ b/docs/cli-design.md @@ -451,6 +451,7 @@ explicit flags take precedence. | `--mtp-only` | Omit MTP-disabled prefill, decode, maintenance, and mixed graphs during preparation. Retain width-one speculative rounds and vision graphs. Requires positive draft depth; rejects `--no-mtp`. The core cannot load with native `--mtp-draft-tokens 0`. | Capture both execution modes | | `--draft-body-quantization {mxfp8}` | Prepare eligible DFlash2 body context, attention latent/query/output, and MLP projections as MXFP8, independently of target conversion and proposal-head precision. Kimi K3.1 Pro requires `--speculative-method dflash2` and positive learned draft depth; DSpark and other recipes reject it. Normalization, convolution, candidate-selector, and absorbed key/value weights retain their precision. Omission preserves checkpoint precision or the existing `online_mxfp8_scope all` behavior. | No additional override | | `--draft-head-quantization {nvfp4,mxfp8}` | Prepare a separate proposal vocabulary head while retaining target-head precision. NVFP4 supports DeepSeek V4/V4.1; MXFP8 supports DeepSeek V4.1. Qwen3.8 dense supports both when the source checkpoint head is BF16, including `qwen3.8-27b-qad`; the packed NVIDIA head cannot be converted through this option. Flash Next supports both with `--speculative-method dflash2` and a BF16 target vocabulary head. Kimi K3.1 Pro supports both with `--speculative-method dflash2` only. This does not quantize the draft body. | Checkpoint precision | +| `--target-head-quantization {mxfp8}` | Prepare the target vocabulary head as MXFP8 for recipes that declare `target_head_quantizations` (such as Qwen3.8 Flash Next with a BF16 checkpoint head), freeing the temporary BF16 vocabulary weight after conversion. Recipes that do not declare the requested format reject it. Command line only; changing it requires re-export. | Checkpoint precision | | `--markov-head-quantization {nvfp4,fp8}` | Prepare the draft Markov transition projection as NVFP4 or row-scaled E4M3 FP8. DeepSeek V4 supports NVFP4; DeepSeek V4.1 supports both. Requires positive draft depth. | Checkpoint precision | | `--vocabulary-parallel-sampling` | Prepare vocabulary-sharded DSpark proposals and block rejection sampling. DeepSeek V4.1 on four GPUs only; three-GPU preparation rejects it. Requires positive draft depth and recipe sampling defaults without top-k, top-p, or min-p filtering, and rejects `--markov-head-quantization nvfp4`. | Full-vocabulary sampling | | `--mtp-draft-tokens N` | Most draft tokens verified in one round; see `MODEL --help` for its limit. Verification capacities cover counts from 0 through `N` within the speculative token capacity. Each complete speculative program records its actual proposal depth independently of target width and aggregate rows. Prefix selection uses measured complete-program cost and completed acceptance or confidence. Zero retains draft state with width-one execution; `--no-mtp` excludes draft weights and state. | Recipe declaration | diff --git a/ignition/cli/__init__.py b/ignition/cli/__init__.py index 5ee757809..658cbb812 100644 --- a/ignition/cli/__init__.py +++ b/ignition/cli/__init__.py @@ -209,6 +209,9 @@ def _preparation_arguments(running, *, model_default="defaults.model", recipes=( " target verification retains its precision (NVFP4: DeepSeek V4/V4.1;" " MXFP8: DeepSeek V4.1; both: Qwen3.8 dense and Flash Next DFlash2 with a BF16 checkpoint head;" " default: checkpoint precision)") + advanced.add_argument("--target-head-quantization", choices=("mxfp8",), + help="prepare the target vocabulary head as MXFP8 for recipes that declare it" + " (default: checkpoint precision)") advanced.add_argument("--markov-head-quantization", choices=("nvfp4", "fp8"), help="prepare the draft Markov transition projection as NVFP4" " or row-scaled E4M3 FP8 (FP8: DeepSeek V4.1; default: checkpoint precision)") diff --git a/ignition/cli/bench.py b/ignition/cli/bench.py index 4e985c2cb..135925288 100644 --- a/ignition/cli/bench.py +++ b/ignition/cli/bench.py @@ -167,6 +167,7 @@ def run(args): autotune_effort=args.autotune_effort, lock_gpu_clocks=args.lock_gpu_clocks, native_dense_activations=args.native_dense_activations, force_moe_decode_a16=args.force_moe_decode_a16, + target_head_quantization=getattr(args, "target_head_quantization", None), shard_hyperconnections=args.shard_hyperconnections, joint_tuning=args.joint_tuning, row_shard_prefill=args.row_shard_prefill, image_concurrency=args.image_concurrency, mixed_prefill=args.mixed_prefill, @@ -239,12 +240,16 @@ def _measure(model, plan, configuration, settings, progress, *, compile_forwards "compiled_forwards": compile_forwards, "torch_version": torch.__version__, "verification_prefixes": settings.verification_prefixes, "logical_verification_width": settings.width, "requested_max_concurrency": plan.concurrency, "prepared_request_capacity": max(settings.batches), - "preparation": {key: preparation[key] for key in ( - "tensor_parallel", "prefill_chunk", "stream_overlap", "context_parallel", "context_parallel_size", - "native_dense_activations", "force_moe_decode_a16", "autotune_effort", "compile_workers", - "speculative_token_capacity", "speculation", "expert_scale_compression", "mla_compute_mode", - "row_shard_prefill", - "online_mxfp8", "online_mxfp8_scope", "language_model_only")}} + "preparation": { + **{key: preparation[key] for key in ( + "tensor_parallel", "prefill_chunk", "stream_overlap", "context_parallel", "context_parallel_size", + "native_dense_activations", "force_moe_decode_a16", "autotune_effort", "compile_workers", + "speculative_token_capacity", "speculation", "expert_scale_compression", "mla_compute_mode", + "row_shard_prefill", + "online_mxfp8", "online_mxfp8_scope", "language_model_only")}, + **({} if "target_head_quantization" not in preparation else { + "target_head_quantization": preparation["target_head_quantization"]}), + }} if settings.speculation_study: details["configuration"]["speculation_study"] = dict( diff --git a/ignition/cli/preparation.py b/ignition/cli/preparation.py index 06ad9e38d..47787f886 100644 --- a/ignition/cli/preparation.py +++ b/ignition/cli/preparation.py @@ -53,7 +53,8 @@ def derive(configuration: Configuration, model: ResolvedModel, host: Host, *, gp lock_gpu_clocks: bool = False, native_dense_activations: bool = False, joint_tuning: bool = False, shard_hyperconnections: bool = False, row_shard_prefill: bool = False, - force_moe_decode_a16: bool | None = None) -> planning.Plan: + force_moe_decode_a16: bool | None = None, + target_head_quantization: str | None = None) -> planning.Plan: """Select GPUs and estimate memory for one checkpoint from the configuration and command-line intent.""" workers = compiler_workers(configuration, compile_workers) result = planning.plan( @@ -69,6 +70,7 @@ def derive(configuration: Configuration, model: ResolvedModel, host: Host, *, gp result = replace(result, compile_workers=workers, hub_cache=configuration.directory("hub_cache"), autotune_effort=tuning_effort(configuration, autotune_effort), force_moe_decode_a16=configuration.get("preparation.force_moe_decode_a16", force_moe_decode_a16).value, + target_head_quantization=target_head_quantization, joint_tuning=joint_tuning, shard_hyperconnections=shard_hyperconnections, lock_gpu_clocks=lock_gpu_clocks, native_dense_activations=native_dense_activations) return tuning_devices(result, host, tuning_gpus) diff --git a/ignition/cli/serve.py b/ignition/cli/serve.py index fa77d4ffb..9d10715db 100644 --- a/ignition/cli/serve.py +++ b/ignition/cli/serve.py @@ -207,6 +207,7 @@ def _export_hosts(args): autotune_effort=tuning_effort(configuration, args.autotune_effort), lock_gpu_clocks=args.lock_gpu_clocks, native_dense_activations=args.native_dense_activations, force_moe_decode_a16=configuration.get("preparation.force_moe_decode_a16", args.force_moe_decode_a16).value, + target_head_quantization=getattr(args, "target_head_quantization", None), shard_hyperconnections=args.shard_hyperconnections, joint_tuning=args.joint_tuning) environment.apply(configuration, local, plan.recipe.b12x_environment) options = _server_options(configuration, model, plan) @@ -274,6 +275,7 @@ def __call__(self, message): compile_workers=args.compile_workers, tuning_gpus=args.tuning_gpus, autotune_effort=args.autotune_effort, lock_gpu_clocks=args.lock_gpu_clocks, native_dense_activations=args.native_dense_activations, force_moe_decode_a16=configuration.get("preparation.force_moe_decode_a16", args.force_moe_decode_a16).value, + target_head_quantization=getattr(args, "target_head_quantization", None), shard_hyperconnections=args.shard_hyperconnections, joint_tuning=args.joint_tuning, row_shard_prefill=args.row_shard_prefill, image_concurrency=args.image_concurrency, @@ -309,6 +311,7 @@ def __call__(self, message): f" · autotune effort {plan.autotune_effort}" f"{' · native dense activations' if plan.native_dense_activations else ''}" f"{' · MoE decode A16 / prefill A4' if plan.force_moe_decode_a16 else ''}" + f"{(' · target head ' + plan.target_head_quantization) if plan.target_head_quantization else ''}" f"{' · DFlash2 proposals' if plan.speculation is not None and plan.speculation.method == 'dflash2' else ''}" f"{' · joint tuning' if plan.joint_tuning else ''}" f"{' · BF16 sharded hyperconnections' if plan.shard_hyperconnections else ''}" @@ -473,6 +476,7 @@ def debug_serve(args) -> int: autotune_effort=tuning_effort(configuration, args.autotune_effort), lock_gpu_clocks=args.lock_gpu_clocks, native_dense_activations=args.native_dense_activations, force_moe_decode_a16=configuration.get("preparation.force_moe_decode_a16", args.force_moe_decode_a16).value, + target_head_quantization=getattr(args, "target_head_quantization", None), shard_hyperconnections=args.shard_hyperconnections, joint_tuning=args.joint_tuning) if rendezvous is None: plan = tuning_devices(plan, host, args.tuning_gpus) diff --git a/ignition/declaration.py b/ignition/declaration.py index da7c3a2ab..023ddbf57 100644 --- a/ignition/declaration.py +++ b/ignition/declaration.py @@ -273,8 +273,9 @@ class Recipe: mla_compute_mode: str = "auto" expert_scale_compression: str | None = None export_repository: str = "" - # Preparation overrides for vocabulary and transition projections used only by proposals. + # Preparation overrides for vocabulary and transition projections. draft_head_quantizations: tuple[str, ...] = () + target_head_quantizations: tuple[str, ...] = () draft_body_quantizations: tuple[str, ...] = () markov_head_quantizations: tuple[str, ...] = () # Supported (world_size, context_parallel_size) hybrid context-parallel topologies. @@ -324,6 +325,8 @@ def __post_init__(self): if any(type(size) is not int or size < 2 or size not in self.ranks for size in self.row_shard_prefill_world_sizes): raise ValueError("row_shard_prefill_world_sizes must name tensor-parallel sizes >= 2 declared in ranks") + if any(name not in ("mxfp8",) for name in self.target_head_quantizations): + raise ValueError("target_head_quantizations must name supported target vocabulary head formats") for name, method in self.speculative_methods.items(): if name not in ("mtp", "dspark", "dflash2") or set(method.ranks) != set(self.ranks): raise ValueError("speculative methods require known names and every declared tensor-parallel size") diff --git a/ignition/planning.py b/ignition/planning.py index 9907e6ac6..057a0976a 100644 --- a/ignition/planning.py +++ b/ignition/planning.py @@ -196,6 +196,7 @@ class Plan: lock_gpu_clocks: bool = False native_dense_activations: bool = False force_moe_decode_a16: bool = False + target_head_quantization: str | None = None hub_cache: Path | None = None tuning_gpus: tuple[Gpu, ...] = () tuning_replica: TuningReplica | None = None @@ -285,6 +286,11 @@ def __post_init__(self): raise UsageError(f"--joint-tuning is not supported by {self.checkpoint.alias}") if self.autotune_effort == "off": raise UsageError("--joint-tuning requires --autotune-effort default or audit") + if self.target_head_quantization is not None and self.target_head_quantization not in self.recipe.target_head_quantizations: + raise UsageError( + f"--target-head-quantization {self.target_head_quantization}: {self.checkpoint.alias}" + " does not prepare this target head format" + ) @property def world_size(self) -> int: @@ -402,6 +408,8 @@ def to_dict(self) -> dict: "lock_gpu_clocks": self.lock_gpu_clocks, "native_dense_activations": self.native_dense_activations, "force_moe_decode_a16": self.force_moe_decode_a16, + **({} if self.target_head_quantization is None else { + "target_head_quantization": self.target_head_quantization}), "tuning_gpus": [gpu.index for gpu in self.tuning_gpus], "speculative_token_capacity": self.speculative_token_capacity, "online_mxfp8": self.online_mxfp8, "online_mxfp8_scope": self.online_mxfp8_scope, "language_model_only": self.language_model_only, diff --git a/ignition/preparation/rebuild_manifest.py b/ignition/preparation/rebuild_manifest.py index c8d77ea6a..3cb70b39e 100644 --- a/ignition/preparation/rebuild_manifest.py +++ b/ignition/preparation/rebuild_manifest.py @@ -299,6 +299,8 @@ def reproduction_arguments(model, plan, *, compiled_forwards, multi_host=False): args.extend(['--mla-compute-mode', plan.mla_compute_mode]) if plan.force_moe_decode_a16: args.append('--force-moe-decode-a16') + if getattr(plan, 'target_head_quantization', None) is not None: + args.extend(['--target-head-quantization', plan.target_head_quantization]) if getattr(plan, 'native_dense_activations', False): args.append('--native-dense-activations') if plan.shard_hyperconnections: @@ -358,6 +360,8 @@ def add(key, scope, value): add('online_mxfp8_scope', SCOPE_TARGET_WEIGHT, online_mxfp8_scope) if plan.expert_scale_compression is not None: add('expert_scale_compression', SCOPE_TARGET_WEIGHT, plan.expert_scale_compression) + if plan.target_head_quantization is not None: + add('target_head_quantization', SCOPE_TARGET_WEIGHT, plan.target_head_quantization) # Shared core-combination semantics (must agree across combined deployments). add('language_model_only', SCOPE_COMBINE, bool(plan.language_model_only)) diff --git a/tests/cli/test_commands.py b/tests/cli/test_commands.py index 307af28e0..018a88484 100644 --- a/tests/cli/test_commands.py +++ b/tests/cli/test_commands.py @@ -19,7 +19,8 @@ MIB = 1 << 20 -def _fixture_recipe(*, ranks=(1, 2, 4), row_shard_world_sizes=(2, 4), joint_tuning=True): +def _fixture_recipe(*, ranks=(1, 2, 4), row_shard_world_sizes=(2, 4), joint_tuning=True, + target_head_quantizations=()): speculation = Speculation(draft_tokens=3) checkpoint = Checkpoint( alias="fixture-tp-model", @@ -48,6 +49,7 @@ def _fixture_recipe(*, ranks=(1, 2, 4), row_shard_world_sizes=(2, 4), joint_tuni speculation=speculation, joint_tuning=joint_tuning, row_shard_prefill_world_sizes=row_shard_world_sizes, + target_head_quantizations=target_head_quantizations, ) @@ -95,3 +97,42 @@ def test_derive_forwards_row_shard_prefill_and_rejects_joint_tuning(tmp_path): configuration, model, host, gpus="0,1", concurrency=concurrency, speculation=recipe.speculation, row_shard_prefill=True, joint_tuning=True, ) + + +@pytest.mark.parametrize("command", ["export", "debug-serve", "bench"]) +def test_target_head_quantization_flag_is_model_agnostic(command, capsys): + parser = _parser() + assert parser.parse_args([command, "fixture-tp-model"]).target_head_quantization is None + assert parser.parse_args([command, "fixture-tp-model", "--target-head-quantization", "mxfp8"]).target_head_quantization == "mxfp8" + + with pytest.raises(SystemExit) as exc: + _parser().parse_args([command, "--help"]) + assert exc.value.code == 0 + help_text = capsys.readouterr().out + section = help_text.split("--target-head-quantization", 1)[1].split("--markov-head-quantization", 1)[0] + assert "Qwen" not in section + + +def test_derive_forwards_and_validates_target_head_quantization(tmp_path): + cfg_path = tmp_path / "config.toml" + cfg_path.write_text("") + configuration = Configuration.load(cfg_path) + host = preparation.Host(tuple(_gpu(i) for i in range(4)), None) + + supported = _fixture_recipe(target_head_quantizations=("mxfp8",)) + supported_model = ResolvedModel(supported, supported.checkpoints[0], "alias") + concurrency = configuration.max_concurrency(supported_model.checkpoint.alias, supported.concurrency, None) + plan = preparation.derive( + configuration, supported_model, host, gpus="0", concurrency=concurrency, + speculation=supported.speculation, target_head_quantization="mxfp8", + ) + assert plan.target_head_quantization == "mxfp8" + assert plan.to_dict()["target_head_quantization"] == "mxfp8" + + unsupported = _fixture_recipe(target_head_quantizations=()) + unsupported_model = ResolvedModel(unsupported, unsupported.checkpoints[0], "alias") + with pytest.raises(UsageError, match="--target-head-quantization mxfp8: fixture-tp-model"): + preparation.derive( + configuration, unsupported_model, host, gpus="0", concurrency=concurrency, + speculation=unsupported.speculation, target_head_quantization="mxfp8", + ) diff --git a/tests/cli/test_planning.py b/tests/cli/test_planning.py index 9faf7c529..0251d8c71 100644 --- a/tests/cli/test_planning.py +++ b/tests/cli/test_planning.py @@ -20,7 +20,7 @@ def _recipe(name="fixture", *, device_gib=60, ranks=(1, 2, 4), speculation=DRAFTING, - row_shard_prefill_world_sizes=(), joint_tuning=False): + row_shard_prefill_world_sizes=(), joint_tuning=False, target_head_quantizations=()): checkpoint = Checkpoint( alias=f"{name}-alias", repository=f"example/{name}", @@ -51,6 +51,7 @@ def _recipe(name="fixture", *, device_gib=60, ranks=(1, 2, 4), speculation=DRAFT speculation=speculation, joint_tuning=joint_tuning, row_shard_prefill_world_sizes=row_shard_prefill_world_sizes, + target_head_quantizations=target_head_quantizations, ) @@ -206,3 +207,47 @@ def decode_params(plan): assert not decoded_index.HasField("rebuild") expected = json_format.ParseDict(manifest, proto.PreparationManifest()) assert decoded_index.preparation.SerializeToString(deterministic=True) == expected.SerializeToString(deterministic=True) + + +def test_target_head_quantization_validation_and_preparation_manifest(monkeypatch): + monkeypatch.setattr("ignition.preparation.source_identity.source_identity", lambda: "test-source") + unsupported = _recipe("plain", ranks=(1, 2), target_head_quantizations=()) + supported = _recipe("quanthead", ranks=(1, 2), target_head_quantizations=("mxfp8",)) + + with pytest.raises(ValueError, match="target_head_quantizations"): + _recipe("bad", ranks=(1,), target_head_quantizations=("nvfp4",)) + + gpu0 = (_gpu(0),) + base = planning.plan(supported, supported.checkpoints[0], gpu0, selected=(0,), + concurrency=4, reserve_bytes=0, speculation=DRAFTING) + assert base.target_head_quantization is None + assert "target_head_quantization" not in base.to_dict() + + quantized = replace(base, target_head_quantization="mxfp8") + assert quantized.target_head_quantization == "mxfp8" + assert quantized.to_dict()["target_head_quantization"] == "mxfp8" + + for candidate in (base, quantized): + manifest = rebuild_manifest.from_plan(SimpleNamespace(directory=None), candidate, compiled_forwards=True) + has_flag = "--target-head-quantization" in manifest["reproduction_args"] + assert has_flag == (candidate.target_head_quantization is not None) + if candidate.target_head_quantization is not None: + idx = manifest["reproduction_args"].index("--target-head-quantization") + assert manifest["reproduction_args"][idx + 1] == candidate.target_head_quantization + encoded = json_format.ParseDict(manifest, proto.PreparationManifest()) + decoded = proto.PreparationManifest.FromString(encoded.SerializeToString(deterministic=True)) + assert list(decoded.reproduction_args) == manifest["reproduction_args"] + keys = [parameter.key for parameter in decoded.parameters] + assert keys == sorted(keys) and len(keys) == len(set(keys)) + by_key = {parameter.key: parameter for parameter in decoded.parameters} + if candidate.target_head_quantization is None: + assert "target_head_quantization" not in by_key + else: + param = by_key["target_head_quantization"] + assert param.scope == proto.PREPARATION_PARAMETER_SCOPE_TARGET_WEIGHT + assert param.value.string_value == "mxfp8" + + plain_plan = planning.plan(unsupported, unsupported.checkpoints[0], gpu0, selected=(0,), + concurrency=4, reserve_bytes=0, speculation=DRAFTING) + with pytest.raises(UsageError, match="--target-head-quantization mxfp8: plain-alias"): + replace(plain_plan, target_head_quantization="mxfp8")