2020import numpy as np
2121import torch
2222import torch .nn .functional as F
23-
2423from executorch .backends .cuda .cuda_backend import CudaBackend
2524from executorch .backends .cuda .cuda_partitioner import CudaPartitioner
2625from executorch .backends .cuda .triton .kernels .tq4_sdpa import tq4_sdpa
@@ -596,7 +595,7 @@ def _run_splitk_vs_fused_test(
596595 seed = 42 ,
597596 ):
598597 """Verify split-K output matches fused kernel output for same inputs.
599-
598+
600599 Runs tq4_sdpa twice: once with kv_len (triggers split-K for Lq=1, kv_len>=256),
601600 and once without kv_len (forces fused kernel path). Both outputs must match
602601 within fp tolerance, proving split-K computes the same result.
@@ -648,7 +647,7 @@ def _run_splitk_vs_fused_test(
648647 k_norms_sliced = k_norms [:, :, :kv_len , :]
649648 v_packed_sliced = v_packed [:, :, :kv_len , :]
650649 v_norms_sliced = v_norms [:, :, :kv_len , :]
651-
650+
652651 out_fused = self .tq4_sdpa (
653652 q ,
654653 k_packed_sliced ,
@@ -693,9 +692,14 @@ def test_kv_len_clamp_decode_gemma_global_splitk(self):
693692 for N in (8192 , 32768 ):
694693 with self .subTest (N = N ):
695694 # Run with split-K (kv_len >= 256 triggers split-K)
696- cos = self ._run_long_kv_test (
697- H_q = 8 , H_kv = 4 , D = 512 , Lq = 1 , kv_len = N , buffer_len = 32768 ,
698- min_cosine = 0.99
695+ _ = self ._run_long_kv_test (
696+ H_q = 8 ,
697+ H_kv = 4 ,
698+ D = 512 ,
699+ Lq = 1 ,
700+ kv_len = N ,
701+ buffer_len = 32768 ,
702+ min_cosine = 0.99 ,
699703 )
700704 # Also verify split-K matches fused kernel by running without kv_len
701705 # (which forces fused kernel path) and comparing outputs
@@ -717,9 +721,14 @@ def test_kv_len_clamp_decode_qwen_splitk(self):
717721 Verifies split-K output matches BOTH fp32 reference AND fused kernel."""
718722 for N in (8192 , 32768 ):
719723 with self .subTest (N = N ):
720- cos = self ._run_long_kv_test (
721- H_q = 16 , H_kv = 2 , D = 256 , Lq = 1 , kv_len = N , buffer_len = 32768 ,
722- min_cosine = 0.99
724+ _ = self ._run_long_kv_test (
725+ H_q = 16 ,
726+ H_kv = 2 ,
727+ D = 256 ,
728+ Lq = 1 ,
729+ kv_len = N ,
730+ buffer_len = 32768 ,
731+ min_cosine = 0.99 ,
723732 )
724733 self ._run_splitk_vs_fused_test (
725734 H_q = 16 , H_kv = 2 , D = 256 , Lq = 1 , kv_len = N , buffer_len = 32768
0 commit comments