Skip to content

For Z-Image-Turbo, make batch size > 1 work.#649

Closed
hinablue wants to merge 6 commits intoostris:mainfrom
hinablue:bs-and-lokr
Closed

For Z-Image-Turbo, make batch size > 1 work.#649
hinablue wants to merge 6 commits intoostris:mainfrom
hinablue:bs-and-lokr

Conversation

@hinablue
Copy link
Copy Markdown

@hinablue hinablue commented Jan 16, 2026

Test on my Mac and work fine (Yeap, I also make the MPS work, but this PR only for Lokr and BS > 1).
These changes should not affect the training of other models.

@hinablue
Copy link
Copy Markdown
Author

Quantize make the result very bad, I need more test.

@hinablue
Copy link
Copy Markdown
Author

hinablue commented Jan 16, 2026

Close it for test.

After 1,000 steps of testing, I found the problem was with generating the sample images; the results for the sample images were terrible. The downloaded Lokr model, however, was usable. I think I need to find the cause.

@hinablue hinablue closed this Jan 16, 2026
@hinablue
Copy link
Copy Markdown
Author

I updated lokr.py to make it usable for generating example images for Z-Image-Turbo Lokr. And Lokr works correctly after training.

New Logical Flow

  1. Dequantization: Remains the same.
  2. Base Output: Directly calls self.org_forward(x) to get the output from the original layer.
  3. Delta Weight: Calculates only the LoKR delta matrix $\Delta W$.
  4. Delta Output: Calculates $x \cdot \Delta W$.
  5. Output Merging: Adds the two together using the formula: $Output = BaseOutput + (DeltaOutput \cdot multiplier)$.

Pros and Cons

  • Pros: Excellent compatibility (works regardless of how the base model is optimized/quantized); lower memory pressure.
  • Cons: Slightly slower computation speed (requires two matrix multiplications).

@hinablue hinablue reopened this Jan 17, 2026
@hinablue hinablue closed this Jan 25, 2026
@hinablue hinablue changed the title For Z-Image-Turbo, make Lokr and batch size > 1 work. For Z-Image-Turbo, make batch size > 1 work. Jan 26, 2026
@hinablue
Copy link
Copy Markdown
Author

Lokr support just update lycoris_lora==3.4.0 🙂

@hinablue
Copy link
Copy Markdown
Author

hinablue commented Jan 27, 2026

Rollback all core changes and focus only on z_image.py to make it compatible with BS > 1.

@Yudelei
Copy link
Copy Markdown

Yudelei commented Jan 29, 2026

I tested this branch on my RTX 5070 Ti (using only Z-Image Turbo + Base model), and batch size=2 worked perfectly—no errors, training ran smoothly.

Thank you very much for your contribution—this fixes a really useful feature for many of us!

@TigonTX
Copy link
Copy Markdown

TigonTX commented Feb 2, 2026

How do I apply this fix to my config?

@Yudelei
Copy link
Copy Markdown

Yudelei commented Feb 2, 2026

How do I apply this fix to my config?

try
git checkout pr-649

@jaretburkett
Copy link
Copy Markdown
Contributor

This issue should be resolved now.

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.

4 participants