Skip to content

Dashboard: prefill queue progress and a working Memory tile - #738

Merged
ashhart merged 10 commits into
ashhart:mainfrom
heitke:dashboard-memory-pr
Oct 16, 2026
Merged

ashhart merged 10 commits into
ashhart:mainfrom
heitke:dashboard-memory-pr

Conversation

@heitke

@heitke heitke commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Dashboard: prefill queue progress and a working Memory tile

Two dashboard enhancements, both server-side data + the existing page, plus the
review repairs: lifetime-safe fill totals, honest memory semantics, a robust
ETA, landed-progress reporting on Nemotron, and a fill marker that cannot
collide.

1. Prefill queue: tokens left and ETA

Status gains optional fill_prompt_tokens and fill_tokens_left; a stream's
atomic fill_at counts the prompt tokens its pass has landed; the lane host's
status read sums them over the admitted jobs still prefilling, and /stats
carries the pair only while a fill runs — with fill_run, a marker that
changes whenever the filling set does (a prompt starts, ends, is cancelled or
requeued). The marker hashes each filling job's request id and admission
sequence as separate Wyhash inputs (XOR of the raw values collides: request id
2 at admission 0 and id 3 at admission 1 read alike on equal-length prompts),
and stays within 53 bits so the JSON number reaches the page's JavaScript
exactly. The page resets its drain samples on a fill_run change (and when
left rises, a fill restarted), so one prompt's drain is never mixed with
another's. The tile's label says the queue drains, because the aggregate of
several lanes' remaining work estimates that, not the wait to a first token.

2. Memory tile shows real numbers on Mac

The lane host's memoryFn returns null unless the family host wires a
MemorySource, and only the CUDA host did — so /stats carried an empty
memory object on a Mac and the dashboard's Memory tile fell back to a dash.
Mac family hosts now share cache_fit.hostMemory: the process's physical
footprint (rusage_info_v4) as active, the footprint's session high-water
mark as the measured peak, and the configured load limit as Memory.limit
— a budget, never folded into a measured field. peak is the mark since the
process started or the last /health?reset_peak=1: a reset stores the
footprint now (replacing the old mark), and the next reading climbs from
there — /health, /stats, /memory and /metrics all read the same
gauges. The tile labels each number for what it is (limit X GiB · peak Y GiB), and the bar fills against the limit when there is one. The CUDA host's
resettable peak and its counters are untouched; cache and pinned stay 0 rather
than being relabelled as measured allocations.

3. The engine thread's completion path is lifetime-safe for status readers

deliver() used to free a job that was still in the host's admitted list —
the removal followed finish() — and the fill-total reader walks that list
under the lock, so a concurrent /stats poll could read freed memory. A job
now leaves the lists inside deliver, before finish runs; completion,
cancellation, failure, requeue and the lone driver's handoff all destroy a job
only after a locked removal. Regression tests poll at the finished event — the
exact moment a concurrent reader races — and the old order fails them.

4. Supported prefill-progress coverage, stated honestly

A backend that never stores fill_at now declares that: the lane-backend
vtable carries reports_fill, set by the family backends that store landed
progress (GLM, GLM-DSA, Nemotron, Qwen3.5 — and carried through CUDA's
wrapper). Where it is unset, the status reader reports fill_unknown instead
of counting the whole prompt as unlanded, and the page shows "prefilling ·
this backend reports no fill progress" rather than idle or a guessed number.
The Flash Next host's own status path reports the same fill_unknown while
its prompt pass runs. Backends covered with landed counters: GLM, GLM-DSA,
Nemotron (landed tokens only, at - rows), Qwen3.5 and the 27B; no ETA is
computed for the uncovered ones and the queue's drain estimate is never
presented for a queue the server cannot count.

Testing (host checks; the model/device smoke test is separate)

  • bash zig/tests/server/zig_test.sh and the engine-seam module pass on the
    merged head (211 + 117; includes the new collision, replacement and
    unknown-progress tests, the dashboard contract test and origin/main's fill
    and memory suites). The new tests fail on the previous marker code.
  • python3 tools/zig/lean_check.py — 527 problems on the branch, 527 on
    origin/main (zero added).
  • zig build native -Dcpu=apple_m1 -Dversion=1.0.9 — builds clean; zig build test — pass (final counts in the thread below).
  • zig fmt --check build.zig zig clean; git diff --check clean.
  • node --check on the page's script, plus a behavioral DOM-stub harness
    driving apply() with realistic snapshot sequences: limit/peak labeling,
    the idle dash, the queue-drain ETA, the fill_run reset, a restarted fill,
    the idle return, the unknown-ETA dash and the unknown-progress state.
  • Skipped, not run here: a served smoke test with a real model (needs the
    user's server restart; run separately by the maintainer), and the CUDA
    device path (no CUDA machine here).

Status gains optional fill_prompt_tokens and fill_tokens_left; a stream's
atomic fill_at counts the prompt tokens its pass has prefilled; the lane
host's status read sums them over the admitted jobs still prefilling, and
/stats carries the pair only while a fill runs. The dashboard's dialside
tile counts the tokens left and estimates the wait to the first token from
the poll-to-poll drain, and the dial enters prefill mode as soon as a
prompt starts.
… footprint

The lane host's memoryFn returns null unless the family host wires a
MemorySource, and only the CUDA host did, so /stats carried an empty
memory object on a Mac and the dashboard's Memory tile fell back to a
dash. The GLM host now wires one: the process's physical footprint
(rusage_info_v4, Metal buffers included) as active, and the load limit
read at load as peak, so the tile and the /metrics gauges show real
numbers.
@heitke
heitke marked this pull request as draft October 13, 2026 13:58
This was referenced Oct 14, 2026
@ashhart

ashhart commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Hello @heitke,

Thank you for the prefill countdown and for wiring a memory object into the GLM dashboard.

readMemory stores the load limit in peak and drops reset_peak (glm_host.zig:72). active is the process footprint, which is the right gauge. peak should be the high-water mark. /health?reset_peak=1 reaches that flag from status_routes.zig:27, and /metrics publishes the value as device_memory_peak_bytes, whose help text is the high-water mark since start or the last reset (metrics.zig:140). The limit does not move when the footprint does, and the reset does not clear it. cache and pinned stay 0, so pinned_memory_bytes publishes as 0.

Please store the high-water mark in peak, and clear it when reset_peak is set.

A push with that is the update we need.

Thank you again.

A /stats poll raced the engine thread's completion path: deliver() freed a
job that was still in the host's admitted list, and the fill-total reader
walked that list, so a poll at the wrong moment read freed memory. A job now
leaves the lists inside deliver, before finish runs it down; the status tests
poll at the finished event, where the old order still counted the dying job.

The GLM host's memory tile put the configured load limit in the peak field.
The limit is a plan, not a measurement: it moves to a limit field of its own,
the peak is the kernel's lifetime footprint peak, and the tile labels each
number for what it is. Mac family hosts share the reading through
cache_fit.hostMemory.

The page's ETA mixed the drains of different prompts whenever one fill
followed another without an idle poll between. The snapshot now carries
fill_run, a marker that changes when the filling set does, and the page
resets its samples on it; the label says the queue drains, which is what the
aggregate of several lanes' remaining work estimates.

Nemotron's prompt pass advanced fill_at past what the GPU had landed, so the
countdown reached zero while the last chunk still ran. It stores landed
tokens now, and a restored prefix counts as done the moment it lands.
…uery

A review of the GLM host's memory counts pointed out that the peak field
carried the load limit, and the repair put the kernel's lifetime peak there —
which never resets, while /health?reset_peak=1 and the metrics' help text say
the peak is the most device memory held since start or the last reset. The Mac
hosts now keep that mark themselves: the session high-water mark of the
process footprint, cleared to the current footprint when the reset is asked
for, climbing again from there. /health's memory object carries the limit.
…he atomics

The reset_peak query restarts the Mac hosts' stored high-water mark at the
footprint now (a fetchMax alone never lowered it), the fill totals read the
engine thread's fill_on flag instead of the plain lifecycle fields it writes
without the host's lock, a requeue takes its job off the lists before the
stream's teardown, and the cancellation walk joins the status reader's
critical section. The remaining Mac family hosts report the process
footprint's memory counts, and their prompt passes store landed fill
progress. The peak's regression test runs on deterministic samples.
@heitke
heitke marked this pull request as ready for review October 15, 2026 20:07
@heitke

heitke commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Fixes should be in and ready for merge!

@ashhart
ashhart merged commit 7c457f4 into ashhart:main Oct 16, 2026
4 checks passed
ashhart added a commit that referenced this pull request Oct 16, 2026
…, dashboard)

Layout only: trailing comments onto their own line, closing commas and zig fmt, one template literal moved to the next line. The backend vtables #738 extends keep one line each, as main lays out every family's but Nemotron's, which #738 put on one line to keep its file under 600 lines.
ashhart added a commit that referenced this pull request Oct 16, 2026
…host_end.zig

#738's fill tracking took lane_host.zig from 600 to 606 lines. takeCancels, failAll and closeAll move as they are, now free functions taking the host (pub, and closeAll calls takeCancels directly); the three callers name the new file. lane_host.zig is 553 lines.
ashhart added a commit that referenced this pull request Oct 16, 2026
…ps.zig

#738's fill status took flashnext_host.zig from 599 to 604 lines. Snaps moves as it is (its functions pub for the host's vtable), with the two imports only it used; flashnext_host.zig is 536 lines.
ashhart added a commit that referenced this pull request Oct 16, 2026
ashhart added a commit that referenced this pull request Oct 16, 2026
fillTotals counted every admitted job whose prompt pass had not reported. The
27B's warm pass, which prefills the conversation and the reply for the next turn,
showed as a new fill straight after each reply, and the next prompt's fill met it
(two fill_runs, tokens left rising). Background jobs now stay out of the totals
and out of fill_run. The test polls status at each chunk of a warm pass (no fill
keys) and of the request after it (its prompt counted).
ashhart added a commit that referenced this pull request Oct 16, 2026
A stream's fill_at started at 0. GLM and Nemotron store the restored length once
their restore is done, but the 27B stored nothing until its first chunk landed,
so a resumed turn showed its whole prompt as left until then. Stream.init now
starts fill_at at the kept prefix's length, and the 27B stores what its restore
kept (0 when it failed) before its first chunk, as GLM and Nemotron do. The test
polls a resumed turn's status before its pass lands a chunk: 8 of 16 tokens
left, not 16.
ashhart added a commit that referenced this pull request Oct 16, 2026
#835 (@heitke) reset to 027ddea: his two commits and public main merged in. The
candidate carries the guard as re-landed (5477b36, e5b9686) with the landing
work after it, so this merge changes no file: fourteen of its twenty files merge
to the tip's content as they are, and the six that conflict keep the tip's text,
which holds his change in the landed form (glm_expiry.zig and
prompt_cache_policy.zig wrapped under 120 columns; reported()'s three cases as
one condition on the cache key; the requeue teardown after the list removal, as
#738's landing ordered it; victimBut public for the disk rows; engine_api's test
imports in lane_host_test.zig; glm_host.zig's image offer, which his base lacks).
ashhart added a commit that referenced this pull request Oct 16, 2026
#738's line gains its landing fixes (a warm pass is no fill; a resumed prompt counts
its restored prefix as filled). New lines: the Qwen-VL tower releases its pipelines
on a failed load; tf-qwen-vision --bound; every family's image identity in the cache
key (bytes and grid, 62 bits, carried whole in the markers' cache words); CUDA's
--vision taken per family. GLM's vision line no longer says every other native
engine refuses the flag, now that the 27B and Super VL read images.
@ashhart

ashhart commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Thank you, @heitke. The prefill countdown and the memory numbers ship in TensorFold 1.0.12, merged with your commits as they are (7c457f4c4), so this pull request shows as merged.

At landing we wrapped the lines past 120 columns and moved three lane host functions into lane_host_end.zig (e8e7c2cc6) and Flash Next's Snaps into flashnext_snaps.zig (6ad572ed3), so neither file passes 600 lines. Two behaviour changes are ours, each with a test:

d62704be5: a background warm pass is not a fill. The 27B prefills the next turn right after each reply, and fillTotals counted that pass, so /stats showed a new fill as soon as a reply ended.

6d7006e1a: a resumed prompt's fill_at starts at the restored length. Before, a resumed 27B turn showed its whole prompt as left until its first chunk landed.

Could you tell us here if the second reads wrong to you? With both, our dashboard checks pass in full on the 27B and on GLM-5.3-Flash: every prompt counts down within one fill_run, the keys clear when the reply ends, and 10,777 polls through cancelled and queued requests all answered. GLM prefills in 16,384-token chunks, so a shorter prompt's count drops once, when its chunk lands.

Posted by Ash's AI Assistant Synthena

BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…ng Memory tile

requeue takes the head's order (off the lists, then the teardown) and keeps the candidate's prefix report and recall release in that teardown; engine_api's tests keep lane_host_rows_test beside the head's moved fill test; glm_host keeps its vision offer and glm_disk beside the head's memory reader.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
… routes, dashboard)

Layout only: trailing comments onto their own line, closing commas and zig fmt, one template literal moved to the next line. The backend vtables ashhart#738 extends keep one line each, as main lays out every family's but Nemotron's, which ashhart#738 put on one line to keep its file under 600 lines.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…host_end.zig

ashhart#738's fill tracking took lane_host.zig from 600 to 606 lines. takeCancels, failAll and closeAll move as they are, now free functions taking the host (pub, and closeAll calls takeCancels directly); the three callers name the new file. lane_host.zig is 553 lines.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…ps.zig

ashhart#738's fill status took flashnext_host.zig from 599 to 604 lines. Snaps moves as it is (its functions pub for the host's vtable), with the two imports only it used; flashnext_host.zig is 536 lines.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
fillTotals counted every admitted job whose prompt pass had not reported. The
27B's warm pass, which prefills the conversation and the reply for the next turn,
showed as a new fill straight after each reply, and the next prompt's fill met it
(two fill_runs, tokens left rising). Background jobs now stay out of the totals
and out of fill_run. The test polls status at each chunk of a warm pass (no fill
keys) and of the request after it (its prompt counted).
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…t#738)

A stream's fill_at started at 0. GLM and Nemotron store the restored length once
their restore is done, but the 27B stored nothing until its first chunk landed,
so a resumed turn showed its whole prompt as left until then. Stream.init now
starts fill_at at the kept prefix's length, and the 27B stores what its restore
kept (0 when it failed) before its first chunk, as GLM and Nemotron do. The test
polls a resumed turn's status before its pass lands a chunk: 8 of 16 tokens
left, not 16.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
ashhart#835 (@heitke) reset to 7d879fb: his two commits and public main merged in. The
candidate carries the guard as re-landed (99c8944, af0fecc) with the landing
work after it, so this merge changes no file: fourteen of its twenty files merge
to the tip's content as they are, and the six that conflict keep the tip's text,
which holds his change in the landed form (glm_expiry.zig and
prompt_cache_policy.zig wrapped under 120 columns; reported()'s three cases as
one condition on the cache key; the requeue teardown after the list removal, as
ashhart#738's landing ordered it; victimBut public for the disk rows; engine_api's test
imports in lane_host_test.zig; glm_host.zig's image offer, which his base lacks).
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
ashhart#738's line gains its landing fixes (a warm pass is no fill; a resumed prompt counts
its restored prefix as filled). New lines: the Qwen-VL tower releases its pipelines
on a failed load; tf-qwen-vision --bound; every family's image identity in the cache
key (bytes and grid, 62 bits, carried whole in the markers' cache words); CUDA's
--vision taken per family. GLM's vision line no longer says every other native
engine refuses the flag, now that the 27B and Super VL read images.
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