Skip to content

[Feat] hicache: Add opt-in legacy Mooncake cache fallback - #44844

Draft
alphabetc1 wants to merge 8 commits into
sgl-project:mainfrom
alphabetc1:feat-mooncake-legacy-fallback
Draft

alphabetc1 wants to merge 8 commits into
sgl-project:mainfrom
alphabetc1:feat-mooncake-legacy-fallback

Conversation

@alphabetc1

@alphabetc1 alphabetc1 commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Moving Mooncake KV objects into dtype-specific tenants in #38362 makes existing, compatible cache objects cold. Add an opt-in migration path that reads verified legacy data on a confirmed miss and promotes it into the new tenant.

Draft; depends on #38362. This branch is based on its head (9e81b5ed5b54e45ff68cff36bbacca5ab25da0c8). The diff against main currently includes that prerequisite; the new fallback is in the final feature commit. Rebase after #38362 merges.

Modifications

  • Add a separate legacy_fallback.py compatibility module. The option is off by default and requires matching stored dtype, host layout, page size, and an explicit verified_compatible=true operator attestation. Operators must verify the remaining representation/model/parallelism parameters and stop all legacy writers; unknown or mixed-format namespaces cannot be migrated safely.
  • Open a separate read-only legacy client in the original configured tenant, before the dtype suffix. It mounts no storage segment, performs no warmup writes, and does not register inference buffers or reuse the primary transfer engine.
  • Prefer primary objects. Fall back only on confirmed absence, validate exact byte length, copy into host buffers, and promote through the primary client. Legacy lookup/read failures remain misses; promotion errors preserve successful reads. Ordinary writes and clear operations never modify the legacy tenant.
  • Disable fallback on clear() to avoid restoring invalidated objects in that backend instance. Remove the option before restarting if those objects must remain invalidated.
  • Initially support ordinary embedded MHA/MLA pools, including multi-buffer reads. Reject standalone clients, unified/logical pools, hybrid/side pools, and group semantics rather than assuming the anchor dtype describes every payload.
  • Document the migration procedure, multi-tenant master requirements, and additional CPU-copy/per-object IO cost.

Accuracy Tests

  • 11 compatibility-module CPU tests passed, exercising actual ctypes buffer writes, primary-hit precedence, confirmed-miss gating, mixed batches, malformed declarations, missing/wrong-size/evicted legacy objects, multi-buffer scatter, and promotion/error handling.
  • Local execution bypassed only sglang.__init__ eager runtime imports using a namespace-package bootstrap; the compatibility implementation and CI registry were loaded normally. Mooncake clients are mocks.
  • Added integration tests for tenant/client setup, unsupported modes, backend read/existence hooks, and clear behavior. The full test_mooncake*.py suite could not collect in the local macOS environment because pybase64 is missing. These integration tests still require execution in the normal CPU CI environment.
  • Pre-commit checks on all five changed files passed.
  • No live Mooncake, RDMA, GPU inference, or model-accuracy run. Before ready-for-review, validate two simultaneous clients, master quotas, migration/promotion, and cleanup against a live multi-tenant Mooncake deployment.

Speed Tests and Profiling

Not run. The disabled mode creates no legacy client or additional RPC. Enabled migration adds a legacy bytes read, a CPU copy, and best-effort per-object promotion; it is intended for temporary warmup.

Checklist

  • Format changed files with pre-commit.
  • Add CPU regression tests.
  • Document configuration, migration assumptions, and limitations.
  • Run the complete Mooncake CPU suite in the normal CI environment.
  • Validate with a live multi-tenant Mooncake deployment.
  • Run inference accuracy and migration throughput checks.

CI States

Latest PR Test (Base): ❌ Run #38998199547
Latest PR Test (Extra): ❌ Run #38998199533
Latest PR Test (AMD ROCm 10): ❌ Run #38998199349

cursoragent and others added 8 commits October 11, 2026 16:04
Two SGLang instances sharing one Mooncake store with the same model
but different --kv-cache-dtype could reuse the wrong cache bytes.
Compose the logical device dtype into Mooncake tenant_id instead of
prefixing object keys, and require mooncake-transfer-engine>=0.3.12.

Co-authored-by: Teng Ma <[email protected]>
Preserve per-rank SSD offload directories alongside the shared tenant-aware setup helper. Adapt the dtype regression fixture to the current storage host-pool format interface.

Validation: all 42 Mooncake CPU unit tests and pre-commit checks on the six PR files passed. Live Mooncake and GPU integration tests were not run.
Signed-off-by: Teng Ma <[email protected]>
Reuse the existing Mooncake setup and tenant compatibility paths instead of refactoring KV and embedding initialization. Keep the shared logical-dtype config field and a single tenant composition helper. Consolidate dtype regressions into the existing tenant test fixture and shorten the documentation.

Validation: 38 Mooncake CPU unit tests and pre-commit on all five PR files passed. Live Mooncake and GPU tests were not run.
Signed-off-by: Teng Ma <[email protected]>
@github-actions github-actions Bot added documentation Improvements or additions to documentation hicache Hierarchical Caching for SGLang memory-pool labels Oct 17, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation hicache Hierarchical Caching for SGLang memory-pool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants