Repository navigation
serve: structured output takes json_object, arrays, anyOf, $ref, integers and numbers, and samples inside the mask - #973
Conversation
…gers and numbers, and samples inside the mask
There was a problem hiding this comment.
Verdict: CLEAN: No proven behavior defect or mechanical quality defect survived review.
Non-blocking
⚠ Measure the added decode allocations: crates/serve/src/constrain/program.rs:1397 adds one head-vector allocation per constrained token, including fixed tokens. allowed:1197 also boxes an iterator per live head at each decision (R39). Reuse the single-head vector's capacity and provide a timed base/head A/B for existing schemas on the contributor's card (R20). Checking this now keeps buffer reuse local to the walker.
Optimization headroom
- E. Less work: crates/serve/src/constrain/program.rs:1223. Repeated string alternatives in
anyOfremain separate heads and each scans the vocabulary. Scan equivalent masks once in the existing pick logic, preserving the heads for transitions. For H identical K-id masks, this removes 4 × K × (H − 1) logical logit bytes read per greedy decision token [derived].
Checked
Duplicates: dryer reports zero candidate pairs. Head::same compares program identity and position, so equivalent masks can remain separate.
Complexity: crapper flags 11 functions. No retained finding rests on complexity alone.
Silent failure: choose_by returns a named NoAllowed error when a drawn id leaves no valid successor.
Tests: the forced-token test checks preservation of the inner forced-id and frame buffers; cloning those buffers would fail its pointer assertions. Rust tests were not executed.
Gates: four dated PIN comments cover retired refusal cases.
Escapes: no C1–C4 pattern applies to the retained items.
Notes
The PR reports gate runs for earlier commits. It supplies no nvidia-smi output or model file path, so GPU evidence is unverified for this head.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
The review is done and the contribution check passed, so I'm merging this. |
구조화 출력이 json_object, 배열, anyOf, $ref, 정수와 숫자를 받고, temperature와 penalty 요청도 마스크 안에서 샘플링하게 했습니다.
What and why
Structured output used to refuse
response_format: {"type": "json_object"}, any schema withitems,anyOf,$ref,$defs, plaininteger,numberornull, and any request that settemperatureabove 0 or a penalty. Clients that send these OpenAI-compatible requests got a 400.This change accepts them.
json_object(alsotext.formaton/v1/responses) builds an arbitrary JSON object grammar in the existing constrain program. The schema subset gainstype: arraywithitems,anyOf, in-schema$ref,integer,numberandnull. Sampled requests apply the request's own sampler (temperature,top_k,top_p,min_p,seed, penalties) to a copy of the logits row with the ids the program forbids set to -inf, so the draw stays inside the mask. Greedy output for the existing subset is unchanged.Release notes: Added: structured output accepts
json_object, arrays,anyOf,$ref, integer and number types, and sampling settings.Code shape
The review reads these first. A box left unticked needs one line of why.
copying it (
AGENTS.md"Common code first",docs/rust-quality.mdR14). Where I found an existing copy, Inamed it below.
(tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
tools/check-comments.sh).PIN(YYYY-MM-DD):and its reason.
cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none": none.All changes are in
crates/serveanddocs/serving.md. The constrain owner (constrain/program.rs,schema.rs,vocab.rs) gains the new grammar parts,$refinlining and the multi-head walk;genloop.rsdraws with the request's sampler;api.rsdrops the temperature and penalty refusal;responses.rsforwardsjson_object.ignore_eosandreasoning_budgetare still refused by name.What I ran
Base
5e743ada812e7377054e4d8a8756b7c466c833ae, head5884ba7981834cae16fbb1f346a92fda2b28d64d. Card: NVIDIA GB10, driver 595.84, CUDA 13.3.1. Model: Qwen3.8-Flash-Next FP4-Local,--ctx-size 16384, one slot.GPU gates, pass, exit code 0:
The other gate-serve test binaries, gate-q38-serve-rules and gate-serve-draft-rules also report
0 failed.Real model:
bloomery-servebuilt withcargo oxide build --arch sm_121a -- -p bloomery-gpu-gates --features glm5next,clef,vision,mimo2,solar2,minimaxm3,flint,gemma-embedding2,hf,checkpoint --release --bin bloomery-serve, then these requests sent to the server. Each of the new requests below is refused with a 400 on base.Responses (all
status=200 valid=True, the response checked against the requested schema):Unit tests:
cargo test -p bloomery-servepasses (393 lib tests);cargo clippy -p bloomery-serve --testsreports no warnings;cargo fmtandtools/check-comments.share clean.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.