[Fix][NPU] fix dp-attn hang when pin_mem is True on NPU (#40446)
This commit is contained in:
@@ -70,6 +70,9 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend):
|
||||
initializer=self._device_module.set_device,
|
||||
initargs=(self._device_id,),
|
||||
)
|
||||
# Event of the last replay; the next rebind waits on it so the device is
|
||||
# done reading the host-side seq_lens array before we rewrite it.
|
||||
self._rebind_fence = None
|
||||
|
||||
@contextmanager
|
||||
def capture_session(self, stream):
|
||||
@@ -175,11 +178,18 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend):
|
||||
|
||||
graph = self._graphs[shape_key]
|
||||
|
||||
if self._rebind_fence is not None:
|
||||
self._rebind_fence.synchronize()
|
||||
|
||||
update_future = self._update_executor.submit(
|
||||
graph.update, cpu_update_input=cpu_update_input
|
||||
)
|
||||
graph.replay()
|
||||
update_future.result()
|
||||
|
||||
fence = self._device_module.Event()
|
||||
fence.record()
|
||||
self._rebind_fence = fence
|
||||
return self._outputs[shape_key]
|
||||
|
||||
def cleanup(self) -> None:
|
||||
|
||||
@@ -56,7 +56,9 @@ class NPUDeviceMixin(DeviceMixin):
|
||||
return torch.npu.mem_get_info(device_id)
|
||||
|
||||
def is_pin_memory_available(self, device=None) -> bool:
|
||||
return False
|
||||
if device is not None and str(device) == "cpu":
|
||||
return False
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def seed_everything(cls, seed: int | None = None) -> None:
|
||||
|
||||
Reference in New Issue
Block a user