Skip to content

Commit 195e99a

Browse files
committed
Hold the global vector cumsum to the tolerance its example allows
CI reached 1.4e-5 on five of 262144 values against the 1e-5 this asserted. The example holds three of its four variants to 1e-5 and this one to 1e-4, which the test flattened to 1e-5 for all four. The looser bound is the right one here: the other three accumulate within a chunk while this one runs the length of the sequence, and the kernel and the reference reach the same sum in a different order. The order depends on how the work divides across cores, which is why 256 elements passed on one machine and not on the other.
1 parent 44dd81f commit 195e99a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

examples_experiment/cumsum_kda/test_example_cumsum_kda.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,9 @@ def test_chunk_global_cumsum_vector(batch, heads, seq_len, s_dim, reverse, head_
119119
actual = example.chunk_global_cumsum_vector(s, reverse=reverse, head_first=head_first)
120120
expected = example.ref_chunk_global_cumsum_vector(s, reverse=reverse, head_first=head_first)
121121

122-
torch.testing.assert_close(actual.cpu(), expected.cpu(), rtol=1e-5, atol=1e-5)
122+
# 1e-4 rather than the 1e-5 the other three hold, which is what the example
123+
# itself allows here: this variant accumulates across the whole sequence
124+
# instead of within a chunk, and the kernel and the reference reach the same
125+
# sum in a different order. At 256 elements that showed up as five values in
126+
# 262144 landing 1.4e-5 apart.
127+
torch.testing.assert_close(actual.cpu(), expected.cpu(), rtol=1e-4, atol=1e-4)

0 commit comments

Comments
 (0)