scheduling_piflow ¶
Diffusers scheduler for distilled Kandinsky 6 PiFlow checkpoints.
Classes¶
fastvideo.models.schedulers.scheduling_piflow.DXPolicy ¶
DXPolicy(denoising_output: Tensor, x_t_src: Tensor, sigma_t_src: Tensor, segment_size: float | Tensor = 1.0, shift: float = 1.0, mode: str = 'grid', eps: float = 0.0001)
Network-free DX policy over one flow-matching segment.
Source code in fastvideo/models/schedulers/scheduling_piflow.py
fastvideo.models.schedulers.scheduling_piflow.PiflowScheduler ¶
PiflowScheduler(num_train_timesteps: int = 1000, shift: float = 5.0, n_grid: int = 10, nfe: int | None = None, eps: float = 1e-06, final_step_size_scale: float = 0.5, num_policy_substeps: int = 128)
Bases: FlowMatchEulerDiscreteScheduler
Few-step PiFlow scheduler for widened-output diffusion transformers.
PiFlow evaluates the denoising model at a small number of grid points and integrates a network-free policy between those evaluations. The scheduler is intended for distilled Kandinsky 6 checkpoints, including the main video/audio model and the video super-resolution model. Their model output contains n_grid predictions per sample channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_train_timesteps | `int`, *optional*, defaults to 1000 | Number of training diffusion steps. | 1000 |
shift | `float`, *optional*, defaults to 5.0 | Flow-matching timestep shift. | 5.0 |
n_grid | `int`, *optional*, defaults to 10 | Number of predictions in the widened model output. | 10 |
nfe | `int`, *optional* | Number of model evaluations used at inference. | None |
eps | `float`, *optional*, defaults to 1e-6 | Minimum timestep and policy denominator. | 1e-06 |
final_step_size_scale | `float`, *optional*, defaults to 0.5 | Relative size of the final raw-timestep segment. | 0.5 |
num_policy_substeps | `int`, *optional*, defaults to 128 | Maximum policy integration substeps per raw-timestep unit. | 128 |
Source code in fastvideo/models/schedulers/scheduling_piflow.py
Methods:¶
fastvideo.models.schedulers.scheduling_piflow.PiflowScheduler.set_timesteps ¶
set_timesteps(num_inference_steps: int | None = None, device: str | device | None = None, sigmas: list[float] | None = None, mu: float | None = None, timesteps: list[float] | None = None) -> None
Set the distilled PiFlow timestep schedule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_inference_steps | `int` | Number of model evaluations. | None |
device | `str` or `torch.device`, *optional* | Device for the schedule. | None |
sigmas | `list[float]`, *optional* | Unsupported custom sigma schedule. | None |
mu | `float`, *optional* | Unsupported dynamic-shift parameter. | None |
timesteps | `list[float]`, *optional* | Unsupported custom timestep schedule. | None |
Source code in fastvideo/models/schedulers/scheduling_piflow.py
fastvideo.models.schedulers.scheduling_piflow.PiflowScheduler.step ¶
step(model_output: FloatTensor, timestep: float | FloatTensor, sample: FloatTensor, return_dict: bool = True) -> FlowMatchEulerDiscreteSchedulerOutput | tuple
Advance one step by integrating the PiFlow policy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_output | `torch.FloatTensor` | Widened model output containing | required |
timestep | `float` or `torch.FloatTensor` | Current scheduler timestep. | required |
sample | `torch.FloatTensor` | Current noisy sample. | required |
return_dict | `bool`, *optional*, defaults to True | Whether to return a [ | True |
Returns:
| Type | Description |
|---|---|
FlowMatchEulerDiscreteSchedulerOutput | tuple | [ |
Source code in fastvideo/models/schedulers/scheduling_piflow.py
Functions:¶
fastvideo.models.schedulers.scheduling_piflow.policy_rollout_fm ¶
policy_rollout_fm(x_t_start: Tensor, sigma_t_start: Tensor, raw_t_start: Tensor, raw_t_end: Tensor, total_substeps: int, policy: DXPolicy) -> tuple[Tensor, Tensor, Tensor]
Integrate policy.pi from raw_t_start to raw_t_end.