Skip to content

fix: restore Qwen Image 2.1 prefix caching in DGL - #2405

Merged
leejet merged 1 commit into
masterfrom
fix/qwen-image-2-1-prefix-cache
Nov 23, 2026
Merged

leejet merged 1 commit into
masterfrom
fix/qwen-image-2-1-prefix-cache

Conversation

@leejet

@leejet leejet commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Restore Qwen Image 2.1 prefix caching after the DGL migration by passing a stable, nonzero prefix_id from each fixed predictor to the runner. Addresses the edit-sampling regression reported in #2401.
  • Give positive, negative, and distinct reference predictors separate IDs within each sampling run. Step-dependent conditioning keeps ID 0. The existing runner handles cache cleanup and low-memory fallback.

Related Issue / Discussion

N/A

Additional Information

N/A

Checklist

Summary by CodeRabbit

  • Bug Fixes
    • Improved image generation with Qwen Image 2.1 models in configurations without controls, IP-Adapters, or PuLID bindings.
    • Generation now better distinguishes eligible model configurations, helping produce more consistent results across image-generation steps.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Qwen Image 2.1 prediction steps now carry a prefix ID. Predictor collection assigns IDs to eligible leaves, and the DiT code passes each ID in QwenImage21DiffusionExtra.

Changes: Qwen Image 2.1 prefix ID flow

Layer / File(s) Summary
Assign and forward prefix IDs
src/dgl/models/diffusion_prediction.h, src/dgl/ops/predictor.cpp, src/dgl/models/dit.cpp
DiffusionPredictionStep gains a uint64_t prefix ID. Predictor collection stores sequential IDs for Qwen Image 2.1 leaves without control, IP-Adapter, or PuLID bindings. Prediction passes the stored ID, or 0 when none is stored, to QwenImage21DiffusionExtra.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • leejet/stable-diffusion.cpp#2401: The prefix ID changes target the reported lack of prefix-cache use during Qwen Image 2.1 edits and the associated slowdown. The reported VRAM retention between jobs is not addressed.

Suggested reviewers: wbruna

Merge Risk: Minimal · up to a56b3

This change restores prefix caching for Qwen Image 2.1 edit sampling by passing a stable prefix ID per predictor. No actionable merge-blocking risk was found, and unsupported cases fall back to the existing uncached behavior.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: restoring Qwen Image 2.1 prefix caching, which matches the raw summary's changes to pass a stable nonzero qwen_prefix_id from predictors to the step. The 'fix:' prefix…
Description check Passed The description has the Summary, Related Issue / Discussion, Additional Information, and Checklist sections from the template. The Summary explains the change and links issue #2401. Related Issue is N…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: restoring Qwen Image 2.1 prefix caching, which matches the raw summary's changes to pass a stable nonzero qwen_prefix_id from predictors to the step. The 'fix:' prefix is conventional and the title is specific enough for a teammate scanning history.

Full details: Description check

Explanation

The description has the Summary, Related Issue / Discussion, Additional Information, and Checklist sections from the template. The Summary explains the change and links issue #2401. Related Issue is N/A, which is acceptable here since the issue is linked in the Summary. Additional Information is N/A, with no verification notes. The checklist is ticked, but the model-documentation item does not clearly apply to this DGL C++ change, which touches no model support docs.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Cppcheck (2.22.0)

Cppcheck (2.22.0) exceeded its 180-second time budget. Findings from completed work are retained; remaining checks are incomplete.

src/dgl/ops/predictor.cpp

Cppcheck interrupted; analysis of this file is incomplete

src/dgl/models/dit.cpp

Cppcheck interrupted; analysis of this file is incomplete

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a3e02706-6414-478a-958b-2aa67f6774f8
Commits

Reviewing files that changed from the base of the PR and between 5b80e1f and a56b3bc.

Files selected for processing: 3

  • src/dgl/models/diffusion_prediction.h
  • src/dgl/models/dit.cpp
  • src/dgl/ops/predictor.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

@leejet
leejet merged commit 91ed009 into master Nov 23, 2026
11 checks passed
@leejet
leejet deleted the fix/qwen-image-2-1-prefix-cache branch November 23, 2026 17:19
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.

1 participant