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:
-
eps(float | None) –epsitself, when it is not held in an attribute (see_eps_source). -
eps_attr(str | None) –Attribute holding
eps, read per instance infuse. -
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
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 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
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.
Source code in vllm/model_executor/models/transformers/fusers/rms_norm.py
_eps_source(graph, module) classmethod ¶
Where fuse should read eps from, resolved once per class.
Source code in vllm/model_executor/models/transformers/fusers/rms_norm.py
fuse(module, prefix, vllm_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.