[CI][Test] Deflake the rms_norm scaling-property assertions (#54271)

Signed-off-by: Oxana Korzh <okorzh@amd.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

Oxana Korzh committed Aug 28, 2026 at 18:08 UTC 1a16c2ad2cb43b68b99a25965ebdb799c690968d
1 file changed +10 -4
tests/kernels/ir/test_layernorm.py
+10 -4
@@ -12,7 +12,7 @@ from tests.ir.ir_test_utils import (
12 clone_args,
13 supported_providers,
14 )
15 -from tests.kernels.allclose_default import get_default_rtol
15 +from tests.utils import set_random_seed
16 from vllm import ir
17 from vllm.platforms import current_platform
18
@@ -52,6 +52,7 @@ def test_rms_norm_registration():
52 )
53 class TestRMSNorm:
54 def test_native_semantics(self, dtype, n_tokens, hidden_size, epsilon):
55 + set_random_seed(0)
56 x, weight, epsilon = ir.ops.rms_norm.generate_inputs(
57 num_tokens=4,
58 hidden_size=8,
@@ -66,9 +67,13 @@ class TestRMSNorm:
67 assert out.dtype == x.dtype
68 assert out.device == x.device
69
69 - # Check the scaling property of rms norm
70 + # Check the scaling property of rms norm. This holds only
71 + # approximately: epsilon does not scale with x, so
72 + # rms_norm(2x) = x / sqrt(mean(x^2) + epsilon/4), which differs from
73 + # rms_norm(x) by the epsilon term. Use the op's declared tolerance
74 + # rather than a tighter hard-coded one.
75 out2 = rms_norm_native(x * 2.0, weight, epsilon=epsilon)
71 - torch.testing.assert_close(out2, out, rtol=get_default_rtol(out), atol=1e-3)
76 + assert_close(ir.ops.rms_norm, out2, out)
77
78 # Mean square should be approximately 1 (ignoring epsilon and weight scaling)
79 combined_norm = out.float() / weight.float()
@@ -266,6 +271,7 @@ def test_vllm_c_fused_add_rms_norm_accepts_nd_input():
271 )
272 class TestFusedAddRMSNorm:
273 def test_native_semantics(self, dtype, n_tokens, hidden_size, epsilon):
274 + set_random_seed(0)
275 x, x_residual, weight, eps = ir.ops.fused_add_rms_norm.generate_inputs(
276 num_tokens=4,
277 hidden_size=8,
@@ -304,7 +310,7 @@ class TestFusedAddRMSNorm:
310 out2, _ = fused_add_rms_norm_native(
311 x * 2.0, torch.zeros_like(x), weight, epsilon=epsilon
312 )
307 - torch.testing.assert_close(out2, out1, rtol=get_default_rtol(out), atol=1e-3)
313 + assert_close(ir.ops.fused_add_rms_norm, out2, out1)
314
315 # Check behavior with and without weight
316 weight1 = torch.ones_like(weight)