Skip to content

vllm.model_executor.hw_agnostic

Modules:

Functions:

  • resolve –

    Return layer name from module for the active path.

resolve(module, name)

Return layer name from module for the active path.

Returns vllm.model_executor.hw_agnostic.layers.<module>.<name> if VLLM_USE_HW_AGNOSTIC is set and that layer exists, else vllm.model_executor.layers.<module>.<name>. Falling back to the in-tree layer while VLLM_USE_HW_AGNOSTIC is set logs a warning.

The Transformers backend builds its layers through this function, so an out-of-tree plugin that subclasses the result and registers it with its register_oot overrides the class that backend builds on either path. Models with a native vLLM implementation always build the in-tree class, and overrides do not yet reach the backend's norms, which are subclasses of RMSNorm and GemmaRMSNorm.

Example

SiluAndMul = hw_agnostic.resolve("activation", "SiluAndMul")

@SiluAndMul.register_oot class MySiluAndMul(SiluAndMul): ...

Parameters:

  • module

    (str) –

    Module path relative to vllm.model_executor.layers, e.g. "layernorm".

  • name

    (str) –

    Name of the layer in that module, e.g. "RMSNorm".

Returns:

  • Any –

    The hw-agnostic or the in-tree object named name.

Raises:

  • AttributeError –

    name exists in neither module.

  • ImportError –

    The hw-agnostic module exists but fails to import, or the in-tree module does not exist.