For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Python class
UniPCMultistepScheduler
UniPCMultistepSchedulerβ
class max.pipelines.diffusion.schedulers.UniPCMultistepScheduler(num_train_timesteps=1000, solver_order=2, prediction_type='flow_prediction', predict_x0=True, solver_type='bh2', lower_order_final=True, disable_corrector=None, thresholding=False, dynamic_thresholding_ratio=0.995, sample_max_value=1.0, use_flow_sigmas=False, flow_shift=1.0, time_shift_type='exponential', final_sigmas_type='zero', order=1, **unused_kwargs)
Bases: object
NumPy-only UniPC multistep scheduler for diffusion models.
Implements the UniPC (Unified Predictor-Corrector) framework with B(h) updates for fast sampling of diffusion models. Supports flow-matching prediction type and the BH2 solver variant.
This scheduler is designed for use with the Wan 2.2 T2V pipeline.
-
Parameters:
-
- num_train_timesteps (int)
- solver_order (int)
- prediction_type (str)
- predict_x0 (bool)
- solver_type (str)
- lower_order_final (bool)
- disable_corrector (list[int] | None)
- thresholding (bool)
- dynamic_thresholding_ratio (float)
- sample_max_value (float)
- use_flow_sigmas (bool)
- flow_shift (float)
- time_shift_type (str)
- final_sigmas_type (str)
- order (int)
begin_indexβ
The index for the first timestep.
build_step_coefficients()β
build_step_coefficients()
Pre-compute all UniPC step coefficients as a dense numpy array.
Returns array of shape [num_steps, 9] with columns
[sigma, corrected_input_scale, corrector_sample_scale, corrector_m0_scale, corrector_m1_scale, corrector_mt_scale, predictor_sample_scale, predictor_m0_scale, predictor_m1_scale].
Must be called AFTER set_timesteps().
convert_model_output()β
convert_model_output(model_output, sample)
Convert the raw model output to x0 prediction.
For flow_prediction: x0 = sample - sigma_t * model_output.
index_for_timestep()β
index_for_timestep(timestep)
Find the index for a given timestep in the schedule.
multistep_uni_c_bh_update()β
multistep_uni_c_bh_update(this_model_output, last_sample, this_sample, order)
One corrector step for UniC (B(h) version).
multistep_uni_p_bh_update()β
multistep_uni_p_bh_update(model_output, sample, order)
One predictor step for UniP (B(h) version).
retrieve_timesteps_and_sigmas()β
retrieve_timesteps_and_sigmas(image_seq_len, num_inference_steps, reverse=False, sigma_min=None)
Build timestep/sigma schedule, with flow-matching support.
Also calls set_timesteps so the scheduler is ready for stepping.
set_begin_index()β
set_begin_index(begin_index=0)
Sets the begin index for the scheduler.
-
Parameters:
-
begin_index (int)
-
Return type:
-
None
set_timesteps()β
set_timesteps(num_inference_steps)
Initialize internal state for a denoising run.
Must be called before the first step() call.
-
Parameters:
-
num_inference_steps (int) β Number of denoising steps.
-
Return type:
-
None
step()β
step(model_output, timestep, sample)
Predict the sample at the previous timestep using UniPC.
Orchestrates the corrector (UniC) and predictor (UniP) updates.
step_indexβ
The index counter for the current timestep.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!