scheduling_flow_map_euler_discrete ¶
Flow-map any-step Euler scheduler for AnyFlow.
The model predicts the average velocity u_θ(x_t, t, r) from time t back to time r, so one Euler step is
x_r = x_t - ((t - r) / num_train_timesteps) * u_θ(x_t, t, r)
regardless of how far apart t and r are. The scheduler also provides the AnyFlow training-time helpers apply_shift (flow-matching shift transform) and get_train_weight (per-timestep loss weight, including beta08).
Standalone — does not depend on diffusers' ConfigMixin/SchedulerMixin.
Classes¶
fastvideo.models.schedulers.scheduling_flow_map_euler_discrete.FlowMapEulerDiscreteScheduler ¶
Bases: BaseScheduler
Minimal flow-map scheduler.
Parameters¶
num_train_timesteps: Discretization granularity for training. t is expressed in absolute units in [0, num_train_timesteps]. shift: Flow-matching shift parameter (Wan video default: 5.0). Set to 1.0 for an identity shift.
Source code in fastvideo/models/schedulers/scheduling_flow_map_euler_discrete.py
Methods:¶
fastvideo.models.schedulers.scheduling_flow_map_euler_discrete.FlowMapEulerDiscreteScheduler.add_noise ¶
Linear flow-matching interpolation: x_t = (1 - σ) * x_0 + σ * ε, where σ = t / num_train_timesteps.
Source code in fastvideo/models/schedulers/scheduling_flow_map_euler_discrete.py
fastvideo.models.schedulers.scheduling_flow_map_euler_discrete.FlowMapEulerDiscreteScheduler.apply_shift ¶
apply_shift(t: Tensor, *, shift: float | None = None) -> Tensor
Apply the flow-matching shift: t' = s * t / (1 + (s - 1) * t).
Operates in the normalized [0, 1] domain — callers should pass t / num_train_timesteps (or sample t directly from [0, 1]).
Source code in fastvideo/models/schedulers/scheduling_flow_map_euler_discrete.py
fastvideo.models.schedulers.scheduling_flow_map_euler_discrete.FlowMapEulerDiscreteScheduler.get_train_weight ¶
Per-timestep training weight, renormalized so the total weight mass equals num_train_timesteps (matching AnyFlow reference's scheduling_flowmap_euler_discrete.py).
beta08: w(t) = t * sqrt(1 - t) (in normalized t-space).
Source code in fastvideo/models/schedulers/scheduling_flow_map_euler_discrete.py
fastvideo.models.schedulers.scheduling_flow_map_euler_discrete.FlowMapEulerDiscreteScheduler.set_timesteps ¶
set_timesteps(*, num_inference_steps: int, device: device | str = 'cpu', custom_timesteps: list[float] | Tensor | None = None) -> None
Build a descending timestep schedule ending at 0.
With num_inference_steps=N the schedule has N + 1 entries [T_max, ..., 0] so a rollout consumes N Euler steps.
custom_timesteps overrides the linspace+shift schedule with a pinned list (in absolute train-timestep units), useful for the AnyFlow paper's hand-tuned [999, 937, 833, 624, 0] schedule.
Source code in fastvideo/models/schedulers/scheduling_flow_map_euler_discrete.py
fastvideo.models.schedulers.scheduling_flow_map_euler_discrete.FlowMapEulerDiscreteScheduler.step ¶
One Euler step from t to r.
model_output is the average-velocity prediction u_θ(x_t, t, r). Both timestep and r_timestep are in absolute train-timestep units ([0, num_train_timesteps]).