vllm.model_executor.layers.fla.ops.layernorm_guard ¶
LayerNormFn ¶
Bases: Function
Source code in vllm/model_executor/layers/fla/ops/layernorm_guard.py
forward staticmethod
¶
forward(
ctx,
x,
weight,
bias,
z=None,
eps=1e-06,
group_size=None,
norm_before_gate=True,
is_rms_norm=False,
)
If z is not None, we do norm(x) * silu(z) if norm_before_gate, else norm(x * silu(z))
Source code in vllm/model_executor/layers/fla/ops/layernorm_guard.py
LayerNormGated ¶
Bases: Module
Source code in vllm/model_executor/layers/fla/ops/layernorm_guard.py
__init__ ¶
__init__(
hidden_size,
eps: float = 1e-05,
group_size: int | None = None,
norm_before_gate: bool = True,
device: device | None = None,
dtype: dtype | None = None,
)
If group_size is not None, we do GroupNorm with each group having group_size elements. group_size=None is equivalent to group_size=hidden_size (i.e. there's only 1 group).
Source code in vllm/model_executor/layers/fla/ops/layernorm_guard.py
forward ¶
If z is not None, we do norm(x) * silu(z) if norm_before_gate, else norm(x * silu(z))
Source code in vllm/model_executor/layers/fla/ops/layernorm_guard.py
RMSNormGated ¶
Bases: Module
Source code in vllm/model_executor/layers/fla/ops/layernorm_guard.py
__init__ ¶
__init__(
hidden_size,
eps: float = 1e-05,
group_size: int | None = None,
norm_before_gate: bool = False,
device: device | None = None,
dtype: dtype | None = None,
)
If group_size is not None, we do GroupNorm with each group having group_size elements. group_size=None is equivalent to group_size=hidden_size (i.e. there's only 1 group).
Source code in vllm/model_executor/layers/fla/ops/layernorm_guard.py
forward ¶
If z is not None, we do norm(x) * silu(z) if norm_before_gate, else norm(x * silu(z))
Source code in vllm/model_executor/layers/fla/ops/layernorm_guard.py
_get_sm_count cached
¶
Get and cache the SM count for a given device.
calc_rows_per_block ¶
Source code in vllm/model_executor/layers/fla/ops/layernorm_guard.py
layer_norm_fwd ¶
layer_norm_fwd(
x: Tensor,
weight: Tensor,
bias: Tensor,
eps: float,
z: Tensor = None,
out: Tensor = None,
group_size: int = None,
norm_before_gate: bool = True,
is_rms_norm: bool = False,
)
Source code in vllm/model_executor/layers/fla/ops/layernorm_guard.py
layer_norm_fwd_kernel ¶
layer_norm_fwd_kernel(
X,
Y,
W,
B,
Z,
Mean,
Rstd,
stride_x_row,
stride_y_row,
stride_z_row,
M,
N: constexpr,
eps,
BLOCK_N: constexpr,
ROWS_PER_BLOCK: constexpr,
HAS_BIAS: constexpr,
HAS_Z: constexpr,
NORM_BEFORE_GATE: constexpr,
IS_RMS_NORM: constexpr,
)
Source code in vllm/model_executor/layers/fla/ops/layernorm_guard.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 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 |
|
layernorm_fn ¶
layernorm_fn(
x,
weight,
bias,
z=None,
eps=1e-06,
group_size=None,
norm_before_gate=True,
is_rms_norm=False,
)
Source code in vllm/model_executor/layers/fla/ops/layernorm_guard.py
rms_norm_ref ¶
rms_norm_ref(
x,
weight,
bias,
z=None,
eps=1e-06,
group_size=None,
norm_before_gate=True,
upcast=True,
)