Skip to content

Commit 07c7322

Browse files
Copilotjustinchuby
andauthored
feat(cli): remove deprecated boolean build-mode flags
Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
1 parent c228b47 commit 07c7322

5 files changed

Lines changed: 35 additions & 79 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020

2121
#### Changed
2222

23-
- The boolean flags `--static-cache`, `--fp8-kv-cache`, and `--text-only` are now
24-
**deprecated aliases** for the matching `--features` value. They still work and
25-
set the same behaviour, but print a deprecation notice on stderr. Companion
23+
- The boolean flags `--static-cache`, `--fp8-kv-cache`, and `--text-only` have
24+
been **removed** in favor of the equivalent `--features` value. Companion
2625
value args (`--max-seq-len`, `--kv-cache-scale-file`) are unchanged.
2726

2827
### FP8 (E4M3) KV-cache export (`--features fp8-kv-cache`)

docs/cli_reference.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ Available features:
187187
| `text-only` | Export the text backbone of a multimodal checkpoint as a standalone decoder-only LLM (see below). |
188188

189189
The legacy boolean flags `--static-cache`, `--fp8-kv-cache`, and
190-
`--text-only` still work but are **deprecated** aliases for the matching
191-
feature and print a warning. Prefer `--features`.
190+
`--text-only` have been removed in favor of `--features`.
192191

193192
```bash
194193
mobius build --model meta-llama/Llama-3.2-1B output/ \
@@ -237,7 +236,7 @@ mobius build --model meta-llama/Llama-3.2-1B output/ \
237236
| `--max-shard-size SIZE` | Maximum shard size for safetensors external data (e.g. `5GB`). Only used with `--external-data safetensors`. |
238237
| `--trust-remote-code` | Trust remote code when loading the HuggingFace model config. |
239238
| `--component NAME` | Build only one component from a diffusers pipeline (e.g. `--component vae_decoder`). |
240-
| `--text-only` | **Deprecated** alias for `--features text-only`. Export the text backbone of a multimodal checkpoint as a standalone decoder-only LLM. Strips vision/audio routing so the decoder uses `GroupQueryAttention` on GQA-capable EPs (build with `--ep cuda`/`dml`). Currently supported for `gemma4_unified` (`google/gemma-4-12B`). Not compatible with `--config` or `--component`. |
239+
| `--kv-cache-scale-file PATH` | Optional JSON file of calibrated per-layer FP8 KV-cache scales (onnxruntime-genai format). Only used with the `fp8-kv-cache` feature; without it all layers use a unit scale of 1.0. |
241240
| `--kv-cache-scale-file PATH` | Optional JSON file of calibrated per-layer FP8 KV-cache scales (onnxruntime-genai format). Only used with the `fp8-kv-cache` feature; without it all layers use a unit scale of 1.0. |
242241

243242
#### Text-only example

examples/gemma4_12b_text_ort_genai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
5757
The equivalent raw-ONNX (no genai_config) build is::
5858
59-
mobius build --model google/gemma-4-12B --text-only --ep cuda --dtype f16 \
59+
mobius build --model google/gemma-4-12B --features text-only --ep cuda --dtype f16 \
6060
out/gemma4_12b_text_onnx/
6161
"""
6262

src/mobius/__main__.py

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import json
1111
import logging
1212
import os
13-
import sys
1413
from typing import TYPE_CHECKING
1514

1615
import tqdm
@@ -36,9 +35,7 @@
3635

3736
# Rust/cargo-style build features. Each feature name (kebab-case) maps to the
3837
# boolean attribute on the parsed args that it enables. `--features a,b` (or a
39-
# repeated `--features`) is the canonical way to toggle these build modes; the
40-
# legacy per-feature boolean flags remain as deprecated aliases that set the
41-
# same attributes.
38+
# repeated `--features`) is the canonical way to toggle these build modes.
4239
_BUILD_FEATURES: dict[str, str] = {
4340
"static-cache": "static_cache",
4441
"fp8-kv-cache": "fp8_kv_cache",
@@ -53,18 +50,11 @@ def _resolve_build_features(args: argparse.Namespace) -> None:
5350
style), e.g. ``--features fp8-kv-cache,static-cache`` or
5451
``--features fp8-kv-cache --features static-cache``. Each recognised feature
5552
sets its corresponding attribute (``fp8-kv-cache`` -> ``args.fp8_kv_cache``).
56-
57-
The legacy boolean flags (``--static-cache``, ``--text-only``,
58-
``--fp8-kv-cache``) still work but are deprecated: using one prints a notice
59-
and sets the same attribute. Unknown feature names raise ``SystemExit``.
53+
Unknown feature names raise ``SystemExit``.
6054
"""
61-
# Warn when a caller uses a deprecated boolean alias directly.
62-
for feature, dest in _BUILD_FEATURES.items():
63-
if getattr(args, dest, False):
64-
print(
65-
f"Warning: --{feature} is deprecated; use --features {feature} instead.",
66-
file=sys.stderr,
67-
)
55+
for dest in _BUILD_FEATURES.values():
56+
if not hasattr(args, dest):
57+
setattr(args, dest, False)
6858

6959
raw = getattr(args, "features", None) or []
7060
requested: list[str] = []
@@ -184,7 +174,7 @@ def _resolve_static_cache_task(model_type: str) -> ModelTask:
184174
return CausalLMTask(static_cache=True, max_seq_len=args.max_seq_len)
185175

186176
# Fold --features into the boolean build-mode attributes before any
187-
# validation reads them (and warn on deprecated boolean aliases).
177+
# validation reads them.
188178
_resolve_build_features(args)
189179

190180
# Validate --max-seq-len requires --static-cache
@@ -725,17 +715,9 @@ def main(argv: list[str] | None = None) -> None:
725715
"may be repeated). Available: "
726716
+ ", ".join(sorted(_BUILD_FEATURES))
727717
+ ". Example: --features fp8-kv-cache,static-cache. This is the "
728-
"canonical replacement for the individual --static-cache / "
729-
"--text-only / --fp8-kv-cache flags."
718+
"canonical way to enable these build modes."
730719
),
731720
)
732-
build_parser.add_argument(
733-
"--static-cache",
734-
action="store_true",
735-
help="[deprecated: use --features static-cache] "
736-
"Use static KV cache (pre-allocated buffers with TensorScatter). "
737-
"Requires models using DecoderLayer or MoEDecoderLayer.",
738-
)
739721
build_parser.add_argument(
740722
"--max-seq-len",
741723
type=int,
@@ -771,31 +753,6 @@ def main(argv: list[str] | None = None) -> None:
771753
"with --config (local directory), they are copied from that directory."
772754
),
773755
)
774-
build_parser.add_argument(
775-
"--text-only",
776-
dest="text_only",
777-
action="store_true",
778-
help=(
779-
"[deprecated: use --features text-only] "
780-
"Export the text backbone of a multimodal checkpoint as a "
781-
"standalone decoder-only LLM. Strips vision/audio routing so the "
782-
"decoder uses GroupQueryAttention on GQA-capable EPs. Currently "
783-
"supported for gemma4_unified (google/gemma-4-12B). Not compatible "
784-
"with --config or --component (use --model <hf-id>)."
785-
),
786-
)
787-
build_parser.add_argument(
788-
"--fp8-kv-cache",
789-
dest="fp8_kv_cache",
790-
action="store_true",
791-
help=(
792-
"[deprecated: use --features fp8-kv-cache] "
793-
"Store the GroupQueryAttention KV cache as FLOAT8E4M3FN (per-tensor "
794-
"E4M3), halving KV-cache memory at long context. Requires a "
795-
"GQA-capable build (e.g. --execution-provider cuda with --dtype "
796-
"f16/bf16) and an ORT runtime with the FP8 KV-cache kernel (SM89+)."
797-
),
798-
)
799756
build_parser.add_argument(
800757
"--kv-cache-scale-file",
801758
dest="kv_cache_scale_file",

tests/cli_test.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,17 @@ def test_build_missing_model_errors(self):
7878
def test_text_only_with_config_errors(self):
7979
"""--text-only is rejected on the --config (local dir) path."""
8080
with tempfile.TemporaryDirectory() as tmpdir, pytest.raises(SystemExit):
81-
main(["build", "--config", tmpdir, tmpdir, "--text-only", "--no-weights"])
81+
main(
82+
[
83+
"build",
84+
"--config",
85+
tmpdir,
86+
tmpdir,
87+
"--features",
88+
"text-only",
89+
"--no-weights",
90+
]
91+
)
8292

8393
def test_text_only_with_component_errors(self):
8494
"""--text-only is rejected when combined with --component."""
@@ -89,7 +99,8 @@ def test_text_only_with_component_errors(self):
8999
"--model",
90100
"google/gemma-4-12B",
91101
tmpdir,
92-
"--text-only",
102+
"--features",
103+
"text-only",
93104
"--component",
94105
"vision_encoder",
95106
"--no-weights",
@@ -116,7 +127,8 @@ def test_text_only_skips_diffusers_autodetect(self):
116127
"--model",
117128
"some/diffusion-repo",
118129
tmpdir,
119-
"--text-only",
130+
"--features",
131+
"text-only",
120132
"--no-weights",
121133
]
122134
)
@@ -134,7 +146,8 @@ def test_build_static_cache(self):
134146
"Qwen/Qwen2.5-0.5B",
135147
tmpdir,
136148
"--no-weights",
137-
"--static-cache",
149+
"--features",
150+
"static-cache",
138151
]
139152
)
140153
assert os.path.isfile(os.path.join(tmpdir, "model.onnx"))
@@ -269,21 +282,6 @@ def test_features_unknown_errors(self):
269282
]
270283
)
271284

272-
def test_deprecated_static_cache_flag_warns(self, capsys):
273-
"""The legacy --static-cache flag still works but warns."""
274-
with tempfile.TemporaryDirectory() as tmpdir:
275-
main(
276-
[
277-
"build",
278-
"--model",
279-
"Qwen/Qwen2.5-0.5B",
280-
tmpdir,
281-
"--no-weights",
282-
"--static-cache",
283-
]
284-
)
285-
assert "--static-cache is deprecated" in capsys.readouterr().err
286-
287285
def test_max_seq_len_without_static_cache_errors(self):
288286
with tempfile.TemporaryDirectory() as tmpdir, pytest.raises(SystemExit):
289287
main(
@@ -308,7 +306,8 @@ def test_static_cache_with_task_errors(self):
308306
"Qwen/Qwen2.5-0.5B",
309307
tmpdir,
310308
"--no-weights",
311-
"--static-cache",
309+
"--features",
310+
"static-cache",
312311
"--task",
313312
"text-generation",
314313
]
@@ -323,7 +322,8 @@ def test_non_positive_max_seq_len_errors(self):
323322
"Qwen/Qwen2.5-0.5B",
324323
tmpdir,
325324
"--no-weights",
326-
"--static-cache",
325+
"--features",
326+
"static-cache",
327327
"--max-seq-len",
328328
"0",
329329
]
@@ -340,7 +340,8 @@ def test_static_cache_with_max_seq_len(self):
340340
"Qwen/Qwen2.5-0.5B",
341341
tmpdir,
342342
"--no-weights",
343-
"--static-cache",
343+
"--features",
344+
"static-cache",
344345
"--max-seq-len",
345346
str(max_seq_len),
346347
]

0 commit comments

Comments
 (0)