vllm.model_executor.layers.layernorm ¶
Custom normalization layers.
GemmaRMSNorm ¶
Bases: CustomOp
RMS normalization for Gemma.
Two differences from the above RMSNorm
- x * (1 + w) instead of x * w.
- (x * w).to(orig_dtype) instead of x.to(orig_dtype) * w.
Source code in vllm/model_executor/layers/layernorm.py
__init__ ¶
forward_cuda ¶
forward_cuda(
x: Tensor, residual: Optional[Tensor] = None
) -> Union[Tensor, tuple[Tensor, Tensor]]
Source code in vllm/model_executor/layers/layernorm.py
forward_native ¶
forward_native(
x: Tensor, residual: Optional[Tensor] = None
) -> Union[Tensor, tuple[Tensor, Tensor]]
PyTorch-native implementation equivalent to forward().
Source code in vllm/model_executor/layers/layernorm.py
forward_static staticmethod
¶
forward_static(
weight: Tensor,
variance_epsilon: float,
x: Tensor,
residual: Optional[Tensor],
) -> Union[Tensor, tuple[Tensor, Tensor]]
PyTorch-native implementation equivalent to forward().
Source code in vllm/model_executor/layers/layernorm.py
LayerNorm ¶
Bases: Module
Layer Normalization.
Source code in vllm/model_executor/layers/layernorm.py
__init__ ¶
Source code in vllm/model_executor/layers/layernorm.py
PolyNorm ¶
Bases: CustomOp
Polynomial normalization.
Computes x -> w_0 * RMSNorm(x^3) + w_1 * RMSNorm(x^2) + w_2 * RMSNorm(x) + b where w_n is the learned weight and b is the bias. Refer to https://arxiv.org/html/2411.03884v1
Source code in vllm/model_executor/layers/layernorm.py
_norm ¶
forward_cuda ¶
forward_native ¶
PyTorch-native implementation equivalent to forward().
Refer to https://github.com/BryceZhuo/PolyCom?tab=readme-ov-file/README.md
Source code in vllm/model_executor/layers/layernorm.py
RMSNorm ¶
Bases: CustomOp
Root mean square normalization.
Computes x -> w * x / sqrt(E[x^2] + eps) where w is the learned weight. Refer to https://arxiv.org/abs/1910.07467
Source code in vllm/model_executor/layers/layernorm.py
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 |
|
rocm_norm_func instance-attribute
¶
rocm_norm_func = dispatch_rocm_rmsnorm_func(
with_fused_add=False, dtype=weight_dtype
)
rocm_norm_func_with_add instance-attribute
¶
rocm_norm_func_with_add = dispatch_rocm_rmsnorm_func(
with_fused_add=True, dtype=weight_dtype
)
variance_size_override instance-attribute
¶
__init__ ¶
__init__(
hidden_size: int,
eps: float = 1e-06,
var_hidden_size: Optional[int] = None,
has_weight: bool = True,
dtype: Optional[dtype] = None,
) -> None
Source code in vllm/model_executor/layers/layernorm.py
forward_cuda ¶
forward_cuda(
x: Tensor, residual: Optional[Tensor] = None
) -> Union[Tensor, tuple[Tensor, Tensor]]
Source code in vllm/model_executor/layers/layernorm.py
forward_hip ¶
Source code in vllm/model_executor/layers/layernorm.py
forward_native ¶
forward_native(
x: Tensor, residual: Optional[Tensor] = None
) -> Union[Tensor, tuple[Tensor, Tensor]]
PyTorch-native implementation equivalent to forward().
Source code in vllm/model_executor/layers/layernorm.py
forward_xpu ¶
Source code in vllm/model_executor/layers/layernorm.py
dispatch_rocm_rmsnorm_func ¶
Source code in vllm/model_executor/layers/layernorm.py
fused_add_rms_norm ¶
fused_add_rms_norm(
x: Tensor,
residual: Tensor,
weight: Tensor,
variance_epsilon: float,
) -> tuple[Tensor, Tensor]
Source code in vllm/model_executor/layers/layernorm.py
poly_norm ¶
Source code in vllm/model_executor/layers/layernorm.py
rms_norm ¶
Source code in vllm/model_executor/layers/layernorm.py
rocm_aiter_rms_norm_fake ¶
rocm_aiter_rms_norm_impl ¶
Source code in vllm/model_executor/layers/layernorm.py
rocm_aiter_rmsnorm2d_fwd_with_add_fake ¶
rocm_aiter_rmsnorm2d_fwd_with_add_impl ¶
rocm_aiter_rmsnorm2d_fwd_with_add_impl(
x: Tensor,
residual: Tensor,
weight: Tensor,
variance_epsilon: float,
) -> tuple[Tensor, Tensor]