refactor: rename gqa_* to attn_*, split-KV for all decode paths
- Rename all csrc/kernels/gqa_*.cuh/cu to attn_*, with _split_q / _split_kv strategy suffix and optional _mma compute suffix - Remove non-split MMA decode kernel, keep only split-KV path - Convert scalar decode fallback to split-KV (o_part/ml_part + combine) - Move combine kernel to attn_decode_split_kv.cuh (shared by both paths) - Rename GQAParams to AttentionParams - Update all C++ #include, PYBIND11, and Python extension references
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
"""CUDA attention kernel wrappers with torch fallback.
|
||||
|
||||
Public API:
|
||||
- ``gqa_decode_attn`` — single-query decode attention
|
||||
- ``gqa_prefill_attn`` — multi-query prefill attention
|
||||
- ``attn_decode`` — single-query decode attention
|
||||
- ``attn_prefill`` — multi-query prefill attention
|
||||
|
||||
Each wrapper dispatches to its compiled CUDA kernel (``astrai.extension.gqa_*``)
|
||||
Each wrapper dispatches to its compiled CUDA kernel (``astrai.extension.attn_*``)
|
||||
when available, otherwise falls back to ``torch.nn.functional.scaled_dot_product_attention``.
|
||||
"""
|
||||
|
||||
from astrai.extension.loader import KERNEL_NAMES, is_available
|
||||
from astrai.extension.ops import gqa_decode_attn, gqa_prefill_attn
|
||||
from astrai.extension.ops import attn_decode, attn_prefill
|
||||
|
||||
__all__ = [
|
||||
"gqa_decode_attn",
|
||||
"gqa_prefill_attn",
|
||||
"attn_decode",
|
||||
"attn_prefill",
|
||||
"is_available",
|
||||
"KERNEL_NAMES",
|
||||
]
|
||||
|
||||
@@ -11,7 +11,7 @@ import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
KERNEL_NAMES = ["gqa_decode_attn", "gqa_prefill_attn"]
|
||||
KERNEL_NAMES = ["attn_decode", "attn_prefill"]
|
||||
|
||||
_available: dict[str, bool] = {}
|
||||
_modules: dict[str, object] = {}
|
||||
|
||||
@@ -42,7 +42,7 @@ def _torch_fallback(
|
||||
)
|
||||
|
||||
|
||||
def gqa_decode_attn(
|
||||
def attn_decode(
|
||||
q: torch.Tensor,
|
||||
k: torch.Tensor,
|
||||
v: torch.Tensor,
|
||||
@@ -51,8 +51,8 @@ def gqa_decode_attn(
|
||||
causal_offset: int = 0,
|
||||
scale: float | None = None,
|
||||
) -> torch.Tensor:
|
||||
if _available["gqa_decode_attn"]:
|
||||
return _modules["gqa_decode_attn"].gqa_decode_attn(
|
||||
if _available["attn_decode"]:
|
||||
return _modules["attn_decode"].attn_decode(
|
||||
q,
|
||||
k,
|
||||
v,
|
||||
@@ -64,7 +64,7 @@ def gqa_decode_attn(
|
||||
return _torch_fallback(q, k, v, mask, is_causal, scale)
|
||||
|
||||
|
||||
def gqa_prefill_attn(
|
||||
def attn_prefill(
|
||||
q: torch.Tensor,
|
||||
k: torch.Tensor,
|
||||
v: torch.Tensor,
|
||||
@@ -73,8 +73,8 @@ def gqa_prefill_attn(
|
||||
causal_offset: int = 0,
|
||||
scale: float | None = None,
|
||||
) -> torch.Tensor:
|
||||
if _available["gqa_prefill_attn"]:
|
||||
return _modules["gqa_prefill_attn"].gqa_prefill_attn(
|
||||
if _available["attn_prefill"]:
|
||||
return _modules["attn_prefill"].attn_prefill(
|
||||
q,
|
||||
k,
|
||||
v,
|
||||
|
||||
Reference in New Issue
Block a user