Repository navigation
[Perf] hicache: Unify PP prefetch hit queries and buffer allocation - #43344
Merged
Merged
Conversation
huangtingwei9988
requested review from
Ying1123,
alphabetc1,
hanming-lu,
hnyls2002,
hzh0425,
ispobock,
merrymercy,
stmatengss,
xiezhq-hermann and
yizhang2077
as code owners
October 9, 2026 09:18
Collaborator
Author
|
/tag-and-rerun-ci |
alphabetc1
reviewed
Oct 11, 2026
Cap local PP prefetch allocation to page-aligned available KV slots before the existing MIN reduction, preserving a common hit under host pressure. Add a file-backend regression for 8192/2048 hits with 4096/4097 capacity.
10 of 21 tasks
Collaborator
Author
|
/rerun-failed-ci |
1 similar comment
Collaborator
Author
|
/rerun-failed-ci |
alphabetc1
approved these changes
Oct 15, 2026
Collaborator
Author
|
/rerun-failed-ci |
stmatengss
approved these changes
Oct 15, 2026
Collaborator
Author
|
/rerun-failed-ci |
Collaborator
Author
|
/rerun-failed-ci |
Collaborator
Author
|
/rerun-failed-ci |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Collaborator
Author
|
/rerun-failed-ci |
1 similar comment
Collaborator
Author
|
/rerun-failed-ci |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
5 tasks done
xiezhq-hermann
added a commit
that referenced
this pull request
Oct 28, 2026
Resolves the rebase against #43344 (the PP ticket thread now runs the hit query itself, so the scheduler-thread reduce this branch guarded is gone and the ticket-thread failure hook moves to its unconditional exit), #44614 (the degrade cut reuses the deadline_expired machinery) and the shared-memory count exchange in _sync_hicache_ready_counts (the health bit is split out on that path too). Test fixtures gain the attributes main added.
detain
pushed a commit
to detain/sglang
that referenced
this pull request
Oct 30, 2026
…liveness A gloo timeout inside the HiCache storage worker collectives (the query thread's hit MIN, the sync thread's ack MIN) killed the worker on every rank, so one rank stuck in its backend left every rank unable to publish L3 queries or acks: under wait_complete every later L3-hit request waited forever, under timeout every one paid the full deadline. sgl-project#43550 guards the backend call only, not the collective, and nothing checked worker liveness. Wrap every worker-thread collective: on failure log once, flag the controller (storage_sync_failed), publish the operation as FAILED (0 hits, 0 completed tokens) and keep the thread alive; after the first failure the broken groups are skipped so the per-rank publication sequence stays intact for the queue-count drain. Fold a rank-local health bit (no sync failure and all storage workers alive) into the MIN-reduce the scheduler thread drain already issues; when the agreed bit drops, apply storage_failure_policy: "disable" (default) degrades to no-L3 until the backend is re-attached (no new prefetch/backup, in-flight prefetches cut like a deadline, drained hits read as misses, progress frozen, gauge sglang:hicache_storage_healthy -> 0), "raise" fails the scheduler. A new storage_sync_timeout extra-config key bounds the sync groups' gloo timeout so a hung peer is detected before torch's 30-minute default. LIVE premise on this stack at 78783f0 (quoted from python/sglang/srt/managers/cache_controller.py:1505-1529) -- the bare, unprotected hit reduce on the query thread: # Outside the guarded query on purpose: every rank must run the # same number of hit-count all_reduces or the sync threads # deadlock, so a locally failed query still participates (with # a zero) instead of skipping the collective. storage_hit_count = self._sync_prefetch_hit_query( operation, storage_hit_count ) ... def _sync_prefetch_hit_query(self, operation, storage_hit_count: int) -> int: """Rank-reduce a hit query (MIN) so every rank agrees on the usable prefix. Runs for every operation, hit or miss.""" hit_count = torch.tensor(storage_hit_count, dtype=torch.int) self._all_reduce( hit_count, torch.distributed.ReduceOp.MIN, self.prefetch_hits_sync_groups, ) return int(hit_count.item()) Port adaptations (cherry-pick -x of 6fa9f21 with conflicts resolved against the post-MERGE-sgl-project#5 + B3 re-plant tree): - The fork's rank-invariant mask payload (entries 209/290, B3's mask-packs-only-when-TRAILING_PAGES refinement) is KEPT on hybrid_cache_controller._sync_prefetch_hit_query; the wrapper only converts a failed reduce into "no agreed boundary" ({} verdicts, 0 hits), so the collective PAYLOAD contract is unchanged. Verified against the tests' reduce mocks (trailing_endpoint, buffer_mode_sidecar). - Upstream's guarded scheduler-thread reduce inside get_prefetch_submission does not exist on this tree (sgl-project#43344 shape, which the PR's own 60c5f3e rebase resolved the same way): the ticket thread runs the hit query, so the failure hook lands on its unconditional except-exit, and the fork's test_command_failure keeps later submissions ticketed. - The health bit folds into _sync_hicache_ready_counts AFTER the queue- size reads (flag-published-before-item order: a counted failed item implies the 0 bit in the same round), keeping the entry-293 pending_storage_hits park/drain and identity guard in _drain_and_alloc_storage_hit between the PR's degraded inserts; the entry-294 deferred ready-sync stays a no-op path (it refuses storage-attached setups). - The PR's shm-exchange split-out of the health bit (its 60c5f3e merge resolution) FOLDS IN HERE: this tree already carries the shm exchange, so a 4-tuple return from the mins path would break the 5-tuple unpack at this commit. Row width stays 8, so storage-enabled rounds take the gloo reduce until the PR's shm-width commit lands (test_shm_tag_exchange expectations track that). - parse_storage_backend_extra_config REGISTERS storage_failure_policy and storage_sync_timeout (non-consuming validate; attach stays the application point), so a bad extra-config fails at parse time on both the boot and runtime PUT paths. - check_prefetch_progress degrades via the entry-217 deadline machinery WITHOUT retry re-arm (poll_miss stays un-armed exactly like the deadline branch; the shared retry cap of entry 293 is untouched). - Fork-only test stubs that bypass __init__ memoize the new attribute in the same convention: test_hybrid_storage_sparse_allocation's TestSparseCheckpointCacheDrain cache gains storage_unavailable=False (its drain reaches the new degraded reads; the file does not exist upstream so the PR could not adapt it). Gate at this commit (CVD=9, prod venv, PYTHONPATH=wt/python): trailing_ endpoint 17P, pp_prefetch_ticket 17P/19sub, buffer_mode_sidecar 6P/6sub, storage_prefetch_lifecycle 28P/31sub, sparse_allocation (entry-290) 13P/14sub, pp_sync_drain 4P, async_ready 7P, shm_tag_exchange green, NEW test_hicache_storage_sync_recovery 4P/4sub (2-rank gloo spawn, CPU-honest), managers trio green; import sglang proven from the tree. (cherry picked from commit 6fa9f21) (cherry picked from commit e63240993bd528a90d0d323035f08217de07a9b6)
5 tasks
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
Query each PP rank’s local storage and allocate prefetch buffers before synchronizing the usable prefix. Combine storage hits and allocation success in the existing MIN reduction, enabling file and other storage backends to use the same PP prefetch flow.
Remove Mooncake’s cross-rank query path and trim surplus buffers after synchronization, preserving the existing prefetch admission and completion interfaces.
Modifications
Accuracy Tests
Speed Tests and Profiling
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ✅ Run #39187608720
Latest PR Test (Extra): ✅ Run #39187608707
Latest PR Test (AMD ROCm 10): ❌ Run #39187608715