Repository navigation
Studio diffusion: arm Z-Image's prompt-length inputs for an int8 / fp8 compile - #14715
Merged
Merged
Conversation
…8 compile An int8 Z-Image (the default when bf16 does not fit, e.g. a 12 GB card) compiles with automatic dynamic, so its shared block recompiled for the caption, image and unified lengths inside the first render and again on the first longer prompt. Add ZImageTransformer2DModel to _FAMILY_SOURCES with the sources PROMPT_LENGTH_POLICY already lists.
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…-text # Conflicts: # studio/backend/core/inference/diffusion_dynamic_text.py # studio/backend/tests/test_diffusion_dynamic_text.py # studio/backend/tests/test_diffusion_prompt_length_policy.py [skip ci]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An int8 Z-Image-Turbo, which is what the default load picks when bf16 would not fit (a 12 GB card here: int8 + group offload), compiles with automatic dynamic (
compile_dynamicreturnsNonefor torchao weights). Its one block class runs the caption refiner (caption tokens), the noise refiner (image tokens) and the main layers (caption + image), so on main:tensor 'x' size mismatch at index 1. expected 4096, actual 32), andtensor 'x' size mismatch at index 1. expected 32, actual 256: the caption is padded to 32-token buckets).#14387 classified Z-Image's prompt-length inputs in
PROMPT_LENGTH_POLICYbut left them out of_FAMILY_SOURCES. This arms them, as FLUX.3 and Qwen-Image already are, so a longer prompt reuses the first compile instead of recompiling.A bf16 Z-Image (resident,
dynamic=True) is unchanged:installarms sources only for an automatic-dynamic compile, and that path already showed 0 recompiles on the same follow-up sequence.Measured (real weights, Tongyi-MAI/Z-Image-Turbo, defaults on a 12 GiB card, one process, B200, torch 2.13)
Follow-up sequence, main vs this branch, same process layout (speed unset, memory auto, which resolves to int8 + group offload + regional compile + CUDA graphs on this card):
x32 to 256)Every image is bit-identical between main and this branch (same sha256 prefixes for the first render, the long prompt, the seed change, the new resolution and the return to 1024).
The 7 first-render recompiles left on this branch are one-time and come from inputs this change does not arm: the refiners pass
adaln_input=Nonewhere the main layers pass a tensor (a different graph by construction), andfreqs_cisreaches the attention processor throughcross_attention_kwargs. No later render recompiles.The host was heavily loaded (load average above 1000), so wall times are what one user saw on that host; the recompile and capture counts are the result.
Changes
diffusion_dynamic_text._FAMILY_SOURCES: addZImageTransformer2DModel: _ZIMAGE_SOURCES(the sources Studio diffusion: record a prompt length's CUDA graph on the first render only #14387 already defined).test_zimage_new_caption_bucket_reuses_the_first_graphs(a Z-Image block stand-in compiled with automatic dynamic, called with caption, image and unified lengths: unarmed it compiles more than once in the first render, armed it compiles once and never again across caption buckets and image sizes). Fails on main (installarms nothing), passes here. The policy test now lists Z-Image among the armed classes.Testing
pytest tests/test_diffusion_dynamic_text.py tests/test_diffusion_prompt_length_policy.py: 33 passed (the new test fails on main).Not covered