Repository navigation
feat(mesh): charge non-streaming single-worker prefill, release on the KV event - #3861
Open
MengqingCao wants to merge 1 commit into
Open
MengqingCao wants to merge 1 commit into
MengqingCao wants to merge 1 commit into
Conversation
…e KV event A non-streaming single-worker request charged no prefill, so agentic saw a worker prefilling a long prompt as idle until the response ended. - The planner charges a single-worker prompt whether or not it streams. - KvEventMonitor::watch_prefill registers a non-streaming request's charge on the selected rank's lane, keyed by the prefix hash of the prompt's last full block; called on HTTP, ext-proc and gRPC. - The index writer releases one watch per stored block, oldest first, and skips charges the first byte already released; a released lane drops its watches and the sweep prunes watches whose guard is gone. Registration holds the subscription's map entry, so a lane cannot be released and reused mid-register. - The first byte stays the fallback: cached repeats, sub-block prompts and workers without a KV event subscription (gRPC single workers today). - docs/agentic_cost.md and the mesh_worker_prefill_tokens help no longer list an uncharged single-worker path. Co-Authored-By: Claude <noreply@anthropic.com>
MengqingCao
force-pushed
the
mengqing/mesh-prefill-nonstreaming-charge
branch
from
November 27, 2026 01:51
f347684 to
dfa18d5
Compare
This branch has not been deployed
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.
Motivation
A non-streaming single-worker request charged no prefill: the router sees no end of prefill before the response, which comes after decoding. A worker prefilling a 32K-token prompt for such a request looked idle to
agentic. Second of the two follow-ups promised in #3481 (Jasen2201's review); the release follows llm-d-router#3975 rather than pollingatom:dp_queued_prefill_tokens.Summary
KvEventMonitor::watch_prefillregisters a non-streaming request's charge on the selectedurl@rank's KV event lane, keyed by the router's prefix hash of the prompt's last full block (ATOM'sBlockStoredcarries no request id). HTTP, ext-proc and gRPC register it.FollowKvEventsStepfollows HTTP workers), so their non-streaming requests release at the response.docs/agentic_cost.mdand the metric help no longer list an uncharged single-worker path.Known limits, not covered by tests: a queued older event or a decode block with the same key can release a watch early, and a longer in-flight prompt sharing the watched block can release a shorter prompt's watch.
Requires the previous PR (ext-proc and gRPC streaming charge).
Test plan
cargo fmt --check;cargo test --lib --features atom-engine(1442 passed);cargo check --features ext-proc --tests;cargo test --tests; mockertest_atomesh_harness;cargo +1.94.0 test --lib(1435 passed)cargo test --lib --features atom-engine,ext-proc -- prefill(85 passed);cargo test --features ext-proc --test ext_proc_tests -- prefill(2 passed)tests/test_atomesh_*, 6 modules) passagenticprefill and non-streaming traffic🤖 Generated with Claude Code