[lora] Fix overlap loading for cancelled requests (#25413)

This commit is contained in:
Erik Wijmans
2026-05-25 15:18:36 +09:00
committed by GitHub
parent 2bd3ac0b5d
commit 87e69d57c4
2 changed files with 98 additions and 9 deletions
+20 -9
View File
@@ -35,6 +35,10 @@ class LoRAOverlapLoader:
Check a LoRA adapter's asynchronous load status, and try to load it if there's capacity
in the memory pool. Returns whether or not the adapter has been loaded.
"""
# Drain completed async loads before status/capacity checks so finished
# adapters no longer count as in-flight.
self._drain_completed_overlap_loads()
lora_pipeline_load_status = self._check_overlap_load_status(lora_id)
if lora_pipeline_load_status == LoRAOverlapLoadStatus.LOADING:
return False
@@ -51,18 +55,25 @@ class LoRAOverlapLoader:
def _check_overlap_load_status(
self, lora_id: Optional[str]
) -> LoRAOverlapLoadStatus:
if lora_id not in self.lora_to_overlap_load_event:
return LoRAOverlapLoadStatus.NOT_LOADED
event = self.lora_to_overlap_load_event[lora_id]
if not event.query():
if lora_id in self.lora_to_overlap_load_event:
return LoRAOverlapLoadStatus.LOADING
torch.cuda.current_stream().wait_event(event)
del self.lora_to_overlap_load_event[lora_id]
# After completed events have been drained, a memory-pool entry with no
# pending event is safe to use on the current stream.
if lora_id in self.lora_manager.memory_pool.uid_to_buffer_id:
return LoRAOverlapLoadStatus.LOADED
return LoRAOverlapLoadStatus.LOADED
return LoRAOverlapLoadStatus.NOT_LOADED
def _drain_completed_overlap_loads(self) -> None:
completed_loads = [
(lora_id, event)
for lora_id, event in self.lora_to_overlap_load_event.items()
if event.query()
]
for lora_id, event in completed_loads:
torch.cuda.current_stream().wait_event(event)
del self.lora_to_overlap_load_event[lora_id]
def _try_start_overlap_load(
self, lora_id: Optional[str], running_loras: set[Optional[str]]