Coverage for / home / jenkins / .local / lib / python3.10 / site-packages / hyper_multicore / __init__.py: 100%
13 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-11-15 05:03 +0800
« prev ^ index » next coverage.py v7.13.1, created at 2026-11-15 05:03 +0800
1# Copyright 2026 Huawei Technologies Co., Ltd
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"""Torch-only Multicore business APIs and generic diagnostic integration."""
17from typing import TYPE_CHECKING, Any
19from hyper_multicore.diagnostics import (
20 MegaKernelDiagnostics, prepare_mega_kernel_diagnostics, validate_mega_kernel_diagnostic_contract,
21)
23if TYPE_CHECKING:
24 from hyper_multicore.modules.mega_gate.module import MegaGate
25 from hyper_multicore.modules.mega_mhc.module import MegaMhc
26 from hyper_multicore.modules.mega_moe.module import MegaMoeExperts
28__all__ = [
29 "MegaGate", "MegaMhc", "MegaMoeExperts", "MegaKernelDiagnostics",
30 "prepare_mega_kernel_diagnostics", "validate_mega_kernel_diagnostic_contract",
31]
34def __getattr__(name: str) -> Any: # pylint: disable=invalid-name
35 """Load optional multicore modules only when their public API is requested."""
36 if name == "MegaMhc":
37 from hyper_multicore.modules.mega_mhc.module import ( # pylint: disable=import-outside-toplevel
38 MegaMhc as value,
39 )
40 elif name == "MegaGate":
41 from hyper_multicore.modules.mega_gate.module import ( # pylint: disable=import-outside-toplevel
42 MegaGate as value,
43 )
44 elif name == "MegaMoeExperts":
45 from hyper_multicore.modules.mega_moe.module import ( # pylint: disable=import-outside-toplevel
46 MegaMoeExperts as value,
47 )
48 else:
49 raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
50 globals()[name] = value
51 return value