Skip to content

Studio: diffusion flow_shift is the effective shift, and min-SNR is recorded as unused for flow-matching runs - #13215

Merged
danielhanchen merged 6 commits into
mainfrom
studio-diffusion-bugfix
Oct 13, 2026
Merged

danielhanchen merged 6 commits into
mainfrom
studio-diffusion-bugfix

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Refs #10590

Two diffusion training settings did not do what they said.

1. A numeric flow_shift was applied on top of the model's own shift

_training_sigma_table applied s*u/(1+(s-1)*u) to scheduler.sigmas. For families whose scheduler bakes a static shift in at init (Tongyi-MAI/Z-Image-Turbo ships shift: 3.0, Tongyi-MAI/Z-Image shift: 6.0, both use_dynamic_shifting: false), those sigmas are already shifted, so the two shifts multiplied:

request trained at (before) trained at (after)
flow_shift=3.0 on Z-Image-Turbo 9.0 3.0
flow_shift=3.0 on Z-Image 18.0 3.0
flow_shift=1.0 on Z-Image-Turbo 3.0 (the model's own) 1.0 (unshifted)
omitted (every family) the model's own schedule unchanged

A number is now the effective shift on the unshifted schedule, the musubi / kohya discrete_flow_shift convention the docstring already cited. Only API requests can set it; the GUI never sends flow_shift.

Resume: the default (omitted) still records the "1.0" token earlier builds wrote for the model's own schedule, so existing checkpoints resume. An explicit number is now recorded as effective:<n>, so a checkpoint trained under the old meaning is refused with the usual "different timestep shift" message instead of continuing at a different shift.

2. snr_gamma was recorded for runs that never applied it

Min-SNR weighting is an SDXL (epsilon-prediction) weighting; nothing in the flow-matching DiT loop reads snr_gamma. The run record and the resume identity still stored the default 5.0, so Previous Runs described a loss weighting that never happened. The flow-matching families now record it as unused (train_recipe_overrides returns snr_gamma: None, the mechanism MiniMax-H3 already uses), and the resume identity treats it as "cannot tell" for them, so checkpoints that recorded 5.0 still resume. SDXL is unchanged.

Tests

  • test_a_numeric_shift_is_the_effective_shift_on_a_static_scheduler: on a shift-3 scheduler, flow_shift=3.0 equals the scheduler's own table, 1.0 is the unshifted uniform table, 2.0 is the linear shift of it.
  • test_the_resume_identity_keeps_the_default_token_and_drops_min_snr_for_flow_families: default token stays "1.0", an old snr_gamma: "5.0" manifest still resumes, an old numeric token is refused, SDXL still records 5.0.
  • Updated defaults in the flow_shift, LTX-2 and MiniMax-H3 tests.
  • tests/test_diffusion_*.py + tests/test_video_*.py: no failure that does not also fail on main (compat preflight and nvfp4 environment failures on both).

…and record min-SNR as unused for flow-matching families
@danielhanchen danielhanchen self-assigned this Oct 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 10, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 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 ⚠️ Failed 2026-10-12T09:11:11.317615Z 21c1130 New commits
ℹ️ 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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 1d5f65f32f

ℹ️ 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

Copy link
Copy Markdown
Member Author

Backend CI (a-k) fails on test_diffusion_dit_trainer_flow_shift.py::test_a_numeric_shift_is_the_effective_shift_on_a_static_scheduler with ModuleNotFoundError: No module named 'diffusers'. Backend CI does not install diffusers, and that file passes on main (10 passed), so it comes from the new test in this PR. It needs pytest.importorskip("diffusers") or a stub scheduler. The Repo tests (CPU, studio) red is the branding contract that #13230 fixed on main, and the GRPO TRL-latest red is the ORPO/CPO row cap that #13203 covers.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@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: 292db590bd

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

return "1.0"
if isinstance(value, str):
return value
return f"effective:{float(value)}"

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 Preserve legacy keys for unchanged dynamic-shift schedules

For an explicit numeric flow_shift on Qwen-Image or LTX-2, this unconditionally changes the checkpoint identity from (for example) "2.2" to "effective:2.2", so resuming any such pre-change checkpoint fails with a timestep-shift mismatch. Those families use dynamic shifting and therefore already supplied an unshifted scheduler.sigmas; both the old implementation and the new _unshifted_sigmas path apply the same s*u/(1+(s-1)*u) transform, so their training semantics did not change. Version the identity only for families with a baked-in static shift, or accept the legacy numeric token for dynamic-shift families.

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.

Fixed in 07bcca4: only families whose scheduler bakes a static shift into sigmas (Z-Image, 3 / 6) get the effective: token; every dynamic-shift or shift-1 family (FLUX.1, FLUX.2, Qwen-Image, Krea 2, LTX-2) keeps the legacy numeric token and resumes older checkpoints. Checked against each family's real scheduler_config.json.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 07bcca42d6

ℹ️ 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 merged commit 92fcec8 into main Oct 13, 2026
@danielhanchen
danielhanchen deleted the studio-diffusion-bugfix branch October 13, 2026 04:19
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.

1 participant