-
Notifications
You must be signed in to change notification settings - Fork 165
feat(sim): no-GPU simulation harness for cache-aware routing and the shared index #2439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
slin1237
wants to merge
1
commit into
main
Choose a base branch
from
feat/sim-harness-on-main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Nit:
pinned_tokenssums per request, so a prefix shared by concurrent requests is counted once per request — not once, as the SGLang formula quoted in the doc comment does. The over-report scales withmax_runningand lands on the same 0.9 gate this change exists to get off.In SGLang,
used = total − available − evictablewhere the non-evictable set is the union of radix nodes withlock_ref > 0. A block held by 80 running requests is one ref-counted node counted once.pinned_tokenswalksself.runningand addsprompt_tokens + generatedfor each, so every shared block is multiplied by the number of requests holding it.Failure scenario, with the committed
local-medium.jsonnumbers (system_prefix_tokens: 2048,max_running: 80,kv_tokens: 1200000,--worker-overload-token-usage 0.9): every session prepends the same 2048-token system prefix, so at full batch widthpinned_tokenscharges 80 × 2048 ≈ 164k tokens for KV that physically holds 2048 — 13.7 points oftoken_usageon a 1.2M pool. Mean prompt overprompt_cdfis ~13.5k, so a full batch is already ~0.8 correctly accounted; the double count pushes it past 0.9 and re-trips the overload gate on exactly the warm, high-concurrency workers. Turn-2 requests make it worse:turn2_ingress: "same"routes the follow-up to the worker already holding the turn-1 prefix, so the requests most likely to be concurrent on one worker are the ones sharing the most tokens.The
.min(p.kv_capacity_tokens)clamp on this line hides it rather than bounding it —token_usagereads a flat 1.0 once the sum crosses capacity, with no signal that it is a counting artifact rather than real pressure.used_tokens's prefix-cache branch already computes the union (cache.len() * block_size+ pending tails); the reportable quantity is that same union restricted to blocks a running request references. If tracking per-request refcounts is more machinery than the harness wants, subtracting each request'scached_tokens(already stored onRunningReq) and adding the matched prefix once would remove the bulk of the double count, since the shared prefix is whatcached_tokensmeasures.