Skip to content

[Bug] circular import error in fused_moe_triton #2386

@BBuf

Description

@BBuf

Checklist

  • 1. I have searched related issues but cannot get the expected help.
  • 2. The bug has not been fixed in the latest version.
  • 3. Please note that if the bug-related issue you submitted lacks corresponding environment info and a minimal reproducible demo, it will be challenging for us to reproduce and resolve the issue, reducing the likelihood of receiving feedback.
  • 4. If the issue you raised is not a bug but a question, please raise a discussion at https://github.com/sgl-project/sglang/discussions/new/choose Otherwise, it will be closed.
  • 5. Please use English, otherwise it will be closed.

Describe the bug

circular import error in fused_moe_triton

root@dlc1ps6tjbkpwsvv-master-0:/mnt/data/bbuf/sglang# python3
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sglang.srt.layers.fused_moe_triton.fused_moe import fused_moe
Warning: Your installation of OpenCV appears to be broken: module 'cv2.dnn' has no attribute 'DictValue'.Please follow the instructions at https://github.com/opencv/opencv-python/issues/884 to correct your environment. The import of cv2 has been skipped.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/mnt/data/bbuf/sglang/python/sglang/srt/layers/fused_moe_triton/__init__.py", line 11, in <module>
    from sglang.srt.layers.fused_moe_triton.layer import (
  File "/mnt/data/bbuf/sglang/python/sglang/srt/layers/fused_moe_triton/layer.py", line 16, in <module>
    from sglang.srt.layers.quantization.base_config import (
  File "/mnt/data/bbuf/sglang/python/sglang/srt/layers/quantization/__init__.py", line 25, in <module>
    from sglang.srt.layers.quantization.fp8 import Fp8Config, Fp8MoEMethod
  File "/mnt/data/bbuf/sglang/python/sglang/srt/layers/quantization/fp8.py", line 27, in <module>
    from sglang.srt.layers.fused_moe_triton import (
ImportError: cannot import name 'FusedMoE' from partially initialized module 'sglang.srt.layers.fused_moe_triton' (most likely due to a circular import) (/mnt/data/bbuf/sglang/python/sglang/srt/layers/fused_moe_triton/__init__.py)
>>> 

Reproduction

python3 
from sglang.srt.layers.fused_moe_triton.fused_moe import fused_moe

Environment

WARNING:mistral_common.tokens.tokenizers.multimodal:Warning: Your installation of OpenCV appears to be broken: module 'cv2.dnn' has no attribute 'DictValue'.Please follow the instructions at opencv/opencv-python#884 to correct your environment. The import of cv2 has been skipped.
Python: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
CUDA available: True
GPU 0,1,2,3,4,5,6,7: NVIDIA A800-SXM4-80GB
GPU 0,1,2,3,4,5,6,7 Compute Capability: 8.0
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 12.3, V12.3.52
CUDA Driver Version: 535.54.03
PyTorch: 2.5.1+cu124
sglang: 0.4.0.post1
flashinfer: 0.1.6+cu121torch2.4
triton: 3.1.0
transformers: 4.47.0
torchao: 0.5.0
numpy: 1.26.4
aiohttp: 3.8.6
fastapi: 0.115.0
hf_transfer: 0.1.8
huggingface_hub: 0.24.6
interegular: 0.3.3
modelscope: 1.18.1
orjson: 3.10.12
packaging: 23.2
psutil: 5.9.4
pydantic: 2.9.0
multipart: 0.0.9
zmq: 26.2.0
uvicorn: 0.30.6
uvloop: 0.20.0
vllm: 0.6.4.post1
openai: 1.46.0
anthropic: 0.34.2
decord: 0.6.0
NVIDIA Topology:
GPU0 GPU1 GPU2 GPU3 GPU4 GPU5 GPU6 GPU7 NIC0 NIC1 NIC2 NIC3 CPU Affinity NUMA Affinity GPU NUMA ID
GPU0 X NV8 NV8 NV8 NV8 NV8 NV8 NV8 PHB PHB PHB PHB 0-31 N/A N/A
GPU1 NV8 X NV8 NV8 NV8 NV8 NV8 NV8 PHB PHB PHB PHB 0-31 N/A N/A
GPU2 NV8 NV8 X NV8 NV8 NV8 NV8 NV8 PHB PHB PHB PHB 0-31 N/A N/A
GPU3 NV8 NV8 NV8 X NV8 NV8 NV8 NV8 PHB PHB PHB PHB 0-31 N/A N/A
GPU4 NV8 NV8 NV8 NV8 X NV8 NV8 NV8 PHB PHB PHB PHB 0-31 N/A N/A
GPU5 NV8 NV8 NV8 NV8 NV8 X NV8 NV8 PHB PHB PHB PHB 0-31 N/A N/A
GPU6 NV8 NV8 NV8 NV8 NV8 NV8 X NV8 PHB PHB PHB PHB 0-31 N/A N/A
GPU7 NV8 NV8 NV8 NV8 NV8 NV8 NV8 X PHB PHB PHB PHB 0-31 N/A N/A
NIC0 PHB PHB PHB PHB PHB PHB PHB PHB X PHB PHB PHB
NIC1 PHB PHB PHB PHB PHB PHB PHB PHB PHB X PHB PHB
NIC2 PHB PHB PHB PHB PHB PHB PHB PHB PHB PHB X PHB
NIC3 PHB PHB PHB PHB PHB PHB PHB PHB PHB PHB PHB X

Legend:

X = Self
SYS = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
PHB = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
PXB = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
PIX = Connection traversing at most a single PCIe bridge
NV# = Connection traversing a bonded set of # NVLinks

NIC Legend:

NIC0: mlx5_0
NIC1: mlx5_1
NIC2: mlx5_2
NIC3: mlx5_3

Hypervisor vendor: KVM
ulimit soft: 102400

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions