summaryrefslogtreecommitdiff
path: root/tests/test_canon_rope.py
diff options
context:
space:
mode:
authorjdj <jdj@kunix.org>2026-10-29 11:50:22 -0700
committerjdj <jdj@kunix.org>2026-10-29 11:50:22 -0700
commita0ddfb1b2f6242fac72f98e8d6ee1888e79667f3 (patch)
treea6e19658bae8466cb177d2ade41ad9176d23c2f8 /tests/test_canon_rope.py
parent2a02fecc86a87a6f1639b80da932b1f9daed8f17 (diff)
downloadvolta-train-kernels-master.tar.gz
volta-train-kernels-master.zip
Validate offsets and canon_rope_attention shapes; default test device cuda:0 with safe skip; narrow README claimsHEADmaster
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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()