Skip to content

[PD] Preserve decode KV across retraction in HiCache - #34801

Merged
cctry merged 5 commits into
sgl-project:mainfrom
cctry:shiyang/pd-host-pool-retraction-backup
Aug 17, 2026
Merged

cctry merged 5 commits into
sgl-project:mainfrom
cctry:shiyang/pd-host-pool-retraction-backup

Conversation

@cctry

@cctry cctry commented Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

PD decode retraction currently preserves KV in per-request CPU tensors. Reusing HiCache host pools avoids a second host-memory path and also lets speculative draft KV survive retraction.

Modifications

  • Add explicit and inferred cpu_tensor / host_pool retraction backends behind --disaggregation-decode-retraction-backup.
  • Resolve the backend once the decode KV pool exists, since it cannot be decided in ServerArgs.__post_init__. The resolved value lands on the config bags via get_context().override(...), and every reader goes through get_disagg() — server_args stays the pristine read-only record.
  • Make --hicache-ratio Optional and give it its default at that same point (1.0 for host-pool retraction, 2.0 otherwise), so a decode server can size the host pool 1:1 with the device pool. The hicache_ratio reads in hiradix_cache.py and hybrid_pool_assembler.py move to get_memory() accordingly — that is the only reason those two files appear in the diff.
  • Reserve and validate HiCache capacity for compatible MHA and hybrid-SWA decode pools.
  • Back up, restore, and discard target plus speculative draft sidecar KV through the flattened L2 transfer path from refactor(hicache): flatten L2 transfer execution #34793.
  • Force host-pool retraction in the PD EAGLE3 integration test and assert retracted requests retain speculative acceptance above the calibrated 1.3 gate.
  • Add a CUDA round-trip test that poisons both target and draft device KV before restoring them at different slots.

Accuracy Tests

Run on the current revision:

  • Python compilation for all changed files
  • All applicable pre-commit hooks on the changed files
  • The _EXPOSED / _OVERRIDDEN_AND_READ pin sets in test_supplied_instance_exposure_ratchet.py are unchanged by this PR, and the mutation / global-config-read ratchets stay at their zero baselines

Run on an earlier revision of this branch, before the rebase onto post-#34793 main:

  • test_decode_queue_cleanup.py
  • test_runtime_context_override.py
  • test_runtime_context_config_bags.py

The CUDA target/draft round-trip and the PD EAGLE3 integration test have not been executed locally (no GPU on the dev host). They are registered in CI.

Speed Tests and Profiling

Not run. The new transfers execute only when decode requests are retracted; the steady-state decode path is unchanged.

Checklist

  • Format code with pre-commit.
  • Add unit and integration tests.
  • Update documentation (no user-facing documentation change needed).
  • Provide accuracy and speed benchmark results (GPU tests are delegated to CI; no steady-state performance change).

CI States

Latest PR Test (Base): ✅ Run #31984438697
Latest PR Test (Extra): ❌ Run #31984438611

@cctry

cctry commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Aug 14, 2026
@cctry

cctry commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@cctry

cctry commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

Acceptance gate calibration: canonical EAGLE3 batch runs measured 1.4286, 1.4286, and 1.4085 (run 26970481008, run 27383114776, run 27389842523); the existing 1.3 EAGLE3 gate leaves 7-9% headroom. Historical MooncakeSpec runs were only about 1.07-1.10 because #21794 switched to EAGLE3 checkpoints but retained --speculative-algorithm EAGLE. Commit a7493ae8f7 corrects the flag to EAGLE3 and uses the calibrated 1.3 floor. Exact forced-retraction rerun: https://github.com/sgl-project/sglang/actions/runs/31770891046.

@cctry
cctry changed the base branch from main to oss/l2-transfer-consolidation August 14, 2026 04:49
@cctry
cctry force-pushed the shiyang/pd-host-pool-retraction-backup branch from a7493ae to 37db4bb Compare August 16, 2026 04:59
cctry and others added 5 commits August 16, 2026 00:34
resume_retracted_reqs now reads the retraction backend off the disagg
bag, so the case has to publish a config instead of injecting one
through a SimpleNamespace server_args.
The offload manager builds its own decode host pool, so pairing it with
the host_pool retraction backend double-books host memory. It also routes
the decode server to UnifiedRadixCache, whose protected_size is a read-only
property, crashing the offload manager's release path.

Auto-resolution now skips host_pool when offload is on, and an explicit
--disaggregation-decode-retraction-backup=host_pool is rejected.
@C1oud4ever

Copy link
Copy Markdown

In my project like 14P6D ,we enabled Hisparse to improve our concurrency , the whole kv cache were stored in host pool . In this scenario , this commit optimization seems to conflict with Hisparse?

@cctry

cctry commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

In my project like 14P6D ,we enabled Hisparse to improve our concurrency , the whole kv cache were stored in host pool . In this scenario , this commit optimization seems to conflict with Hisparse?

I am not familiar with Hisparse but before this PR retraction with Hisparse will crash the engine? Also, it is expected that the whole KI will be backed up so that the decode can resume.

@C1oud4ever

Copy link
Copy Markdown

In my project like 14P6D ,we enabled Hisparse to improve our concurrency , the whole kv cache were stored in host pool . In this scenario , this commit optimization seems to conflict with Hisparse?

I am not familiar with Hisparse but before this PR retraction with Hisparse will crash the engine? Also, it is expected that the whole KI will be backed up so that the decode can resume.

Yep,PD retraction triggers crashes of D-node in our production environment, so we rolled out fixes targeting this issue. However, these fixes introduced more side effects, including performance regression and the need for manual maintenance of the preallocation queue.

Seems Hisparse is not good enough in SGLang sofar :)

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

Labels

bypass-fastfail hicache Hierarchical Caching for SGLang run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants