A timestep is a discrete stage in a diffusion schedule. During forward diffusion, each stage adds noise; during reverse diffusion, stages remove it until the data becomes clean. As t increases from 0 toward T, the clean-image contribution decreases and the noise contribution increases. section 15.1.1
The timestep tells a denoising U-Net how noisy its input is. The model encodes t with sine and cosine functions into a 128-value vector, then expands and broadcasts that embedding to match image-feature shapes such as (128, 64, 64). section 15.3.2
A timestep participates in diffusion in three practical ways:
- Training randomly selects a timestep, adds the corresponding noise to a clean image, and trains the U-Net to predict that noise. section 15.4
- Inference traverses selected timesteps in reverse, repeatedly using the model prediction to transform noise into a cleaner image. section 15.4.2
- The number of inference steps need not equal the full training schedule: 50 steps can use 980, 960, through 0 from a 1,000-step schedule. section 15.4.2
Generating flowers across timesteps
Start with pure random noise at t = 1000. Apply the trained denoising U-Net at t = 980, then 960, continuing through t = 0. Intermediate images show the gradual transition from noisy structure to a clean flower; selected checkpoints include t = 800, 600, 400, 200, and 0. section 15.4.2
Listing 15.7 Defining a generate() method in the DDIMScheduler() class
@torch.no_grad()
def generate(self,model,device,batch_size=1,generator=None,
eta=1.0,use_clipped_model_output=True,num_inference_steps=50):
imgs=[]
image=torch.randn((batch_size,model.in_channels,model.sample_size,
model.sample_size),
generator=generator).to(device) #1
self.set_timesteps(num_inference_steps)
for t in tqdm(self.timesteps): #2
model_output = model(image, t)["sample"] #3
image = self.step(model_output,t,image,eta,
use_clipped_model_output=\
use_clipped_model_output) #4
img = unnormalize_to_zero_to_one(image)
img = img.cpu().permute(0, 2, 3, 1).numpy()
imgs.append(img) #5
image = unnormalize_to_zero_to_one(image)
image = image.cpu().permute(0, 2, 3, 1).numpy()
return {"sample": image}, imgs
Inspect how a DDIM scheduler initializes random noise, sets inference timesteps, passes each t to the model, applies the scheduler step, and stores intermediate images. section 15.4.2




