[Feature] Support batch invariant rms norm with residual (#42453)
Signed-off-by: yewentao256 <zhyanwentao@126.com>
This commit is contained in:
@@ -106,12 +106,16 @@ class RMSNorm(CustomOp):
|
||||
x: torch.Tensor,
|
||||
residual: torch.Tensor | None = None,
|
||||
) -> torch.Tensor | tuple[torch.Tensor, torch.Tensor]:
|
||||
if (
|
||||
envs.VLLM_BATCH_INVARIANT
|
||||
and residual is None
|
||||
and self.variance_size_override is None
|
||||
):
|
||||
return rms_norm_batch_invariant(x, self.weight.data, self.variance_epsilon)
|
||||
if envs.VLLM_BATCH_INVARIANT:
|
||||
assert self.variance_size_override is None, (
|
||||
"Batch invariance is not supported for variance_size_override"
|
||||
)
|
||||
return rms_norm_batch_invariant(
|
||||
x,
|
||||
self.weight.data,
|
||||
self.variance_epsilon,
|
||||
residual=residual,
|
||||
)
|
||||
|
||||
return self.forward_native(x, residual)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user