v9.1.1
Menu

Karras Sigma Schedule

hardFREEForward Process and Noise SchedulesDiffusion ModelsDiffusion Models 1

Problem Statement

The EDM / Karras samplers parameterize diffusion by noise level sigma instead of a discrete beta schedule, and place the sampling sigmas on a warped grid controlled by rho. Build that schedule.

Background

Karras et al. (2022) define N sampling steps whose sigmas interpolate between sigma_max and sigma_min in a rho-warped space (higher rho concentrates steps near sigma_min):

σi=(σmax⁡1/ρ+iN−1(σmin⁡1/ρ−σmax⁡1/ρ))ρ,i=0,…,N−1\sigma_i = \left(\sigma_{\max}^{1/\rho} + \frac{i}{N-1}\big(\sigma_{\min}^{1/\rho} - \sigma_{\max}^{1/\rho}\big)\right)^{\rho}, \quad i = 0, \dots, N-1

so sigma_0 = sigma_max and sigma_{N-1} = sigma_min. A final sigma = 0 is appended for the last denoising jump to a clean sample.

Your Task

Implement:

def karras_sigmas(N, sigma_min, sigma_max, rho=7.0):

Return a list of N + 1 sigmas (the N warped values followed by 0.0), rounded to 4 decimals.

Input Format

  • N (int): number of sampling steps, N >= 2.
  • sigma_min, sigma_max (float): 0 < sigma_min < sigma_max.
  • rho (float): warp exponent.

Output Format

  • A list of N + 1 floats rounded to 4 decimals.

Sample

print(karras_sigmas(3, 0.1, 10.0, 7.0))

Output:

[10.0, 1.4507, 0.1, 0.0]

Example

Input
print(karras_sigmas(3, 0.1, 10.0, 7.0))
Output
[10.0, 1.4507, 0.1, 0.0]
Reasoning
  • Inputs: N =3= 3 sampling steps, noise levels from sigma_max =10= 10 down to sigma_min =0.1= 0.1, and warp exponent rho =7= 7. The output therefore holds N+1=4N + 1 = 4 values.
  • Warp the endpoints: take the 1/ρ1/\rho power of each, 101/7≈1.3895010^{1/7} \approx 1.38950 and 0.11/7≈0.719690.1^{1/7} \approx 0.71969. In this warped space the gap between them is only about 0.670.67.
  • Evenly spaced fractions: with N=3N = 3, the fraction iN−1\frac{i}{N-1} takes the values 0,12,10, \tfrac{1}{2}, 1, so the three warped values are the two endpoints and their midpoint 1.38950+0.719692≈1.05459\frac{1.38950 + 0.71969}{2} \approx 1.05459.
  • Unwarp: raising back to the 7th power gives 1010, 1.054597≈1.45071.05459^7 \approx 1.4507 and 0.10.1. The endpoints return exactly to σmax⁡\sigma_{\max} and σmin⁡\sigma_{\min}.
  • Finish: append the clean-sample level 00 and round to 4 decimals: [10.0, 1.4507, 0.1, 0.0].
  • Notice: the middle sigma sits far below the arithmetic midpoint 5.055.05 (which is what ρ=1\rho = 1 would give). A large ρ\rho crowds the steps toward the small, detail-refining noise levels.

Constraints

  • N >= 2, 0 < sigma_min < sigma_max, rho > 0.
  • Interpolate in sigma^{1/rho} space, then raise to rho.
  • Append a trailing 0.0; round to 4 decimals.

More from Diffusion Models 1

solution.py

Test results

Sign in to run your code against the test cases.