Skip to content

[wip] sync with upstream zImage #17822

Merged
mickqian merged 4 commits intosgl-project:mainfrom
yhyang201:zimage
Jan 29, 2026
Merged

[wip] sync with upstream zImage #17822
mickqian merged 4 commits intosgl-project:mainfrom
yhyang201:zimage

Conversation

@yhyang201
Copy link
Collaborator

Motivation

Modifications

Accuracy Tests

Benchmarking and Profiling

Checklist

Review Process

  1. Ping Merge Oncalls to start the PR flow. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • /tag-run-ci-label, /rerun-failed-ci, /tag-and-rerun-ci
  4. After green CI and required approvals, ask Merge Oncalls to merge.

@github-actions github-actions bot added the diffusion SGLang Diffusion label Jan 27, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yhyang201, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request synchronizes the Z-Image model integration with its upstream source by introducing distinct configurations for 'Turbo' and standard Z-Image models. It enhances the Z-Image pipeline with negative conditioning capabilities and refactors sampling parameters to provide separate defaults for each model variant, ensuring accurate model detection and configuration within the system.

Highlights

  • Negative Conditioning Support: Added a new method prepare_neg_cond_kwargs to the ZImagePipelineConfig to support negative conditioning, enhancing control over image generation.
  • Z-Image Sampling Parameter Refactoring: Refactored Z-Image sampling parameters by renaming the original ZImageSamplingParams to ZImageTurboSamplingParams and introducing a new ZImageSamplingParams class with distinct default values, differentiating between 'Turbo' and standard Z-Image models.
  • Updated Model Registration: Modified the model registry to correctly associate the new ZImageTurboSamplingParams with 'Z-Image-Turbo' models and the new ZImageSamplingParams with standard 'Z-Image' models, including refined model detection logic.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new prepare_neg_cond_kwargs method in zimage.py and refactors sampling parameters in sample/zimage.py to distinguish between 'Turbo' and standard ZImage models. The changes in registry.py correctly reflect these new configurations. However, there is a critical issue in the prepare_neg_cond_kwargs method where positive prompt embeddings are used instead of negative ones, which will lead to incorrect model behavior. Additionally, the default negative prompt for the new ZImageSamplingParams could be clarified.

def prepare_neg_cond_kwargs(self, batch, device, rotary_emb, dtype):
return {
"freqs_cis": self.get_freqs_cis(
batch.prompt_embeds[0],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The prepare_neg_cond_kwargs method is intended for negative conditioning, but it currently uses batch.prompt_embeds[0] to generate freqs_cis. This should be batch.negative_prompt_embeds[0] to correctly apply negative conditioning. Using positive prompt embeddings here will lead to incorrect model behavior and potentially degraded generation quality.

Suggested change
batch.prompt_embeds[0],
batch.negative_prompt_embeds[0],

num_inference_steps: int = 50

num_frames: int = 1
negative_prompt: str = " "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The negative_prompt for ZImageSamplingParams is set to a single space " ". This deviates significantly from the detailed default negative prompt in the base SamplingParams class. If the intention is to effectively disable negative prompting or use a minimal one, consider using None or an empty string "" for clarity, or add a comment explaining why a single space is specifically required for this model.

@yhyang201 yhyang201 marked this pull request as ready for review January 28, 2026 04:07
@yhyang201 yhyang201 requested a review from mickqian as a code owner January 28, 2026 04:07
@gemini-code-assist
Copy link
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@yhyang201
Copy link
Collaborator Author

/tag-and-rerun-ci

@mickqian
Copy link
Collaborator

/rerun-failed-ci

hf_model_paths=[
"Tongyi-MAI/Z-Image",
],
model_detectors=[
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could it works without these two model_detectors lines?

@mickqian mickqian merged commit 3c2f4c7 into sgl-project:main Jan 29, 2026
176 of 188 checks passed
yafengio added a commit to yafengio/sglang that referenced this pull request Jan 30, 2026
- fix CI formatting issues
- bump torchada version
- revert incorrect changes

Signed-off-by: yafeng.li <yafeng.li@mthreads.com>

[diffusion] model: sync with upstream z-Image  (sgl-project#17822)
charlesHsuGG pushed a commit to charlesHsuGG/sglang that referenced this pull request Jan 30, 2026
Chen-0210 pushed a commit to Chen-0210/sglang that referenced this pull request Jan 30, 2026
sfiisf pushed a commit to sfiisf/sglang that referenced this pull request Feb 5, 2026
Johnsonms pushed a commit to Johnsonms/sglang that referenced this pull request Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants