mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4636] [GUI] Monitor: KV context ring with a legend lamp that follows the Model-state badges #5124
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#5124
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/4636
Author: @thisisspartan
Created: 10/29/2026
Status: 🔄 Open
Base:
main← Head:feat/kv-monitor-full📝 Commits (5)
f41400eMonitor: KV context donut with a state legend lamp; live.reused reports the resumed prefix246ab4ewebtest: drive the Context ring lamp, kvTokens geometry and a chronological /metrics stream through the served page6f6f592Monitor UI: keep only one-line why-comments in the KV ring code; add legend tone threshold cases (85% warn, 84.9% none, 90% warn) to the browser test0fa4cd1Monitor UI: drop the unmeasured AA-readable claim from the legend dim-row commentcb62a6dMonitor: scope the Context ring to the serving engine's telemetry📊 Changes
10 files changed (+569 additions, -26 deletions)
View changed files
📝
serve/replicas.py(+29 -2)📝
serve/server.py(+14 -0)📝
serve/split.py(+7 -1)📝
serve/test_replicas.py(+48 -0)📝
serve/test_server.py(+107 -0)📝
serve/test_split.py(+20 -0)📝
serve/web/app.css(+35 -6)📝
serve/web/app.js(+64 -10)📝
serve/web/index.html(+22 -7)📝
tools/webtest/browser_test.mjs(+223 -0)📄 Description
Problem and result
While a request runs, the Monitor's Context card shows one number -- used / window. Nothing about a
prompt that reuses a cached prefix is visible during the request: how much of the prompt was served
from cache, how many tokens are being read now, how much was generated, and how much headroom is
left. Reuse appears only after the request finishes, in the Reused column.
After this change the Context card is a four-arc ring -- Cached (prefix), Reading (prefill),
Generating (decode), Free -- whose legend rows carry the token counts, plus a legend lamp: exactly
one legend row is lit. The lamp follows the effective state key used by
renderMonitor: when nolocal load/unload operation is active and
live.queued > 0the key isqueued, otherwiselive.state; the key mapsreadingto Prefill,generatingto Decode, and every other value(including
queued) to Free. The Cached legend row is never selected. The center keeps the exactusage figure and percent; a warn tone starts at 85 % of the window and the danger tone applies only
on a real overflow against a known window. The cached arc is live during the request because
/metricsnow carriesreusedfor the running request (additivelive.reusedline; previouslythat counter existed only in finished-request records).
The four ring numbers are request-scoped and must not mix one request's telemetry with another's. A
review of the first head found three places where they could: the replica progress/rate fell back to
the first replica reporting a value even after that request had finished, the split-serve hand-over
briefly exposed the decode engine's stale last request, and the idle Cached arc was drawn from the
last finished record without checking whether the engine had restarted since (after a restart the KV
cache is gone). The final head closes these:
serve/replicas.pyreadsprogress/prefill_tok_s_meanonly from a replica with a request inflight, and reports
genas None on the status thread instead of replica 0's.serve/split.pykeepscuron the prefill engine through the decode engine's session restore.serve/server.pyparsesRESUME nso a batch admission reports its real reused count, and marksthe engine generation on
/metricsand on history records.serve/web/app.jsclears the idle Context arc when the record's generation predates the engine's.Scope
The ring, the legend lamp, the live
reusedfield, and the telemetry-scoping correction -- nothingelse. The in-flight request row, the speed card and the
mtp_accdraft-acceptance metric are out ofscope; if they are wanted they will be proposed separately after maintainer feedback. The diff is 10
files, +569/-26 against
main, all inserve/andtools/webtest/. Existing behavior is untouched:the native basement bars, the request table and every other card stay as they were.
Related discussion
This narrows #4636 to the items above. The earlier wide draft of this branch (head
a2610a1d45c2d71e8a73dc752047738cfa7b2480) is marked Superseded in my 2026-10-31 comment on this PR.
#4297 proposed this four-segment context donut with percent and token counts; it has had no
maintainer response yet (open, 0 comments). The telemetry-scoping correction addresses a self-review
finding and needs no separate issue. Full raw validation logs for the first head, the complete run
table and the red-demo runs are in the comment
https://github.com/Niko1221/Strata/pull/4636#issuecomment-6587766382
Approach
All arcs draw from data the engine already produces:
prompt_tokens,prompt_read,generated,and the request's
reused(the same source as the Reused column).serve/server.pyadds oneadditive
reusedfield to the live request entry, and both the live entry and finished records gaina
genfield carrying the engine process generation. Attribution in the normal case follows theactive request: the value is the prefix-cache counter of the engine currently serving it -- with a
single engine holding one request in flight, that is the request whose state is displayed; under
split serve,
serve/split.pyreports it fromcur, the prefill side during prefill and the decodeside during decode, and
curstays on the prefill side through the decode engine's session restore.With several concurrent replicas the
/metricshandler runs without a request-local view, andserve/replicas.pyreads the running counters only from a replica with a request in flight, so afinished replica's stale value can no longer leak into the ring; the value still belongs to whichever
in-flight replica is read first, not necessarily to the request whose state is displayed -- Limits
states this caveat. The batch per-slot and split-serve decode-side attributions remain
runtime-unvalidated. The ring scales those four numbers to
max_context; when used exceeds thewindow the arcs scale down so the ring still represents the proportions, and the percent goes to the
danger tone. The idle Cached arc uses the last finished record only while its
genequals theengine's current
gen-- after a restart the record is older and the ring stays empty rather thanshowing a cache that no longer exists. The lamp follows
on, the same local value the card uses tolight its state badges in the same render pass. No new colors: arc colors are existing kit tokens, so
the ring follows the theme automatically. Existing test files gain additions only --
serve/test_server.py,serve/test_replicas.py,serve/test_split.pyandtools/webtest/browser_test.mjs;git diff upstream/mainremoves zero lines from them; #4297expected the existing test files to stay untouched, this update does not meet that expectation.
Validation
Tested at
cb62a6d6a2on basec62d5e3a; Ubuntu 24.04.4 LTS,Python 3.12.3, Node v22.22.3. Every command below exists in the repo.
Passed
node --check serve/web/app.jsandnode --check tools/webtest/browser_test.mjs-- clean.python3 -m unittest serve.test_monitor serve.test_replicas serve.test_split-- Ran 65, OK.python3 -m unittest serve.test_server-- Ran 363, OK.python3 -m unittest $(ls serve/test_*.py | sed 's|/|.|g; s|\.py$||' | tr '\n' ' ')-- Ran 1308, OK (skipped=28); the same command on the unmodified base
c62d5e3aran 1303, OK(skipped=28) -- 5 added tests, no other failures.
python3 -m unittest serve.test_replicas.ReusedRouting.test_progress_is_read_from_the_replica_in_flight serve.test_replicas.ReusedRouting.test_prefill_rate_is_read_from_the_replica_in_flight serve.test_server.ControlLineReading.test_resume_line_sets_reused serve.test_server.EngineGenerationMarker.test_history_and_engine_carry_the_generation serve.test_split.Handover.test_cur_stays_on_the_prefill_engine_during_the_restore-- Ran 5, OK.node serve/test_web_history.js,node serve/test_web_i18n.js,node serve/test_web_math.js,node serve/test_web_preview.js-- 34 ok, 0 fail.cb62a6d6, the submitted revision:titlepass,Linux / runtime requirements onlypass (8 m 22 s).Failed
None observed.
Not run
node tools/webtest/browser_test.mjs(documented in that file's header;WEBTEST_MODULESandCHROME_BINpoint at the local puppeteer-core and Chromium) -- thisenvironment has no Chromium/Chrome and no puppeteer-core, so it could not run on
cb62a6d6. Thering-geometry, lamp-matrix and chronological-stream cases were validated 3/3 at the previous head
0fa4cd12(raw output in the comment linked above); this head changes none of that code except oneadded idle edge case, which is source-level only and not browser-run here.
/metricsonly; live behavior on a running engine is not verified, including multi-replica
reusedattribution under concurrent load and batch per-slot attribution.
Windows-only skips, none touched by this diff).
serve/(Python) andtools/webtest/(JavaScript) only, no backend C++ files.
Limits
to the request whose state is displayed. The current fallback selects the first in-flight replica
reporting a non-zero value. Per-request DONE accounting is separate and unaffected. Batch per-slot
attribution and split-serve decode-side reporting have not been validated.
reusedshown during a request comes from the engine's prefix-cache accounting; on a resumedsession after a restart it reports the restored prefix.
last state. The center percent is the exact usage figure and is not capped: on overflow it can
read above 100 % (the previous gauge capped at 100 %).
onvalue the state badges use in the same render pass, so Freeis lit whenever Queued is lit -- also while a request is reading or generating (the queue outranks
the state badge).
getComputedStyle, WCAG 1.4.11ratio against the measured Context-card background). Arcs below the 3:1 graphical-object
threshold: light theme -- decode 2.54:1, Cached 1.27:1, Free 1.00:1; dark theme -- Cached 1.31:1,
Free 1.00:1. Every arc is additionally identified by its legend row and token count.
0fa4cd12).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.