Unverified Commit 62797440 authored by Chang Su's avatar Chang Su Committed by GitHub
Browse files

[Lint] Add `python/sglang` to ruff F401 checks and remove unused imports in files (#11685)

parent 2614adf9
......@@ -20,18 +20,13 @@ from typing import Callable, Iterable, List, Optional, Tuple, Union
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from einops import rearrange
from transformers.activations import ACT2FN
from transformers.models.qwen2_5_vl.modeling_qwen2_5_vl import (
Qwen2_5_VisionRotaryEmbedding,
)
from sglang.srt.configs.qwen3_vl import (
Qwen3VLConfig,
Qwen3VLTextConfig,
Qwen3VLVisionConfig,
)
from sglang.srt.configs.qwen3_vl import Qwen3VLConfig, Qwen3VLVisionConfig
from sglang.srt.layers.attention.vision import VisionAttention
from sglang.srt.layers.linear import ColumnParallelLinear, RowParallelLinear
from sglang.srt.layers.logits_processor import LogitsProcessor
......@@ -47,11 +42,7 @@ from sglang.srt.managers.schedule_batch import (
MultimodalDataItem,
MultimodalInputs,
)
from sglang.srt.model_executor.forward_batch_info import (
ForwardBatch,
ForwardMode,
PPProxyTensors,
)
from sglang.srt.model_executor.forward_batch_info import ForwardBatch, PPProxyTensors
from sglang.srt.model_loader.weight_utils import default_weight_loader
from sglang.srt.models.qwen3 import Qwen3Model
from sglang.srt.utils import add_prefix
......
......@@ -25,12 +25,8 @@ from sglang.srt.distributed import (
get_moe_expert_parallel_world_size,
get_tensor_model_parallel_rank,
)
from sglang.srt.layers.logits_processor import LogitsProcessor
from sglang.srt.layers.moe.fused_moe_triton.layer import FusedMoE
from sglang.srt.layers.quantization.base_config import QuantizationConfig
from sglang.srt.layers.vocab_parallel_embedding import ParallelLMHead
from sglang.srt.managers.mm_utils import general_mm_embed_routine
from sglang.srt.managers.schedule_batch import MultimodalDataItem
from sglang.srt.model_executor.forward_batch_info import ForwardBatch, PPProxyTensors
from sglang.srt.model_loader.weight_utils import default_weight_loader
from sglang.srt.models.qwen3_moe import Qwen3MoeModel
......
# SPDX-License-Identifier: Apache-2.0
import itertools
from typing import Iterable, Optional, Tuple
import torch
......
......@@ -17,7 +17,6 @@ import logging
from typing import Iterable, List, Optional, Tuple
import torch
import torch.nn.functional as F
from torch import nn
from transformers import LlamaConfig
......
import logging
import math
from collections.abc import Iterable
from math import sqrt
from typing import Any, Dict, Iterable, List, Literal, Optional, Tuple, TypedDict, Union
from typing import Any, Dict, Iterable, List, Optional, Tuple
import torch
from torch import nn
......
......@@ -18,9 +18,6 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from typing import List, Union
import torch
from sglang.srt.managers.schedule_batch import Modality, MultimodalDataItem
from sglang.srt.models.deepseek_vl2 import DeepseekVL2ForCausalLM
from sglang.srt.multimodal.processors.base_processor import (
BaseMultimodalProcessor,
......
import asyncio
import math
import re
from typing import Dict, List, Union
......
import re
from typing import List, Union
from decord import VideoReader
......@@ -9,10 +8,7 @@ from sglang.srt.models.glm4v_moe import Glm4vMoeForConditionalGeneration
from sglang.srt.multimodal.processors.base_processor import (
BaseMultimodalProcessor as SGLangBaseProcessor,
)
from sglang.srt.multimodal.processors.base_processor import (
BaseMultiModalProcessorOutput,
MultimodalSpecialTokens,
)
from sglang.srt.multimodal.processors.base_processor import MultimodalSpecialTokens
class Glm4vImageProcessor(SGLangBaseProcessor):
......
......@@ -4,10 +4,8 @@ from functools import lru_cache
import numpy as np
import torch
import torchvision.transforms as T
from decord import VideoReader, cpu, gpu
from PIL import Image
from torchvision.transforms import InterpolationMode
from sglang.srt.managers.schedule_batch import Modality, MultimodalDataItem
from sglang.srt.models.interns1 import InternS1ForConditionalGeneration
......
from typing import List, Union
from sglang.srt.managers.schedule_batch import Modality, MultimodalDataItem
from sglang.srt.models.deepseek_janus_pro import MultiModalityCausalLM
from sglang.srt.multimodal.processors.base_processor import (
BaseMultimodalProcessor,
......
from typing import List, Union
import torch
from transformers.image_utils import SizeDict
from transformers.models.llama4.image_processing_llama4_fast import (
find_supported_resolutions,
get_best_fit,
)
from sglang.srt.managers.schedule_batch import Modality, MultimodalDataItem
from sglang.srt.models.mllama4 import Llama4ForConditionalGeneration
from sglang.srt.multimodal.processors.base_processor import (
BaseMultimodalProcessor,
......
......@@ -3,7 +3,6 @@ from typing import List, Union
from transformers.processing_utils import ProcessorMixin
from sglang.srt.managers.schedule_batch import Modality, MultimodalDataItem
from sglang.srt.models.phi4mm import Phi4MMForCausalLM
from sglang.srt.multimodal.processors.base_processor import (
BaseMultimodalProcessor,
......
import math
import re
from itertools import product
from typing import List, Literal, Optional, TypedDict, Union
from typing import List, Optional, Union
import numpy as np
import torch
......
import re
from typing import Dict, Optional, Tuple, Type
from sglang.srt.parser.harmony_parser import HarmonyParser
......
......@@ -5,7 +5,7 @@ Handles merging of YAML configuration files with command-line arguments.
import logging
from pathlib import Path
from typing import Any, Dict, List, Union
from typing import Any, Dict, List
import yaml
......
......@@ -56,7 +56,7 @@ from sglang.srt.utils import (
)
if is_cuda():
from sgl_kernel import segment_packbits
from sgl_kernel import segment_packbits # noqa: F401
logger = logging.getLogger(__name__)
SGLANG_RETURN_ORIGINAL_LOGPROB = get_bool_env_var("SGLANG_RETURN_ORIGINAL_LOGPROB")
......
......@@ -22,8 +22,6 @@ from sglang.srt.managers.schedule_batch import Req
from sglang.srt.utils import is_cuda, is_hip
if TYPE_CHECKING:
from sglang.srt.mem_cache.allocator import TokenToKVPoolAllocator
from sglang.srt.mem_cache.memory_pool import ReqToTokenPool
from sglang.srt.speculative.eagle_info import EagleVerifyInput
......
......@@ -11,7 +11,7 @@ from sglang.srt.speculative.spec_utils import draft_tp_context, load_token_map
from sglang.srt.utils import empty_context, get_bool_env_var, is_cuda
if is_cuda():
from sgl_kernel import segment_packbits
from sgl_kernel import segment_packbits # noqa: F401
logger = logging.getLogger(__name__)
SGLANG_RETURN_ORIGINAL_LOGPROB = get_bool_env_var("SGLANG_RETURN_ORIGINAL_LOGPROB")
......
......@@ -228,7 +228,7 @@ def support_triton(backend: str) -> bool:
try:
import sgl_kernel
import sgl_kernel # noqa: F401
is_intel_amx_backend_available = hasattr(
torch.ops.sgl_kernel, "convert_weight_packed"
......@@ -1556,7 +1556,7 @@ def get_hpu_memory_capacity():
def get_npu_memory_capacity():
try:
import torch_npu
import torch_npu # noqa: F401
return torch.npu.mem_get_info()[1] // 1024 // 1024 # unit: MB
except ImportError as e:
......@@ -1743,7 +1743,7 @@ def get_device(device_id: Optional[int] = None) -> str:
if is_habana_available():
try:
import habana_frameworks.torch.hpu
import habana_frameworks.torch.hpu # noqa: F401
if torch.hpu.is_available():
if device_id == None:
......@@ -1773,7 +1773,7 @@ def get_device_count() -> int:
if is_habana_available():
try:
import habana_frameworks.torch.hpu
import habana_frameworks.torch.hpu # noqa: F401
if torch.hpu.is_available():
return torch.hpu.device_count()
......
import logging
import os
from dataclasses import dataclass
from multiprocessing import shared_memory
from pathlib import Path
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment