summaryrefslogtreecommitdiff
path: root/tests/test_canon_rope.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_canon_rope.py')
-rw-r--r--tests/test_canon_rope.py13
1 files changed, 13 insertions, 0 deletions
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()