kandinsky5 ¶
Classes¶
fastvideo.pipelines.stages.kandinsky5.Kandinsky5DenoisingStage ¶
Bases: PipelineStage
Source code in fastvideo/pipelines/stages/kandinsky5.py
Methods:¶
fastvideo.pipelines.stages.kandinsky5.Kandinsky5DenoisingStage.fast_sta_nabla staticmethod ¶
fast_sta_nabla(T: int, H: int, W: int, wT: int = 3, wH: int = 3, wW: int = 3, device: device | str = 'cuda') -> Tensor
Create a sparse temporal attention (STA) mask for efficient video generation.
This method generates a mask that limits attention to nearby frames and spatial positions, reducing computational complexity for video generation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
T | int | Number of temporal frames | required |
H | int | Height in latent space | required |
W | int | Width in latent space | required |
wT | int | Temporal attention window size | 3 |
wH | int | Height attention window size | 3 |
wW | int | Width attention window size | 3 |
device | str | Device to create tensor on | 'cuda' |
Returns:
| Type | Description |
|---|---|
Tensor | torch.Tensor: Sparse attention mask of shape (THW, THW) |
Source code in fastvideo/pipelines/stages/kandinsky5.py
fastvideo.pipelines.stages.kandinsky5.Kandinsky5DenoisingStage.get_sparse_params ¶
Generate sparse attention parameters for the transformer based on sample dimensions.
This method computes the sparse attention configuration needed for efficient video processing in the transformer model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample | Tensor | Input sample tensor | required |
device | device | Device to place tensors on | required |
Returns:
| Name | Type | Description |
|---|---|---|
Dict | dict[str, Any] | None | Dictionary containing sparse attention parameters |
Source code in fastvideo/pipelines/stages/kandinsky5.py
fastvideo.pipelines.stages.kandinsky5.Kandinsky5DmdDenoisingStage ¶
Bases: Kandinsky5DenoisingStage
DMD (few fixed steps, no CFG) variant of Kandinsky5DenoisingStage.
Reuses the parent's RoPE/scale_factor/sparse-params helpers; only the denoising loop differs: a fixed short timestep schedule (pipeline_config.dmd_denoising_steps) with a single forward pass per step and no classifier-free-guidance branch, matching DMD's distilled few-step generator.
dmd_denoising_steps values (e.g. [1000, 750, 500, 250]) are literal final target timesteps -- that's how DMD2Method on the training side resolves them: nearest-sigma lookup against a scheduler that has never had set_timesteps called on it, so e.g. "750" maps to sigma 0.75. This stage therefore keeps a private FlowMatchEulerDiscreteScheduler (same shift as the pipeline scheduler) and drives it directly via predict-x0 + re-noise, exactly mirroring DMD2Method._student_rollout's "simulate" branch and Wan's own DmdDenoisingStage. It must NOT reuse the pipeline's shared scheduler object through scheduler.step(): by the time this stage runs, TimestepPreparationStage has already called scheduler.set_timesteps(timesteps=dmd_denoising_steps) on it, which re-applies the flow-match shift warp on top of values that are already final (e.g. sigma 0.75 -> 0.9375 at shift=5) -- a double shift that leaves every step far noisier than the student was trained for, so the sampled video is still mostly noise after the last step instead of converged.
Source code in fastvideo/pipelines/stages/kandinsky5.py
fastvideo.pipelines.stages.kandinsky5.Kandinsky5ImageEncodingStage ¶
Kandinsky5ImageEncodingStage(vae: ParallelTiledVAE, pipeline=None)
Bases: EncodingStage
Encode the conditioning image into a VAE latent for I2V.