From a0ddfb1b2f6242fac72f98e8d6ee1888e79667f3 Mon Sep 17 00:00:00 2001 From: jdj Date: Thu, 29 Oct 2026 11:50:22 -0700 Subject: Validate offsets and canon_rope_attention shapes; default test device cuda:0 with safe skip; narrow README claims Co-Authored-By: Claude Opus 5.5 --- tests/test_canon_rope.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/test_canon_rope.py') diff --git a/tests/test_canon_rope.py b/tests/test_canon_rope.py index c9f939d..9a4db6e 100644 --- a/tests/test_canon_rope.py +++ b/tests/test_canon_rope.py @@ -39,6 +39,19 @@ class TestCanonRope(unittest.TestCase): for name, a, b in zip("qkv", ours, ref): self.assertTrue(torch.equal(a.reshape(b.shape), b), f"{name} differs from the Triton reference") + def test_canon_attention_rejects_bad_shapes(self): + from volta_kernels import canon_rope_attention + qkv, w, m1, m2, cos, sin = canon_inputs(B=1, T=192, doc_starts=(0,), dev=device()) + off = torch.tensor([0, 192], device=device()) + with self.assertRaisesRegex(RuntimeError, "128"): # T=192 passes fwd, fails bwd + canon_rope_attention(qkv, w, m1, m2, cos, sin, off) + qkv, w, m1, m2, cos, sin = canon_inputs(B=1, T=256, doc_starts=(0,), dev=device()) + off = torch.tensor([0, 256], device=device()) + with self.assertRaisesRegex(RuntimeError, "1536"): + canon_rope_attention(qkv[..., :1024].contiguous(), w, m1, m2, cos, sin, off) + with self.assertRaisesRegex(RuntimeError, "fp16"): + canon_rope_attention(qkv.float(), w, m1, m2, cos, sin, off) + if __name__ == "__main__": unittest.main() -- cgit v1.2.3