mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2466] [CLOSED] engine+serve: the confidence monitor (STRATA_CONFIDENCE=1, measurement only) #4054
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#4054
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/2466
Author: @MrKop-git
Created: 10/14/2026
Status: ❌ Closed
Base:
main← Head:pr/confidence-monitor📝 Commits (1)
7b1c08cengine+serve: the confidence monitor (STRATA_CONFIDENCE=1, measurement only) - ActKV's token confidence, trend slope and a /metrics summary📊 Changes
9 files changed (+341 additions, -2 deletions)
View changed files
📝
CMakeLists.txt(+3 -0)📝
docs/DETAILS.md(+10 -0)➕
include/strata/core/confidence.hpp(+109 -0)📝
include/strata/core/verify.hpp(+5 -0)📝
serve/server.py(+28 -1)📝
serve/test_server.py(+51 -1)➕
src/core/confidence_test.cpp(+82 -0)📝
src/core/verify.cpp(+30 -0)📝
src/program/generate.cpp(+23 -0)📄 Description
Summary
An online number for "is the model confident right now" - ActKV's confidence signal (arXiv:2609.31395, section 6), which its evaluation used to detect an insufficient KV budget from the model's own behaviour:
T= the negative mean log-probability of the top 20 predicted tokens (a higherTis a sharper distribution).Tand ActKV's trend slopealpha(sliding min-pool w=64 s=8, bottom 10% kept, first-order fit; negative means confidence is falling). The engine emitsCONF <tokens> <mean> <slope>just before the request'sDONE; the server attaches it to the request row andGET /metricscarries a"confidence"summary (count, mean, last mean, last slope).Why it belongs in the engine: it is the signal for comparing lossy settings the numbers cannot -
--kv q4_0againstint8, a tight--kv-resident- and later for budget feedback. The constants are ActKV's evaluation values; nothing here claims they are right for Strata, and no default changes.What it changes and what it leaves alone
STRATA_CONFIDENCE=1in the environment turns it on. Without the flag nothing runs: no copies, no line changes, every answer unchanged. The flag copies the head's logits from the GPU once per window (theSTRATA_LOGPOSpattern), so it slows the decode - likeSTRATA_DECODE_TIMING, for comparing, not timing. No Metal path (it says so and turns itself off there).How it was checked
src/core/confidence_test.cpp(CPU): the math on hand-worked rows (a flat row givesT = log V, a peaked row the exact value), the pooling, and the time ordering the trend fit needs - that last one caught a bug in my first cut (sorting the bottom set destroyed the trend).serve/test_server.py(ConfidenceMonitor): theCONF-before-DONEpairing, a badCONFline refusing to poisonDONE, the row fields and the summary throughGET /metrics. The full serve suite passes: 787 tests, 11 skipped.--serve, twoGENs in one session,STRATA_CONFIDENCE=1): a 128-token repeating prompt reportsCONF 7 5.7530 0.000000, a scattered-id promptCONF 1 4.7600 0.000000- the metric moves the way ActKV's signal should.slopeis 0 for requests shorter than one pool window (pinned by the test too).Not tested
HIP (no toolchain here) and SYCL (separate engine tree). Multi-window trend behaviour on a long request (the live run's requests are short - the slope path is exercised in the unit test, not on hardware). Any threshold for "confidence is too low" - this PR is the measurement, not the alarm.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.