Skip to content
Closed
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
1 change: 1 addition & 0 deletions docs/cli-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
3 changes: 3 additions & 0 deletions ignition/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
17 changes: 11 additions & 6 deletions ignition/cli/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion ignition/cli/preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions ignition/cli/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 ''}"
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion ignition/declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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")
Expand Down
8 changes: 8 additions & 0 deletions ignition/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions ignition/preparation/rebuild_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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))
Expand Down
43 changes: 42 additions & 1 deletion tests/cli/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
)


Expand Down Expand Up @@ -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",
)
Loading