Karras Sigma Schedule
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):
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
print(karras_sigmas(3, 0.1, 10.0, 7.0))
[10.0, 1.4507, 0.1, 0.0]
- Inputs:
Nsampling steps, noise levels fromsigma_maxdown tosigma_min, and warp exponentrho. The output therefore holds values. - Warp the endpoints: take the power of each, and . In this warped space the gap between them is only about .
- Evenly spaced fractions: with , the fraction takes the values , so the three warped values are the two endpoints and their midpoint .
- Unwarp: raising back to the 7th power gives , and . The endpoints return exactly to and .
- Finish: append the clean-sample level and round to 4 decimals:
[10.0, 1.4507, 0.1, 0.0]. - Notice: the middle sigma sits far below the arithmetic midpoint (which is what would give). A large 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 torho. - Append a trailing
0.0; round to 4 decimals.