[Feature] Support batch invariant rms norm with residual (#42453)

Signed-off-by: yewentao256 <zhyanwentao@126.com>
This commit is contained in:
Wentao Ye
2026-06-03 15:22:01 -04:00
committed by GitHub
parent a248b45d05
commit dad95e34d8
3 changed files with 39 additions and 41 deletions
+10 -6
View File
@@ -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)