Skip to content

[Bugfix] Fix write-through events not processed when scheduler is idle#20560

Merged
hnyls2002 merged 1 commit intosgl-project:mainfrom
youngrok-XCENA:youngrok/fix-hicache-write-through-idle
Mar 17, 2026
Merged

[Bugfix] Fix write-through events not processed when scheduler is idle#20560
hnyls2002 merged 1 commit intosgl-project:mainfrom
youngrok-XCENA:youngrok/fix-hicache-write-through-idle

Conversation

@youngrok-XCENA
Copy link
Copy Markdown
Contributor

@youngrok-XCENA youngrok-XCENA commented Mar 14, 2026

Motivation

I am developing CXL memory-based KV cache sharing (Maru). HiCache's 3-tier hierarchy (L1 GPU → L2 Host → L3 Storage) is a great fit for this, so I integrated it as an L3 backend and started validation testing.

During KV sharing tests between two SGLang instances, I found that write-through completions are never flushed to L3 storage while the scheduler is idle. check_hicache_events() is called inside _get_new_batch_prefill_raw() after an early return that fires when waiting_queue is empty. During idle periods, the method returns before reaching check_hicache_events(), so the write-through pipeline (GPU→Host→L3) never completes and the other instance sees zero cache hits.
This bug affects all HiCache L3 backends (not just Maru) when using write-through policy.

Modifications

Move check_hicache_events() call before the early-return condition in _get_new_batch_prefill_raw(), so write-through completions and prefetch events are processed on every scheduler tick regardless of whether new prefill work is available.

Checklist

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@xiezhq-hermann xiezhq-hermann self-assigned this Mar 17, 2026
@hnyls2002
Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@hnyls2002 hnyls2002 merged commit 079a1fd into sgl-project:main Mar 17, 2026
85 of 109 checks passed
JustinTong0323 pushed a commit to JustinTong0323/sglang that referenced this pull request Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants