LLaDA icon indicating copy to clipboard operation
LLaDA copied to clipboard

[Help Needed] mmengine.Config.fromfile() resolves wrong path for local configs

Open SIKAI-C opened this issue 1 month ago • 4 comments

[Help Needed] mmengine.Config.fromfile() resolves wrong path for local configs

Description

I’m encountering a ConfigParsingError when trying to run OpenCompass locally using my editable installation.
mmengine.Config.fromfile() tries to import config files from an incorrect path under ~/.conda site-packages/docs/configs/..., even though the files exist correctly in my local folder.

Error Trace

Traceback (most recent call last):
  File "~/.conda/envs/dllm/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "~/.conda/envs/dllm/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "folder_dir/LLaDA/opencompass/run.py", line 4, in <module>
    main()
  File "folder_dir/LLaDA/opencompass/opencompass/cli/main.py", line 258, in main
    cfg = get_config_from_arg(args)
  File "folder_dir/LLaDA/opencompass/opencompass/utils/run.py", line 97, in get_config_from_arg
    config = Config.fromfile(args.config, format_python_code=False)
  File "~/.conda/envs/dllm/lib/python3.10/site-packages/mmengine/config/config.py", line 494, in fromfile
    raise e
  File "~/.conda/envs/dllm/lib/python3.10/site-packages/mmengine/config/config.py", line 492, in fromfile
    cfg_dict, imported_names = Config._parse_lazy_import(filename)
  File "~/.conda/envs/dllm/lib/python3.10/site-packages/mmengine/config/config.py", line 1074, in _parse_lazy_import
    raise ConfigParsingError(
mmengine.config.utils.ConfigParsingError: ~/.conda/envs/dllm/lib/python3.10/site-packages/docs/configs/datasets/gsm8k/gsm8k_gen_base.py not found! It means that incorrect module is defined in `with read_base(): = from opencompass.configs.datasets.gsm8k.gsm8k_gen_base import ...`, please make sure the base config module is valid and is consistent with the prior import logic

Environment

  • OpenCompass version: local editable install (pip install -e .)
  • Python: 3.10
  • OS: Linux (cluster environment)

What I’ve tried

  • Verified that opencompass and opencompass.configs both resolve to my local repo:
python -c "import subprocess,os; subprocess.check_call(['python','-c',                                                                                                           
\"import opencompass, opencompass.configs as c; \
print(opencompass.__file__); print(list(opencompass.__path__)); \
print(list(c.__path__))\"], env=os.environ)"

cur_dir/LLaDA/opencompass/opencompass/__init__.py
['cur_dir/LLaDA/opencompass/opencompass']
['cur_dir/LLaDA/opencompass/opencompass/configs']
  • Added a local PYTHONPATH override for the repo
  • Still seeing mmengine resolve the path incorrectly to site-packages/docs/...

Additional Content

I’ve spent several hours debugging this and confirmed the file path is correct in my repo. Would appreciate any guidance on fixing or correctly configuring this.

SIKAI-C avatar Oct 24 '25 20:10 SIKAI-C

Hi SIKAI-C! Could you please provide the exact command you executed that led to this problem?

xushaoxuan123 avatar Oct 27 '25 07:10 xushaoxuan123

Thank you for your reply.

Here are the steps I followed:

  • I cloned the LLaDA repository into the current directory.
  • Then, I ran cd LLaDA/opencompass and installed the package using pip install -e .
  • I downloaded the corresponding dataset to the current directory and updated the config file at LLaDA/opencompass/opencompass/configs/datasets/[dataset_name]/xx.py to point to the correct dataset directory.
  • Finally, I ran the command:
python3 -m LLaDA.opencompass.run LLaDA/opencompass/examples/llada_base_gen_gsm8k.py -w z_artifacts/llada_eval/llada_base_gsm8k

Do you think there's anything wrong with the steps I followed?

What confuses me most is that although I installed opencompass in editable mode in the current directory, it seems like mmengine is still trying to load the config files from:

~/.conda/envs/list/dllm/lib/python3.10/site-packages/docs/configs/datasets/gsm8k/gsm8k_gen_base.py

SIKAI-C avatar Oct 30 '25 18:10 SIKAI-C

I encounter the same issue.

tonyckc avatar Oct 31 '25 08:10 tonyckc

Resolved for me

Solution 1

Modified the LLaDA/opencompass/examples/xxx.py's import part as:

with read_base():
    from ..opencompass.configs.datasets.gsm8k.gsm8k_gen_base import gsm8k_datasets
    from ..opencompass.configs.models.dllm.llada_base_8b import models as llada_base_8b_models

Solution 2

with read_base():
    from LLaDA.opencompass.opencompass.configs.datasets.gsm8k.gsm8k_gen_base import gsm8k_datasets
    from LLaDA.opencompass.opencompass.configs.models.dllm.llada_base_8b import models as llada_base_8b_models

💡 Why It Happens

  • The read_base() function itself is only a marker (it just yields, doesn’t affect paths).
  • During parsing, _parse_lazy_import() treats all imports under with read_base(): as absolute imports.
  • The first segment of the import path (opencompass or docs) is assumed to be an installed package, so it resolves to the environment’s site-packages path.

SIKAI-C avatar Oct 31 '25 14:10 SIKAI-C