Repository navigation
Serving/issue 2 chunked prefill - #6
bhargavchintam merged 3 commits into
Conversation
Aaqibhafeezkhan
left a comment
There was a problem hiding this comment.
Verified KV-cache and next-token-logit equivalence across four chunk sizes, with decode steps interleaved between chunks and the resulting maximum wait reported.
|
Please review/merge |
bhargavchintam
left a comment
There was a problem hiding this comment.
Thanks for this, @Aaqibhafeezkhan, and sorry the review took a while. I approved the CI run, and all three jobs (Python 3.10, 3.12 and 3.13) printed 30/30 checks passed (run 40671325140). The new check's line from the 3.10 job:
PASS serving/chunked_prefill.py 0.12s max_err=5.55e-17 (chunked KV and next-token logits == full pr…
3.12 and 3.13 printed the same max_err=5.55e-17. The equivalence part is what #2 asked for: K, V, every prefill logit and the logits of the next decode step match a full prefill for chunk sizes 1, 2, 4 and 8.
One change before I merge: the decode wait is printed from min(chunk_size, len(PROMPT)), so the script states the wait instead of measuring it. Could prefill_chunked record how many prompt tokens ran before each interleaved decode step (the end - start of the chunk just before it) and return the largest? Then the script can assert it is at most chunk_size and print it next to the unchunked wait of len(PROMPT) tokens, so the README's "wait falls from 16 to at most 8 token slots" comes from the run like the other rows.
Two small ones, your call:
other_logitsis computed but never read. Comparing it with the same request decoded on its own would show the interleaving leaves that request unchanged; otherwise it can go.assert len(PROMPT) > max((1, 2, 4, 8))checks the setup, so it reads better above the loop.
Aaqibhafeezkhan
left a comment
There was a problem hiding this comment.
Thanks for the review. I've pushed the requested updates in commit 619dd1b.
- Decode wait is now measured during execution rather than calculated from a formula.
- Added a comparison against an independently decoded reference to verify interleaving doesn't change the other request's logits.
- Moved the prompt-length assertion before the loop.
I also updated the README with the measured results. The numerical validation passes locally across all tested chunk sizes.
Summary
Validation
The check compares chunk sizes 1, 2, 4 and 8 against full prefill, asserting numerical equivalence with a tolerance of
1e-10. It reports the maximum error and decode waiting slots for each chunk size.Closes #2