repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
sglang | python/sglang/srt/layers/dp_attention.py | .py | from __future__ import annotations
import functools
import logging
from contextlib import contextmanager
from enum import IntEnum, auto
from typing import TYPE_CHECKING, List, Optional, Tuple
import torch
import triton
import triton.language as tl
from sglang.srt.distributed import (
GroupCoordinator,
get_at... | 1,002 | 37,432 |
sglang | python/sglang/srt/layers/k3_ar_fusion.py | .py | """K3 MNNVL fused all-reduce dispatch.
Auto-enabled on SM100/SM103 when CustomAllReduceV2 with multicast is
available; ``SGLANG_K3_AR_FUSION`` overrides in either direction (0 = off,
1 = attempt anywhere and warn when unavailable).
Glue between the model and the ``kernels.ops.kimi_k3.all_reduce`` kernels. Small
messa... | 388 | 13,036 |
sglang | python/sglang/srt/layers/sampler.py | .py | import logging
from functools import partial
from typing import Callable, Dict, List, Optional, Tuple
import torch
import torch.distributed as dist
from torch import nn
from sglang.kernels.ops.sampling.murmur_hash import murmur_hash32
from sglang.srt.distributed import get_tp_group
from sglang.srt.layers.dp_attention... | 804 | 33,425 |
sglang | python/sglang/srt/layers/amx_utils.py | .py | import logging
import torch
import transformers
from sglang.srt.utils import cpu_has_amx_support
logger = logging.getLogger(__name__)
from enum import IntEnum
class CPUQuantMethod(IntEnum):
UNQUANT = 0
INT8_W8A8 = 1
FP8_W8A16 = 2
INT4_W4A8 = 3
MXFP4 = 4
class CPUQuantAlgo(IntEnum):
AWQ =... | 226 | 7,326 |
sglang | python/sglang/srt/layers/vocab_parallel_embedding.py | .py | # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# Adapted from https://github.com/vllm-project/vllm/blob/v0.6.3.post1/vllm/model_executor/layers/vocab_parallel_embedding.py
import logging
from dataclasses import dataclass
from typing import List, Optional, Seq... | 666 | 26,877 |
sglang | python/sglang/srt/layers/logsumexp.py | .py | """Single-pass online row logsumexp, optionally fused with a small top-k.
Reads the input exactly once with fp32 accumulation and writes per-row
``(max, log_sum_exp - max)`` fp32 pairs. Keeping the two terms separate lets
callers compute ``logprob[i] = (logit[i] - max) - log_sum`` the same
shift-invariant way log-soft... | 299 | 11,397 |
sglang | python/sglang/srt/layers/pooler.py | .py | # adapted from
# https://github.com/vllm-project/vllm/blob/82a1b1a82b1fbb454c82a9ef95730b929c9b270c/vllm/model_executor/layers/pooler.py
from __future__ import annotations
from dataclasses import dataclass
from enum import IntEnum
from typing import TYPE_CHECKING, List, Optional
import torch
import torch.nn as nn
fr... | 264 | 9,933 |
sglang | python/sglang/srt/layers/dcp/layout.py | .py | # Copyright 2023-2026 SGLang Team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 66 | 2,397 |
sglang | python/sglang/srt/layers/dcp/__init__.py | .py | # Copyright 2023-2026 SGLang Team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 83 | 3,469 |
sglang | python/sglang/srt/layers/dcp/planner.py | .py | # Copyright 2023-2026 SGLang Team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 189 | 6,240 |
sglang | python/sglang/srt/layers/dcp/comm.py | .py | # Copyright 2023-2026 SGLang Team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 573 | 19,970 |
sglang | python/sglang/srt/layers/quantization/w4afp8.py | .py | from __future__ import annotations
import logging
from typing import TYPE_CHECKING, Any, Dict, List, Optional
import torch
from torch.nn import Module
from torch.nn.parameter import Parameter
from sglang.srt.layers.quantization.base_config import (
FusedMoEMethodBase,
QuantizationConfig,
QuantizeMethodBa... | 432 | 15,076 |
sglang | python/sglang/srt/layers/quantization/w8a8_int8.py | .py | from __future__ import annotations
import logging
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, cast
import torch
from torch.nn.parameter import Parameter
from sglang.kernels.ops.quantization.int8_kernel import per_token_quant_int8
from sglang.srt.layers.amx... | 388 | 13,170 |
sglang | python/sglang/srt/layers/quantization/bitsandbytes.py | .py | # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# Adapted from: https://github.com/vllm-project/vllm/blob/d4d2751732c3ccae162a5a0160c7d4fe05d2779a/vllm/model_executor/layers/quantization/bitsandbytes.py
from __future__ import annotations
from typing import TYP... | 602 | 20,694 |
sglang | python/sglang/srt/layers/quantization/int8_utils.py | .py | from typing import List, Optional, Tuple
import torch
from sglang.kernels.ops.quantization.int8_kernel import (
per_token_group_quant_int8,
w8a8_block_int8_matmul,
)
def apply_w8a8_block_int8_linear(
input: torch.Tensor,
weight: torch.Tensor,
block_size: List[int],
weight_scale: torch.Tensor... | 74 | 2,357 |
sglang | python/sglang/srt/layers/quantization/base_scheme.py | .py | # SPDX-License-Identifier: Apache-2.0
from abc import ABC, abstractmethod
from typing import Optional
import torch
__all__ = ["BaseLinearScheme", "BaseMoEScheme"]
class BaseLinearScheme(ABC):
"""
Abstract class used to describe the weight creation and forward pass
of different quantization schemes.
... | 77 | 2,228 |
sglang | python/sglang/srt/layers/quantization/unquant.py | .py | from __future__ import annotations
import logging
from enum import Enum
from typing import TYPE_CHECKING, Callable, List, Optional
logger = logging.getLogger(__name__)
import torch
import torch.nn.functional as F
from torch.nn.parameter import Parameter
from sglang.kernels.fused_op import BaseFusedOp
from sglang.sr... | 967 | 37,195 |
sglang | python/sglang/srt/layers/quantization/moe_wna16.py | .py | # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# Adapted from https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/layers/quantization/moe_wna16.py
from __future__ import annotations
import logging
from typing import TYPE_CHECKING, Any, Dict, Li... | 511 | 19,467 |
sglang | python/sglang/srt/layers/quantization/marlin_utils_fp8.py | .py | # SPDX-License-Identifier: Apache-2.0
import logging
from typing import Optional
import torch
from sglang.srt.layers.quantization.marlin_utils import (
USE_FP32_REDUCE_DEFAULT,
marlin_make_workspace,
marlin_permute_bias,
marlin_permute_scales,
should_use_atomic_add_reduce,
)
from sglang.srt.layer... | 373 | 13,193 |
sglang | python/sglang/srt/layers/quantization/kvfp4_tensor.py | .py | # Copyright 2025 SGLang Team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, so... | 300 | 10,791 |
sglang | python/sglang/srt/layers/quantization/utils.py | .py | # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# Adapted from https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/layers/quantization/utils/quant_utils.py
from __future__ import annotations
import re
from copy import deepcopy
from types import... | 781 | 26,824 |
sglang | python/sglang/srt/layers/quantization/npu_mxfp4.py | .py | """MXFP4 W4A8 online quantization config (MXFP4 weights + MXFP8 activations).
Triggered by ``--quantization mxfp_w4a8``.
Online mode: FP16/BF16 weights are quantised to MXFP4 in
``process_weights_after_loading``; activations are dynamically quantised to
MXFP8 (``float8_e4m3fn`` + UE8M0 block scale) at inference time ... | 128 | 4,469 |
sglang | python/sglang/srt/layers/quantization/quark_int4fp8_moe.py | .py | import logging
from typing import TYPE_CHECKING, Any, Dict, List, Optional
import torch
from tqdm import tqdm
from tqdm.std import EMA
from sglang.srt.layers.int4fp8_utils import (
pack_int4_to_int32,
quantize_fp8_scale_tensorwise,
quantize_int4_scale_columnwise,
)
from sglang.srt.layers.moe import MoeRun... | 447 | 16,085 |
sglang | python/sglang/srt/layers/quantization/fp8.py | .py | # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# Adapted from https://github.com/vllm-project/vllm/blob/v0.6.4.post1/vllm/model_executor/layers/quantization/fp8.py
from __future__ import annotations
import logging
from typing import TYPE_CHECKING, Any, Dict,... | 2,717 | 113,852 |
sglang | python/sglang/srt/layers/quantization/petit.py | .py | # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# Adapted from https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/layers/quantization/modelopt.py
import logging
from typing import Any, Dict, List, Optional
import regex as re
import torch
from... | 256 | 9,101 |
sglang | python/sglang/srt/layers/quantization/__init__.py | .py | # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# Adapted from https://raw.githubusercontent.com/vllm-project/vllm/v0.5.5/vllm/model_executor/layers/quantization/__init__.py
from __future__ import annotations
import builtins
import inspect
from typing import T... | 174 | 5,912 |
sglang | python/sglang/srt/layers/quantization/mxfp4_flashinfer_cutlass_moe.py | .py | """DeepSeek-V4 MXFP4 expert backend backed by FlashInfer CUTLASS MoE.
``Fp8Config`` selects this backend for SM90 and SM120; SM100 uses the
TRT-LLM implementation.
"""
from __future__ import annotations
import logging
import os
from typing import TYPE_CHECKING
import torch
from torch.nn import Module
from torch.nn.... | 200 | 7,770 |
sglang | python/sglang/srt/layers/quantization/marlin_utils_fp4.py | .py | from __future__ import annotations
import logging
import torch
from sglang.srt.layers.quantization.marlin_utils import (
USE_FP32_REDUCE_DEFAULT,
marlin_make_workspace,
marlin_permute_bias,
marlin_permute_scales,
should_use_atomic_add_reduce,
)
from sglang.srt.layers.quantization.utils import get... | 556 | 21,378 |
sglang | python/sglang/srt/layers/quantization/humming_utils.py | .py | from typing import Any
import regex as re
import torch
from humming.layer import HummingInputSchema, HummingMethod
from humming.schema import BaseWeightSchema
from sglang.srt.environ import envs
from sglang.srt.layers.linear import LinearBase
from sglang.srt.layers.moe.fused_moe_triton.layer import FusedMoE
def hum... | 157 | 5,177 |
sglang | python/sglang/srt/layers/quantization/modelopt_quant.py | .py | # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# Adapted from https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/layers/quantization/modelopt.py
from __future__ import annotations
import logging
from typing import TYPE_CHECKING, Any, Dict, Lis... | 2,891 | 118,192 |
sglang | python/sglang/srt/layers/quantization/nvfp4_online.py | .py | # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from __future__ import annotations
import logging
import re
import threading
from typing import Any, Callable, Dict, List, Optional
import torch
from sglang.srt.environ import envs
from sglang.srt.layers.quant... | 683 | 24,998 |
sglang | python/sglang/srt/layers/quantization/marlin_utils.py | .py | # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# Adapted from https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/layers/quantization/utils/marlin_utils.py
from __future__ import annotations
import logging
from dataclasses import dataclass
fro... | 1,008 | 32,716 |
sglang | python/sglang/srt/layers/quantization/mxfp8_block_convert.py | .py | """Convert MXFP8 weights to block-fp8 [128,128] for AMD gfx942 (CDNA3 / MI300).
gfx942 has no hardware MX-scaled matmul: Triton's ``tl.dot_scaled`` fails to
lower and the gfx950 ``mfma_scale`` intrinsics are unavailable. So MXFP8
checkpoints (e4m3fn weights + 1x32 UE8M0 scales) are converted at load time to
block-wise... | 73 | 2,819 |
sglang | python/sglang/srt/layers/quantization/online_quantization.py | .py | # Adapted from https://github.com/vllm-project/vllm/pull/31914
import torch
from torch.utils._python_dispatch import TorchDispatchMode
class CopyNumelCounter(TorchDispatchMode):
"""
Tracks total number of elements modified with `copy_`. Useful for keeping
track of weight loading where underlying weights c... | 24 | 763 |
sglang | python/sglang/srt/layers/quantization/mxfp4_marlin_moe.py | .py | from __future__ import annotations
import logging
from typing import TYPE_CHECKING
import torch
from torch.nn import Module
from sglang.srt.layers.moe.moe_runner.marlin import MarlinMoeQuantInfo
from sglang.srt.layers.moe.utils import MoeRunnerBackend
from sglang.srt.utils import log_info_on_rank0, round_up, set_wei... | 197 | 7,525 |
sglang | python/sglang/srt/layers/quantization/mlx.py | .py | """Marker config and auto-detect hook for MLX backend quantization presets.
The MLX backend (``python/sglang/srt/hardware_backend/mlx/``) performs its own
quantization at model load time via :func:`mlx_lm.utils.quantize_model`. The
standard PyTorch ``QuantizationConfig`` machinery is never invoked on that
path.
This ... | 125 | 4,796 |
sglang | python/sglang/srt/layers/quantization/mxfp4_tensor.py | .py | # SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# ht... | 136 | 5,389 |
sglang | python/sglang/srt/layers/quantization/base_config.py | .py | # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# Adapted from https://raw.githubusercontent.com/vllm-project/vllm/v0.5.5/vllm/model_executor/layers/quantization/base_config.py
from __future__ import annotations
import inspect
from abc import ABC, abstractmeth... | 280 | 9,963 |
sglang | python/sglang/srt/layers/quantization/dequantization.py | .py | """
Utilities to manage the dequantization of weights.
"""
from typing import Optional
import torch
from sglang.srt.layers.quantization.fp8_utils import (
block_quant_dequant,
inverse_transform_scale_ue8m0,
)
from sglang.srt.utils import set_weight_attrs
NVFP4_BLOCK_SIZE = 16
_FP4_E2M1_LUT = torch.tensor(
... | 98 | 2,428 |
sglang | python/sglang/srt/layers/quantization/gguf.py | .py | # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# Adapted from: https://github.com/vllm-project/vllm/blob/ab3e80042eac24dd362408e6d63ad98768046359/vllm/model_executor/layers/quantization/gguf.py
from __future__ import annotations
import logging
import warnings... | 971 | 35,237 |
sglang | python/sglang/srt/layers/quantization/w8a8_fp8.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, List, Optional
import torch
from torch.nn.parameter import Parameter
from sglang.kernels.ops.quantization.fp8_kernel import (
fp8_dtype,
is_fp8_fnuz,
per_token_group_quant_fp8,
)
from sglang.srt.layers.moe import MoeRunner, M... | 309 | 10,549 |
sglang | python/sglang/srt/layers/quantization/fp4_kv_cache_quant_method.py | .py | # Copyright 2025 SGLang Team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, so... | 838 | 29,744 |
sglang | python/sglang/srt/layers/quantization/kv_cache.py | .py | # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# Adapted from https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/layers/quantization/kv_cache.py
import logging
import torch
from sglang.kernels.ops.quantization.fp8_kernel import is_fp8_fnuz
f... | 86 | 3,394 |
sglang | python/sglang/srt/layers/quantization/mxfp4.py | .py | # SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in complian... | 1,930 | 83,668 |
sglang | python/sglang/srt/layers/quantization/mxfp4_humming_moe.py | .py | from __future__ import annotations
import logging
from typing import TYPE_CHECKING
import torch
from torch.nn import Module, Parameter
from sglang.srt.layers.moe.utils import MoeRunnerBackend
from sglang.srt.utils import log_info_on_rank0
if TYPE_CHECKING:
from sglang.srt.layers.moe.token_dispatcher import Comb... | 102 | 3,178 |
sglang | python/sglang/srt/layers/quantization/auto_round.py | .py | # SPDX-License-Identifier: Apache-2.0
import logging
import re
from fractions import Fraction
from typing import Any, Optional, Union
import torch
logger = logging.getLogger(__name__)
from sglang.srt.layers.quantization.utils import get_scalar_types
ScalarType, scalar_types = get_scalar_types()
from sglang.srt.la... | 567 | 21,649 |
sglang | python/sglang/srt/layers/quantization/mxfp4_flashinfer_trtllm_moe.py | .py | from __future__ import annotations
import logging
from typing import TYPE_CHECKING
import torch
from torch.nn import Module
from torch.nn.parameter import Parameter
from sglang.kernels.ops.moe.pack_topk_ids import PackTopkIds
from sglang.srt.distributed import get_tp_group
from sglang.srt.distributed.device_communic... | 407 | 14,654 |
sglang | python/sglang/srt/layers/quantization/npu_mxfp4_w4a4.py | .py | """MXFP4 W4A4 online quantization config (dual-level MXFP4 weights + activations).
Triggered by ``--quantization mxfp4`` on the Ascend NPU backend. On CUDA / AMD /
CPU the ``mxfp4`` key resolves to the upstream :class:`Mxfp4Config` (OCP MXFP4
MoE) instead; the per-device split is done at registration time in
``sglang.... | 141 | 5,632 |
sglang | python/sglang/srt/layers/quantization/rocm_mxfp4_utils.py | .py | from aiter.ops.triton.batched_gemm_afp4wfp4_pre_quant import (
batched_gemm_afp4wfp4_pre_quant,
)
from aiter.ops.triton.fused_mxfp4_quant import (
fused_flatten_mxfp4_quant,
fused_rms_mxfp4_quant,
)
__all__ = [
"fused_rms_mxfp4_quant",
"fused_flatten_mxfp4_quant",
"batched_gemm_afp4wfp4_pre_qua... | 14 | 327 |
sglang | python/sglang/srt/layers/quantization/fp4_utils.py | .py | from __future__ import annotations
import logging
from enum import Enum
from typing import TYPE_CHECKING, Optional
import torch
from sglang.srt.utils.common import (
get_device_capability,
is_cuda,
is_sm100_supported,
)
from sglang.srt.utils.custom_op import register_custom_op_from_extern
if TYPE_CHECKI... | 167 | 5,454 |
sglang | python/sglang/srt/layers/quantization/petit_utils.py | .py | from typing import Optional
import torch
try:
from petit_kernel import mul_nvfp4_a16, process_nvfp4_scales, repack_nvfp4
except ImportError:
def _check_petit_nvfp4_supported(
quant_method: str, group_size: Optional[int]
) -> tuple[bool, Optional[str]]:
return (
False,
... | 105 | 3,245 |
sglang | python/sglang/srt/layers/quantization/humming.py | .py | # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import json
import math
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, List
import regex as re
import torch
from sglang.srt.environ import envs
from sglang.srt.layers.linear import L... | 916 | 35,754 |
sglang | python/sglang/srt/layers/quantization/blockwise_int8.py | .py | # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# Adapted from https://github.com/vllm-project/vllm/blob/v0.6.4.post1/vllm/model_executor/layers/quantization/fp8.py
from __future__ import annotations
import logging
from typing import TYPE_CHECKING, Any, Dict,... | 386 | 14,186 |
sglang | python/sglang/srt/layers/quantization/fp8_utils.py | .py | from __future__ import annotations
import logging
from enum import Enum
from functools import lru_cache, partial
from typing import TYPE_CHECKING, Callable, List, Optional, Tuple, Union
import torch
from sglang.kernels.ops.quantization.fp8_kernel import (
sglang_per_token_group_quant_fp8,
sglang_per_token_gr... | 2,108 | 77,013 |
sglang | python/sglang/srt/layers/quantization/quark/utils.py | .py | # SPDX-License-Identifier: Apache-2.0
import re
from collections.abc import Iterable, Mapping
from dataclasses import dataclass
from types import MappingProxyType
from typing import Any, Optional
@dataclass
class Nvfp4SourceConfig:
"""Dispatch marker for online NVFP4 -> MXFP4 re-quantization, carried on
`Qua... | 225 | 7,922 |
sglang | python/sglang/srt/layers/quantization/quark/weights.py | .py | # SPDX-License-Identifier: Apache-2.0
import math
import re
import torch
from sglang.srt.runtime_context import get_parallel
from sglang.srt.utils import is_cuda
_is_cuda = is_cuda()
def load_gptoss_weight_quark(
model,
weights,
*,
is_nextn: bool,
weight_name_mapping,
) -> None:
# Regex ma... | 244 | 9,396 |
sglang | python/sglang/srt/layers/quantization/quark/quark.py | .py | # SPDX-License-Identifier: Apache-2.0
import fnmatch
import logging
import re
from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast
import torch
from sglang.srt.layers.linear import LinearBase
from sglang.srt.layers.moe import MoeRunnerConfig
from sglang.srt.layers.quantization.base_config import ( # no... | 1,093 | 42,796 |
sglang | python/sglang/srt/layers/quantization/quark/schemes/quark_w8a8_fp8.py | .py | # SPDX-License-Identifier: Apache-2.0
from typing import Any, Callable, Optional, cast
import torch
from torch.nn import Parameter
from sglang.kernels.ops.quantization.fp8_kernel import is_fp8_fnuz
from sglang.srt.layers.parameter import (
ChannelQuantScaleParameter,
ModelWeightParameter,
PerTensorScaleP... | 187 | 6,918 |
sglang | python/sglang/srt/layers/quantization/quark/schemes/__init__.py | .py | # SPDX-License-Identifier: Apache-2.0
from .quark_scheme import QuarkLinearScheme, QuarkMoEScheme
from .quark_w4a4_mxfp4 import QuarkW4A4MXFP4
from .quark_w4a4_mxfp4_moe import QuarkW4A4MXFp4MoE
from .quark_w4a8_mxfp4_moe import QuarkW4A8MXFp4MoE
from .quark_w8a8_fp8 import QuarkW8A8Fp8
from .quark_w8a8_fp8_moe import... | 19 | 514 |
sglang | python/sglang/srt/layers/quantization/quark/schemes/quark_w4a8_mxfp4_moe.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import logging
from dataclasses import replace
from typing import TYPE_CHECKING, Any
import torch
from sglang.srt.environ import envs
from sglang.srt.layers.moe import MoeRunner, MoeRunnerBackend, MoeRunnerConfig
from sglang.srt.layers.moe.uti... | 408 | 15,677 |
sglang | python/sglang/srt/layers/quantization/quark/schemes/quark_w4a4_mxfp4.py | .py | # SPDX-License-Identifier: Apache-2.0
import logging
import threading
from typing import Any, Callable, Optional
import torch
from sglang.srt.layers.parameter import (
GroupQuantScaleParameter,
ModelWeightParameter,
PackedvLLMParameter,
PerTensorScaleParameter,
)
from sglang.srt.layers.quantization i... | 696 | 26,242 |
sglang | python/sglang/srt/layers/quantization/quark/schemes/quark_w8a8_fp8_moe.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import logging
from typing import TYPE_CHECKING, Any
import torch
from sglang.kernels.ops.quantization.fp8_kernel import is_fp8_fnuz, scaled_fp8_quant
from sglang.srt.layers.moe import MoeRunner, MoeRunnerBackend, MoeRunnerConfig
from sglang.s... | 313 | 12,534 |
sglang | python/sglang/srt/layers/quantization/quark/schemes/quark_w4a4_mxfp4_moe.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import logging
import threading
from typing import TYPE_CHECKING, Any
import torch
from sglang.srt.layers.moe import MoeRunner, MoeRunnerBackend, MoeRunnerConfig
from sglang.srt.layers.moe.utils import get_moe_weight_sizes
from sglang.srt.laye... | 891 | 37,247 |
sglang | python/sglang/srt/layers/quantization/quark/schemes/quark_scheme.py | .py | # SPDX-License-Identifier: Apache-2.0
from abc import abstractmethod
from typing import TYPE_CHECKING, Optional
import torch
from sglang.srt.layers.moe import MoeRunnerConfig
from sglang.srt.layers.quantization.base_scheme import BaseLinearScheme, BaseMoEScheme
if TYPE_CHECKING:
from sglang.srt.layers.moe.token... | 117 | 3,288 |
sglang | python/sglang/srt/layers/quantization/compressed_tensors/utils.py | .py | # Adapted from https://github.com/vllm-project/vllm/tree/main/vllm/model_executor/layers/quantization/compressed_tensors
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import re
from types import MappingProxyType
from typing import Iterable, List, Mapping, Op... | 235 | 8,490 |
sglang | python/sglang/srt/layers/quantization/compressed_tensors/compressed_tensors.py | .py | # Adapted from https://github.com/vllm-project/vllm/tree/main/vllm/model_executor/layers/quantization/compressed_tensors
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from __future__ import annotations
import logging
from contextlib import suppress
from typi... | 1,156 | 46,096 |
sglang | python/sglang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a8_int8_moe.py | .py | from __future__ import annotations
import logging
from typing import TYPE_CHECKING
import torch
from sglang.srt.hardware_backend.npu.quantization.moe_methods import (
NPUW4A8Int8MoEMethod,
)
from sglang.srt.layers.moe.moe_runner import MoeRunner, MoeRunnerConfig
from sglang.srt.layers.moe.utils import MoeRunnerB... | 303 | 11,339 |
sglang | python/sglang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_wNa16_moe.py | .py | from __future__ import annotations
import enum
import logging
from enum import Enum
from typing import TYPE_CHECKING
import torch
from compressed_tensors import CompressionFormat
from sglang.srt.hardware_backend.gpu.quantization.gptq_kernels import (
gptq_marlin_moe_repack,
)
from sglang.srt.hardware_backend.npu... | 732 | 27,606 |
sglang | python/sglang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a4_mxint4_moe.py | .py | from __future__ import annotations
import logging
from typing import TYPE_CHECKING
import torch
from compressed_tensors import CompressionFormat
from sglang.srt.distributed import get_tp_group
from sglang.srt.distributed.device_communicators.pynccl_allocator import (
use_symmetric_memory,
)
from sglang.srt.layer... | 365 | 14,189 |
sglang | python/sglang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a8_fp8_moe.py | .py | """W4AFP8 MoE scheme: INT4 group-quantized weights + 8-bit dynamic activations.
Loads INT4 weights from compressed-tensors pack-quantized format,
converts to CUTLASS W4A8 layout, and runs CUTLASS grouped GEMM
with dynamic 8-bit (FP8 or INT8) activation quantization.
"""
from __future__ import annotations
import logg... | 324 | 11,356 |
sglang | python/sglang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a8_int8_moe.py | .py | from __future__ import annotations
import logging
from typing import TYPE_CHECKING
import torch
from compressed_tensors.quantization import QuantizationStrategy
from sglang.srt.hardware_backend.npu.quantization.moe_methods import (
NPUW8A8Int8MoEMethod,
)
from sglang.srt.layers.moe.moe_runner import MoeRunner, M... | 158 | 5,677 |
sglang | python/sglang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a4_nvfp4.py | .py | # Adapted from https://github.com/vllm-project/vllm/tree/main/vllm/model_executor/layers/quantization/compressed_tensors
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import logging
from collections.abc import Callable
from typing import Optional
import torc... | 170 | 5,944 |
sglang | python/sglang/srt/layers/quantization/compressed_tensors/schemes/__init__.py | .py | # SPDX-License-Identifier: Apache-2.0
from .compressed_tensors_scheme import (
CompressedTensorsLinearScheme,
CompressedTensorsMoEScheme,
)
from .compressed_tensors_w4a4_mxint4_moe import CompressedTensorsMxInt4MoE
from .compressed_tensors_w4a4_nvfp4 import CompressedTensorsW4A4Fp4
from .compressed_tensors_w4a... | 47 | 1,832 |
sglang | python/sglang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_wNa16.py | .py | # Adapted from https://github.com/vllm-project/vllm/tree/main/vllm/model_executor/layers/quantization/compressed_tensors
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import logging
from typing import Callable, Optional
import torch
from compressed_tensors.... | 341 | 13,005 |
sglang | python/sglang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a4_nvfp4_moe.py | .py | from __future__ import annotations
import logging
from typing import TYPE_CHECKING
import torch
from sglang.srt.layers.moe import MoeRunner, MoeRunnerBackend, MoeRunnerConfig
from sglang.srt.layers.moe.utils import get_moe_runner_backend
from sglang.srt.layers.quantization.compressed_tensors.schemes import (
Com... | 364 | 13,826 |
sglang | python/sglang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a16_fp8.py | .py | # Adapted from https://github.com/vllm-project/vllm/tree/main/vllm/model_executor/layers/quantization/compressed_tensors
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from typing import Callable, List, Optional
import torch
from compressed_tensors.quantizat... | 137 | 5,063 |
sglang | python/sglang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a8_int8.py | .py | # Adapted from https://github.com/vllm-project/vllm/tree/main/vllm/model_executor/layers/quantization/compressed_tensors
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from typing import Callable, Optional
import torch
from compressed_tensors.quantization im... | 205 | 8,098 |
sglang | python/sglang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a8_fp8.py | .py | # Adapted from https://github.com/vllm-project/vllm/tree/main/vllm/model_executor/layers/quantization/compressed_tensors
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from typing import Callable, Optional
import torch
from compressed_tensors.quantization im... | 281 | 11,071 |
sglang | python/sglang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_scheme.py | .py | # Adapted from https://github.com/vllm-project/vllm/tree/main/vllm/model_executor/layers/quantization/compressed_tensors
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from abc import abstractmethod
from typing import TYPE_CHECKING, Optional
import torch
fr... | 119 | 3,549 |
sglang | python/sglang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a8_fp8_moe.py | .py | from __future__ import annotations
import logging
from typing import TYPE_CHECKING
import torch
from compressed_tensors.quantization import QuantizationStrategy
from sglang.kernels.ops.quantization.fp8_kernel import is_fp8_fnuz, scaled_fp8_quant
from sglang.srt.layers.moe import MoeRunner, MoeRunnerBackend, MoeRunne... | 446 | 18,204 |
sglang | python/sglang/srt/layers/quantization/gptq/__init__.py | .py | # SPDX-License-Identifier: Apache-2.0
from .gptq import (
CPUGPTQConfig,
GPTQAscendConfig,
GPTQConfig,
GPTQLinearMethod,
GPTQMarlinConfig,
GPTQMarlinLinearMethod,
GPTQMarlinMoEMethod,
GPTQMoEMethod,
check_marlin_format,
)
from .schemes import (
GPTQAscendLinearScheme,
GPTQIn... | 42 | 899 |
sglang | python/sglang/srt/layers/quantization/gptq/gptq.py | .py | from __future__ import annotations
import logging
from fractions import Fraction
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
import torch
from sglang.srt.layers.moe import MoeRunnerConfig
from sglang.srt.layers.quantization.base_config import (
FusedMoEMethodBase,
LinearMethodBase,
... | 650 | 22,146 |
sglang | python/sglang/srt/layers/quantization/gptq/schemes/gptq_linear.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING, Optional
import torch
from sglang.srt.layers.parameter import (
ChannelQuantScaleParameter,
GroupQuantScaleParameter,
PackedColumnParameter,
PackedvLLMParameter,
RowvLLMParameter,
)
from sgl... | 172 | 5,877 |
sglang | python/sglang/srt/layers/quantization/gptq/schemes/gptq_moe.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING
import torch
from sglang.srt.hardware_backend.npu.quantization.moe_methods import (
NPUWNA16Int4MoEMethod,
)
from sglang.srt.layers.linear import set_weight_attrs
from sglang.srt.layers.moe.moe_runner import... | 337 | 11,558 |
sglang | python/sglang/srt/layers/quantization/gptq/schemes/gptq_marlin.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING, Optional
import torch
from sglang.srt.layers.parameter import (
ChannelQuantScaleParameter,
GroupQuantScaleParameter,
PackedColumnParameter,
PackedvLLMParameter,
RowvLLMParameter,
)
from sgl... | 159 | 5,073 |
sglang | python/sglang/srt/layers/quantization/gptq/schemes/__init__.py | .py | # SPDX-License-Identifier: Apache-2.0
from .gptq_cpu import GPTQIntelAMXLinearScheme, GPTQIntelAMXMoEScheme
from .gptq_linear import GPTQAscendLinearScheme, GPTQLinearScheme
from .gptq_marlin import GPTQMarlinLinearScheme
from .gptq_moe import GPTQMarlinMoEScheme, GPTQMoEAscendScheme
from .gptq_scheme import GPTQLinea... | 20 | 618 |
sglang | python/sglang/srt/layers/quantization/gptq/schemes/gptq_cpu.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING
import torch
from sglang.srt.hardware_backend.cpu.quantization.gptq_kernels import (
GPTQIntelAMXLinearKernel,
GPTQIntelAMXMoEKernel,
)
from sglang.srt.layers.linear import set_weight_attrs
from sglang.s... | 286 | 9,845 |
sglang | python/sglang/srt/layers/quantization/gptq/schemes/gptq_scheme.py | .py | # SPDX-License-Identifier: Apache-2.0
from abc import abstractmethod
from typing import TYPE_CHECKING, Optional
import torch
from sglang.srt.layers.moe import MoeRunnerConfig
from sglang.srt.layers.quantization.base_scheme import BaseLinearScheme, BaseMoEScheme
if TYPE_CHECKING:
from sglang.srt.layers.moe.token... | 55 | 1,472 |
sglang | python/sglang/srt/layers/quantization/awq/awq.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import logging
import warnings
from typing import TYPE_CHECKING, Any, Dict, List, Optional
import torch
from sglang.srt.layers.linear import LinearBase
from sglang.srt.layers.moe import MoeRunnerConfig
from sglang.srt.layers.quantization.base_c... | 491 | 16,739 |
sglang | python/sglang/srt/layers/quantization/awq/__init__.py | .py | # SPDX-License-Identifier: Apache-2.0
from sglang.kernels.ops.quantization.awq_triton import (
awq_dequantize_decomposition,
awq_dequantize_triton,
)
from .awq import (
AWQConfig,
AWQCPUConfig,
AWQLinearMethod,
AWQMarlinConfig,
AWQMoEMethod,
)
from .schemes import (
AWQAscendLinearSche... | 37 | 726 |
sglang | python/sglang/srt/layers/quantization/awq/schemes/awq_moe.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING
import torch
from sglang.srt.layers.linear import set_weight_attrs
from sglang.srt.layers.moe.moe_runner import MoeRunner, MoeRunnerConfig
from sglang.srt.layers.moe.utils import MoeRunnerBackend, get_moe_runner... | 193 | 6,582 |
sglang | python/sglang/srt/layers/quantization/awq/schemes/awq_marlin.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING, Optional
import torch
from sglang.srt.layers.parameter import GroupQuantScaleParameter, PackedvLLMParameter
from sglang.srt.layers.quantization.marlin_utils import verify_marlin_supports_shape
from .awq_scheme... | 110 | 3,464 |
sglang | python/sglang/srt/layers/quantization/awq/schemes/__init__.py | .py | # SPDX-License-Identifier: Apache-2.0
from .awq_cpu import AWQIntelAMXLinearScheme, AWQIntelAMXMoEScheme
from .awq_linear import AWQAscendLinearScheme, AWQLinearScheme
from .awq_marlin import AWQMarlinLinearScheme
from .awq_moe import AWQAscendMoEScheme, AWQMoEScheme
from .awq_scheme import AWQLinearSchemeBase, AWQMoE... | 20 | 583 |
sglang | python/sglang/srt/layers/quantization/awq/schemes/awq_linear.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING, List, Optional
import torch
from sglang.srt.layers.parameter import GroupQuantScaleParameter, PackedvLLMParameter
from .awq_scheme import AWQLinearSchemeBase
if TYPE_CHECKING:
from sglang.srt.layers.quant... | 111 | 3,654 |
sglang | python/sglang/srt/layers/quantization/awq/schemes/awq_cpu.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING
import torch
from sglang.srt.hardware_backend.cpu.quantization.awq_kernels import (
AWQIntelAMXLinearKernel,
AWQIntelAMXMoEKernel,
)
from sglang.srt.layers.moe import MoeRunnerConfig
from .awq_linear im... | 41 | 1,157 |
sglang | python/sglang/srt/layers/quantization/awq/schemes/awq_scheme.py | .py | # SPDX-License-Identifier: Apache-2.0
from abc import abstractmethod
from typing import TYPE_CHECKING, Optional
import torch
from sglang.srt.layers.moe import MoeRunnerConfig
from sglang.srt.layers.quantization.base_scheme import BaseLinearScheme, BaseMoEScheme
if TYPE_CHECKING:
from sglang.srt.layers.moe.token... | 55 | 1,468 |
sglang | python/sglang/srt/layers/quantization/modelslim/modelslim.py | .py | from __future__ import annotations
import logging
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, Tuple, Union, cast
import torch
from sglang.srt.hardware_backend.npu.quantization.linear_method_npu import (
_NPULinearMethodBase,
)
from sglang.srt.layers.mo... | 543 | 20,844 |
sglang | python/sglang/srt/layers/quantization/modelslim/schemes/modelslim_w8a8_int8_moe.py | .py | from __future__ import annotations
import logging
from typing import Any, Dict
import torch
from sglang.srt.hardware_backend.npu.quantization.moe_methods import (
NPUW8A8Int8MoEMethod,
)
from sglang.srt.layers.quantization.modelslim.schemes import ModelSlimMoEScheme
from sglang.srt.utils import set_weight_attrs
... | 101 | 3,261 |
sglang | python/sglang/srt/layers/quantization/modelslim/schemes/modelslim_w4a8_int8_moe.py | .py | from __future__ import annotations
import logging
from typing import Any, Dict
import torch
from sglang.srt.hardware_backend.npu.quantization.moe_methods import (
NPUW4A8Int8MoEMethod,
)
from sglang.srt.layers.quantization.modelslim.schemes import ModelSlimMoEScheme
from sglang.srt.utils import set_weight_attrs
... | 146 | 5,217 |
sglang | python/sglang/srt/layers/quantization/modelslim/schemes/__init__.py | .py | # SPDX-License-Identifier: Apache-2.0
# NOTE: Import order is critical to avoid circular dependency.
# modelslim_mxfp8 imports ModelSlimLinearScheme from this package,
# so the base class must be imported first.
# isort: off
from .modelslim_scheme import ModelSlimLinearScheme, ModelSlimMoEScheme
from .modelslim_mxfp8 ... | 33 | 1,126 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.