|
8 | 8 | from ais_bench.benchmark.models.local_models.base import BaseModel |
9 | 9 | from ais_bench.benchmark.models import APITemplateParser |
10 | 10 | from ais_bench.benchmark.registry import MODELS |
11 | | - |
12 | | -from mindspore import Tensor, Model |
13 | | -from mindformers import MindFormerConfig, build_context |
14 | | -from mindformers.models import build_network |
15 | | -from mindformers.core.parallel_config import build_parallel_config |
16 | | -from mindformers.utils.load_checkpoint_utils import get_load_path_after_hf_convert |
17 | | -from mindformers.trainer.utils import transform_and_load_checkpoint |
18 | | - |
| 11 | +try: |
| 12 | + from mindspore import Tensor, Model |
| 13 | + from mindformers import MindFormerConfig, build_context |
| 14 | + from mindformers.models import build_network |
| 15 | + from mindformers.core.parallel_config import build_parallel_config |
| 16 | + from mindformers.utils.load_checkpoint_utils import get_load_path_after_hf_convert |
| 17 | + from mindformers.trainer.utils import transform_and_load_checkpoint |
| 18 | +except ModuleNotFoundError as _mf_err: |
| 19 | + MIND_FORMERS_INSTALL_GUIDE = ( |
| 20 | + "MindSpore/MindFormers is not available in the current environment. " |
| 21 | + "To use `MindFormerModel`, install MindSpore and MindFormers and ensure any required " |
| 22 | + "environment variables for your device are configured.\n\n" |
| 23 | + "Quick steps (examples):\n" |
| 24 | + " 1) Follow the official MindSpore installation guide for your platform: " |
| 25 | + "https://www.mindspore.cn/install/en.\n" |
| 26 | + " 2) Install MindFormers: `pip install mindformers` (or follow its docs); " |
| 27 | + "alternatively, add a local MindFormers checkout to your PYTHONPATH, e.g.:\n" |
| 28 | + " PYTHONPATH=/path/to/mindformers:$PYTHONPATH\n" |
| 29 | + ) |
| 30 | + raise ModuleNotFoundError(MIND_FORMERS_INSTALL_GUIDE) from _mf_err |
19 | 31 |
|
20 | 32 |
|
21 | 33 | class MultiTokenEOSCriteria(transformers.StoppingCriteria): |
|
0 commit comments