Repository navigation
Give every subcommand the same runtime flags - #1368
Merged
Merged
Conversation
`serve` answered the same four questions as `generate`, `run` and `transcribe` -- which backend, which device, how much VRAM, how much host RAM -- and answered them in a different vocabulary. It had no `--backend` and no `--device`; instead it inferred the backend from `--native-device`, a name that existed on no other subcommand and was therefore undiscoverable from any of their help output. It also took the model only as `--model` while every other subcommand takes it positionally. The practical cost is that a command line learned from one subcommand is rejected by another. `onnx-genai serve MODEL --backend native --device cuda:6` -- the obvious extrapolation from `run` -- failed twice in a row, once on the positional model and once on `--backend`, with clap's usage text listing neither. The flags now live once, in `onnx-genai-server::runtime_args`, and are flattened into all four subcommands. That crate is the lowest layer both the unified CLI and the standalone server binary already depend on, and it already carries clap with the `env` feature. A flag added there appears everywhere with the same name, grammar and help text, so the surfaces cannot drift apart again. Behaviour changes that follow from unifying, each covered by a test: - `serve` accepts the model positionally, sharing the model-source arg group so giving it twice is refused while parsing rather than after the process has started. - Naming a `--device` implies the native backend on every subcommand. `serve` already worked this way via `--native-device`; previously `generate --device cuda:0` parsed, ran on ORT, and ignored the device. - `--vram-limit` and the rest gain the env fallbacks `serve` had. - `--model-id` alongside `--models-dir`/`--models-config` is now an error instead of being silently ignored, which hid typo'd invocations. `--native-device` keeps working and is hidden from help, so existing service units are unaffected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0190e2eb-abe4-451f-b36d-44a035a99b7e
The interactive-session test asserted a `--device cuda:3` survives into the engine config, but the flag is only applied under `native-backend`: without the native decoder compiled in there is nothing that could honor a device, so the config keeps `None` and the test failed on a default build. Assert the backend unconditionally, since that part holds either way, and the device only where a device means something. Also drop an empty test that was left behind as a placeholder; an empty body asserts nothing while reading in output as a passing case. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0190e2eb-abe4-451f-b36d-44a035a99b7e
🔴 Benchmark Regression DetectedComparison of criterion micro-benchmarks: PR head vs merge-base, measured on the same runner in the same job (base first → PR second).
Visual flags: Host infoWhat this cannot catch
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
serveanswers the same four questions asgenerate,runandtranscribe--which backend, which device, how much VRAM, how much host RAM -- in a different
vocabulary. Before this change:
--backend--device--native-device)--host-ram-limit--cpu-cores--modelonly)So a command line learned from one subcommand is rejected by another.
onnx-genai serve MODEL --backend native --device cuda:6-- the obviousextrapolation from
run-- fails twice in a row, once on the positional modeland once on
--backend, and clap's usage text lists neither. The flag thatdoes work,
--native-device, appears in no other subcommand's help, so thereis nowhere to discover it from.
The change
The flags now live once, in
onnx-genai-server::runtime_args, and areflattened into all four subcommands. That crate is the lowest layer both the
unified CLI and the standalone server binary already depend on, and it already
carries clap with the
envfeature. A flag added there appears everywhere withthe same name, grammar and help text, so the surfaces cannot drift apart again.
Duplicated definitions removed along the way:
EngineArgs,CpuArgs, thedevice enum, and the
--backend,--deviceand memory-limit parsers eachexisted twice, and
parse_native_devicehad two implementations that disagreedabout whether
autoandgpuwere valid.Behaviour changes
Each has a test:
serveaccepts the model positionally. Both spellings share the model-sourcearg group, so giving it twice is refused while parsing rather than after the
process has started.
--deviceimplies the native backend on every subcommand.servealready worked this way through
--native-device; previouslygenerate --device cuda:0parsed, ran on ORT and ignored the device.--vram-limitand friends gain the env fallbacksservealready had.--model-idalongside--models-dir/--models-configis an error instead ofbeing silently ignored, which hid typo'd invocations.
--native-devicekeeps working and is hidden from help, so existing serviceunits are unaffected.
--devicewins if both are given.Verification
cargo test -p onnx-genai-server --lib --features native-backend— 16 testsacross
cli::andruntime_args::, all passing; full lib 237 passed.cargo test -p onnx-genai-cli --lib --features native-cuda— 118 passed.cargo fmt --all --checkandcargo clippyclean.onnx-genai serve ~/models/... --backend native --device cuda:6 --addr 127.0.0.1:18082loads and serves a chat completion, which is the invocation that failed before.