update pre-commit config (#18860)

This commit is contained in:
SoluMilken
2026-02-16 00:18:31 +08:00
committed by GitHub
parent f7603203b0
commit 07a24f1a38
135 changed files with 239 additions and 198 deletions
@@ -36,27 +36,28 @@ struct dtype_trait {};
} \
static_assert(true)
SGL_REGISTER_DTYPE_TRAIT(fp32_t, fp32x2_t, SGL_REGISTER_TYPE_END; //
SGL_REGISTER_FROM_FUNCTION(fp16_t, __half2float);
SGL_REGISTER_FROM_FUNCTION(bf16_t, __bfloat162float);
SGL_REGISTER_UNARY_FUNCTION(abs, fabsf);
SGL_REGISTER_UNARY_FUNCTION(sqrt, sqrtf);
SGL_REGISTER_UNARY_FUNCTION(rsqrt, rsqrtf);
SGL_REGISTER_BINARY_FUNCTION(max, fmaxf);
SGL_REGISTER_BINARY_FUNCTION(min, fminf););
SGL_REGISTER_DTYPE_TRAIT(
fp32_t, fp32x2_t, SGL_REGISTER_TYPE_END; //
SGL_REGISTER_FROM_FUNCTION(fp16_t, __half2float);
SGL_REGISTER_FROM_FUNCTION(bf16_t, __bfloat162float);
SGL_REGISTER_UNARY_FUNCTION(abs, fabsf);
SGL_REGISTER_UNARY_FUNCTION(sqrt, sqrtf);
SGL_REGISTER_UNARY_FUNCTION(rsqrt, rsqrtf);
SGL_REGISTER_BINARY_FUNCTION(max, fmaxf);
SGL_REGISTER_BINARY_FUNCTION(min, fminf););
SGL_REGISTER_DTYPE_TRAIT(fp16_t, fp16x2_t);
SGL_REGISTER_DTYPE_TRAIT(bf16_t, bf16x2_t);
/// TODO: Add ROCM implementation
SGL_REGISTER_DTYPE_TRAIT(fp32x2_t, fp32x4_t, SGL_REGISTER_TYPE_END;
SGL_REGISTER_FROM_FUNCTION(fp16x2_t, __half22float2);
SGL_REGISTER_FROM_FUNCTION(bf16x2_t, __bfloat1622float2););
SGL_REGISTER_DTYPE_TRAIT(
fp32x2_t, fp32x4_t, SGL_REGISTER_TYPE_END; SGL_REGISTER_FROM_FUNCTION(fp16x2_t, __half22float2);
SGL_REGISTER_FROM_FUNCTION(bf16x2_t, __bfloat1622float2););
SGL_REGISTER_DTYPE_TRAIT(fp16x2_t, void, SGL_REGISTER_TYPE_END;
SGL_REGISTER_FROM_FUNCTION(fp32x2_t, __float22half2_rn););
SGL_REGISTER_DTYPE_TRAIT(
fp16x2_t, void, SGL_REGISTER_TYPE_END; SGL_REGISTER_FROM_FUNCTION(fp32x2_t, __float22half2_rn););
SGL_REGISTER_DTYPE_TRAIT(bf16x2_t, void, SGL_REGISTER_TYPE_END;
SGL_REGISTER_FROM_FUNCTION(fp32x2_t, __float22bfloat162_rn););
SGL_REGISTER_DTYPE_TRAIT(
bf16x2_t, void, SGL_REGISTER_TYPE_END; SGL_REGISTER_FROM_FUNCTION(fp32x2_t, __float22bfloat162_rn););
#undef SGL_REGISTER_DTYPE_TRAIT
#undef SGL_REGISTER_FROM_FUNCTION
@@ -243,12 +243,10 @@ def run_sgl_diffusion_webui(server_args: ServerArgs):
# print banner
delimiter = "=" * 80
url = local_url or f"http://localhost:{server_args.webui_port}"
print(
f"""
print(f"""
{delimiter}
\033[1mSGLang Diffusion WebUI available at:\033[0m \033[1;4;92m{url}\033[0m
{delimiter}
"""
)
""")
demo.block_thread()
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
"""Qwen3 text encoder configuration for SGLang diffusion models."""
from dataclasses import dataclass, field
from sglang.multimodal_gen.configs.models.encoders.base import (
@@ -9,6 +9,7 @@ diffusion transformer (DiT) inference:
- cache-dit integration: Block-level caching with DBCache and TaylorSeer
"""
from sglang.multimodal_gen.runtime.cache.cache_dit_integration import (
CacheDitConfig,
enable_cache_on_dual_transformer,
@@ -29,6 +29,7 @@ The typical workflow is:
If you only need to use the distributed environment without model parallelism,
you can skip the model parallel initialization and destruction steps.
"""
import contextlib
import datetime
import os
@@ -71,7 +72,7 @@ TensorMetadata = namedtuple("TensorMetadata", ["device", "dtype", "size"])
def _split_tensor_dict(
tensor_dict: dict[str, torch.Tensor | Any]
tensor_dict: dict[str, torch.Tensor | Any],
) -> tuple[list[tuple[str, Any]], list[torch.Tensor]]:
"""Split the tensor dictionary into two parts:
1. A list of (key, value) pairs. If the value is a tensor, it is replaced
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
# Adapted from vllm: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/model_executor/layers/activation.py
"""Custom activation functions."""
import math
from typing import Any
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
# Adapted from vllm: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/model_executor/layers/layernorm.py
"""Custom normalization layers."""
from typing import Optional, Tuple, Union
import torch
@@ -25,6 +25,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Rotary Positional Embeddings."""
import functools
from collections import OrderedDict
from typing import Any, Optional, Tuple
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
# Adapted from vllm: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/model_executor/layers/utils.py
"""Utility methods for model layers."""
import inspect
from typing import Any, Callable, List, Optional
@@ -12,7 +12,10 @@ from diffusers.models.embeddings import (
from diffusers.models.embeddings import (
CombinedTimestepTextProjEmbeddings as _CombinedTimestepTextProjEmbeddings,
)
from diffusers.models.embeddings import PixArtAlphaTextProjection, TimestepEmbedding
from diffusers.models.embeddings import (
PixArtAlphaTextProjection,
TimestepEmbedding,
)
from diffusers.models.embeddings import Timesteps as _Timesteps
from diffusers.models.embeddings import (
get_timestep_embedding as timestep_embedding_diffusers,
@@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
"""Utilities for selecting and loading models."""
import contextlib
import glob
import os
@@ -30,7 +31,7 @@ def set_default_torch_dtype(dtype: torch.dtype):
def get_param_names_mapping(
mapping_dict: dict[str, str]
mapping_dict: dict[str, str],
) -> Callable[[str], tuple[str, Any, Any]]:
"""
Creates a mapping function that transforms parameter names using regex patterns.
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
# Adapted from vllm: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/model_executor/model_loader/weight_utils.py
"""Utilities for downloading and initializing model weights."""
import hashlib
import json
import os
@@ -5,6 +5,7 @@
# Adapted from transformers: https://github.com/huggingface/transformers/blob/v4.39.0/src/transformers/models/clip/modeling_clip.py
"""Minimal implementation of CLIPVisionModel intended to be only used
within a vision language model."""
from collections.abc import Iterable
from typing import Optional
@@ -25,6 +25,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Inference-only LLaMA model compatible with HuggingFace weights."""
from collections.abc import Iterable
from typing import Any
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
# Adapted from: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/model_executor/utils.py
"""Utils for model executor."""
from typing import Any
import torch
@@ -8,7 +8,6 @@ This module contains an implementation of the Hunyuan video diffusion pipeline
using the modular pipeline architecture.
"""
from sglang.multimodal_gen.runtime.pipelines_core.composed_pipeline_base import (
ComposedPipelineBase,
)
@@ -4,6 +4,7 @@
"""
Synchronous pipeline executor implementation.
"""
from typing import List
from sglang.multimodal_gen.runtime.pipelines_core.executors.pipeline_executor import (
@@ -5,6 +5,7 @@ This stage extends LatentPreparationStage to handle device mismatch issues
that occur when tensors are pickled and unpickled via broadcast_pyobj in
multi-GPU scenarios.
"""
import dataclasses
import torch
@@ -4,6 +4,7 @@
"""
Input validation stage for diffusion pipelines.
"""
import numpy as np
import torch
import torchvision.transforms.functional as TF
@@ -4,6 +4,7 @@
"""
Latent preparation stage for diffusion pipelines.
"""
from diffusers.utils.torch_utils import randn_tensor
from sglang.multimodal_gen.runtime.distributed import get_local_torch_device
@@ -6,6 +6,7 @@
This file is a platform abstraction for ROCm GPUs,
adjusted to match the structure and interface of `cuda.py`.
"""
from functools import lru_cache
from typing import Any
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
# Inspired by SGLang: https://github.com/sgl-project/sglang/blob/main/python/sglang/srt/server_args.py
"""The arguments of sglang-diffusion Inference."""
import argparse
import dataclasses
import inspect
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
# adapted from vllm: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/logger.py
"""Logging configuration for sglang.multimodal_gen."""
import argparse
import contextlib
import datetime
@@ -1,8 +1,9 @@
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
"""
Common generate cli test, one test for image and video each
Common generate cli test, one test for image and video each
"""
import dataclasses
import os
import shlex
@@ -1,5 +1,5 @@
"""
This file upload the media generated in diffusion-nightly-test to a slack channel of SGLang
This file upload the media generated in diffusion-nightly-test to a slack channel of SGLang
"""
import logging
+2 -2
View File
@@ -4855,7 +4855,7 @@ def nvmlDeviceGetFieldValues(handle, fieldIds):
for i, fieldId in enumerate(fieldIds):
try:
(values[i].fieldId, values[i].scopeId) = fieldId
values[i].fieldId, values[i].scopeId = fieldId
except TypeError:
values[i].fieldId = fieldId
@@ -4871,7 +4871,7 @@ def nvmlDeviceClearFieldValues(handle, fieldIds):
for i, fieldId in enumerate(fieldIds):
try:
(values[i].fieldId, values[i].scopeId) = fieldId
values[i].fieldId, values[i].scopeId = fieldId
except TypeError:
values[i].fieldId = fieldId
@@ -15,6 +15,7 @@
Checkpoint-engine integration for SGLang.
This module provides weight update functionality via IPC for checkpoint-engine compatibility.
"""
import logging
from typing import Callable, Dict, Optional
@@ -13,7 +13,7 @@ else:
def weak_ref_tensors(
tensors: Union[torch.Tensor, list[torch.Tensor], tuple[torch.Tensor]]
tensors: Union[torch.Tensor, list[torch.Tensor], tuple[torch.Tensor]],
) -> Union[torch.Tensor, list[Any], tuple[Any], Any]:
"""
Convenience function to create weak references to tensors,
+2 -1
View File
@@ -14,7 +14,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" EXAONE model configuration """
"""EXAONE model configuration"""
from typing import Any, Dict
from transformers.configuration_utils import PretrainedConfig
-1
View File
@@ -14,7 +14,6 @@
# limitations under the License.
"""Falcon-H1 model configuration"""
from transformers.configuration_utils import PretrainedConfig
from transformers.utils import logging
@@ -970,7 +970,7 @@ class MooncakeKVManager(CommonKVManager):
self._handle_aux_data(msg)
continue
(bootstrap_room, status, prefill_rank) = msg
bootstrap_room, status, prefill_rank = msg
status = int(status.decode("ascii"))
bootstrap_room = int(bootstrap_room.decode("ascii"))
prefill_rank = int(prefill_rank.decode("ascii"))
@@ -21,6 +21,7 @@ If you only need to use the distributed environment without model/pipeline
parallelism, you can skip the model parallel initialization and destruction
steps.
"""
import contextlib
import gc
import logging
@@ -79,7 +80,7 @@ class P2PWork:
def _split_tensor_dict(
tensor_dict: Dict[str, Union[torch.Tensor, Any]]
tensor_dict: Dict[str, Union[torch.Tensor, Any]],
) -> Tuple[List[Tuple[str, Any]], List[torch.Tensor]]:
"""Split the tensor dictionary into two parts:
1. A list of (key, value) pairs. If the value is a tensor, it is replaced
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
# Adapted from vLLM's OpenAIServingResponses
"""Handler for /v1/responses requests"""
from __future__ import annotations
import asyncio
@@ -186,7 +186,7 @@ class BaseFormatDetector(ABC):
if start_idx >= len(current_text):
return StreamingParseResult()
(obj, end_idx) = _partial_json_loads(current_text[start_idx:], flags)
obj, end_idx = _partial_json_loads(current_text[start_idx:], flags)
is_current_complete = _is_complete_json(
current_text[start_idx : start_idx + end_idx]
@@ -11,7 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
""" Run the model with npu graph and torch.compile """
"""Run the model with npu graph and torch.compile"""
from __future__ import annotations
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
"""Attention layer with Dual chunk flash attention and sparse attention.
"""
"""Attention layer with Dual chunk flash attention and sparse attention."""
import functools
import logging
import math
@@ -670,9 +670,9 @@ class KimiLinearAttnBackend(MambaAttnBackendBase):
**kwargs,
):
assert isinstance(mixed_qkv, Tuple)
(q_proj_states, k_proj_states, v_proj_states) = mixed_qkv
(q_conv_weights, k_conv_weights, v_conv_weights) = layer.conv_weights
(q_conv_bias, k_conv_bias, v_conv_bias) = layer.bias
q_proj_states, k_proj_states, v_proj_states = mixed_qkv
q_conv_weights, k_conv_weights, v_conv_weights = layer.conv_weights
q_conv_bias, k_conv_bias, v_conv_bias = layer.bias
layer_cache = self.req_to_token_pool.mamba2_layer_cache(layer.layer_id)
q_conv_state, k_conv_state, v_conv_state = layer_cache.conv
@@ -744,9 +744,9 @@ class KimiLinearAttnBackend(MambaAttnBackendBase):
)
assert isinstance(mixed_qkv, Tuple)
(q_proj_states, k_proj_states, v_proj_states) = mixed_qkv
(q_conv_weights, k_conv_weights, v_conv_weights) = layer.conv_weights
(q_conv_bias, k_conv_bias, v_conv_bias) = layer.bias
q_proj_states, k_proj_states, v_proj_states = mixed_qkv
q_conv_weights, k_conv_weights, v_conv_weights = layer.conv_weights
q_conv_bias, k_conv_bias, v_conv_bias = layer.bias
query_start_loc = self.forward_metadata.query_start_loc
cache_indices = self.forward_metadata.mamba_cache_indices
@@ -2,6 +2,7 @@
"""
Copyright (c) Ant Financial Service Group and its affiliates.
"""
# Copied from https://code.alipay.com/pia/PainlessInferenceAcceleration/blob/v0.0.6/flood/flood/ops/seg_la.py
from dataclasses import dataclass
@@ -38,7 +38,7 @@ def prefill_attention_wave(
output_shape = (shape.total_seq_len, shape.num_query_heads, shape.head_size_kv)
# Run the wave kernel.
mfma_variant = (MMAType.F32_16x16x16_F16, MMAType.F32_16x16x16_F16)
(prefill, hyperparams) = get_prefill_attention_kernel(
prefill, hyperparams = get_prefill_attention_kernel(
shape,
mfma_variant,
q.shape,
+1 -1
View File
@@ -376,7 +376,7 @@ class LogitsProcessor(nn.Module):
logprobs_result = self.process_input_logprobs(input_logits, logits_metadata)
else:
(logprobs_result, sampled_logits) = self.process_input_logprobs_by_chunk(
logprobs_result, sampled_logits = self.process_input_logprobs_by_chunk(
pruned_states,
sample_indices,
input_logprob_indices,
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
"""Cutlass W4A8 MoE kernel."""
from typing import Optional
import torch
@@ -63,11 +63,9 @@ class ModelSlimMoEMethod(FusedMoEMethodBase):
logger.info_once("Using ModelSlimW8A8Int8MoE")
return ModelSlimW8A8Int8MoE(quant_config)
else:
logger.warning(
f"Unsupported FusedMoe modelslim scheme: \
logger.warning(f"Unsupported FusedMoe modelslim scheme: \
{quant_config.quant_description.get(prefix_in_quant_config.strip())} \
in layer: {prefix}"
)
in layer: {prefix}")
return None
@@ -12,6 +12,7 @@
# limitations under the License.
# ==============================================================================
"""Radix attention."""
from __future__ import annotations
from enum import Enum
@@ -12,6 +12,7 @@
# limitations under the License.
# ==============================================================================
"""Radix linear attention."""
from __future__ import annotations
from typing import TYPE_CHECKING, Optional, Tuple, Union
+2 -1
View File
@@ -1,5 +1,6 @@
# Adapted from https://raw.githubusercontent.com/vllm-project/vllm/refs/tags/v0.6.6.post1/vllm/model_executor/layers/rotary_embedding.py
"""Rotary Positional Embeddings."""
from __future__ import annotations
import itertools
@@ -2896,7 +2897,7 @@ class DualChunkRotaryEmbedding(MultiPlatformOp):
self.local_size = local_size
self.dtype = dtype
self.device = torch.device(f"cuda:{torch.cuda.current_device()}")
(q_cache, qc_cache, k_cache, qc_no_clamp_cache, q_inter_cache) = (
q_cache, qc_cache, k_cache, qc_no_clamp_cache, q_inter_cache = (
self._compute_cos_sin_cache()
)
+1
View File
@@ -12,6 +12,7 @@
# limitations under the License.
# ==============================================================================
"""A tensor parallel worker."""
from __future__ import annotations
import logging
@@ -639,7 +639,7 @@ class MambaRadixCache(BasePrefixCache):
match_result = self.match_prefix(
MatchPrefixParams(key=RadixKey(page_aligned_token_ids, req.extra_key))
)
(new_indices, new_last_node) = (
new_indices, new_last_node = (
match_result.device_indices,
match_result.last_device_node,
)
@@ -8,7 +8,9 @@ from typing import Optional
import psutil
import torch
from sglang.jit_kernel.hicache import can_use_hicache_jit_kernel
from sglang.jit_kernel.hicache import (
can_use_hicache_jit_kernel,
)
from sglang.jit_kernel.hicache import (
transfer_hicache_all_layer as jit_transfer_hicache_all_layer,
)
+1 -1
View File
@@ -523,7 +523,7 @@ class RadixCache(BasePrefixCache):
# The prefix indices could be updated, reuse it
match_result = self.match_prefix(MatchPrefixParams(key=radix_key))
(new_indices, new_last_node) = (
new_indices, new_last_node = (
match_result.device_indices,
match_result.last_device_node,
)
@@ -556,7 +556,7 @@ class SWARadixCache(BasePrefixCache):
match_result = self.match_prefix(
MatchPrefixParams(key=RadixKey(page_aligned_token_ids, req.extra_key))
)
(new_indices, new_last_node) = (
new_indices, new_last_node = (
match_result.device_indices,
match_result.last_device_node,
)
+1
View File
@@ -12,6 +12,7 @@
# limitations under the License.
# ==============================================================================
"""Utilities for Prometheus Metrics Collection."""
import dataclasses
import logging
import os
+1
View File
@@ -12,6 +12,7 @@
# limitations under the License.
# ==============================================================================
"""Utilities for Prometheus Metrics."""
import math
from typing import List
+1
View File
@@ -1,6 +1,7 @@
# Adapted from https://github.com/vllm-project/vllm/blob/v0.6.4.post1/vllm/model_executor/model_loader/utils.py
"""Utilities for selecting and loading models."""
import concurrent.futures
import contextlib
import logging
@@ -1,6 +1,7 @@
# Adapted from https://github.com/vllm-project/vllm/blob/v0.6.4.post1/vllm/model_executor/model_loader/weight_utils.py
"""Utilities for downloading and initializing model weights."""
import collections
import concurrent.futures
import fnmatch
@@ -140,12 +141,10 @@ def convert_bin_to_safetensor_file(
sf_size = os.stat(sf_filename).st_size
pt_size = os.stat(pt_filename).st_size
if (sf_size - pt_size) / pt_size > 0.01:
raise RuntimeError(
f"""The file size different is more than 1%:
raise RuntimeError(f"""The file size different is more than 1%:
- {sf_filename}: {sf_size}
- {pt_filename}: {pt_size}
"""
)
""")
# check if the tensors are the same
reloaded = safetensors.torch.load_file(sf_filename)
+1
View File
@@ -18,6 +18,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Inference-only BaiChuan model compatible with HuggingFace weights."""
import math
from typing import Iterable, Optional, Tuple
+1
View File
@@ -18,6 +18,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""SGLang BailingMoE model."""
import logging
from typing import Iterable, List, Optional, Tuple, Union
@@ -18,6 +18,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""SGLang BailingMoENextN model."""
import logging
from typing import Iterable, Optional, Tuple
@@ -13,6 +13,7 @@
# ==============================================================================
"""Inference-only DeepSeek NextN Speculative Decoding."""
import logging
from typing import Iterable, Optional, Tuple
+1
View File
@@ -16,6 +16,7 @@
# Adapted from
# https://github.com/vllm-project/vllm/blob/c7f2cf2b7f67bce5842fedfdba508440fe257375/vllm/model_executor/models/llama.py#L1
"""Inference-only Apertus model compatible with HuggingFace weights."""
import copy
import logging
import math
+1
View File
@@ -15,6 +15,7 @@
# Adapted from:
# https://github.com/vllm-project/vllm/blob/fb6af8bc086328ca6659e72d11ffd4309ce4de22/vllm/model_executor/models/deepseek_v2.py
"""Inference-only DeepseekV2 model."""
from __future__ import annotations
import logging
+1 -1
View File
@@ -12,7 +12,7 @@
# limitations under the License.
# ==============================================================================
""" Inference-only Ernie4.5 model compatible with baidu/ERNIE-4.5-*-PT weights. """
"""Inference-only Ernie4.5 model compatible with baidu/ERNIE-4.5-*-PT weights."""
from typing import Iterable, List, Optional, Tuple, Union
+1 -1
View File
@@ -12,7 +12,7 @@
# limitations under the License.
# ==============================================================================
""" Inference-only Ernie4.5 VL model compatible with baidu/ERNIE-4.5-VL-*-PT weights. """
"""Inference-only Ernie4.5 VL model compatible with baidu/ERNIE-4.5-VL-*-PT weights."""
import logging
from itertools import islice
+1
View File
@@ -11,6 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Inference-only Ernie45-VL model compatible with HuggingFace weights."""
import logging
from functools import lru_cache, partial
from typing import Iterable, List, Optional, Tuple, Type
+1 -1
View File
@@ -12,7 +12,7 @@
# limitations under the License.
# ==============================================================================
""" Ernie4.5 MTP model compatible with baidu/ERNIE-4.5-*-PT weights. """
"""Ernie4.5 MTP model compatible with baidu/ERNIE-4.5-*-PT weights."""
from typing import Iterable, Optional, Tuple
+1
View File
@@ -17,6 +17,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Inference-only GPT-2 model compatible with HuggingFace weights."""
from typing import Iterable, Optional, Tuple, Type
import torch
+1
View File
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Inference-only HunYuan model compatible with HuggingFace weights."""
import re
from typing import Any, Dict, Iterable, Optional, Tuple
+1
View File
@@ -18,6 +18,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""SGLang LLaDA2MoeModelLM model."""
import logging
from typing import Iterable, Optional, Tuple, Union
+1
View File
@@ -1,6 +1,7 @@
# Adapted from:
# https://github.com/vllm-project/vllm/blob/7193774b1ff8603ad5bf4598e5efba0d9a39b436/vllm/model_executor/models/mllama.py
"""PyTorch Mllama model."""
import math
from typing import Iterable, List, Optional, Tuple, Union
+1
View File
@@ -14,6 +14,7 @@
# Adapted from https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/nemotron_nas.py
"""Inference-only deci model compatible with HuggingFace weights."""
from typing import Iterable, Optional, Tuple, Type, Union
import torch
+1
View File
@@ -15,6 +15,7 @@
# Adapted from
# https://github.com/vllm-project/vllm/blob/c7f2cf2b7f67bce5842fedfdba508440fe257375/vllm/model_executor/models/olmo.py#L1
"""Inference-only OLMo model compatible with HuggingFace weights."""
from typing import Iterable, Optional, Tuple
import torch
+1
View File
@@ -15,6 +15,7 @@
# Adapted from
# https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/olmo2.py
"""Inference-only OLMo2 model compatible with HuggingFace weights."""
from functools import partial
from typing import Iterable, Optional, Tuple
+1
View File
@@ -13,6 +13,7 @@
# ==============================================================================
"""Inference-only OPT model compatible with HuggingFace weights."""
import logging
from collections.abc import Iterable
from typing import Optional, Union
+1
View File
@@ -7,6 +7,7 @@
# LICENSE: https://huggingface.co/OrionStarAI/Orion-14B-Base/blob/main/LICENSE
# Adapted from https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/orion.py
"""Inference-only Orion-14B model compatible with HuggingFace weights."""
from collections.abc import Iterable
from typing import Any, Optional, Tuple
+6 -2
View File
@@ -23,11 +23,15 @@ import torch
import torch.nn as nn
import torch.nn.functional as F
from transformers import PixtralVisionConfig, PretrainedConfig
from transformers.models.pixtral.modeling_pixtral import PixtralRotaryEmbedding
from transformers.models.pixtral.modeling_pixtral import (
PixtralRotaryEmbedding,
)
from transformers.models.pixtral.modeling_pixtral import (
generate_block_attention_mask as _get_pixtral_attention_mask,
)
from transformers.models.pixtral.modeling_pixtral import position_ids_in_meshgrid
from transformers.models.pixtral.modeling_pixtral import (
position_ids_in_meshgrid,
)
from sglang.srt.layers.activation import SiluAndMul
from sglang.srt.layers.attention.vision import VisionAttention
+1
View File
@@ -15,6 +15,7 @@
# Adapted from llama2.py
# Modify details for the adaptation of Qwen2 model.
"""Inference-only Qwen2 model compatible with HuggingFace weights."""
import logging
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
+1
View File
@@ -22,6 +22,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Inference-only Qwen2-VL model compatible with HuggingFace weights."""
import logging
import re
from functools import partial
+1
View File
@@ -22,6 +22,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Inference-only Qwen2-Audio model compatible with HuggingFace weights."""
import logging
from typing import Any, Iterable, List, Optional, Tuple
+1
View File
@@ -22,6 +22,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Inference-only Qwen2-VL model compatible with HuggingFace weights."""
import logging
from functools import lru_cache, partial
from typing import Iterable, List, Optional, Tuple, Type, TypedDict
+1
View File
@@ -13,6 +13,7 @@
# limitations under the License.
# ==============================================================================
"""Inference-only Qwen3.5 model and Qwen3.5 MoE model compatible with HuggingFace weights."""
import logging
from functools import lru_cache
from typing import Iterable, Optional, Set, Tuple, Union
+1
View File
@@ -13,6 +13,7 @@
# ==============================================================================
"""Inference-only Qwen3_5 MTP model."""
import logging
from typing import Iterable, Optional, Tuple
+2 -2
View File
@@ -366,8 +366,8 @@ class Qwen3GatedDeltaNet(nn.Module):
# [b, sq, ng, (hn + hn + np/ng * hn + np/ng + np/ng)]
# --> [b, sq, ng, hn], [b, sq, ng, hn], [b, sq, ng, np/ng * hn], [b, sq, ng, np/ng * hn], [b, sq, ng, np/ng], [b, sq, ng, np/ng]
(query, key, value, z) = torch.split(mixed_qkvz, split_arg_list_qkvz, dim=2)
(b, a) = torch.split(mixed_ba, split_arg_list_ba, dim=2)
query, key, value, z = torch.split(mixed_qkvz, split_arg_list_qkvz, dim=2)
b, a = torch.split(mixed_ba, split_arg_list_ba, dim=2)
# [b, sq, ng, np/ng * hn] -> [b, sq, np, hn]
value = value.reshape(value.size(0), -1, self.head_v_dim)
@@ -13,6 +13,7 @@
# ==============================================================================
"""Inference-only Qwen3Next MTP Speculative Decoding."""
import logging
from typing import Iterable, Optional, Tuple
@@ -13,6 +13,7 @@
# limitations under the License.
# ==============================================================================
"""Inference-only Qwen3-VL model compatible with HuggingFace weights."""
import math
from typing import Iterable, List, Optional, Tuple
+1
View File
@@ -13,6 +13,7 @@
# limitations under the License.
# ==============================================================================
"""Inference-only Qwen3-VL model compatible with HuggingFace weights."""
import logging
import math
import re
+1
View File
@@ -13,6 +13,7 @@
# limitations under the License.
# ==============================================================================
"""Inference-only Qwen3-VL model compatible with HuggingFace weights."""
import logging
import re
from functools import lru_cache
+2 -1
View File
@@ -20,7 +20,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Adapted from https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/starcoder2.py
""" PyTorch Starcoder2 model."""
"""PyTorch Starcoder2 model."""
from collections.abc import Iterable
from typing import Optional, Tuple
+1
View File
@@ -15,6 +15,7 @@
# Adapted from
# https://github.com/vllm-project/vllm/blob/a1a2aaadb9122f05667140e39cf67e5736c8b6d6/vllm/model_executor/models/transformers.py
"""Wrapper around `transformers` models"""
import logging
import re
from typing import Iterable, Literal, Optional, Tuple, Union
@@ -13,6 +13,7 @@
# ==============================================================================
"""ViT CUDA Graph Runner class."""
from __future__ import annotations
from typing import Dict, Hashable, Tuple
+2 -1
View File
@@ -27,6 +27,7 @@ LLaVA-NeXT : https://llava-vl.github.io/blog/2024-01-30-llava-next/
LLaVA-Onevision : https://arxiv.org/pdf/2408.03326
"""
import ast
import itertools
import math
@@ -519,7 +520,7 @@ def run_dp_sharded_mrope_vision_model(
# image_to_tp_rank = [0, 2, 1, 3]
# gpu_sample_counts = [1, 3]
# grouped_pixel_values_len = [1000, 350]
(image_to_tp_rank, gpu_sample_counts, grouped_pixel_values_len) = (
image_to_tp_rank, gpu_sample_counts, grouped_pixel_values_len = (
get_dp_encoder_lb_assignment(patches_per_image, tp_size)
)
@@ -15,7 +15,9 @@ from sglang.srt.models.ernie45_vl import Ernie4_5_VLMoeForConditionalGeneration
from sglang.srt.multimodal.processors.base_processor import (
BaseMultimodalProcessor as SGLangBaseProcessor,
)
from sglang.srt.multimodal.processors.base_processor import MultimodalSpecialTokens
from sglang.srt.multimodal.processors.base_processor import (
MultimodalSpecialTokens,
)
from sglang.srt.utils import get_bool_env_var, is_npu, logger
_is_npu = is_npu()
@@ -7,7 +7,9 @@ from sglang.srt.models.glm_ocr import GlmOcrForConditionalGeneration
from sglang.srt.multimodal.processors.base_processor import (
BaseMultimodalProcessor as SGLangBaseProcessor,
)
from sglang.srt.multimodal.processors.base_processor import MultimodalSpecialTokens
from sglang.srt.multimodal.processors.base_processor import (
MultimodalSpecialTokens,
)
class Glm4vImageProcessor(SGLangBaseProcessor):
@@ -8,7 +8,9 @@ from sglang.srt.models.kimi_k25 import KimiK25ForConditionalGeneration
from sglang.srt.multimodal.processors.base_processor import (
BaseMultimodalProcessor as SGLangBaseProcessor,
)
from sglang.srt.multimodal.processors.base_processor import MultimodalSpecialTokens
from sglang.srt.multimodal.processors.base_processor import (
MultimodalSpecialTokens,
)
# Compatible with KimiVLForConditionalGeneration
@@ -5,7 +5,9 @@ from sglang.srt.models.kimi_vl import KimiVLForConditionalGeneration
from sglang.srt.multimodal.processors.base_processor import (
BaseMultimodalProcessor as SGLangBaseProcessor,
)
from sglang.srt.multimodal.processors.base_processor import MultimodalSpecialTokens
from sglang.srt.multimodal.processors.base_processor import (
MultimodalSpecialTokens,
)
# Compatible with KimiVLForConditionalGeneration
@@ -26,7 +26,9 @@ from sglang.srt.models.qwen3_vl_moe import Qwen3VLMoeForConditionalGeneration
from sglang.srt.multimodal.processors.base_processor import (
BaseMultimodalProcessor as SGLangBaseProcessor,
)
from sglang.srt.multimodal.processors.base_processor import MultimodalSpecialTokens
from sglang.srt.multimodal.processors.base_processor import (
MultimodalSpecialTokens,
)
from sglang.utils import logger
IMAGE_FACTOR = 28
@@ -15,7 +15,9 @@ from sglang.srt.models.step3_vl_10b import StepVLForConditionalGeneration
from sglang.srt.multimodal.processors.base_processor import (
BaseMultimodalProcessor as SGLangBaseProcessor,
)
from sglang.srt.multimodal.processors.base_processor import MultimodalSpecialTokens
from sglang.srt.multimodal.processors.base_processor import (
MultimodalSpecialTokens,
)
ImageWithPatches = tuple[Image.Image, list[Image.Image], list[int] | None]
@@ -13,6 +13,7 @@
# ==============================================================================
"""ViT CUDA Graph Runner class."""
from __future__ import annotations
import inspect
@@ -13,7 +13,6 @@
# ==============================================================================
"""Completion templates."""
import dataclasses
import logging
from enum import auto
+1
View File
@@ -12,6 +12,7 @@
# limitations under the License.
# ==============================================================================
"""Common utilities."""
from __future__ import annotations
import argparse
+1 -1
View File
@@ -117,7 +117,7 @@ def _random_like(t: torch.Tensor):
def _postprocess_tensors(
raw: Dict[str, torch.Tensor]
raw: Dict[str, torch.Tensor],
) -> Iterable[Tuple[str, bool, torch.Tensor]]:
from sglang.srt.debug_utils.dumper import get_tensor_info
+2 -4
View File
@@ -531,15 +531,13 @@ def wait_for_server(
headers={"Authorization": "Bearer None"},
)
time.sleep(5)
print_highlight(
"""\n
print_highlight("""\n
NOTE: Typically, the server runs in a separate terminal.
In this notebook, we run the server and notebook code together, so their outputs are combined.
To improve clarity, the server logs are displayed in the original black color, while the notebook outputs are highlighted in blue.
To reduce the log length, we set the log level to warning for the server, the default log level is info.
We are running those notebooks in a CI environment, so the throughput is not representative of the actual performance.
"""
)
""")
class TypeBasedDispatcher: