[HiCache] Check in-flight async ops in is_fully_idle() before attach/detach (#20746)

This commit is contained in:
Liangsheng Yin
2026-03-17 17:28:26 -07:00
committed by GitHub
parent c5d2528bff
commit 4d3976b6c5
5 changed files with 39 additions and 15 deletions
+19
View File
@@ -167,6 +167,25 @@ def download_image_with_retry(image_url: str, max_retries: int = 3) -> Image.Ima
time.sleep(2**i)
def flush_cache_with_retry(
base_url: str, retries: int = 5, interval: float = 2.0
) -> bool:
"""Flush device cache with retry.
The scheduler may still have in-flight HiCache async ops (GPU↔Host↔L3)
that prevent is_fully_idle() from returning True, so we retry.
"""
for _ in range(retries):
try:
response = requests.post(f"{base_url}/flush_cache", timeout=10)
if response.status_code == 200:
return True
except requests.RequestException:
pass
time.sleep(interval)
return False
def is_in_ci():
"""Return whether it is in CI runner."""
return get_bool_env_var("SGLANG_IS_IN_CI")