Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Zai org CogVideo CogVideoXDPMScheduler From Config

From Leeroopedia


Template:Implementation

Overview

Concrete tool for configuring the CogVideoX DPM noise scheduler for inference provided by the diffusers library. The scheduler controls the denoising step function and timestep selection during video generation.

Source

inference/cli_demo.py:L140-142

Signature

pipe.scheduler = CogVideoXDPMScheduler.from_config(
    pipe.scheduler.config,
    timestep_spacing: str = "trailing"
) -> CogVideoXDPMScheduler

Alternative for 2B Models

pipe.scheduler = CogVideoXDDIMScheduler.from_config(
    pipe.scheduler.config,
    timestep_spacing: str = "trailing"
) -> CogVideoXDDIMScheduler

Key Parameters

Parameter Type Default Description
config dict (required) Scheduler configuration from pipe.scheduler.config. Carries over all training-time scheduler settings.
timestep_spacing str "trailing" Timestep spacing strategy. Use "trailing" for proper alignment with CogVideoX training schedule.

Inputs

  • Existing scheduler config -- The configuration dictionary from the pipeline's default scheduler (pipe.scheduler.config), which contains training-time parameters such as beta schedule, prediction type, and number of training timesteps.

Outputs

  • Configured scheduler instance -- A CogVideoXDPMScheduler (or CogVideoXDDIMScheduler) instance that is assigned directly to pipe.scheduler.

Usage Example

from diffusers import CogVideoXPipeline, CogVideoXDPMScheduler, CogVideoXDDIMScheduler
import torch

# Load pipeline
pipe = CogVideoXPipeline.from_pretrained(
    "THUDM/CogVideoX-5b",
    torch_dtype=torch.bfloat16
)

# For 5B models: use DPM scheduler
pipe.scheduler = CogVideoXDPMScheduler.from_config(
    pipe.scheduler.config,
    timestep_spacing="trailing"
)

# For 2B models (alternative): use DDIM scheduler
# pipe.scheduler = CogVideoXDDIMScheduler.from_config(
#     pipe.scheduler.config,
#     timestep_spacing="trailing"
# )

Import

from diffusers import CogVideoXDPMScheduler, CogVideoXDDIMScheduler

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment