Skip to content

Studio: use ComfyUI's default settings for FLUX.1, Qwen-Image, Z-Image, Ideogram 4, Wan2.2 and HunyuanVideo-1.5 - #12616

Merged
danielhanchen merged 20 commits into
mainfrom
reland/pr-12516
Oct 3, 2026
Merged

danielhanchen merged 20 commits into
mainfrom
reland/pr-12516

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Re-opens #12516 for review. It was merged before its review converged and was reverted in #12569.

The change is the original squash commit, cherry-picked unchanged (git cherry-pick -x fd2522bfc), with authorship kept for @danielhanchen. The full description and discussion are on #12516.
#12569 has merged, so this PR targets main and its diff shows only this change.

UI before / after

Images page after loading unsloth/Z-Image-Turbo-GGUF (Q4_K_M), merge base vs this branch: the seeded Steps move from 9 to 8 (ComfyUI's Z-Image-Turbo template), Guidance stays 0, and the rest of the panel is unchanged.

Images page Steps 9 before, 8 after

Studio UI regression check

Base b1da4866a vs head fffd068df. Functional: NO_REGRESSION, UI coverage 65%, 3 visual change(s), 1 text-only change(s). Only steps whose screenshots differ are shown.

diffusion_gen/s02_images_page: | reproduced on confirm (VISUAL_DIFF)
diffusion_gen/s02_images_page

diffusion_video/s02_video_page: | reproduced on confirm (VISUAL_DIFF)
diffusion_video/s02_video_page

diffusion_video/s04_clip_in_ui: masks cover 21% of the shot | reproduced on confirm (VISUAL_DIFF)
diffusion_video/s04_clip_in_ui

Step Text / structure change
crawl/r_chat

Etherll and others added 12 commits October 2, 2026 14:53
…and lighten both drag copies" (#12499)

This reverts commit 9838541. It was merged before Codex review converged; it will be re-opened for review.
…11187)" (#11361)

This reverts commit cd4d5c1. It was merged before Codex review converged; it will be re-opened for review.
… saved" (#12505)

This reverts commit a91ee37. It was merged before Codex review converged; it will be re-opened for review.
…advancing" (#12523)

This reverts commit d8740d3. It was merged before Codex review converged; it will be re-opened for review.
…row" (#12529)

This reverts commit 5b78baf. It was merged before Codex review converged; it will be re-opened for review.
…ersized request streams pinned groups" (#12526)

This reverts commit d883d2d. It was merged before Codex review converged; it will be re-opened for review.
…, Z-Image, Ideogram 4, Wan2.2 and HunyuanVideo-1.5" (#12516)

This reverts commit fd2522b. It was merged before Codex review converged; it will be re-opened for review.
…ndow" (#12514)

This reverts commit dae96ea. It was merged before Codex review converged; it will be re-opened for review.
…#12486)

This reverts commit ed6d0e8. It was merged before Codex review converged; it will be re-opened for review.
…names" (#12475)

This reverts commit 079dc91. It was merged before Codex review converged; it will be re-opened for review.
#12562 (make carried rows a faintly frosted, darker copy) landed after this
branch was cut and restyles the shared ghost rule that #12499 introduced: it
relies on --row-ghost-surface and .model-picker-row-ghost, and edits
model-picker-pinned-drag-preview.test.ts, all of which the #12499 revert
removes. Keeping it without #12499 leaves .sidebar-row-ghost reading an unset
variable, so the conflict is resolved by dropping #12562's two hunks as well.
It should be re-opened together with #12499. #12563, #12564 and #12597 are kept.
…e, Ideogram 4, Wan2.2 and HunyuanVideo-1.5 (#12516)

* Match ComfyUI's FLUX.1 T5 prompt length (256 floor, real length, 512 cap)

diffusers pads every FLUX.1 T5 prompt to 512 tokens and runs T5 without an
attention mask, so the padding changes the embeddings and adds 256 joint
attention tokens per step. ComfyUI pads to 256 and otherwise keeps the real
length. Pass max_sequence_length = clamp(T5 length incl. EOS, 256, 512) per
chunk for flux.1 and flux.1-kontext, signature gated, never over an explicit
value; the negative prompt counts only when true CFG encodes it.

* Run Qwen-Image true CFG with an empty negative like ComfyUI

diffusers enables Qwen-Image true CFG only when a negative prompt is passed,
and Studio sends none when the box is blank, so the default guidance 4 never
applied CFG. ComfyUI encodes an empty negative and applies CFG. For
true_cfg_scale families with guidance above 1 and no negative, pass an empty
negative; an explicit negative and guidance <= 1 are unchanged.

* Image steps and guidance defaults follow ComfyUI's templates

Default (steps, guidance) per model now match ComfyUI's official template for
the same checkpoint: FLUX.1 dev / Kontext / Krea dev 20 steps (Krea dev at the
FLUX guidance default 3.5), FLUX.2 dev 20, FLUX.2 klein base 20 at CFG 5,
Qwen-Image-2.1 25, Qwen-Image-Edit 2511 40 at 4, Qwen-Image-2512 50 at 4,
Z-Image-Turbo 8, Z-Image base 25 at 3.0 (diffusers Z-Image guidance is
ComfyUI cfg - 1), SDXL 25. Backend and UI tables stay in sync; explicit
request values are untouched.

* Ideogram 4 defaults to ComfyUI's 20-step constant-guidance schedule

ComfyUI's Ideogram 4 template samples 20 steps at constant guidance 7 with
the logit-normal schedule at mu 0.5 / std 1.75. Default to 20 / 7 and pass
those schedule parameters whenever guidance is constant; an explicit 48
steps at 7 still runs the card's tapered schedule with the pipeline's own
mu / std.

* Video steps and guidance defaults follow ComfyUI's templates

ComfyUI's official templates sample Wan2.2-TI2V-5B at 20 steps / CFG 5,
Wan2.2-T2V-A14B at 20 steps / CFG 3.5 (Lightning LoRA off) and
HunyuanVideo-1.5 at 20 steps / CFG 6, against Studio's 50-step defaults.
Match them in the family defaults, the per-variant table (A14B now has its
own key ahead of the generic Wan one) and the UI table. Explicit values are
unchanged.

* Sample Qwen-Image, Z-Image, Wan2.2 and HunyuanVideo-1.5 at ComfyUI's shift

The shipped schedulers shift sigmas differently from ComfyUI's defaults for
the same models: Qwen-Image / Qwen-Image-Edit resolve a dynamic exponential
shift (about 2.0 at 1024 px) with a 0.02 terminal stretch against a constant
3.1, Z-Image base ships 6.0 against 3.0, Wan2.2 TI2V-5B / T2V-A14B ship 5.0 /
3.0 against 8 / 5, HunyuanVideo-1.5 480p / 720p ship 5.0 / 9.0 against 7.
Add a per-family comfy_flow_shift and rebuild the scheduler at load with that
static shift (no dynamic mu, no terminal stretch). Families without the field
keep their shipped scheduler.

* Ideogram 4: follow ComfyUI's Default preset and its CFG override

The template's scheduler widgets are stale: steps / mu / std come from the
'Default' preset (20 / 0.0 / 1.75), and a CFG override in the model path
drops guidance 7 to 3 over the sampling range 0.7 to 1.0, which on the
shift-1 flow model is sigma <= 0.3. Use mu 0.0 / std 1.75 and, at the
default guidance 7, pass a per-step guidance_schedule of 7 then 3 on exactly
the steps whose logit-normal sigma is <= 0.3 (last 3 of 20 at 1024^2).
Other guidance values stay constant; an explicit 48 / 7 keeps the card
taper.

* FLUX.1 T5: bucket prompts past 256 tokens to 512

Every distinct T5 length is a new denoiser shape. On the compiled default
path with CUDA graphs, exact lengths cost a 14 s recompile for the first
length past 256 and a 0.4 to 1 s graph capture for each further one, until
the 4-graph cap made later shapes (resolution changes included) run eager.
Keep ComfyUI's 256 for prompts up to 256 tokens and pad longer ones to 512,
the old behaviour: two shapes per resolution. This deviates from ComfyUI's
exact length for 257 to 512 token prompts only (unmasked padding changes
their embeddings slightly).

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Ideogram 4 defaults comment: mu 0.0 and the 7 to 3 guidance switch

* sd.cpp: map Z-Image's diffusers guidance to standard CFG

The shared Z-Image default is now diffusers' g = 3 (ComfyUI cfg 4), but sd-cli takes
--cfg-scale as standard CFG, so the native engine sampled Z-Image base at cfg 3.
Pass g + 1 for Z-Image; Turbo's 0 still turns CFG off.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Etherll <[email protected]>
(cherry picked from commit fd2522b)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-03T14:23:28.126454Z b2f3176 Manual request
🔒 Security Review ⚠️ Failed 2026-10-03T10:48:33.102657Z a5d53a3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Base automatically changed from revert/unconverged-2026-10-02 to main October 3, 2026 10:51
danielhanchen and others added 3 commits October 3, 2026 03:51
…e, Ideogram 4, Wan2.2 and HunyuanVideo-1.5 (#12516)

* Match ComfyUI's FLUX.1 T5 prompt length (256 floor, real length, 512 cap)

diffusers pads every FLUX.1 T5 prompt to 512 tokens and runs T5 without an
attention mask, so the padding changes the embeddings and adds 256 joint
attention tokens per step. ComfyUI pads to 256 and otherwise keeps the real
length. Pass max_sequence_length = clamp(T5 length incl. EOS, 256, 512) per
chunk for flux.1 and flux.1-kontext, signature gated, never over an explicit
value; the negative prompt counts only when true CFG encodes it.

* Run Qwen-Image true CFG with an empty negative like ComfyUI

diffusers enables Qwen-Image true CFG only when a negative prompt is passed,
and Studio sends none when the box is blank, so the default guidance 4 never
applied CFG. ComfyUI encodes an empty negative and applies CFG. For
true_cfg_scale families with guidance above 1 and no negative, pass an empty
negative; an explicit negative and guidance <= 1 are unchanged.

* Image steps and guidance defaults follow ComfyUI's templates

Default (steps, guidance) per model now match ComfyUI's official template for
the same checkpoint: FLUX.1 dev / Kontext / Krea dev 20 steps (Krea dev at the
FLUX guidance default 3.5), FLUX.2 dev 20, FLUX.2 klein base 20 at CFG 5,
Qwen-Image-2.1 25, Qwen-Image-Edit 2511 40 at 4, Qwen-Image-2512 50 at 4,
Z-Image-Turbo 8, Z-Image base 25 at 3.0 (diffusers Z-Image guidance is
ComfyUI cfg - 1), SDXL 25. Backend and UI tables stay in sync; explicit
request values are untouched.

* Ideogram 4 defaults to ComfyUI's 20-step constant-guidance schedule

ComfyUI's Ideogram 4 template samples 20 steps at constant guidance 7 with
the logit-normal schedule at mu 0.5 / std 1.75. Default to 20 / 7 and pass
those schedule parameters whenever guidance is constant; an explicit 48
steps at 7 still runs the card's tapered schedule with the pipeline's own
mu / std.

* Video steps and guidance defaults follow ComfyUI's templates

ComfyUI's official templates sample Wan2.2-TI2V-5B at 20 steps / CFG 5,
Wan2.2-T2V-A14B at 20 steps / CFG 3.5 (Lightning LoRA off) and
HunyuanVideo-1.5 at 20 steps / CFG 6, against Studio's 50-step defaults.
Match them in the family defaults, the per-variant table (A14B now has its
own key ahead of the generic Wan one) and the UI table. Explicit values are
unchanged.

* Sample Qwen-Image, Z-Image, Wan2.2 and HunyuanVideo-1.5 at ComfyUI's shift

The shipped schedulers shift sigmas differently from ComfyUI's defaults for
the same models: Qwen-Image / Qwen-Image-Edit resolve a dynamic exponential
shift (about 2.0 at 1024 px) with a 0.02 terminal stretch against a constant
3.1, Z-Image base ships 6.0 against 3.0, Wan2.2 TI2V-5B / T2V-A14B ship 5.0 /
3.0 against 8 / 5, HunyuanVideo-1.5 480p / 720p ship 5.0 / 9.0 against 7.
Add a per-family comfy_flow_shift and rebuild the scheduler at load with that
static shift (no dynamic mu, no terminal stretch). Families without the field
keep their shipped scheduler.

* Ideogram 4: follow ComfyUI's Default preset and its CFG override

The template's scheduler widgets are stale: steps / mu / std come from the
'Default' preset (20 / 0.0 / 1.75), and a CFG override in the model path
drops guidance 7 to 3 over the sampling range 0.7 to 1.0, which on the
shift-1 flow model is sigma <= 0.3. Use mu 0.0 / std 1.75 and, at the
default guidance 7, pass a per-step guidance_schedule of 7 then 3 on exactly
the steps whose logit-normal sigma is <= 0.3 (last 3 of 20 at 1024^2).
Other guidance values stay constant; an explicit 48 / 7 keeps the card
taper.

* FLUX.1 T5: bucket prompts past 256 tokens to 512

Every distinct T5 length is a new denoiser shape. On the compiled default
path with CUDA graphs, exact lengths cost a 14 s recompile for the first
length past 256 and a 0.4 to 1 s graph capture for each further one, until
the 4-graph cap made later shapes (resolution changes included) run eager.
Keep ComfyUI's 256 for prompts up to 256 tokens and pad longer ones to 512,
the old behaviour: two shapes per resolution. This deviates from ComfyUI's
exact length for 257 to 512 token prompts only (unmasked padding changes
their embeddings slightly).

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Ideogram 4 defaults comment: mu 0.0 and the 7 to 3 guidance switch

* sd.cpp: map Z-Image's diffusers guidance to standard CFG

The shared Z-Image default is now diffusers' g = 3 (ComfyUI cfg 4), but sd-cli takes
--cfg-scale as standard CFG, so the native engine sampled Z-Image base at cfg 3.
Pass g + 1 for Z-Image; Turbo's 0 still turns CFG off.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Etherll <[email protected]>
(cherry picked from commit fd2522b)
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2c9e402f98

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment on lines +819 to +821
("a14b", 20, 3.5),
("wan2.2-14b", 20, 3.5),
("wan", 20, 5.0),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle all A14B aliases before generic Wan

The A14B family registry also accepts wan-t2v and wan2.2-t2v, but neither identifier contains a14b or wan2.2-14b, so both fall through to the generic wan entry and receive guidance 5.0 instead of the new A14B default 3.5. The frontend table has the same matching gap, so selecting either supported alias produces the wrong ComfyUI settings in both API and UI paths; add the remaining A14B aliases ahead of the generic match.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Defaults are resolved from the loaded gguf/repo/base_repo, not the family alias. Every A14B repo Studio loads carries A14B in its name and the family base_repo resolves to 20 steps / 3.5, and the UI only offers the canonical wan2.2-t2v-a14b name.

),
DiffusionFamily(
name = "qwen-image",
comfy_flow_shift = 3.1, # ComfyUI ModelSamplingAuraFlow 3.1 (Qwen-Image templates)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply the Qwen 3.1 shift to the native engine

When Qwen-Image runs through the stable-diffusion.cpp backend, this new comfy_flow_shift field is never read: SdCppDiffusionBackend copies the separate fam.sd_cpp_flow_shift, which remains 3.0, into every generation command. Consequently only the Diffusers engine adopts the advertised ComfyUI shift of 3.1, while selecting the native engine silently retains the old schedule; update the native shift alongside this field or use one shared value.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This change scopes the 3.1 shift to the Diffusers scheduler. The native engine keeps stable-diffusion.cpp's own documented Qwen-Image invocation (docs/qwen_image.md: --sampling-method euler --flow-shift 3), which this PR does not touch.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 0334e70374

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@danielhanchen danielhanchen self-assigned this Oct 3, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e54120dda1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

# so only the community repacks load.
VideoFamily(
name = "hunyuanvideo-1.5",
comfy_flow_shift = 7.0, # ComfyUI model default and template shift 7

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the 480p Hunyuan schedule at shift 5

When the 480p T2V family is loaded through Diffusers, apply_comfy_flow_shift now replaces its shipped shift 5.0 scheduler with 7.0. Shift 7 is used by the mirrored 720p ComfyUI template, while HunyuanVideo-1.5 recommends shift 5 for 480p T2V; the repository itself also records the 480p/720p shipped shifts as 5.0/9.0 in test_video_families.py:345. This therefore runs every default 480p generation on the wrong noise schedule; leave that family at 5.0 (or keep its shipped scheduler) and reserve 7.0 for the template variant that actually uses it. HunyuanVideo-1.5 inference configurations

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ComfyUI's own HunyuanVideo15 model (comfy/supported_models.py) sets sampling shift 7.0 for every 1.5 variant, 480p included, and this change follows ComfyUI as the baseline rather than the vendor's per-resolution recipe. The 5.0/9.0 values in the test are the shipped diffusers scheduler configs that the rebuild replaces.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: b2f317680a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 3, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 3, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 3, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 3, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

The red Chat UI Tests here is not caused by this PR. The permission step fails on heading "Enable Full access?". #12630 reworded that dialog, which broke the step on main. The run was built on a main from before the fix: #12640 (merged as 93769f5) changes that lookup. A rebase onto main or a re-run of the Chat UI jobs should clear it.

@danielhanchen
danielhanchen merged commit e8f30ca into main Oct 3, 2026
@danielhanchen
danielhanchen deleted the reland/pr-12516 branch October 3, 2026 17:44
JoshuaL3000 pushed a commit to JoshuaL3000/unsloth that referenced this pull request Oct 4, 2026
…e, Ideogram 4, Wan2.2 and HunyuanVideo-1.5 (unslothai#12616)

* Revert "Studio: lift a carried model picker row like a sidebar chat, and lighten both drag copies" (unslothai#12499)

This reverts commit 9838541. It was merged before Codex review converged; it will be re-opened for review.

* Revert "fix(studio): WSL2 Windows localhost hint in startup banner (unslothai#11187)" (unslothai#11361)

This reverts commit cd4d5c1. It was merged before Codex review converged; it will be re-opened for review.

* Revert "Studio: stop rejecting --mmproj-device CUDA1 when gpu_ids are saved" (unslothai#12505)

This reverts commit a91ee37. It was merged before Codex review converged; it will be re-opened for review.

* Revert "Studio: renew the chat-run lease while long prefill is still advancing" (unslothai#12523)

This reverts commit d8740d3. It was merged before Codex review converged; it will be re-opened for review.

* Revert "Count only the lock's own waits in the unlockable-filesystem row" (unslothai#12529)

This reverts commit 5b78baf. It was merged before Codex review converged; it will be re-opened for review.

* Revert "Studio: move torchao int8 weights back to the GPU after an oversized request streams pinned groups" (unslothai#12526)

This reverts commit d883d2d. It was merged before Codex review converged; it will be re-opened for review.

* Revert "Studio: use ComfyUI's default settings for FLUX.1, Qwen-Image, Z-Image, Ideogram 4, Wan2.2 and HunyuanVideo-1.5" (unslothai#12516)

This reverts commit fd2522b. It was merged before Codex review converged; it will be re-opened for review.

* Revert "Parity: keep the reap-margin check off the edge of its own window" (unslothai#12514)

This reverts commit dae96ea. It was merged before Codex review converged; it will be re-opened for review.

* Revert "Studio: train a dataset's system column as the system prompt" (unslothai#12486)

This reverts commit ed6d0e8. It was merged before Codex review converged; it will be re-opened for review.

* Revert "fix(studio): prevent IME confirmation from submitting chat renames" (unslothai#12475)

This reverts commit 079dc91. It was merged before Codex review converged; it will be re-opened for review.

* Studio: use ComfyUI's default settings for FLUX.1, Qwen-Image, Z-Image, Ideogram 4, Wan2.2 and HunyuanVideo-1.5 (unslothai#12516)

* Match ComfyUI's FLUX.1 T5 prompt length (256 floor, real length, 512 cap)

diffusers pads every FLUX.1 T5 prompt to 512 tokens and runs T5 without an
attention mask, so the padding changes the embeddings and adds 256 joint
attention tokens per step. ComfyUI pads to 256 and otherwise keeps the real
length. Pass max_sequence_length = clamp(T5 length incl. EOS, 256, 512) per
chunk for flux.1 and flux.1-kontext, signature gated, never over an explicit
value; the negative prompt counts only when true CFG encodes it.

* Run Qwen-Image true CFG with an empty negative like ComfyUI

diffusers enables Qwen-Image true CFG only when a negative prompt is passed,
and Studio sends none when the box is blank, so the default guidance 4 never
applied CFG. ComfyUI encodes an empty negative and applies CFG. For
true_cfg_scale families with guidance above 1 and no negative, pass an empty
negative; an explicit negative and guidance <= 1 are unchanged.

* Image steps and guidance defaults follow ComfyUI's templates

Default (steps, guidance) per model now match ComfyUI's official template for
the same checkpoint: FLUX.1 dev / Kontext / Krea dev 20 steps (Krea dev at the
FLUX guidance default 3.5), FLUX.2 dev 20, FLUX.2 klein base 20 at CFG 5,
Qwen-Image-2.1 25, Qwen-Image-Edit 2511 40 at 4, Qwen-Image-2512 50 at 4,
Z-Image-Turbo 8, Z-Image base 25 at 3.0 (diffusers Z-Image guidance is
ComfyUI cfg - 1), SDXL 25. Backend and UI tables stay in sync; explicit
request values are untouched.

* Ideogram 4 defaults to ComfyUI's 20-step constant-guidance schedule

ComfyUI's Ideogram 4 template samples 20 steps at constant guidance 7 with
the logit-normal schedule at mu 0.5 / std 1.75. Default to 20 / 7 and pass
those schedule parameters whenever guidance is constant; an explicit 48
steps at 7 still runs the card's tapered schedule with the pipeline's own
mu / std.

* Video steps and guidance defaults follow ComfyUI's templates

ComfyUI's official templates sample Wan2.2-TI2V-5B at 20 steps / CFG 5,
Wan2.2-T2V-A14B at 20 steps / CFG 3.5 (Lightning LoRA off) and
HunyuanVideo-1.5 at 20 steps / CFG 6, against Studio's 50-step defaults.
Match them in the family defaults, the per-variant table (A14B now has its
own key ahead of the generic Wan one) and the UI table. Explicit values are
unchanged.

* Sample Qwen-Image, Z-Image, Wan2.2 and HunyuanVideo-1.5 at ComfyUI's shift

The shipped schedulers shift sigmas differently from ComfyUI's defaults for
the same models: Qwen-Image / Qwen-Image-Edit resolve a dynamic exponential
shift (about 2.0 at 1024 px) with a 0.02 terminal stretch against a constant
3.1, Z-Image base ships 6.0 against 3.0, Wan2.2 TI2V-5B / T2V-A14B ship 5.0 /
3.0 against 8 / 5, HunyuanVideo-1.5 480p / 720p ship 5.0 / 9.0 against 7.
Add a per-family comfy_flow_shift and rebuild the scheduler at load with that
static shift (no dynamic mu, no terminal stretch). Families without the field
keep their shipped scheduler.

* Ideogram 4: follow ComfyUI's Default preset and its CFG override

The template's scheduler widgets are stale: steps / mu / std come from the
'Default' preset (20 / 0.0 / 1.75), and a CFG override in the model path
drops guidance 7 to 3 over the sampling range 0.7 to 1.0, which on the
shift-1 flow model is sigma <= 0.3. Use mu 0.0 / std 1.75 and, at the
default guidance 7, pass a per-step guidance_schedule of 7 then 3 on exactly
the steps whose logit-normal sigma is <= 0.3 (last 3 of 20 at 1024^2).
Other guidance values stay constant; an explicit 48 / 7 keeps the card
taper.

* FLUX.1 T5: bucket prompts past 256 tokens to 512

Every distinct T5 length is a new denoiser shape. On the compiled default
path with CUDA graphs, exact lengths cost a 14 s recompile for the first
length past 256 and a 0.4 to 1 s graph capture for each further one, until
the 4-graph cap made later shapes (resolution changes included) run eager.
Keep ComfyUI's 256 for prompts up to 256 tokens and pad longer ones to 512,
the old behaviour: two shapes per resolution. This deviates from ComfyUI's
exact length for 257 to 512 token prompts only (unmasked padding changes
their embeddings slightly).

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Ideogram 4 defaults comment: mu 0.0 and the 7 to 3 guidance switch

* sd.cpp: map Z-Image's diffusers guidance to standard CFG

The shared Z-Image default is now diffusers' g = 3 (ComfyUI cfg 4), but sd-cli takes
--cfg-scale as standard CFG, so the native engine sampled Z-Image base at cfg 3.
Pass g + 1 for Z-Image; Turbo's 0 still turns CFG off.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Etherll <[email protected]>
(cherry picked from commit fd2522b)

* Studio: use ComfyUI's default settings for FLUX.1, Qwen-Image, Z-Image, Ideogram 4, Wan2.2 and HunyuanVideo-1.5 (unslothai#12516)

* Match ComfyUI's FLUX.1 T5 prompt length (256 floor, real length, 512 cap)

diffusers pads every FLUX.1 T5 prompt to 512 tokens and runs T5 without an
attention mask, so the padding changes the embeddings and adds 256 joint
attention tokens per step. ComfyUI pads to 256 and otherwise keeps the real
length. Pass max_sequence_length = clamp(T5 length incl. EOS, 256, 512) per
chunk for flux.1 and flux.1-kontext, signature gated, never over an explicit
value; the negative prompt counts only when true CFG encodes it.

* Run Qwen-Image true CFG with an empty negative like ComfyUI

diffusers enables Qwen-Image true CFG only when a negative prompt is passed,
and Studio sends none when the box is blank, so the default guidance 4 never
applied CFG. ComfyUI encodes an empty negative and applies CFG. For
true_cfg_scale families with guidance above 1 and no negative, pass an empty
negative; an explicit negative and guidance <= 1 are unchanged.

* Image steps and guidance defaults follow ComfyUI's templates

Default (steps, guidance) per model now match ComfyUI's official template for
the same checkpoint: FLUX.1 dev / Kontext / Krea dev 20 steps (Krea dev at the
FLUX guidance default 3.5), FLUX.2 dev 20, FLUX.2 klein base 20 at CFG 5,
Qwen-Image-2.1 25, Qwen-Image-Edit 2511 40 at 4, Qwen-Image-2512 50 at 4,
Z-Image-Turbo 8, Z-Image base 25 at 3.0 (diffusers Z-Image guidance is
ComfyUI cfg - 1), SDXL 25. Backend and UI tables stay in sync; explicit
request values are untouched.

* Ideogram 4 defaults to ComfyUI's 20-step constant-guidance schedule

ComfyUI's Ideogram 4 template samples 20 steps at constant guidance 7 with
the logit-normal schedule at mu 0.5 / std 1.75. Default to 20 / 7 and pass
those schedule parameters whenever guidance is constant; an explicit 48
steps at 7 still runs the card's tapered schedule with the pipeline's own
mu / std.

* Video steps and guidance defaults follow ComfyUI's templates

ComfyUI's official templates sample Wan2.2-TI2V-5B at 20 steps / CFG 5,
Wan2.2-T2V-A14B at 20 steps / CFG 3.5 (Lightning LoRA off) and
HunyuanVideo-1.5 at 20 steps / CFG 6, against Studio's 50-step defaults.
Match them in the family defaults, the per-variant table (A14B now has its
own key ahead of the generic Wan one) and the UI table. Explicit values are
unchanged.

* Sample Qwen-Image, Z-Image, Wan2.2 and HunyuanVideo-1.5 at ComfyUI's shift

The shipped schedulers shift sigmas differently from ComfyUI's defaults for
the same models: Qwen-Image / Qwen-Image-Edit resolve a dynamic exponential
shift (about 2.0 at 1024 px) with a 0.02 terminal stretch against a constant
3.1, Z-Image base ships 6.0 against 3.0, Wan2.2 TI2V-5B / T2V-A14B ship 5.0 /
3.0 against 8 / 5, HunyuanVideo-1.5 480p / 720p ship 5.0 / 9.0 against 7.
Add a per-family comfy_flow_shift and rebuild the scheduler at load with that
static shift (no dynamic mu, no terminal stretch). Families without the field
keep their shipped scheduler.

* Ideogram 4: follow ComfyUI's Default preset and its CFG override

The template's scheduler widgets are stale: steps / mu / std come from the
'Default' preset (20 / 0.0 / 1.75), and a CFG override in the model path
drops guidance 7 to 3 over the sampling range 0.7 to 1.0, which on the
shift-1 flow model is sigma <= 0.3. Use mu 0.0 / std 1.75 and, at the
default guidance 7, pass a per-step guidance_schedule of 7 then 3 on exactly
the steps whose logit-normal sigma is <= 0.3 (last 3 of 20 at 1024^2).
Other guidance values stay constant; an explicit 48 / 7 keeps the card
taper.

* FLUX.1 T5: bucket prompts past 256 tokens to 512

Every distinct T5 length is a new denoiser shape. On the compiled default
path with CUDA graphs, exact lengths cost a 14 s recompile for the first
length past 256 and a 0.4 to 1 s graph capture for each further one, until
the 4-graph cap made later shapes (resolution changes included) run eager.
Keep ComfyUI's 256 for prompts up to 256 tokens and pad longer ones to 512,
the old behaviour: two shapes per resolution. This deviates from ComfyUI's
exact length for 257 to 512 token prompts only (unmasked padding changes
their embeddings slightly).

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Ideogram 4 defaults comment: mu 0.0 and the 7 to 3 guidance switch

* sd.cpp: map Z-Image's diffusers guidance to standard CFG

The shared Z-Image default is now diffusers' g = 3 (ComfyUI cfg 4), but sd-cli takes
--cfg-scale as standard CFG, so the native engine sampled Z-Image base at cfg 3.
Pass g + 1 for Z-Image; Turbo's 0 still turns CFG off.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Etherll <[email protected]>
(cherry picked from commit fd2522b)

* Tighten comments in ComfyUI parity changes

* Keep Qwen-Image-Edit-2509 on its ComfyUI template shift 3.0

* Studio: pick the Ideogram 4 ComfyUI preset by step count so 48 steps keeps std 1.5

* Trim comments in the ComfyUI defaults change

* Studio: keep Qwen-Image-Edit-2509 on its ComfyUI template defaults (20 steps, guidance 4)

* Drop a duplicated test docstring

---------

Co-authored-by: Etherl <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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.

2 participants