Repository navigation
[Docs] Deferring the refill is refuted: decode 92 → 0.4 tok/s for 72–188 ms of TTFT - #21
Merged
Merged
Conversation
…ok/s
I built the flag (STRATA_REFILL_DEFER, one if in the serve prompt path,
default unchanged) precisely because the refill looked like dead weight:
it costs 0.319 ms per lent slot and runs between the read and "prompt
done", so the first token waits 72-188 ms for it.
Measured on the same ladder, six samples per size:
tokens refill kept refill deferred decode kept decode deferred
126 398 ms 2,945 ms 92.0 tok/s 30.9
456 539 ms 3,126 ms 91.8 0.5
1608 1,468 ms 3,953 ms 74.3 0.4
The per-sample sequence says why: at 126 tokens requests 1-2 are normal
(0.553, 0.537 s) and request 3 is 3.069 s - the collapse starts once the
cache holds the previous prompt's experts. The borrowed slots ARE the
decode working set, so the refill is a prefetch for the tokens about to be
generated. Skipping it moves the cost from one transfer per request to a
streamed fetch per token.
So item 1 of the ranked list closes as refuted, with the numbers, and item
2 becomes the narrower and surviving question: not when to refill but how
much - only the experts the first decode positions route are worth
pre-loading.
Artifacts: the ladders, both engine logs, the source patch as a diff, the
A/B driver, the analysis script.
Also records the build trap that cost one cycle: build-sycl-aot's CMake
home is sycl/, so it compiles sycl/src/program/generate.cpp - patching
src/program/generate.cpp builds nothing ("ninja: no work to do").
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.
Problem and result
Item 1 of the ranked list was "defer the slot refill past the first token", worth 72–188 ms of TTFT. I built it as a
flag (
STRATA_REFILL_DEFER, oneifin the serve prompt path, default unchanged) and measured it. It is refuted, andbadly — it saves the 72–188 ms and costs two orders of magnitude of decode:
Mechanism, from the per-sample sequence: at 126 tokens requests 1–2 are normal (0.553, 0.537 s) and request 3 is
3.069 s. The collapse starts once the cache holds the previous prompt's experts. The borrowed slots are the decode
working set, so the refill is a prefetch for the tokens about to be generated; skipping it converts one 72–188 ms
transfer per request into a streamed expert fetch per token. 0.32 ms/slot buys 92 tok/s over 0.5.
So the refill is not dead weight, and "when" was the wrong question. "How much" survives: only the experts the first
decode positions actually route are worth pre-loading — item 2 of §4 now.
Related discussion
Approach
STRATA_REFILL_DEFER=1), default OFF, so both arms run on onebinary and the default path is untouched.
ninja strata) and ran the same ladder on both arms, six samples per size, with the trace on.rather than only that it happened.
Validation
Passed:
earlier build, so the flag alone changed nothing.
deferred arm at 456 and 1,608 tokens.
generated in X ms (Y tok/s)line, not inferred from TTFT.:8095(http=200, engine 0.1.58).Failed:
ninja: no work to do.build-sycl-aot'sCMAKE_HOME_DIRECTORYissycl/, so itcompiles
sycl/src/program/generate.cpp, notsrc/program/generate.cpp. The portable copy was reverted from backupand the SYCL copy patched; the patch ships as a diff.
BEFORE: unbound variable— an unescaped$expanded by the outer shell inside the window'sbash -c; fixed the way the trace driver already does it.Not run:
Limits
sampling error is not the explanation.
generation would be needed to characterise the collapse, which is not worth measuring given the conclusion.