Skip to content

Reset local prefix cache on sleep - #5035

Merged
RunningLeon merged 6 commits into
InternLM:mainfrom
RunningLeon:fix/sleep-prefix-cache
Oct 21, 2026
Merged

RunningLeon merged 6 commits into
InternLM:mainfrom
RunningLeon:fix/sleep-prefix-cache

Conversation

@RunningLeon

Copy link
Copy Markdown
Collaborator

Motivation

Sleep discards worker cache storage but leaves local prefix-cache metadata intact, causing stale KV and state-checkpoint reuse after wakeup.

Modification

  • Clear local prefix-cache blocks and state checkpoints after workers and KV transfers drain.
  • Preserve remote Store objects for normal post-wakeup reloads.
  • Add regression coverage for cache ownership and sleep/wakeup ordering.

Validation: 394 unit tests passed. DP4/EP4 E2E passed for GLM-5.3 Flash with MTP3 and Qwen3 Mooncake Store with prefix caching on/off (96 requests). GLM-5.3 + Store is unsupported on the base branch.

Checklist

  • Pre-commit checks passed.
  • Regression tests added.
  • No new downstream dependency requirements.
  • Lifecycle docstrings updated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved issues were identified in ownership cleanup, drain ordering, or regression coverage.

0 open findings

What changed in this PR

Prevents stale local KV-cache and state-checkpoint reuse after sleep while preserving remote Store objects for normal reloads.

Changes:

  • Reset local prefix-cache metadata after workers and transfers drain.
  • Guard cache cleanup against live references and pinned checkpoints.
  • Add ownership and sleep/wakeup regression coverage.
File Description
tests/​pytorch/​paging/​test_scheduler_kv_transfer.py Tests transfer draining and cache reset guards.
tests/​pytorch/​paging/​test_block_trie/​test_clear.py Tests ownership release, idempotence, and pin protection.
tests/​pytorch/​engine/​test_engine_sleep.py Tests cache invalidation and sleep/wakeup ordering.
lmdeploy/​pytorch/​paging/​scheduler.py Coordinates transfer completion and local cache reset.
lmdeploy/​pytorch/​paging/​block_trie/​trie.py Adds guarded prefix-cache cleanup.
lmdeploy/​pytorch/​engine/​engine.py Invokes cache reset after worker sleep.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@RunningLeon RunningLeon removed the WIP label Oct 19, 2026
Comment thread lmdeploy/pytorch/engine/model_agent/agent.py Outdated
@RunningLeon
RunningLeon merged commit 2b3464e into InternLM:main Oct 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants