Skip to content

Commit 59838cc

Browse files
committed
lint
1 parent 3a97902 commit 59838cc

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

backends/cuda/tests/test_tq4_sdpa.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import numpy as np
2121
import torch
2222
import torch.nn.functional as F
23-
2423
from executorch.backends.cuda.cuda_backend import CudaBackend
2524
from executorch.backends.cuda.cuda_partitioner import CudaPartitioner
2625
from 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

backends/cuda/triton/kernels/tq4_sdpa.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,9 +1158,7 @@ def _tq4_sdpa_decode_reduce_kernel(
11581158
o_s = tl.load(o_ptrs)
11591159

11601160
# Rescale by exp(m_s - m_global)
1161-
alpha = tl.where(
1162-
m_global > -float("inf"), tl.math.exp2(m_s - m_global), 0.0
1163-
)
1161+
alpha = tl.where(m_global > -float("inf"), tl.math.exp2(m_s - m_global), 0.0)
11641162
acc += o_s * alpha
11651163
l_global += l_s * alpha
11661164

0 commit comments

Comments
 (0)