Skip to content

Commit 40ede34

Browse files
committed
[KMCompiler][Test] Compare an override at the operator's own tolerance
1 parent a8a683c commit 40ede34

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

tests/test_fused_deepseek_v4_qnorm_rope_kv_rope_quant_insert.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,5 +695,16 @@ def test_backend_override_matches_generic(
695695
"bytes differ"
696696
)
697697
# q goes through a 512-element RMSNorm reduction whose tree may legitimately
698-
# differ between decompositions, so allow a bf16 ULP there.
699-
torch.testing.assert_close(q, q_gen, rtol=1e-3, atol=1e-3)
698+
# differ between decompositions: a 2-D [TPP, 512] tile assigns lanes
699+
# differently than a 1-D 512 block, so `variance` rounds differently, and
700+
# that propagates through rsqrt into the stored bf16. Measured on a Hygon
701+
# BW1000 at num_tokens=511: 5 of 16744448 elements differ, by up to 2 bf16
702+
# ULP (7.8e-3 absolute, 7.8e-3 relative).
703+
#
704+
# The tolerance is the operator's own -- the same rtol/atol the accuracy
705+
# tests above use against the torch reference. Asserting that an override
706+
# tracks the generic kernel more closely than either tracks the reference
707+
# would be asserting something the operator never promised. (It is in fact
708+
# bit-identical on MetaX C550, but that is a property of one backend's lane
709+
# assignment, not a contract.)
710+
torch.testing.assert_close(q, q_gen, rtol=1e-2, atol=1e-2)

0 commit comments

Comments
 (0)