Repository navigation
Conversation
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.
Stack on #603.
Diff against #603
Summary
HiCache write-through acks can make tokens evictable after
cache_finished_req()has already checked retention. The idle cache can then exceed either the startup or runtime token cap.Enforce retention after
check_hicache_events()andloading_check()return, using native eviction. The load hook waits for unpinning and covers calls fromis_load_back_event_done()outside the event poll.Before
Example: a zero token cap, with 956 tokens protected by the final write-through copy.
sequenceDiagram participant S as Scheduler participant C as Prefix cache S->>C: cache_finished_req(req) C->>C: Check retention cap: 0 evictable tokens Note over C: Copy still protects 956 tokens S->>C: check_hicache_events() C->>C: writing_check(): synchronize ack, release copy lock C->>C: loading_check() C-->>S: Return Note over C: 956 tokens now evictable, exceeding cap 0After
sequenceDiagram participant S as Scheduler participant H as Retention wrapper participant C as Prefix cache S->>H: check_hicache_events() H->>C: Original check_hicache_events() C->>C: writing_check(): synchronize ack, release copy lock C->>H: loading_check() H->>C: Original loading_check() Note over C: Complete any load unlocks and unpinning C-->>H: Return H->>C: Enforce retention cap C->>C: Native evict(EvictParams(num_tokens=956)) H-->>C: Return C-->>H: Original event poll returns H->>C: Enforce retention cap (already satisfied) H-->>S: ReturnTest
Real GPU before/after runs: RTX A2000 12GB, SGLang 0.5.20, Qwen2.5-0.5B-Instruct, TP=, HiCache
page_first/write_through.0256, after a new request-1All 10 requests completed, generating 320 tokens. Every paired request produced identical complete output token IDs. The patched repeated request restored 924 tokens from the host; real write/load acks were observed without injecting cache nodes or completion events.