[Feature] Support JIT set kv cache (#16273)
This commit is contained in:
@@ -17,12 +17,12 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
@cache_once
|
||||
def _jit_norm_module(head_dims: int, dtype: torch.dtype) -> Module:
|
||||
args = make_cpp_args(head_dims, is_arch_support_pdl(), dtype)
|
||||
def _jit_qknorm_module(head_dim: int, dtype: torch.dtype) -> Module:
|
||||
args = make_cpp_args(head_dim, is_arch_support_pdl(), dtype)
|
||||
return load_jit(
|
||||
"norm",
|
||||
"qknorm",
|
||||
*args,
|
||||
cuda_files=["norm.cuh"],
|
||||
cuda_files=["elementwise/qknorm.cuh"],
|
||||
cuda_wrappers=[("qknorm", f"QKNormKernel<{args}>::run")],
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ def can_use_fused_inplace_qknorm(head_dim: int, dtype: torch.dtype) -> bool:
|
||||
logger.warning(f"Unsupported head_dim={head_dim} for JIT QK-Norm kernel")
|
||||
return False
|
||||
try:
|
||||
_jit_norm_module(head_dim, dtype)
|
||||
_jit_qknorm_module(head_dim, dtype)
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to load JIT QK-Norm kernel: {e}")
|
||||
@@ -51,5 +51,5 @@ def fused_inplace_qknorm(
|
||||
head_dim: int = 0,
|
||||
) -> None:
|
||||
head_dim = head_dim or q.size(-1)
|
||||
module = _jit_norm_module(head_dim, q.dtype)
|
||||
module = _jit_qknorm_module(head_dim, q.dtype)
|
||||
module.qknorm(q, k, q_weight, k_weight, eps)
|
||||
|
||||
Reference in New Issue
Block a user