mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4467] [Engine] serve: cvec auto - the "auto" sampling value, per-request threshold, and verdict attribution #5060
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5060
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4467
Author: @jerry78424
Created: 10/28/2026
Status: 🔄 Open
Base:
main← Head:pr/cvec-auto-serve📝 Commits (2)
fcdd2a6engine: cvec auto (cvec=2) - measure the refusal direction at prefill, steer only flagged decodesef6df15serve: cvec auto - the "auto" sampling value, per-request threshold, and verdict attribution📊 Changes
17 files changed (+613 additions, -74 deletions)
View changed files
📝
include/strata/kernels/cvec.hpp(+20 -4)📝
include/strata/prefill/kernels.hpp(+5 -3)📝
metal/src/engine/stubs.cpp(+6 -2)📝
metal/src/engine/stubs_0145.cpp(+1 -1)📝
serve/server.py(+111 -10)➕
serve/test_projection_key.py(+170 -0)📝
serve/test_web_badges.py(+26 -1)📝
serve/web/app.js(+5 -1)📝
src/core/verify.cpp(+2 -2)📝
src/kernels/cuda/cvec.cu(+62 -19)📝
src/kernels/cvec_parity.cpp(+71 -0)📝
src/prefill/kernels.cu(+12 -6)📝
src/prefill/prefill.cpp(+9 -5)📝
src/program/generate.cpp(+90 -5)📝
sycl/src/kernels/cuda/cvec.dp.cpp(+16 -10)📝
sycl/src/prefill/kernels.dp.cpp(+4 -2)📝
sycl/src/program/generate.cpp(+3 -3)📄 Description
Problem and result
The engine (companion PR #4466) accepts
experimental_speed_projection: 2("auto") with a per-request refusal gate and prints its verdict on the control stdout, but the server never read it: the field normalized to bool (on/off) only, and the verdict was invisible per request.Before: bool normalization; no gate field in the request history or the built-in page. After: the request body accepts bool, the string
"auto", or the integer 2, plus an optionalcvec_threshold(forwarded ascvec_thresh=on theGENIline;/settingsand the config file take bool-or-"auto"). The engine'sCVECAUTOverdict twin (generate.cpp:15766, the machine line behind its human log line) is captured off the control stdout and recorded on its own request's history entry: a newgatefield besideprojection,"steer"or"stock",nullfor bool requests and for auto requests an engine never gated (batched, or an engine without the twin; a wholly-cached auto request still gets its line, measured zero, reportedstock). The verdict is echoed to the server's stdout for the live log, and the built-in page marks an auto request that steered. Requests that never ask for auto are untouched; the default path is unchanged.Related discussion
Scope issue: https://github.com/Niko1221/Strata/issues/4465. Engine PR #4466 carries the gate itself; split so each surface is reviewable alone. Merge order: engine first. On an engine without the gate,
cvec=2reads as plain on (undocumented; the old test was!= 0), so auto on an old engine would silently steer everything while the history honestly reportsprojection: "auto", gate: null.Approach
The verdict is captured in the pump from the engine's control stdout (the
CVECAUTOtwin, printed at the prefill→decode seam on the solo path only, like the gate itself); the parser accepts the-infthresh spelling a harness gets from--cvec-threshold -inf(the engine's own log-only default is thelowest()sentinel; both spellings parse). Attribution: the request reads the pump's verdict counter at the start of its fifo turn and takes the newest verdict when the turn ends, so a queued request cannot record another's verdict; the counter survives an engine restart. History stays honest: bool stays bool,"auto"/2 normalize, absent means on (the existing ESP semantics). The built-in Chat's own toggle pins bool (local intent); auto is reachable through the API and settings.Validation
Passed:
python -m pytest serve/test_projection_key.py serve/test_web_badges.py serve/test_monitor.py(branch tipef6df156): 34 passed (20 + 4 + 10) - verdict parser (measure line,-infthresh,nan/infinite/infirejected, the human log line and the batched refusal parse to None), the auto domain, history tri-state, the gate badge states (steered auto renders the green ESP, unsteered the neutral auto);test_monitor.pyas the untouched regression companion.Live matrix (engine 0.1.52 built from nested cb034726, RTX 5090, threshold -0.9;
bench/results/2026-10-28-cvec-auto-acceptance/): auto + harmful → the child log carries the gate line... -> steer; auto + benign →-> stock; a batched auto request →batched -> stock. That build predates this serve PR (no pump capture or historygatefield yet), so those two surfaces rest on the unit tests above and the code, not on this pass.Attribution under load (outcome evaluation, engine 0.1.52 built from the same cvec sources at the pre-split nested 4c671ed0;
bench/results/2026-10-28-cvec-auto-calibration-iq3s/cvec-outcome-qad.manifest.json+cvec-engine-outcome-qad.login that session): 86 auto requests produced 172 gate lines, prefill + answer-room re-gate per request (thinking wrapped up after one token viareasoning_budget_tokens=1); the serve stdout echo (1:1 with each pump capture) carries all 172, and the ordered zip attributed every request, zero no-line verdicts. Two borderline prompts flipped stock→steer at the re-gate, both lines recorded per request (verdict= prefill,regate_verdict= the tail). Serve's newest-verdict-wins attribution is exercised by the unit tests for that rule; the outcome artifact reads the engine log, so the history side of the re-gate events is code-verified, not captured.CI
metal-link(macOS) on this PR: pass.Failed: none observed.
Not run: the re-gate's steer→stock direction (only the acceptance F-1 repro, at thinking budget 256; the outcome battery's two re-gate events were both stock→steer);
--replicas(see Limits); a live wholly-cached or batched auto request with history-gate inspection (the parser side is unit-tested; the engine-side all-zero twin-print is code-traced, not exercised).Limits
Attribution is solo-only (the engine prints verdicts only on the solo path; under
--batchthe gate logsbatched -> stockand the request is served stock,gate: null). A wholly-cached auto request measures nothing and is reportedstock. The re-issue path (ANSWER_ROOM under thinking) re-gates on the thinking tail and the newest verdict wins, so a harmful first pass that steered can have its re-issued decode decoded stock; the outcome evaluation exercised stock→steer, the steer→stock direction only the acceptance F-1 repro.--replicas: the proxy delegates to the current child, but the summedbatchproperty makes every replica request read as batched, so the attribution guard nullsgateunconditionally under--replicas(a wrong verdict is unreachable; the counter split is moot); never exercised.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.