Repository navigation
Native server: prefill time included in decode seconds, so long prompts read as collapsed decodes - #588
Native server: prefill time included in decode seconds, so long prompts read as collapsed decodes#588eleqtrizit wants to merge 1 commit into
Conversation
…decode time, as tokens_per_second divides them: a consumer reading seconds as decode no longer counts the prompt in it (cherry picked from commit 10d2f1a)
|
Thank you, @eleqtrizit. Decode-time We checked it on an M3 Ultra with an 8,478-token prompt and a 256-token reply. Before,
|
…_seconds and time_to_first_token measure After ashhart#588 seconds is the reply's decode time; the Python 0.6 server's seconds stays the whole request.
… and ashhart#576's line in the file's style
…_seconds and time_to_first_token measure After ashhart#588 seconds is the reply's decode time; the Python 0.6 server's seconds stays the whole request.
… and ashhart#576's line in the file's style
What this changes
A side-by-side of the native and Python engines on the same long-context bench was comparing two different measurements. The native server streamed its
tensorfoldblock carryingsecondsas the whole request's wall time, prompt included, and the bench readgen_tok / secondsas the decode rate — so a 128k prompt put its 8.6-second prefill inside the decode cell and printed a decode rate that fell toward zero as the prompt grew, an apparent collapse that was never the engine's.This changes the native server's chat runtime block to carry
secondsas the reply's decode time — the same secondstokens_per_secondalready divides — so a consumer readingsecondsas decode seconds (llm-bench's tensorfold branch does) no longer counts the prompt in a long-context reply's decode rate, and both columns of that comparison become decode-only.This PR
zig main (prefill time included in decode time)
Receipt
Environment, with the TensorFold commit, MLX or PyTorch version, machine and GPU, checkpoint and revision:
Linux x86_64, zig 0.17.0, no MLX or PyTorch in the loop; commit
77fdb75atop0d83398(main). The native CUDA server against checkpointTensorFold/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit, revisiond9d758fb83953437f7263256b0d96157e2a348b8, served with--no-thinking --context 131000; the consumer is llm-bench, which readsgen_tok / secondsfrom the streamedtensorfoldblock.Exactness, from
tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false:Not needed for tokens: this changes a reply's reported seconds alone; no
weight, kernel, round or sampling path is touched, and the streamed reply's
bytes are identical. The block stays self-consistent, before and after:
tokens_per_secondisdecode_tokens / secondson both sides of thechange — only which seconds those are moves, from the request's whole wall
to its decode span.
Decode speed before and after, from
tools/bench_openai.py:Not from bench_openai; one streamed chat request at each of 2k, 8k, 32k, 64k and 128k contexts, 512 tokens, greedy, read through llm-bench. Before, the same bench counted an 8.6-second 128k prefill inside the 128k decode cell; after, it does not, so the before and after tables are the same engine measured by a moving ruler — the after column, not the before, is the one comparable against the Python engine's:
Prompt speed before and after, from
tools/prefill_cold.py:Not from prefill_cold; the same requests'
prompt_tok / prefill_secondsis unchanged by this (a prompt's timing fields are untouched), so there is nothing to measure here.Tests run, with pass, fail and skip counts:
zig build testexit 0, including the server framing goldens (theirsecondsfield matches through the<t>timing placeholders, so no golden changed);zig build test-cuda-hostexit 0. The suites print no pass/fail counts of their own; the exit codes are the record.Not run, and why:
Metal on the Mac build — the block builder is the same
chat.zigon either platform, and the goldens cover the framing on the host suite; no Mac was at hand to serve on one.tools/bench_concurrent.py's concurrent and reuse cells — the block's shape, not its consumer behavior under load, is what changed, and the client's own decode spans (measured beside the block's seconds, at 2k through 128k) are the record instead.Checklist
Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
Drafted output equals
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Untouched: no engine change.)No precision traded for speed. If the bits change, the description says which sums change and why. (No model sums are in this change;
secondsandtokens_per_secondstay divisors of the same quantities on either side of it.)Prompt processing is no slower than the last release. (Untouched.)
The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not. (Ran the Linux CUDA native server; could not run Metal on a Mac.)
New tests fail before the change, pass after it, and skip cleanly without their dependency. (No new test: the framing goldens already assert the block's shape through their
<t>placeholders, and pass unchanged, which is the point — only the field's value semantics move, and no golden pinned them.)Comments and docstrings are one line. No measurements or history in the source.
No personal data, machine names, internal hosts or local paths. No AI attribution lines.