Repository navigation
[Feature] Add graceful scheduler shutdown; free hisparse host buffer on exit - #28779
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements a graceful shutdown mechanism to release pinned host KV buffers (such as those used by HiSparse) in userspace, preventing process teardown from stalling in uninterruptible sleep during kernel reclaim. Key changes include adding explicit unregistration methods, handling SIGTERM in the scheduler process, and updating process termination utilities to support graceful timeouts. However, two critical issues were identified in the review: first, an undefined helper function _still_holding_resources in kill_process_tree will cause a NameError at runtime, which can be resolved by using psutil.wait_procs; second, due to PEP 475, the SIGTERM handler needs to raise SystemExit(0) to successfully interrupt blocking socket/pipe reads and trigger the cleanup block.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
/rerun-test test_dsa_glm5_hisparse.py |
|
Results for 🚀 |
|
Results for 🚀 |
…ul-teardown # Conflicts: # python/sglang/srt/mem_cache/memory_pool_host.py
|
/tag-and-rerun-ci |
|
Results for 🚀 |
The scheduler previously had no graceful-shutdown path — it was always SIGKILL'd, so its resources were reclaimed by the kernel. This adds a
ShutdownReqcontrol message that breaks the event loop (broadcast across TP ranks, so they stop in lockstep) and releases resources in userspace via arelease_host_resourceshook before exit.The first consumer unregisters HiSparse's large pinned host KV buffer (
cudaHostRegister'd, many GB per rank), whose kernel-side unpin on SIGKILL was stalling process teardown for tens of seconds (uninterruptible sleep).CI States
Latest PR Test (Base): 🚫 Run #27918296308
Latest PR Test (Extra): ❌ Run #27918296249