Skip to content

vllm.model_executor.models.transformers.fusers.rms_norm

RMSNorm fuser: detect the norm structurally and swap in vLLM's fused RMSNorm.

Classes:

  • RMSNormFuser –

    Fuser for RMSNorm patterns, including Gemma-style zero-centered weights.

  • TPAwareGemmaRMSNorm –

    GemmaRMSNorm that reconstructs a TP-sharded input before normalizing.

  • TPAwareNormMixin –

    Mixin for RMSNorms that reconstructs a TP-sharded input before normalizing.

  • TPAwareRMSNorm –

    RMSNorm that reconstructs a TP-sharded input before normalizing.

RMSNormFuser dataclass

Bases: BaseFuser

Fuser for RMSNorm patterns, including Gemma-style zero-centered weights.

Methods:

  • fuse –

    Fuse the matched RMSNorm pattern into a vLLM fused RMSNorm CustomOp.

  • match –

    Match a graph to the RMSNorm pattern, returning a fuser if found.

Attributes:

  • eps (float | None) –

    eps itself, when it is not held in an attribute (see _eps_source).

  • eps_attr (str | None) –

    Attribute holding eps, read per instance in fuse.

  • source_cls (str) –

    Class name of the norm this was matched from (for logging).

  • zero_centered (bool) –

    Gemma-style (1 + weight) scaling (weight initialised at zero).

eps = None class-attribute instance-attribute

eps itself, when it is not held in an attribute (see _eps_source).

eps_attr = None class-attribute instance-attribute

Attribute holding eps, read per instance in fuse.

source_cls instance-attribute

Class name of the norm this was matched from (for logging).

zero_centered instance-attribute

Gemma-style (1 + weight) scaling (weight initialised at zero).

_eps_from_graph(graph) staticmethod

Extract the eps constant from the graph, if present.

_eps_source(graph, module) classmethod

Where fuse should read eps from, resolved once per class.

fuse(module, prefix, vllm_config)

Fuse the matched RMSNorm pattern into a vLLM fused RMSNorm CustomOp.

match(graph, module) classmethod

Match a graph to the RMSNorm pattern, returning a fuser if found.

TPAwareGemmaRMSNorm

Bases: TPAwareNormMixin, GemmaRMSNorm

GemmaRMSNorm that reconstructs a TP-sharded input before normalizing.

TPAwareNormMixin

Bases: Module

Mixin for RMSNorms that reconstructs a TP-sharded input before normalizing.

TPAwareRMSNorm

Bases: TPAwareNormMixin, RMSNorm

RMSNorm that reconstructs a TP-sharded input before normalizing.

_has_trailing_compute(graph, node)

Does the forward compute anything after node before returning?

_is_inverse_sqrt(node)

Detect rsqrt(v), or the pow(v, -0.5) / v ** -0.5 spelling of it.

_is_one_plus(node)

1 + weight in either operand order (marks a zero-centered weight).

_is_squared(node, x)

x**2, x.square() or x * x, through any dtype casts.

_operand(node, index, name)

Operand index of node, whether it was passed positionally or as name.

_variance_eps(rsqrt, x)

eps from rsqrt(mean(x**2, -1) + eps), or None if not that shape.