Skip to content

field to override the timestep shift for sampling - #1692

Open
dxqb wants to merge 1 commit into
Nerogar:masterfrom
dxqb:sample-shift-override-squashed
Open

field to override the timestep shift for sampling#1692
dxqb wants to merge 1 commit into
Nerogar:masterfrom
dxqb:sample-shift-override-squashed

Conversation

@dxqb

@dxqb dxqb commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Flow-matching models shift the sampling schedule. This PR lets you override this automated calculation.

This is especially intended for video models where the linear interpolation defined in the scheduler config breaks down, because the number of tokens are far beyond the calibrated max shift and the calculation becomes an exponential extrapolation, resulting in huge shifts.

However, it can be useful for other models and SwarmUI also lets you override the shift, so this PR adds it first for existing models

Summary

Test plan

  • pre-commit run --all-files passes
  • Launched the affected UI or script and exercised the change
  • Tested with at least one real preset / config when relevant (note which: LTX)

AI assistance

  • AI-assisted — I have read every line in this diff and can defend each change

Flow-matching models shift the sampling schedule, either derived per sample from
the token count (Flux 1, Flux 2, Qwen, Krea 2) or fixed by the scheduler config
(Z-Image, Chroma, Anima, Ernie, HunyuanVideo). This adds an optional
override_shift to SampleConfig and an "override shift:" entry in the sample
frame, shown for the model types listed in ModelType.supports_sample_shift_override().
Empty keeps the model's own shift, so nothing changes unless the field is filled in.

The models that derive a shift take the override in place of
calculate_timestep_shift. Flux 2 is the odd one out: it works in mu directly via
compute_empirical_mu, so the override goes in as log(shift) to keep the field
meaning one thing across models. The fixed-shift models stamp it on their private
scheduler copy with set_shift(), which set_timesteps() honours for both the
step-count and the explicit-sigmas call shapes. The two mechanisms build
different sigma grids, so the derived-shift samplers keep passing mu rather than
switching to a static shift.

The entry goes in the row below the steps entry, which moves the inpainting
switch and the inpainting image paths down one row each.

Ideogram is deliberately left out. Its sampler computes a resolution-aware mu and
feeds it to a logit-normal sigma generator rather than to the scheduler's shift,
so "shift" would not mean the same thing there.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.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.

1 participant