FlowUniPCMultistepScheduler vs FlowDPMSolverMultistepScheduler in LongLive: Technical Differences Explained
FlowUniPCMultistepScheduler implements a predictor-corrector framework with optional correction steps and plug-in solver support, while FlowDPMSolverMultistepScheduler provides a deterministic high-order ODE solver using DPMSolver++ updates without separate corrector passes, both residing in the wan_5b/utils package and supporting flow prediction for the NVlabs/LongLive video generation pipeline.
When generating videos with NVlabs/LongLive, selecting the right noise scheduler significantly impacts sampling speed and output quality. Both FlowUniPCMultistepScheduler and FlowDPMSolverMultistepScheduler inherit from SchedulerMixin and ConfigMixin, yet they implement fundamentally different numerical strategies for solving the diffusion ODE in wan_5b/utils/fm_solvers_unipc.py and wan_5b/utils/fm_solvers.py respectively. Understanding these architectural distinctions allows you to optimize inference for different step counts and stability requirements.
Core Algorithmic Architectures
UniPC Predictor-Corrector Framework
FlowUniPCMultistepScheduler implements the UniPC (Unified Predictor-Corrector) algorithm, a training-free multistep framework that decouples prediction from correction. The scheduler maintains buffers of past model outputs (self.model_outputs) and timesteps (self.timestep_list) to construct high-order approximations.
The core update cycle involves:
multistep_uni_p_bh_update: The Uni-P predictor step using B-type integrators (bh1orbh2)multistep_uni_c_bh_update: The optional Uni-C corrector step that refines the prediction- External solver support: The
solver_pparameter allows plugging in alternative schedulers as the predictor component
DPMSolver++ Deterministic Integration
FlowDPMSolverMultistepScheduler implements the DPMSolver++ family of high-order deterministic ODE solvers. Unlike UniPC, this scheduler does not separate prediction and correction into distinct phases; instead, it relies on multistep updates that inherently provide higher-order accuracy.
The implementation selects from:
dpm_solver_first_order_update: First-order Euler-style stepmultistep_dpm_solver_second_order_update: Second-order multistep updatemultistep_dpm_solver_third_order_update: Third-order multistep update
The algorithm_type parameter distinguishes between dpmsolver++ (operating on flow/data predictions) and dpmsolver (operating on noise predictions), with dpmsolver++ being the recommended default for flow-prediction models.
Implementation Details in LongLive Source Code
FlowUniPCMultistepScheduler Architecture
Located in wan_5b/utils/fm_solvers_unipc.py, the FlowUniPCMultistepScheduler class executes a distinct two-phase process at each timestep:
- Conversion: Transforms raw model output to flow-type quantities via
convert_model_output - Correction: Optionally applies
multistep_uni_c_bh_updateunless the current step appears indisable_corrector - Prediction: Computes the next state using
multistep_uni_p_bh_updatewith the selected B-type formulation (bh1orbh2) - Order reduction: Applies
lower_order_finallogic to stabilize sampling when using fewer than 15 steps
Key parameters include solver_order (where effective accuracy equals solver_order + 1 due to the corrector) and solver_type restricted to {"bh1", "bh2"}.
FlowDPMSolverMultistepScheduler Architecture
Found in wan_5b/utils/fm_solvers.py, the FlowDPMSolverMultistepScheduler follows a single-pass update strategy:
- Conversion: Adjusts model output based on
algorithm_type(flow vs. noise prediction) - Order selection: Chooses between first-, second-, or third-order updates based on
solver_orderand current step count - Final step handling: Optionally switches to Euler via
euler_at_finalor adjusts final sigma values usingfinal_sigmas_type("zero"vs"sigma_min")
This scheduler supports solver_type options of {"midpoint", "heun"} for the underlying Runge-Kutta-style integrators and provides variance handling branches for SDE-type solvers when applicable.
Configuration Parameters and Capabilities
Solver Orders and Types
FlowUniPCMultistepScheduler accepts solver_order ≥ 1, where setting solver_order=2 yields effective third-order accuracy due to the corrector step. The solver_type selects between bh1 and bh2 B-type integrators.
FlowDPMSolverMultistepScheduler restricts solver_order to {1, 2, 3} with no automatic order elevation from correctors. The solver_type chooses between midpoint and heun classical integrators.
Flow Prediction and Dynamic Shifting
Both schedulers fix prediction_type to "flow_prediction" and support dynamic shifting via use_dynamic_shifting and shift parameters for variable-resolution inputs. They also share optional dynamic thresholding controls (thresholding, dynamic_thresholding_ratio, sample_max_value) to prevent value overflow during sampling.
Practical Code Examples
Configuring FlowUniPCMultistepScheduler
from wan_5b.utils.fm_solvers_unipc import FlowUniPCMultistepScheduler
uni_pc = FlowUniPCMultistepScheduler(
num_train_timesteps=1000,
solver_order=2, # Effective order = 3 with corrector
prediction_type="flow_prediction",
solver_type="bh2", # B-type integrator
lower_order_final=True, # Stabilize final steps
disable_corrector=[0] # Disable corrector on first step
)
uni_pc.set_timesteps(num_inference_steps=50, device="cuda")
# Inference loop
sample = torch.randn(batch, 4, 64, 64, device="cuda")
for t in uni_pc.timesteps:
model_output = diffusion_model(sample, t) # Your model call
sample = uni_pc.step(
model_output=model_output,
timestep=t,
sample=sample,
return_dict=False
)[0]
Configuring FlowDPMSolverMultistepScheduler
from wan_5b.utils.fm_solvers import FlowDPMSolverMultistepScheduler
dpmsolver = FlowDPMSolverMultistepScheduler(
num_train_timesteps=1000,
solver_order=2, # Second-order DPMSolver++
prediction_type="flow_prediction",
algorithm_type="dpmsolver++", # Data prediction mode
solver_type="midpoint",
lower_order_final=True,
euler_at_final=False,
final_sigmas_type="zero"
)
dpmsolver.set_timesteps(num_inference_steps=50, device="cuda")
sample = torch.randn(batch, 4, 64, 64, device="cuda")
for t in dpmsolver.timesteps:
model_output = diffusion_model(sample, t)
sample = dpmsolver.step(
model_output=model_output,
timestep=t,
sample=sample,
return_dict=False
)[0]
Summary
-
FlowUniPCMultistepScheduler utilizes a predictor-corrector architecture with optional
multistep_uni_c_bh_updatecorrector steps and supports external predictor injection viasolver_p, making it ideal for very few inference steps where correction improves accuracy. -
FlowDPMSolverMultistepScheduler employs single-pass high-order updates without a separate corrector, using
multistep_dpm_solver_second_order_updateor third-order variants, providing proven stability as the default choice for most diffusion pipelines. -
Both schedulers reside in
wan_5b/utils/, inherit fromSchedulerMixin, supportflow_predictionand dynamic shifting, and exposelower_order_finalfor stabilizing short inference runs.
Frequently Asked Questions
Which scheduler should I use for few-step inference in LongLive?
Use FlowUniPCMultistepScheduler when running fewer than 20 inference steps. The optional corrector (multistep_uni_c_bh_update) can improve sample quality at low step counts, and the disable_corrector list allows fine-grained control over when correction applies. For step counts above 20 where speed is prioritized, FlowDPMSolverMultistepScheduler provides sufficient accuracy without the overhead of separate corrector passes.
Can I disable the corrector in FlowUniPCMultistepScheduler?
Yes, the corrector is optional. Pass a list of step indices to the disable_corrector parameter during initialization, such as disable_corrector=[0, 1] to skip correction on the first two steps. This is particularly useful when applying strong guidance scales early in sampling, where the corrector might introduce instability.
What is the difference between algorithm_type dpmsolver and dpmsolver++?
dpmsolver++ operates on flow or data predictions, while dpmsolver operates on noise predictions. According to the implementation in wan_5b/utils/fm_solvers.py, dpmsolver++ is the recommended setting for flow-prediction models like those in LongLive, as it provides better stability and sample quality. The dpmsolver variant exists for compatibility with noise-prediction model formulations.
Are these schedulers interchangeable in the LongLive pipeline?
Yes, both schedulers are drop-in replacements for each other. As shown in the example pipelines (text2video.py, image2video.py), you can instantiate either FlowUniPCMultistepScheduler or FlowDPMSolverMultistepScheduler and pass it to the pipeline's sample_scheduler parameter. Both classes implement the same interface from SchedulerMixin, ensuring compatibility with the set_timesteps and step methods used throughout the codebase.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →