Skip to content

serve: --config FILE reads a start's flags from one JSON object, under the command line's - #982

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-config-file
Oct 29, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-config-file

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

bloomery-serve --config FILE로 서버 설정을 JSON 파일 하나에서 읽을 수 있게 했고, 명령줄이 파일보다 우선합니다.

What and why

A server start with many flags had no way to be saved and reused. bloomery-serve --config FILE reads a start's flags from one JSON object. A key is a flag name without its dashes ("ctx-size": 65536 is --ctx-size 65536), a value is a string or a number, a switch is true, and a flag that may repeat takes a list. The command line wins over the file, the file wins over the LLAMA_ARG_* variables, and those win over the BLOOMERY_* levers and the seat defaults. At start, each entry prints one line on stderr saying how it was read, or that the command line replaced it. API key values are never printed.

The file's flags go through the same parsing and preflight as command-line flags, so a key no seat takes is refused by the seat's own unknown argument error before any fetch or load. A file that is not a JSON object, a JSON syntax error, a key named twice, a key written with dashes, an action key (plan, levers, help, version, list-devices, records-schema, recommend, dry-run, json, config), a false, null, object or empty-list value, a value given to a switch, true given to a flag that needs a value, and a second --config all exit 64 (usage) with a message that names the key and the file, before any model is read. docs/serving.md has a new "The settings file" section and README.md one sentence.

Release notes: Added: bloomery-serve --config FILE reads the start's flags from a JSON file; the command line still wins.

Code shape

The review reads these first. A box left unticked needs one line of why.

  • No second copy. Logic two models (or two call sites) share has one common owner; I lifted it there instead of
    copying it (AGENTS.md "Common code first", docs/rust-quality.md R14). Where I found an existing copy, I
    named it below.
  • Model code holds only architecture facts. A model's own files carry only what its architecture forces
    (tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
  • Dead code is gone. Nothing I made unused is left behind (functions, flags, gate clauses, docs).
  • No silent failure. Undefined input is a named error or panic, never a defined-looking output.
  • Comments state what is true now. No dates, issue numbers or how a bug was found (tools/check-comments.sh).
  • No relaxed gate. No band, tolerance or lint moved to make a check pass; a re-pin carries PIN(YYYY-MM-DD):
    and its reason.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line), or "none": the duplicate-key check in crates/gpu-gates/src/serve_config.rs:176 uses the same serde visitor approach as crates/serve/src/api.rs:1708. That one is a private function that reads only the logit_bias object of a request body, while this one reads the top-level keys of the file, so they do not share a body.

What I ran

Tested head aa1963c89b3c790b9c74f33bc2baf521ca1c8a87 on base 7163db37ff5c25f41870df1692bce5777536f22e, on a DGX Spark (NVIDIA GB10, driver 595.84) with the Qwen3.8 FP4-Local checkpoint (nvidia/Qwen3.8-Flash-Next-FP4-Local, revision b9ce18a6887e18c089fdea8509a33e63429a3300). The duplicate-key check was added after this run and ran on its own at head 74398a840f73cd7031a150959b95e9b4c1d251b2.

Unit tests (serve_config::, llama_launch::, llama_place::, with --features deepseek41,gemma-embedding2,hf --lib):

test result: ok. 44 passed; 0 failed; 0 ignored; 0 measured; 260 filtered out; finished in 0.00s

Preflight tests (--test serve_preflight), including a_config_file_key_no_seat_takes_is_refused_before_the_fetch:

test result: ok. 47 passed; 0 failed; 3 ignored; 0 measured; 0 filtered out; finished in 0.39s

A key no seat takes, with {"model-file": "<model folder>", "ctx-size": 65536, "ctxx": 1} as the file. It exits 64 in 0 seconds, before the model loads:

bloomery-serve: <dir>/unknown.json: ctxx is read as --ctxx 1
bloomery-serve: no seat takes these arguments, each refusing them as follows (--model names the seat):
  --model qwen38: unknown argument "--ctxx": usage: bloomery-serve-qwen38 [--host H] [--port P]
== unknown key rc=64 seconds=0

The command line wins. The file sets ctx-size to 65536; with --ctx-size 32768 --plan added:

bloomery-serve: <dir>/served.json: ctx-size is set, and the command line's --ctx-size replaces it
parallel rule=slots slots=2 slot_ctx=16384 total=32768 from=flag pass=one

The file alone (--plan):

parallel rule=slots slots=2 slot_ctx=32768 total=65536 from=flag pass=one

Serving. --config served.json and -m <model folder> --ctx-size 65536 --parallel 2 --port 18094 --alias q38-config both came up (== serve file up=1, == serve flags up=1). The two /props replies differ only in engine.args, the command line itself; model_alias (q38-config), total_slots (2), n_ctx, default_generation_settings, model_path and build_info are the same.

A key named twice, with {"model-file": "<model folder>", "ctx-size": 65536, "ctx-size": 32768} as the file. It exits 64 before the load:

bloomery-serve: --config <dir>/twice.json: ctx-size is named twice at line 1 column 141
{"schema":"bloomery.event/1","event":"error","exit":64,"code":"usage", ...}

cargo test -p gpu-gates --lib serve_config:: on that head: test result: ok. 2 passed; 0 failed.

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

…r the command line's

Each key is a flag's name without its dashes and its value the flag's: a string or a number, true
for a switch, a list for a flag given more than once. The file's flags go in front of the command
line's, and a flag the command line gives in any spelling replaces the file's entry for it, as does
a flag that sets the same thing another way (the model's path and repo, the embedding model's, a
projector and its off switch, the routed experts' place, --place and the flags that name cards), so
the order is the command line, the file, llama-server's variables, the levers and the default. One
line on stderr says what each entry was read as or which flag replaced it, never an API key's value.
A file that is no JSON object, a key named twice, written with its dashes or naming an action, and a
value of the wrong type are refused by name before the model is read; a key no seat takes is refused
by the seat.
@github-actions github-actions Bot added documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app needs-gpu Changes code a card must check, and carries no gate run on a card serve The HTTP server: crates/serve tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 29, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: CLEAN: No must-fix defect was found in the changed startup and JSON validation paths.

Non-blocking

⚠ Pin malformed-file refusals to exit 64: bloomery_serve.rs:694. The current branch correctly uses Code::Usage. Changing it to Code::Refused would leave all six new tests green: the executable tests use valid JSON, and the unit tests call joined directly.
Pin this public exit contract now. Insert before cleanup at serve_preflight.rs:468:

std::fs::write(&path, "{").unwrap();
checked_refusal_as(
    "config-syntax",
    &["--config", path.to_str().unwrap()],
    &[],
    "--config",
    Code::Usage,
);

Checked

Duplicates: 20 new or exposed items checked; no actionable duplicate. Keys reuses the existing visitor. The existing json_type helper has different boolean/type wording. Dryer reported zero pairs; gpu-gates was excluded and checked manually.
Complexity: joined is new at 22, combining file decoding/validation and override merging/notes; those are its split boundaries. run rose 66→68 through one startup error branch.
Silent failure: three absence/skip paths followed: file variant detection, CLI variant detection, and overridden entries. Invalid model values reach named parser errors; overridden entries are validated and reported.
Tests: static mutation check of all six new tests. Keeping replaced entries (serve_config.rs:105), dropping duplicate/type/action checks (:74/:133/:151), or dropping source equivalence (:92) makes assertions fail. Skipping expansion (bloomery_serve.rs:692) fails the process tests; removing source groups (serve_config.rs:36–38) fails their expected downstream errors. The exit-class mutant passes, as above. Tests were not executed.
Gates: no existing gate, tolerance or pin removed or relaxed; the recipe adds the configuration tests.
Escape catalog: C1–C4 checked; none match. The change adds no decode, prefill or kernel work.

Notes

The PR body has no FAIL-first output, nvidia-smi line, or just gate-* command output. Its reported test runs do not establish GPU evidence.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/bloomery_serve.rs, crates/gpu-gates/src/lib.rs, crates/gpu-gates/src/llama_launch.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit 6084611 into midagedev:main Oct 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app needs-gpu Changes code a card must check, and carries no gate run on a card serve The HTTP server: crates/serve tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant