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–GemmaRMSNormthat reconstructs a TP-sharded input before normalizing. -
TPAwareNormMixin–Mixin for RMSNorms that reconstructs a TP-sharded input before normalizing.
-
TPAwareRMSNorm–RMSNormthat 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:
-
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).
Source code in vllm/model_executor/models/transformers/fusers/rms_norm.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
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.
Source code in vllm/model_executor/models/transformers/fusers/rms_norm.py
fuse(module, prefix, model_config, quant_config) ¶
Fuse the matched RMSNorm pattern into a vLLM fused RMSNorm CustomOp.
Source code in vllm/model_executor/models/transformers/fusers/rms_norm.py
match(graph, module) classmethod ¶
Match a graph to the RMSNorm pattern, returning a fuser if found.
Source code in vllm/model_executor/models/transformers/fusers/rms_norm.py
TPAwareGemmaRMSNorm ¶
Bases: TPAwareNormMixin, GemmaRMSNorm
GemmaRMSNorm that reconstructs a TP-sharded input before normalizing.
Source code in vllm/model_executor/models/transformers/fusers/rms_norm.py
TPAwareNormMixin ¶
Bases: Module
Mixin for RMSNorms that reconstructs a TP-sharded input before normalizing.
Source code in vllm/model_executor/models/transformers/fusers/rms_norm.py
TPAwareRMSNorm ¶
Bases: TPAwareNormMixin, RMSNorm
RMSNorm that reconstructs a TP-sharded input before normalizing.
Source code in vllm/model_executor/models/transformers/fusers/rms_norm.py
_has_trailing_compute(graph, node) ¶
Does the forward compute anything after node before returning?
Source code in vllm/model_executor/models/transformers/fusers/rms_norm.py
_is_one_plus(node) ¶
1 + weight in either operand order (marks a zero-centered weight).
Source code in vllm/model_executor/models/transformers/fusers/rms_norm.py
_is_squared(node, x) ¶
x**2, x.square() or x * x, through any dtype casts.
Source code in vllm/model_executor/models/transformers/fusers/rms_norm.py
_variance_eps(rsqrt, x) ¶
eps from rsqrt(mean(x**2, -1) + eps), or None if not that shape.