[Kernel] Migrate DSA + DSV4 attention kernels to sglang.kernels (RFC #29630, Phase 2.5, 5/7) (#30792)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
4ae9cc3c81
commit
ba5be86d42
@@ -9,8 +9,8 @@ from typing import Tuple
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
from sglang.srt.layers.attention.dsa.tilelang_kernel import act_quant
|
||||
from sglang.srt.layers.attention.dsa.triton_kernel import act_quant as act_quant_triton
|
||||
from sglang.kernels.ops.attention.dsa.tilelang_kernel import act_quant
|
||||
from sglang.kernels.ops.attention.dsa.triton_kernel import act_quant as act_quant_triton
|
||||
|
||||
|
||||
def benchmark_kernel(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import torch
|
||||
|
||||
from sglang.srt.layers.attention.dsa.index_buf_accessor import (
|
||||
from sglang.kernels.ops.attention.dsa.index_buf_accessor import (
|
||||
_get_k_and_s_triton_kernel,
|
||||
)
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ Test coverage:
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
from sglang.srt.layers.attention.dsa.index_buf_accessor import GetK, GetKAndS, GetS
|
||||
from sglang.kernels.ops.attention.dsa.index_buf_accessor import GetK, GetKAndS, GetS
|
||||
|
||||
|
||||
class MockDSATokenToKVPool:
|
||||
|
||||
@@ -15,7 +15,7 @@ from sglang.kernels.ops.attention.deepseek_v4_rope import (
|
||||
apply_rotary_emb_triton,
|
||||
precompute_freqs_cis,
|
||||
)
|
||||
from sglang.srt.layers.attention.dsv4.fp4_indexer import (
|
||||
from sglang.kernels.ops.attention.dsv4.fp4_indexer import (
|
||||
quantize_fp4_indexer_tensor,
|
||||
store_fp4_index_k_cache,
|
||||
)
|
||||
|
||||
@@ -188,7 +188,7 @@ def _reference_quantize_and_store(
|
||||
|
||||
def _import_act_quant():
|
||||
try:
|
||||
from sglang.srt.layers.attention.dsa.triton_kernel import act_quant
|
||||
from sglang.kernels.ops.attention.dsa.triton_kernel import act_quant
|
||||
|
||||
return act_quant
|
||||
except Exception:
|
||||
|
||||
@@ -720,7 +720,7 @@ class TestDSAIndexer(CustomTestCase):
|
||||
self.assertEqual(indexer.layer_id, self.config["layer_id"])
|
||||
|
||||
@patch("sglang.srt.layers.attention.dsa.dsa_indexer.deep_gemm")
|
||||
@patch("sglang.srt.layers.attention.dsa.triton_kernel.act_quant")
|
||||
@patch("sglang.kernels.ops.attention.dsa.triton_kernel.act_quant")
|
||||
def test_forward_extend_mode(self, mock_act_quant, mock_deep_gemm):
|
||||
"""Test indexer forward pass in extend mode."""
|
||||
if not self.supports_fp8:
|
||||
@@ -802,7 +802,7 @@ class TestDSAIndexer(CustomTestCase):
|
||||
)
|
||||
|
||||
@patch("sglang.srt.layers.attention.dsa.dsa_indexer.deep_gemm")
|
||||
@patch("sglang.srt.layers.attention.dsa.triton_kernel.act_quant")
|
||||
@patch("sglang.kernels.ops.attention.dsa.triton_kernel.act_quant")
|
||||
def test_forward_decode_mode(self, mock_act_quant, mock_deep_gemm):
|
||||
"""Test indexer forward pass in decode mode."""
|
||||
if not self.supports_fp8:
|
||||
|
||||
@@ -3,8 +3,8 @@ from unittest.mock import patch
|
||||
|
||||
import torch
|
||||
|
||||
import sglang.srt.layers.attention.dsa.transform_index as transform_index_module
|
||||
from sglang.srt.layers.attention.dsa.transform_index import (
|
||||
import sglang.kernels.ops.attention.dsa.transform_index as transform_index_module
|
||||
from sglang.kernels.ops.attention.dsa.transform_index import (
|
||||
transform_index_page_table_decode_fast,
|
||||
transform_index_page_table_prefill_fast,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user