modelscope / modelscope/DiffSynth-Studio

ModuleNotFoundError when importing diffsynth.pipelines.qwen_image - Circular Import Issue

Open
#765 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
13.1k
Forks
1.3k
Avg merge
13h 12m
Merged PRs (30d)
45

Description

I'm trying to train a Qwen-Image LoRA using the provided training scripts, but encountering a module import error
when running the training command.

Environment:

  • OS: Windows 11
  • Python: 3.11
  • DiffSynth-Studio: Latest from main branch
  • Installation method: pip install -e .

Steps to Reproduce:

  1. Clone the repository: git clone https://github.com/modelscope/DiffSynth-Studio.git
  2. Install the package: cd DiffSynth-Studio && pip install -e .
  3. Run the training script: accelerate launch examples/qwen_image/model_training/train.py

Error Traceback:
Traceback (most recent call last):
File "E:\dif\DiffSynth-Studio\examples\qwen_image\model_training\train.py", line 2, in
from diffsynth.pipelines.qwen_image import QwenImagePipeline, ModelConfig
File "E:\dif\DiffSynth-Studio\diffsynth_init_.py", line 2, in
from .models import *
File "E:\dif\DiffSynth-Studio\diffsynth\models_init_.py", line 1, in
from .model_manager import *
File "E:\dif\DiffSynth-Studio\diffsynth\models\model_manager.py", line 4, in
from .downloader import download_models, download_customized_models, Preset_model_id, Preset_model_website
File "E:\dif\DiffSynth-Studio\diffsynth\models\downloader.py", line 6, in
from ..configs.model_config import preset_models_on_huggingface, preset_models_on_modelscope, Preset_model_id
File "E:\dif\DiffSynth-Studio\diffsynth\configs\model_config.py", line 76, in
from ..models.qwen_image_text_encoder import QwenImageTextEncoder
[Error continues with circular import chain]

Analysis:
This appears to be a circular import issue where:

  1. diffsynth.init.py imports from models
  2. models.model_manager imports from downloader
  3. downloader imports from configs.model_config
  4. model_config tries to import back to models.qwen_image_text_encoder

This creates a circular dependency that prevents the module from loading properly.

Questions:

  1. Is the current training setup supposed to work out of the box?
  2. Are there any missing dependencies or installation steps?
  3. Could this be related to the recent Qwen-Image FP8 updates mentioned in recent commits?
  4. Should the imports in model_config.py be moved or made conditional to avoid circular dependencies?

Attempted Solutions:

  • Reinstalled with pip install -e .
  • Tried different Python versions
  • Ensured all dependencies are installed
  • Verified the repository is up to date

Any guidance on resolving this import issue would be greatly appreciated. Thank you!


Additional Context:
I'm specifically trying to train a custom LoRA on a personal dataset following the examples provided in
examples/qwen_image/model_training/. The goal is to fine-tune Qwen-Image for specific image generation tasks.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running accelerate launch examples/qwen_image/model_training/train.py and follow the import chain through diffsynth/__init__.py, diffsynth/models/model_manager.py, diffsynth/models/downloader.py, and diffsynth/configs/model_config.py. Check how model_config.py imports QwenImageTextEncoder and identify the dependency cycle. Done means the Qwen-Image training entry point imports without the reported circular-import error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.