改动 / #2532

#2532 feat(setup): add --engine-args to pass extra engine flags to the run config

open · @hlo-world · 0 评论 · 去 GitHub 看

Setup & installMulti-GPUModels & quants

说明

## Motivation

setup.sh already exposes some of the engine's flags as its own options (--context, --kv, --vram-reserve-mib, --parallel, ...), but the engine has far more levers than setup has options: the MTP verify depth (--spec) and the prefill chunk size (--prefill), for example, have no setup-side switch. A user who wants them has to hand-edit the generated run config - and a later setup run can rewrite that edit out from under them.

This PR adds one generic switch instead of one option per engine flag: `--engine-args`, a shell-quoted string of extra engine arguments appended to the model's engine arguments, in both install paths (own-path families and ready-made packs).

## How it works

- `--engine-args` takes a shell-quoted string, e.g. `--engine-args '--prefill 1024 --spec 3'`. Parsed with shlex, so quotes around individual values work.
- Replace-not-duplicate: a same-named flag setup already wrote as a flag value pair is dropped before the extras are appended, so `--engine-args --prefill 1024` overrides setup's `--prefill` instead of leaving two occurrences. The engine takes the last occurrence of a flag either way. A two-value flag (such as `--control-vector-layer-range`) is matched by its value count, so it is replaced whole.
- The pre-v0.1.13 config migration (a `--prefill 2048` becomes `auto`) skips a `--prefill` named in the extras: that value is the user's own, not a legacy default.
- After a calibration runs, the saved extras are re-merged on top of it: calibration resets every flag in tools/calibrate.py DEFAULTS, and a user-chosen value would otherwise be moved or dropped.
- Persistence: the raw string is saved in the run config as `engine_args_extra` (added to SETUP_KEYS), so re-running setup keeps the extras without re-passing them; passing the flag again overrides the saved value. `--engine-args ''` clears them.
- Verification: unit tests for the merge (append, replace, two-value arity, boolean flags) and the calibration re-apply, plus an end-to-end `--engine-args` run through `install_own_path` in tools/test_setup_qwen36.py.

## Usage

```
./setup.sh --setup --family qwen36 --model UD-Q4_K_XL --engine-args '--prefill 1024 --spec 3 --ple-io ram'
```

The generated run config's `args` ends with the extras, and a later `./setup.sh` run for the same model keeps them.

---

**Review response** (second revision): the three reported issues are fixed - the test Namespace gains `engine_args` (plus end-to-end and unit coverage for the option), the merge matches same-named flags by their value count so a two-value flag is replaced whole instead of leaving a stray token, and the saved extras are re-merged right after each `CAL.apply` so a user-chosen value stays on top of the calibration. tools/test_setup_qwen36.py passes (21 tests), as does the rest of the setup/calibrate suites.

本站相关内容

相关页面的快捷入口。