Skip to content

fix(template): keep MiMo dependencies optional - #9886

Merged
hjh0119 merged 1 commit into
modelscope:mainfrom
RerankerGuo:fix/lazy-mimo-optional-dependency
Aug 11, 2026
Merged

fix(template): keep MiMo dependencies optional#9886
hjh0119 merged 1 commit into
modelscope:mainfrom
RerankerGuo:fix/lazy-mimo-optional-dependency

Conversation

@RerankerGuo

Copy link
Copy Markdown
Contributor

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

PR information

MiMo-V2.5 support added qwen_vl_utils as a module-level import in
swift.template.templates.mimo. Because all template modules are registered
when swift.template is imported, environments without that model-specific
optional dependency could no longer import unrelated template, dataset,
inference, trainer, or export modules.

This is visible in the NPU job for #9880, where 34 test modules failed during
collection with:

ModuleNotFoundError: No module named 'qwen_vl_utils'

The dependency is already declared in the MiMo model's requires list. This
change follows the existing Qwen, Llava, Dots, and Valley template pattern by
importing fetch_image and fetch_video only when MiMo media is actually
processed. MiMo users still receive the dependency error at the relevant
feature boundary, while unrelated imports remain available.

A subprocess regression test explicitly blocks every qwen_vl_utils import
and verifies that swift.template still imports successfully.

Experiment results

Before:

.venv/bin/python -m unittest tests.general.test_optional_template_dependencies
ModuleNotFoundError: No module named 'qwen_vl_utils'
FAILED (errors=1)

After:

.venv/bin/python tests/run.py \
  --test_dir tests/general \
  --pattern test_optional_template_dependencies.py
SUCCESS (Runs=1, success=1)

.venv/bin/python -m unittest tests.general.test_model
Ran 1 test
OK

.venv/bin/pre-commit run --all-files
All hooks passed

The local environment does not have qwen-vl-utils installed, so the direct
swift.template, swift.infer_engine.protocol, and swift.dataset imports
also verify the real missing-dependency path.

Delay qwen_vl_utils imports until MiMo media processing so unrelated template, dataset, and trainer imports keep working without the optional package. Add a subprocess regression test that blocks the dependency explicitly.

Test: python tests/run.py --test_dir tests/general --pattern test_optional_template_dependencies.py
@RerankerGuo

RerankerGuo commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

CI note: the new optional-dependency regression test passes in the CUDA run
(test_template_import_without_qwen_vl_utils, 7.8s). The run's only error is
the repository-wide ModuleNotFoundError: transformers.models.gemma3 in
test_gemma3_template.py, after the shared environment dependency mutation
already traced on #9862:
#9862 (comment).
Lint passes, and the NPU unittest is still running.

@hjh0119
hjh0119 merged commit 1dbd1bf into modelscope:main Aug 11, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants