[HiCache] Optimize HiCache host pool free-list release - #30658
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
/tag-run-ci-label |
hzh0425
left a comment
There was a problem hiding this comment.
LGTM,PLS Add this optimization for MambaPoolHost.free() and DeepSeekV4PagedHostPool.free()
|
/rerun-group hicache |
|
Results for 🚀 🚀 🚀 🚀 |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
3 similar comments
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
| [self.free_slots, indices.to(dtype=torch.int64, device="cpu").flatten()] | ||
| ) | ||
| indices_cpu = indices.cpu() | ||
| if indices_cpu.numel() == 0: |
There was a problem hiding this comment.
should we still need flatten? @huangtingwei9988
There was a problem hiding this comment.
flatten() is redundant because indices is already 1-D
…0658) Co-authored-by: Zhangheng <hzh0425@apache.org>
…0658) Co-authored-by: Zhangheng <hzh0425@apache.org>

Motivation
HiCache host-pool
free()currently appends released slots back tofree_slotswith an eagertorch.cat:For large host pools,
free_slotscan contain millions of entries. Even when only a small number of slots is released, this operation copies the entire free-list on everyfree()call. In decode, this shows up insidescheduler.process_batch_resultafter HiCache write-back / host eviction and can introduce multi-millisecond CPU spikes.The fix is to make host-pool slot release lazy, matching the device allocator’s
free_pages + release_pagespattern:free()only records released chunks inrelease_slots.available_size()includes bothfree_slotsand pending released slots.alloc()continues to allocate fromfree_slotsdirectly while possible.free_slotsis insufficient doesalloc()mergerelease_slotsback intofree_slotsonce, then proceed with the normal allocation path.This removes the eager large
torch.catfrom the hotfree()path while preserving the existing free-list allocation semantics.benchmark
In this run, the host KV cache capacity reported by metrics was 6,611,072 token slots
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 #29303604544
Latest PR Test (Extra): ✅ Run #29303604433