|
| 1 | +# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +import sys |
| 16 | +from contextlib import suppress |
| 17 | +from typing import TYPE_CHECKING |
| 18 | + |
| 19 | +from ...utils.lazy_import import _LazyModule |
| 20 | + |
| 21 | +import_structure = { |
| 22 | + "modular_moe_layer": ["ModularMoELayer"], |
| 23 | + "moe_communication": ["MoECommunicationInterface", "AllToAllMoECommunication", "DeepEPMoECommunication"], |
| 24 | + "moe_expert": ["MoEExpertInterface", "StandardMoEExpert", "Qwen2MLP"], |
| 25 | + "moe_gate": ["PretrainedMoEGate"], |
| 26 | + "moe_factory": ["QuickAccessMoEFactory"], |
| 27 | +} |
| 28 | + |
| 29 | +if TYPE_CHECKING: |
| 30 | + from .modular_moe_layer import ModularMoELayer |
| 31 | + from .moe_communication import ( |
| 32 | + AllToAllMoECommunication, |
| 33 | + DeepEPMoECommunication, |
| 34 | + MoECommunicationInterface, |
| 35 | + ) |
| 36 | + from .moe_expert import MoEExpertInterface, Qwen2MLP, StandardMoEExpert |
| 37 | + from .moe_factory import * |
| 38 | + from .moe_gate import PretrainedMoEGate |
| 39 | +else: |
| 40 | + sys.modules[__name__] = _LazyModule( |
| 41 | + __name__, |
| 42 | + globals()["__file__"], |
| 43 | + import_structure, |
| 44 | + module_spec=__spec__, |
| 45 | + ) |
0 commit comments