Skip to content

[FEAT] support for z-image-turbo - #815

Merged
lmxyy merged 17 commits into
nunchaku-ai:mainfrom
devgdovg:feat/z-image-turbo
Dec 20, 2025
Merged

[FEAT] support for z-image-turbo#815
lmxyy merged 17 commits into
nunchaku-ai:mainfrom
devgdovg:feat/z-image-turbo

Conversation

@devgdovg

@devgdovg devgdovg commented Dec 5, 2025

Copy link
Copy Markdown
Contributor

Motivation

Supports for https://huggingface.co/Tongyi-MAI/Z-Image-Turbo and maybe future Z-Image-Base & Z-Image-Edit

Modifications

Checklist

  • Code is formatted using Pre-Commit hooks.
  • Relevant unit tests are added in the tests directory following the guidance in Contribution Guide.
  • Documentation and example scripts in examples are updated if necessary.
  • Throughput/latency benchmarks and quality evaluations are included where applicable.
  • For reviewers: If you're only helping merge the main branch and haven't contributed code to this PR, please remove yourself as a co-author when merging.
  • Please feel free to join our Slack, Discord or WeChat to discuss your PR.

@devgdovg
devgdovg marked this pull request as ready for review December 5, 2025 16:32
@atgctg

atgctg commented Dec 6, 2025

Copy link
Copy Markdown

Hi, I would like to test the FP4 version. Could you please publish the SVDQ safetensors on Huggingface?

@juntaosun

Copy link
Copy Markdown

Could you please publish the SVDQ safetensors on Huggingface?

@lmxyy

lmxyy commented Dec 7, 2025

Copy link
Copy Markdown
Collaborator

Could you please publish the SVDQ safetensors on Huggingface?

let me test first.

@devgdovg

devgdovg commented Dec 7, 2025

Copy link
Copy Markdown
Contributor Author

Test cases added. @lmxyy
But before model checkpoints are published to huggingface hub, we should modify the path value to a temporary local directory in the test cases in order to run.

@lmxyy lmxyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you also update the docs correspondingly?

@devgdovg

devgdovg commented Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

Could you also update the docs correspondingly?

ok.

@juntaosun

Copy link
Copy Markdown

@devgdovg Does it support Lora loading for z-image-turbo?

@praveenmaniyan

Copy link
Copy Markdown

@devgdovg really appreciate your efforts in getting this functionality work. Can we get an update on this implementation. Is the model ready, or by when can we have this feature available?

Thanks in advance.

@vgabbo

vgabbo commented Dec 13, 2025

Copy link
Copy Markdown

I want to thank you for the contribution, really appreciate efforts. I will keep following PR, Z-turbo in nunchaku is very good news.

@juntaosun

Copy link
Copy Markdown

Is the model ready, or by when can we have this feature available?

@devgdovg
devgdovg requested a review from lmxyy December 14, 2025 12:49
@devgdovg

Copy link
Copy Markdown
Contributor Author

@devgdovg Does it support Lora loading for z-image-turbo?

not yet in this PR.

@vgabbo

vgabbo commented Dec 17, 2025

Copy link
Copy Markdown

Sorry to disturb, I was curious, is this faster than original one @devgdovg ? How much time does it take, compared to other models? Nunchaku is really strong, sometimes it offers specialized kernels and so I was curious to understand if they are used also in z-turbo. Thank you.

@devgdovg

Copy link
Copy Markdown
Contributor Author

Sorry to disturb, I was curious, is this faster than original one @devgdovg ? How much time does it take, compared to other models? Nunchaku is really strong, sometimes it offers specialized kernels and so I was curious to understand if they are used also in z-turbo. Thank you.

According to the testing I've done so far, Nunchaku optimized z-image-turbo model is definitely faster compared to fp16/fp8 models provided by Comfy-Org. Am waiting for @lmxyy to review all the stuff, including code/docs/models.

@zwukong

zwukong commented Dec 20, 2025

Copy link
Copy Markdown

merge一下吧,模型已经上传了

@zwukong

zwukong commented Dec 20, 2025

Copy link
Copy Markdown

256版本报错

File "M:\ComfyUI\312_cu128\ComfyUI\custom_nodes\ComfyUI-nunchaku\nodes\models\zimage.py", line 153, in _load
    patch_scale_key(model.diffusion_model, patched_sd)
  File "M:\ComfyUI\312_cu128\python_embeded\Lib\site-packages\nunchaku\models\transformers\utils.py", line 168, in patch_scale_key
    assert state_dict[k].dtype == state_dict_from_checkpoint[k].dtype
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

prompt=prompt,
height=1024,
width=1024,
num_inference_steps=8, # This actually results in 8 DiT forwards

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This should probably be set to num_inference_steps=9 to match the official example: https://github.com/Tongyi-MAI/Z-Image?tab=readme-ov-file#-quick-start

@lmxyy lmxyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

passing tests, merged

@lmxyy
lmxyy merged commit 715b6e5 into nunchaku-ai:main Dec 20, 2025
3 checks passed
@Ph0rk0z

Ph0rk0z commented Dec 20, 2025

Copy link
Copy Markdown

256版本报错

File "M:\ComfyUI\312_cu128\ComfyUI\custom_nodes\ComfyUI-nunchaku\nodes\models\zimage.py", line 153, in _load
    patch_scale_key(model.diffusion_model, patched_sd)
  File "M:\ComfyUI\312_cu128\python_embeded\Lib\site-packages\nunchaku\models\transformers\utils.py", line 168, in patch_scale_key
    assert state_dict[k].dtype == state_dict_from_checkpoint[k].dtype
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

Same problem with 256. Will try 128. Skip assert did not work.

edit: 128 has the problem too. I commented out the code that calls this function and it inferences at least. also the FP16_downscale patch isn't compatible.

@badraymen

Copy link
Copy Markdown

Plz sir don't forget the controlnet of zimage in the pack

@fappaz fappaz mentioned this pull request Dec 21, 2025
2 tasks
@Heliumrich

Copy link
Copy Markdown

Apparently the quality is poor.
Hopefully it will work better with non-distilled base model. (and with lora support ootb!)

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.

10 participants