main
py 61 lines 1.68 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 """Qwen4Exp model package."""
4
5 from typing import TYPE_CHECKING, Any
6
7 from .common.hyperconnection import (
8 GatedResidual,
9 GroupedGemmaRMSNorm,
10 HyperConnectionBase,
11 HyperConnectionConfig,
12 )
13
14 if TYPE_CHECKING:
15 from .nvidia.model import (
16 Qwen4ExpForCausalLM,
17 Qwen4ExpForConditionalGeneration,
18 )
19 from .nvidia.mtp import Qwen4ExpMTP
20
21
22 def __getattr__(name: str) -> Any:
23 if name in {
24 "Qwen4ExpForCausalLM",
25 "Qwen4ExpForConditionalGeneration",
26 "Qwen4ExpMTP",
27 }:
28 from vllm.platforms import current_platform
29
30 if current_platform.is_xpu() or current_platform.is_tpu():
31 raise NotImplementedError("Qwen4Exp currently supports CUDA and ROCm only")
32 if current_platform.is_rocm():
33 from .amd.model import (
34 Qwen4ExpForCausalLM,
35 Qwen4ExpForConditionalGeneration,
36 )
37 from .amd.mtp import Qwen4ExpMTP
38 else:
39 from .nvidia.model import (
40 Qwen4ExpForCausalLM,
41 Qwen4ExpForConditionalGeneration,
42 )
43 from .nvidia.mtp import Qwen4ExpMTP
44
45 return {
46 "Qwen4ExpForCausalLM": Qwen4ExpForCausalLM,
47 "Qwen4ExpForConditionalGeneration": (Qwen4ExpForConditionalGeneration),
48 "Qwen4ExpMTP": Qwen4ExpMTP,
49 }[name]
50 raise AttributeError(name)
51
52
53 __all__ = [
54 "GatedResidual",
55 "GroupedGemmaRMSNorm",
56 "HyperConnectionBase",
57 "HyperConnectionConfig",
58 "Qwen4ExpForCausalLM",
59 "Qwen4ExpForConditionalGeneration",
60 "Qwen4ExpMTP",
61 ]