Skip to content

vllm.model_executor.kernels.linear.zentorch_utils

Gates zentorch CPU linear dispatch on platform/op availability.

Functions:

  • has_zentorch_op

    Return True when running on Zen CPU with all named ops registered.

_moe_activation_to_str(activation)

Normalize activation to a lowercase string (enum-safe).

Source code in vllm/model_executor/kernels/linear/zentorch_utils.py
def _moe_activation_to_str(activation: object) -> str:
    """Normalize activation to a lowercase string (enum-safe)."""
    if hasattr(activation, "value"):
        return str(activation.value).lower()
    return str(activation).lower()

has_zentorch_op(op_names)

Return True when running on Zen CPU with all named ops registered.

Source code in vllm/model_executor/kernels/linear/zentorch_utils.py
def has_zentorch_op(op_names: list[str]) -> bool:
    """Return ``True`` when running on Zen CPU with all named ops registered."""
    if not op_names:
        raise ValueError("has_zentorch_op requires at least one op name")
    if not current_platform.is_zen_cpu():
        return False
    ns = getattr(torch.ops, "zentorch", None)
    if ns is None:
        return False
    return all(hasattr(ns, op_name) for op_name in op_names)