__init__.py 1.66 KB
Newer Older
1
2
3
import ctypes
import os

4
5
import torch

6
7
8
9
10
11
if os.path.exists("/usr/local/cuda/targets/x86_64-linux/lib/libcudart.so.12"):
    ctypes.CDLL(
        "/usr/local/cuda/targets/x86_64-linux/lib/libcudart.so.12",
        mode=ctypes.RTLD_GLOBAL,
    )

12
13
from sgl_kernel import common_ops
from sgl_kernel.allreduce import *
14
15
16
17
from sgl_kernel.attention import (
    cutlass_mla_decode,
    cutlass_mla_get_workspace_size,
    lightning_attention_decode,
Yineng Zhang's avatar
Yineng Zhang committed
18
    merge_state,
19
    merge_state_v2,
20
)
21
from sgl_kernel.elementwise import (
22
23
24
25
26
27
28
29
30
    apply_rope_with_cos_sin_cache_inplace,
    fused_add_rmsnorm,
    gelu_and_mul,
    gelu_tanh_and_mul,
    gemma_fused_add_rmsnorm,
    gemma_rmsnorm,
    rmsnorm,
    silu_and_mul,
)
31
from sgl_kernel.gemm import (
32
    awq_dequantize,
33
    bmm_fp8,
Trevor Morris's avatar
Trevor Morris committed
34
    cutlass_scaled_fp4_mm,
35
36
37
    fp8_blockwise_scaled_mm,
    fp8_scaled_mm,
    int8_scaled_mm,
Trevor Morris's avatar
Trevor Morris committed
38
    scaled_fp4_quant,
39
    sgl_per_tensor_quant_fp8,
40
    sgl_per_token_group_quant_fp8,
41
    sgl_per_token_group_quant_int8,
42
    sgl_per_token_quant_fp8,
43
)
44
from sgl_kernel.grammar import apply_token_bitmask_inplace_cuda
45
46
47
48
49
50
from sgl_kernel.moe import (
    fp8_blockwise_scaled_grouped_mm,
    moe_align_block_size,
    moe_fused_gate,
    topk_softmax,
)
51
from sgl_kernel.sampling import (
52
53
54
55
56
57
    min_p_sampling_from_probs,
    top_k_renorm_prob,
    top_k_top_p_sampling_from_probs,
    top_p_renorm_prob,
    top_p_sampling_from_probs,
)
58
from sgl_kernel.speculative import (
59
    build_tree_kernel_efficient,
60
    segment_packbits,
61
    tree_speculative_sampling_target_only,
62
    verify_tree_greedy,
63
)
Lianmin Zheng's avatar
Lianmin Zheng committed
64
from sgl_kernel.version import __version__
65
66
67
68

build_tree_kernel = (
    None  # TODO(ying): remove this after updating the sglang python code.
)