[Feature, Hardware] Enable SGLang on XPU GPUs via PyTorch (#1480)

This commit is contained in:
Zhang, Liangang
2024-10-12 18:10:32 +00:00
committed by GitHub
parent e37cdab0c6
commit 5d638c92f5
8 changed files with 55 additions and 19 deletions
@@ -26,7 +26,9 @@ from sglang.srt.layers.attention.triton_ops.prefill_attention import (
context_attention_fwd,
)
CUDA_CAPABILITY = torch.cuda.get_device_capability()
is_cuda_available = torch.cuda.is_available()
if is_cuda_available:
CUDA_CAPABILITY = torch.cuda.get_device_capability()
@triton.jit
@@ -286,12 +288,12 @@ def extend_attention_fwd(
BLOCK_DPE = 0
BLOCK_DV = triton.next_power_of_2(Lv)
if CUDA_CAPABILITY[0] >= 9:
if is_cuda_available and CUDA_CAPABILITY[0] >= 9:
if Lq <= 256:
BLOCK_M, BLOCK_N = (128, 64)
else:
BLOCK_M, BLOCK_N = (32, 64)
elif CUDA_CAPABILITY[0] >= 8:
elif is_cuda_available and CUDA_CAPABILITY[0] >= 8:
if Lq <= 128:
BLOCK_M, BLOCK_N = (128, 128)
elif Lq <= 256:
@@ -24,7 +24,9 @@ import torch
import triton
import triton.language as tl
CUDA_CAPABILITY = torch.cuda.get_device_capability()
is_cuda_available = torch.cuda.is_available()
if is_cuda_available:
CUDA_CAPABILITY = torch.cuda.get_device_capability()
@triton.jit
@@ -145,7 +147,7 @@ def _fwd_kernel(
def context_attention_fwd(q, k, v, o, b_start_loc, b_seq_len, max_input_len):
if CUDA_CAPABILITY[0] >= 8:
if is_cuda_available and CUDA_CAPABILITY[0] >= 8:
BLOCK = 128
else:
BLOCK = 64