← Back to Pull requests

[model, lora] feat: add Qwen-Image-2.1 LoRA training #1244

Open
unknown opened this pull request with 480 lines diff across 6 files
View on GitHub
unknown unknown commented on Sep 25, 2026 12:39 UTC
Author

What does this PR do?

Add online text-to-image LoRA training support for Qwen-Image-2.1.

The integration loads the official Qwen3-VL text encoder and Qwen-Image-2.1
VAE, delegates transformer computation to Diffusers, and trains attention
LoRA adapters through VeOmni's existing DiTTrainer.

Test

Current validation after merging main 5040b347 (2026-10-23): CPU, PyTorch 2.11.0, Transformers 5.16.1, Diffusers 0.41.0.dev0 and Hugging Face Hub 1.33.0.

  • Extended existing CI collection scopes: tests/models/diffusers/test_qwen_image21.py, tests/data/test_dit_data_contract.py and tests/models/base/test_auto_registry.py.

  • Combined focused suite: 155 passed, 2 CUDA-only skipped.

  • The dependency-overlay CI step reuses the existing 14-unit model selection through the accelerator scheduler, filtering qwen_image21 or test_auto_registry. Local scheduler execution: 147 passed, 2 CUDA-only skipped across exactly 131 registry and 18 Qwen cases. CPU cases reserve zero cards; CUDA cases declare an accelerator plan.

  • CI retains the normal suite, then installs Diffusers revision bdc2bea37a36038c44452811610489ea30ede229 and Hub 1.33.0, requires all Qwen components, and runs the filtered selection in a separate output directory.

  • URL decoding fixtures implement main's HTTP-status check while retaining the alpha-preservation assertions.

  • make quality and branch whitespace checks pass. GPU hardware was not rerun for this integration update.
  • VEOMNI_REQUIRE_QWEN_IMAGE21=1 python -m pytest -q \
      tests/models/diffusers/test_qwen_image21.py \
      tests/data/test_dit_data_contract.py tests/models/base/test_auto_registry.py
    VEOMNI_REQUIRE_QWEN_IMAGE21=1 python -m scripts.ci.accelerator \
      --backend cuda --suite unit --only 14-unit \
      --pytest-arg=-k --pytest-arg="qwen_image21 or test_auto_registry" \
      --output-dir outputs/accelerator-ci/qwen-image21-upstream
    

    Earlier hardware validation, before this main integration: one A800 DiTTrainer step at 512x512 produced finite loss 2.86, gradient norm 1.26 and 30.85 GiB peak memory, with DCP and PEFT adapter export. The resolution sweep passed through 4608x4608 and reached CUDA OOM at 4864x4864. Those runs do not validate this updated revision.

    API and Usage Example

    CUDA_VISIBLE_DEVICES=0 NPROC_PER_NODE=1 \
    bash train.sh tasks/train_dit.py configs/dit/qwen_image21_lora.yaml \
      --model.model_path /path/to/Qwen-Image-2.1/transformer \
      --model.condition_model_path /path/to/Qwen-Image-2.1 \
      --data.train_path /path/to/train.jsonl \
      --train.checkpoint.output_dir /path/to/output
    

    Design & Code Changes

  • Register Qwen-Image-2.1 only when the required Diffusers components exist.

  • Add VeOmni transformer and condition-model wrappers.

  • Use the official resolution-dependent FlowMatch schedule and scale_noise.

  • Add single-GPU LoRA configuration, toy registry configuration, tests,

  • documentation, and GPU CI coverage.
  • Keep image editing, offline latents, sequence parallelism, and

  • full-parameter training outside the current scope.

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Added Qwen-Image-2.1 support for text-to-image training and inference.
    Added a configuration for training Qwen-Image-2.1 LoRA adapters.
    Added Qwen-Image-2.1 to the supported models list.
    Added optional RGBA image loading to preserve transparency; RGB remains the default.
    Documentation
    Added a guide covering setup, dataset formats, launch instructions, validation results, and current limitations.
    Tests
    * Added coverage for Qwen-Image-2.1 behavior, image preprocessing, serialization, and LoRA workflows.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 480 lines (+360 / -120) across 6 files Reviewer: Levius-Fubuki Review duration: 96100m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.54) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.54 · 480 lines diff across 6 files
    0.54
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.369
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #1244"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 54.3% (MEDIUM) · Higher = larger blast radius
    54.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 30% · Safe to merge
    30%