[Edge][WP3] Add CPU OmniPlatform (AR + generation stages on vLLM's CPU backend)

* vllm_omni/platforms/cpu/platform.py: CPUOmniPlatform(OmniPlatform, CpuPlatform)
  selected when VLLM_TARGET_DEVICE=cpu or a +cpu vLLM wheel is installed
  (builtin plugin "cpu"; explicit CPU target short-circuits accelerator probes
  like vLLM does). NUMA-based memory queries, one logical device, no graph
  wrapper (sentinel type for isinstance checks), inductor opt-in via
  VLLM_OMNI_CPU_INDUCTOR=1, diffusion stages unsupported.
* vllm_omni/platforms/cpu/worker: CPUARWorker / CPUGenerationWorker compose
  vLLM's CPUWorker with the Omni mixin (XPU pattern); CPUARModelRunner /
  CPUGenerationModelRunner compose the Omni runners with CPUModelRunner
  (no graphs, no async omni output; sleep/wake return error ACKs).
* patch.py skips the CuMem patch on CPU-only torch; Qwen3-TTS speaker encoder
  and prompt-embeds dtype follow the model dtype (float32/float16 on CPU).
* vllm_omni/deploy/qwen3_tts.yaml: `platforms: cpu:` overlay (eager, no async
  scheduling, absolute kv_cache_memory_bytes, disjoint OMP thread ranges).
* requirements/cpu.txt (+psutil, intel-openmp), docs/getting_started/installation/cpu.md.

Measured (this x86 Xeon 8480C host, vllm 0.28.0+cpu, bf16, 12+4 threads):
Qwen3-TTS 0.6B CustomVoice end-to-end on CPU, 12 prompts: TTFA p50 292 ms,
RTF ~1.7 (25-frame chunk ~4.6 s), init 185 s. Result JSON + init timeline
committed under benchmarks/tts/edge_results/.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
tzhouamandClaude Fable 5.1 committed 2026-09-09 11:02:14 +08:00
1 parent 55192de984
commit 35e43b9983
18 files changed
+1740 -7

No files matched your search

@@ -0,0 +1,2 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
@@ -0,0 +1,62 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
"""CPU model runners for Omni AR and generation stages.
MRO: ``CPUARModelRunner -> GPUARModelRunner -> OmniGPUModelRunner -> (omni
mixins) -> CPUModelRunner -> GPUModelRunner``. ``CPUModelRunner.__init__``
runs vLLM's CPU shims (torch.cuda placeholders, ``_postprocess_tensors``,
``_postprocess_triton``) around ``GPUModelRunner.__init__``; the Omni layers
then add their buffers on the CPU device. Nothing CUDA-graph related can be
reached because ``CpuPlatform.check_and_update_config`` forces
``cudagraph_capture_sizes=[]`` and ``async_scheduling=False``.
"""
from __future__ import annotations
from vllm.logger import init_logger
from vllm.v1.worker.cpu_model_runner import CPUModelRunner
from vllm_omni.worker.gpu_ar_model_runner import GPUARModelRunner
from vllm_omni.worker.gpu_generation_model_runner import GPUGenerationModelRunner
logger = init_logger(__name__)
class _CPUOmniRunnerMixin:
"""Overrides shared by the CPU AR and generation runners."""
def _assert_cpu_invariants(self) -> None:
if getattr(self, "use_async_scheduling", False):
raise RuntimeError(
"CPU Omni runners require async_scheduling=False (vLLM's CpuPlatform forces it); "
"the async omni-output path uses CUDA streams."
)
def _init_device_properties(self) -> None:
self.num_sms = None
def _sync_device(self) -> None:
return None
def capture_model(self) -> int:
# No graphs on CPU; keep the call cheap and explicit.
return 0
def _capture_talker_mtp_graphs(self) -> None:
return None
class CPUARModelRunner(_CPUOmniRunnerMixin, GPUARModelRunner, CPUModelRunner):
"""AR (talker / thinker) runner on CPU."""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._assert_cpu_invariants()
class CPUGenerationModelRunner(_CPUOmniRunnerMixin, GPUGenerationModelRunner, CPUModelRunner):
"""Generation (code2wav / decoder) runner on CPU."""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._assert_cpu_invariants()
@@ -0,0 +1,63 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
"""CPU workers for Omni AR and generation stages (XPU-worker pattern).
``CPUWorker`` owns the CPU specifics (NUMA binding, ``init_cpu_memory_env``,
gloo, NUMA-based ``determine_available_memory``, no cudagraph warm-up); the
Omni mixin only loads omni plugins in the worker process. Sleep/wake are not
supported on CPU and return an error ACK instead of raising in the RPC loop.
"""
from __future__ import annotations
import vllm.v1.worker.cpu.shm # noqa: F401 # patches torch.Event/torch.cuda.Stream; must be first
from vllm.logger import init_logger
from vllm.v1.worker.cpu_worker import CPUWorker
from vllm_omni.diffusion.data import OmniACK
from vllm_omni.engine.init_timeline import timed_phase
from vllm_omni.platforms.cpu.worker.cpu_ar_model_runner import CPUARModelRunner, CPUGenerationModelRunner
from vllm_omni.worker.mixins import OmniWorkerMixin
logger = init_logger(__name__)
class _CPUOmniWorkerMixin:
model_runner_cls: type
@timed_phase("init_device")
def init_device(self) -> None:
super().init_device() # type: ignore[misc]
if getattr(self, "use_v2_model_runner", False):
logger.warning("OMNI CPU worker forces v1 model runner for omni hooks.")
self.use_v2_model_runner = False
# CPUWorker.init_device built a plain CPUModelRunner; replace it with the omni runner.
self.model_runner = self.model_runner_cls(self.vllm_config, self.device)
@staticmethod
def _task_id(task) -> str:
if isinstance(task, dict):
return str(task.get("task_id", ""))
return str(getattr(task, "task_id", ""))
def handle_sleep_task(self, task) -> OmniACK:
return OmniACK(
task_id=self._task_id(task), status="ERROR", error_msg="sleep mode is not supported on the CPU OmniPlatform"
)
def handle_wake_task(self, task) -> OmniACK:
return OmniACK(
task_id=self._task_id(task), status="ERROR", error_msg="wake-up is not supported on the CPU OmniPlatform"
)
class CPUARWorker(_CPUOmniWorkerMixin, OmniWorkerMixin, CPUWorker):
"""CPU AR worker for thinker / talker stages."""
model_runner_cls = CPUARModelRunner
class CPUGenerationWorker(_CPUOmniWorkerMixin, OmniWorkerMixin, CPUWorker):
"""CPU generation worker for decoder / code2wav stages."""
model_runner_cls = CPUGenerationModelRunner
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
"""Import-path shim: the CPU generation worker lives next to the AR worker."""
from vllm_omni.platforms.cpu.worker.cpu_ar_worker import CPUGenerationWorker
__all__ = ["CPUGenerationWorker"]