multiproc_xpu_executor.py 921 B

123456789101112131415161718192021222324
  1. import aphrodite.common.envs as envs
  2. from aphrodite.common.utils import make_async
  3. from aphrodite.executor.multiproc_gpu_executor import (
  4. MultiprocessingGPUExecutor, MultiprocessingGPUExecutorAsync)
  5. from aphrodite.executor.xpu_executor import XPUExecutor
  6. class MultiprocessingXPUExecutor(MultiprocessingGPUExecutor, XPUExecutor):
  7. """Python multiprocessing-based multi-XPU executor"""
  8. def _check_executor_parameters(self):
  9. mp_method = envs.APHRODITE_WORKER_MULTIPROC_METHOD
  10. if mp_method != "spawn":
  11. raise RuntimeError(
  12. "XPU multiprocess executor only support spawn as mp method"
  13. )
  14. class MultiprocessingXPUExecutorAsync(
  15. MultiprocessingXPUExecutor, MultiprocessingGPUExecutorAsync
  16. ):
  17. def __init__(self, *args, **kwargs):
  18. super().__init__(*args, **kwargs)
  19. self.driver_exec_model = make_async(self.driver_worker.execute_model)