Repository navigation
Conversation
…prompt tokens, rounds, prefill time /health reports figures /metrics left out, so a Prometheus scraper had to poll /health beside it. Both HTTP layers now publish them, where each server counts them: - generation_tokens_running (gauge): the running replies' tokens so far. Added to generation_tokens_total it counts tokens as they are generated, as /health's completion_tokens_total does on CUDA. - prompt_tokens_cached_total: prompt tokens read from a kept prompt state (vLLM's name too). - decode_rounds_total: decode rounds; generation_tokens_total over it is the tokens a round. - request_prefill_seconds, mirrored as vLLM's request_prefill_time_seconds: each finished request's prompt pass (the CUDA engine's prefill_s; on the Mac server the job's start to its prefill's end). - requests_running_max (gauge), where the engine has a limit to read: the concurrent CUDA scheduler's max_streams, the Mac server's lane count. CUDA reads them from the engine stats /health already folds and from /health's own live requests; the Mac server from its job and stream. Tests: tests/test_metrics.py (both servers, the HTTP layer, the mirror).
8 tasks done
ashhart
added a commit
that referenced
this pull request
Oct 6, 2026
…367, #407) /metrics gains four readings. request_time_per_output_token_seconds (vLLM's TPOT) is, for each finished reply, the server's time from its first generated token to its last over its tokens less one, in buckets from 2.5 ms to 1 s; a one-token reply adds no sample. generation_tokens_running counts what live replies have generated so far, from a snapshot the engine thread takes between rounds, so a scrape never reads a stream the engine is changing. decode_rounds_total counts the rounds finished replies used. request_prefill_seconds, repeated as vLLM's request_prefill_time_seconds, is each finished reply's prompt pass as the engine measured it, from the job's start to the end of its prefill. The reply's tensorfold.prefill_seconds now reports that same span, so it no longer includes time spent waiting for a lane. The cached-prompt counter stays out until an engine counts kept-prefix hits. Tests: the TPOT arithmetic, the bucket a sample lands in, and render() through a stub engine (the new families present, no cached family). The scripted test engine reports a prefill span, and the server parity check lists the four /metrics cases as expected differences, since the Python server does not have these families. Co-authored-by: juliankang4 <[email protected]> Co-authored-by: MiaAI-Lab <[email protected]>
Owner
|
Thank you, @MiaAI-Lab. This landed in the Zig engine as 8debb38, with your credit. The Zig The Python engine is frozen (#286), so this PR closes with that. Thanks for tying every family to the |
Closed
grearjake-star
added a commit
to grearjake-star/TensorFold
that referenced
this pull request
Oct 8, 2026
… tokens, rounds, prefill time /health reported figures that /metrics left out, so a Prometheus scraper had to poll /health beside it and parse JSON. /metrics now carries generation_tokens_running (the running replies' tokens so far), prompt_tokens_cached_total (prompt tokens read from a kept prompt state), decode_rounds_total, request_prefill_seconds (mirrored as vLLM's request_prefill_time_seconds) and, where the engine has a limit to read, requests_running_max. A family the server cannot count is left out, never sent as zero. Merged beside this tree's TPOT histogram (ashhart#367); the macOS footprint gauge stays out with the Mac server. Observability only. Upstream: ashhart#407, closed unmerged with the Python engine frozen; the maintainer landed the same families in the Zig server. Co-authored-by: MiaAI-Lab <[email protected]>
This was referenced Oct 9, 2026
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
…shhart#367, ashhart#407) /metrics gains four readings. request_time_per_output_token_seconds (vLLM's TPOT) is, for each finished reply, the server's time from its first generated token to its last over its tokens less one, in buckets from 2.5 ms to 1 s; a one-token reply adds no sample. generation_tokens_running counts what live replies have generated so far, from a snapshot the engine thread takes between rounds, so a scrape never reads a stream the engine is changing. decode_rounds_total counts the rounds finished replies used. request_prefill_seconds, repeated as vLLM's request_prefill_time_seconds, is each finished reply's prompt pass as the engine measured it, from the job's start to the end of its prefill. The reply's tensorfold.prefill_seconds now reports that same span, so it no longer includes time spent waiting for a lane. The cached-prompt counter stays out until an engine counts kept-prefix hits. Tests: the TPOT arithmetic, the bucket a sample lands in, and render() through a stub engine (the new families present, no cached family). The scripted test engine reports a prefill span, and the server parity check lists the four /metrics cases as expected differences, since the Python server does not have these families. Co-authored-by: juliankang4 <[email protected]> Co-authored-by: MiaAI-Lab <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/healthreports figures that/metricsleaves out, so a Prometheus scraper that wants them has to poll/healthbeside it and parse JSON. This puts them on
/metrics, on both HTTP layers (the CUDA server and the Mac server),under the
tensorfold:prefix and with the vLLM mirror where vLLM has a family for the same reading. It builds on the/metricsmodule from #110 (@ashhart), its vLLM names from #156 (@jeidbugs404) andrequest_decode_secondsfrom#269 (@sxuff), and follows their rule: a family the server cannot count is left out, never sent as a zero.
What
/metricsgains/healthfield it matchesgeneration_tokens_runningcompletion_tokens_totalminus the finished replies' tokensprompt_tokens_cached_totalcachedcached_tokenscached_tokens_totaldecode_rounds_totalroundsroundsrounds_totalrequest_prefill_seconds(mirrorrequest_prefill_time_seconds)prefill_sstarted_attoprefilled_at(the done line'sprefill=)prefill_seconds_totalis its_sumrequests_running_maxmax_streams; left out on one-request enginesmax_batch_size(the lane count)streams.max,max_batch_sizeWhy each one:
generation_tokens_running.generation_tokens_totalcounts finished requests only, so a long reply shows upas one jump when it ends, and a decode-rate panel reads zero for minutes.
generation_tokens_total + generation_tokens_runningcounts tokens as they are generated, as the CUDA/health'scompletion_tokens_totaldoes (the TUI's telemetry reads
/healthfor exactly this today). It is a gauge, so the existing counter keeps itsmeaning.
prompt_tokens_cached_total, as @Acermax asked for on feat: the CUDA server publishes live token totals on /health #79, under that name. It is also vLLM's own name(
vllm:prompt_tokens_cached), so no mirror is needed. Overprompt_tokens_totalit is the prompt-cache hit rate.decode_rounds_total.generation_tokens_totalover it is the tokens a round, the draft payoff thatmtp_accepted_totalalone does not give.request_prefill_seconds.prompt_tokens_totalminus the cached tokens, over its_sum, is the prompt rate.vLLM's dashboard reads
request_prefill_time_seconds_sum, which the mirror fills.requests_running_max, so a saturation panel (requests_running / requests_running_max) needs noconfiguration.
Left out on purpose:
requests_total(every histogram's_countalready counts finished requests),decode_seconds_total(request_decode_seconds_sum), the drafted and accepted totals (mtp_*_total), the contextwindow (configuration, not a reading), and the Mac
/health's MLX memory split (active, cache, peak): that isMetal-only, which we could not run.
How
server/metrics.py(383 to 455 lines):Metricskeeps the cached-token and round counters and a prefillhistogram, and a small table of the Mac server's running requests' tokens by HTTP thread (
beginandtokenswriteit,
finish_requestdrops it).notetakescached,roundsandprefill. On the CUDA server,rendersums thelive requests' tokens from
/health's ownHealth.live, under its lock.cuda/health.py: the fold that feeds/healthhands the engine'scached,roundsandprefill_stonote.docs/api.md: the new families.No engine, scheduler or request path changes: the new code runs when a request ends, when a Mac request's token chunk
arrives (one dictionary write under the metrics lock), and at scrape time.
Related
#367 (@juliankang4, a TPOT histogram) also changes
server/metrics.py,cuda/health.pyandtests/test_metrics.py.The two add different families, so whichever lands second may need a small merge where both extend
metrics.note.Receipt
Environment. TensorFold 0.6.5 (
609ca41) against this branch on it. NGC PyTorch 26.07 container (PyTorch2.13.0a0+9186a08, CUDA 13.3, Python 3.12),
pip install "tensorfold[test] @ git+...@609ca41", the branch'ssrc/tensorfoldmounted over the installed package. Two DGX Sparks (GB10, 128 GB each),--tp 2over their CX7cable (NCCL on both RoCE rails,
NCCL_IB_HCAas the RUNBOOK says). CheckpointMia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFoldat
078455ff; serve arguments--tp 2 --context 131072, otherwise the defaults (--drafter autopicked the MTP headand
incoai/GLM-5.3-Flash-DFlash2atbf582e4from the cache). Before and after ran on the same two machines in thesame session, one boot each.
/metricsagainst/health, live (a 600-token greedy reply, scraped 4 s in and after it; the same counters on0.6.5for contrast):/metrics/metrics/healthgeneration_tokens_total19,770 (finished only)generation_tokens_running259 = 20,029completion_tokens_total20,029prompt_tokens_cached_total1,501cached_tokens_total1,501decode_rounds_total10,946rounds_total10,946request_prefill_seconds_sum811.775115 (_count119)prefill_seconds_total811.775115 (requests_total119)request_prefill_time_secondscarried the same sum and count.requests_running_maxis left out here, as it shouldbe: GLM on CUDA serves one request at a time and has no limit to read.
Exactness (
python3 tools/bench_concurrent.py http://127.0.0.1:8877 glm-flash --alone --serial, 4 streams,256 tokens, 3 reps): every concurrent reply equal to its solo run and every solo run equal to
"draft": false, onboth trees.
A greedy 64-token reply had the same
token_sha(ba2f337c82d8) on both trees.Decode (
python3 tools/bench_openai.py http://127.0.0.1:8877 glm-flash, 64 tokens, 5 reps, median tok/s):Boots in this order: 0.6.5, this branch, a third tree that does not touch this code (#301's branch, twice), 0.6.5
again.
The sampled cells' five reps have the same shape in every run (code, T=1.0: 36.1-36.4, 26.1-26.3, 34.9-35.3,
35.4-35.6, 31.8-32.2), the drafts' acceptance on those seeds, so the medians compare directly. The first 0.6.5 run had
CPU tests running beside rank 1; the rest did not.
Prompt speed (
tools/prefill_cold.py, cold prompts, median of 3, tok/s):Per rep (time to first token, s), with the third tree's boot (#301's branch, which changes no prompt code either):
This branch's medians read 0-4.5% below 0.6.5 at 16k-64k, from two or three slow reps (32k: 71.9 and 71.2 s,
64k: 144.6 s); its fastest reps match 0.6.5's. Nothing in this change runs during a prompt pass (the new code runs
when a request ends and at scrape time, and
prefill_coldscrapes nothing), so we read it as boot-to-boot noise, butwe had one boot of each and could not run the alternating order the contributing guide asks for at a few percent.
Please rerun if it matters.
Tests (CPU, the NGC 26.07 container, no GPU):
tests/test_metrics.py tests/test_metrics_footprint_host.py tests/test_cuda_server_health.py tests/test_health_memory.py: 34 passed, 1 skipped, 1 failed on this branch. The failure istest_health_memory.py::test_health_reports_the_budget_and_the_process_footprint, which reads macOS's processfootprint and fails the same way on
0.6.5on Linux.tests/test_metrics.pyagainst0.6.5's source: 6 of its tests fail there (the five new ones, and the existingscrape test whose list of families now names the new ones), and all pass here.
python -m pytest -q -p no:randomly --timeout 120 testsin the NGC 26.07 container on an aarch64 CPU (no GPU, no MLX): 4,052 passed, 135 failed, 11 errors, 172 skipped on this branch, against 4,047 passed and the same 135 failed, 11 errors and 172 skipped on 0.6.5. The failures and errors are the same tests on both trees: they need MLX or macOS (test_lane_server.py,test_request_reasoning.py,test_prompt_fill.pyand the like), and one,test_cancellation.py::test_streaming_socket_disconnect_during_decode_releases_the_active_row, loops onrecvthere until pytest-timeout's 120 s stops it (without the timeout the suite hangs at that test). The five more passing are the new tests.New tests: both servers' new families from their own counters, the Mac server's running tokens across two threads,
the CUDA HTTP layer's
/metricsagainst its/healthduring and after a request, the limit only where an engine hasone, and the prefill mirror.
Not run. Metal: we have no Mac. The Mac server's new families are covered by the CPU tests with stand-in jobs
and streams, not by a Mac chat;
test_a_mac_chat_counts_the_reply_the_http_thread_returns(MLX) skips here. Theconcurrent CUDA engines (
--parallelN > 1 on Qwen and Flash Next), whererequests_running_maxand several runningstreams show up, ran only in the tests, not on a server.