Skip to content

feat: --dashboard, a live stats page - #400

Closed
heitke wants to merge 10 commits into
ashhart:mainfrom
heitke:live-dashboard
Closed

heitke wants to merge 10 commits into
ashhart:mainfrom
heitke:live-dashboard

Conversation

@heitke

@heitke heitke commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

This PR was 100% vibe-coded by GLM 5.3 Flash 4bit on my Mac M3 Ultra 256gb. I wanted a dashboard like this so I built one. It seems like others might find it useful as well, so I created this PR. Below is all AI generated:

--dashboard: a live stats page for the Mac server

Closes nothing; proposes a feature for the 0.7.0 milestone.

What it is

tensorfold serve --dashboard starts one sampler thread and serves a self-contained stats page at /dashboard, fed by a JSON snapshot at /stats. No new dependencies, one static HTML file, no build step. The routes 404 unless the flag is set, and the page's own 1 Hz polls stay out of the access log (a poll would otherwise drown the terminal in GET /stats 200 lines).

Why

The terminal live line shows one instant in time; a dashboard shows the shape of a serving session — what the rate did over a reply, how close memory is to its budget, what a failing request looked like. This runs on the same Mac as the server, needs no monitoring stack, and reads only what the scheduler already computes: the sampler never takes engine state or locks, so a dashboard tab costs a decode of a few hundred bytes, never a stall.

The page

  • One dial, two modes. Prefill and decode share the same arc — the server never does both at once, so the arc colors by whichever mode is live (blue log-scale sweep while prefilling, banded linear scale while decoding). The numbers are the same ones the terminal's live line prints.
  • Prefill queue. While a prompt fills: tokens left across the filling prompts and an ETA, computed from the completed-chunks average rate (the steady number, not the 2-second burst the live line shows — that burst reads as the dial "falling and restarting" between chunks).
  • Decode-rate history. A strip chart of the last 5 minutes, drawn from the timestamped samples the 5-minute min/mean/max statistic already records. Idle seconds leave gaps, so the x-axis follows time, not the point index.
  • Memory tile. Active + cache against the budget, with peak, where the platform reports it.
  • Lifetime totals. Requests, prompt and generated tokens, mean TTFT, and cumulative MTP draft acceptance — the same counters /metrics publishes, from finished requests.
  • Recent requests. The last 32 finished requests with per-request tok/s, prefill/decode split, cache hit/miss, and rounds; timestamps are Unix seconds so the page's "ago" labels stay right across clock skew.
  • Speculative state. Live MTP acceptance per stream, alongside the cumulative figure.

Dark and light follow the OS; the layout folds to a single column on a narrow window.

Design constraints kept

  • Read-only. The page never changes inference settings; there is nothing to click.
  • Sampler off by default. Nothing starts without --dashboard, and TENSORFOLD_NO_LIVE still silences the terminal line.
  • A raising page never stops a serve. Every sampler tick and record call is guarded; failures degrade to a stale banner in the browser, not a 500 in a request.
  • No engine state taken. The sampler reads scheduler bookkeeping (meters, _fills lengths, job stamps) between rounds, the same contract context_snapshot() documents.
  • The CUDA server answers /dashboard with a plain "not wired yet" message rather than an empty page; its metrics route is untouched.

Tests

tests/test_stats_dashboard.py covers the rolling rate's min/max/mean and window eviction, the prefill average ring, the snapshot's tiles against the scheduler's own accounting, both routes' 404-without-the-flag behavior, the access-log quieting, and the request-history rows. Full suite on this branch: 4522 passed, 929 skipped (the same MLX/CUDA-gated skips as main).

Notes for reviewers

  • The sampler hands itself to the scheduler through scheduler.stats (the same path the live line uses); fill_progress is a read over Filling.left, no locks beyond the store's own.
  • connections.filling is bool(scheduler.filling) — on the 0.6 scheduler filling is a list, and is not None would always be true.
  • Request rows stamp time.time() for the page's relative labels but keep durations on perf_counter() readings; the two clocks never mix in one subtraction.

Andy and others added 9 commits September 29, 2026 16:25
tensorfold serve --dashboard samples the numbers the live line already
computes once a second and serves them at /stats, with the page at
/dashboard: the decode/prefill dial, context used and window, cached
tokens, MLX memory against the budget, the 5-minute decode min/max,
and the average prefill rate. One static file, one sampler thread, no
new dependencies; the routes 404 without the flag. The CUDA server
says so plainly rather than serving an empty page.
The memory tile gains the context tile's bar, scaled against the
process budget. A new tile shows the live streams' speculative state
(drafts accepted of drafted). Below the tiles, the page lists finished
requests newest first: total/prefill/decode seconds, the request's own
tok/s plus the burst range its last rounds reached, prompt and reply
tokens, cache hit or miss, rounds, and per-request acceptance — fed by
the scheduler's retire path, 32 kept.
cli.py: upstream moved the serve parser into cli_args.build_parser; the
--dashboard flag lives there now and the collector hooks ride on the new
function layout. prompt_fill.py: keep upstream's fed/left/passed fill
accounting and record the same fed count into the dashboard collector.
context_snapshot and stream_spec_snapshot walked the single _filling job
the 0.4.0 scheduler kept; fills are a PromptFill._fills list now, whose
jobs the upstream Scheduler.filling property already returns.
The page loaded fine from a repo checkout (tests run against src/) but a
pip install served 404s: package-data had no entry for tensorfold.server.
The 5-minute RollingRate history the sampler already records now renders
as a strip chart under the dial: a cyan line over the sparse timestamped
points (idle seconds leave gaps, so x follows the timestamp), a sliding
5-minute window, a dashed peak guide and a fill under the line. The
section hides until the first poll delivers points.
- 'totals': lifetime prompt/generated tokens, request count, mean TTFT and
  cumulative draft acceptance from the finished-request metrics /metrics
  publishes, shown as a strip under the tiles (hidden until one finishes)
- 'kv_pool': the fullest live stream's cache occupancy against the context
  window — the TUI's KV peak pool — under the context bar
@heitke heitke changed the title feat: --dashboard, a live stats page for the Mac server feat: --dashboard, a live stats page Oct 4, 2026
ashhart added a commit that referenced this pull request Oct 6, 2026
…400)

With --dashboard (off by default) the native server serves a small
self-contained page at /dashboard and the JSON snapshot it polls at /stats:
running and waiting requests, decode and prefill rates, tokens in flight and
finished, decode rounds, the draft totals, and memory where the engine reports
it. Without the flag both paths are unknown routes (404). With API keys set,
both need a key like the rest of the API, so the page suits keyless, usually
local, servers. Successful /stats reads stay out of the access log, so the
page's once-a-second polls do not flood it. The Python CLI hands the flag to
the native engine only.

Tests check the page's fields and the /stats snapshot's keys, with memory left
out when unknown.

Co-authored-by: heitke <[email protected]>
@ashhart

ashhart commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Thank you, @heitke. A first version landed in the Zig engine as 96dc312, with your credit. tensorfold serve --dashboard serves /dashboard and a /stats snapshot, both 404 without the flag, and the page's own once-a-second polls stay out of the request log.

The Zig page is smaller than yours so far, with live cards for running and waiting requests, tokens in flight and finished, decode and prefill rates, rounds, and peak memory where the engine reports it. Your decode-rate history, recent-requests table and prefill ETA aren't carried yet.

The Python engine is frozen (#286), so this PR closes with that. Thanks for building the page you wanted and sharing it.

@ashhart ashhart closed this Oct 6, 2026
@ashhart ashhart mentioned this pull request Oct 6, 2026
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…shhart#400)

With --dashboard (off by default) the native server serves a small
self-contained page at /dashboard and the JSON snapshot it polls at /stats:
running and waiting requests, decode and prefill rates, tokens in flight and
finished, decode rounds, the draft totals, and memory where the engine reports
it. Without the flag both paths are unknown routes (404). With API keys set,
both need a key like the rest of the API, so the page suits keyless, usually
local, servers. Successful /stats reads stay out of the access log, so the
page's once-a-second polls do not flood it. The Python CLI hands the flag to
the native engine only.

Tests check the page's fields and the /stats snapshot's keys, with memory left
out when unknown.

Co-authored-by: heitke <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants