PIXELBANKv9.1.0
Menu

Terminal SNR and the Zero-SNR Fix

Problem Statement

Common schedules never fully destroy the signal: at the last step alpha_bar_T is slightly above 0, leaking image information the sampler can never remove. Detect this and apply the "enforce zero terminal SNR" rescaling from Lin et al. (2024).

Background

The signal-to-noise ratio at step t is SNR_t = alpha_bar_t / (1 - alpha_bar_t). A schedule has zero terminal SNR iff alpha_bar_T = 0. The fix rescales the sqrt(alpha_bar) curve linearly so its first value is unchanged and its last value becomes 0:

αˉt′=αˉt−αˉTαˉ0−αˉT⋅αˉ0\sqrt{\bar{\alpha}_t}' = \frac{\sqrt{\bar{\alpha}_t} - \sqrt{\bar{\alpha}_{T}}}{\sqrt{\bar{\alpha}_0} - \sqrt{\bar{\alpha}_{T}}}\cdot \sqrt{\bar{\alpha}_0}

then square back to get the corrected alpha_bar.

Your Task

Implement:

def fix_zero_terminal_snr(alpha_bar):

Return the corrected alpha_bar list rounded to 6 decimals. The last value must be exactly 0.0.

Input Format

  • alpha_bar: list of T cumulative products (decreasing).

Output Format

  • A list of T floats rounded to 6 decimals.

Sample

print(fix_zero_terminal_snr([0.81, 0.36, 0.04]))

Output:

[0.81, 0.26449, 0.0]

Example:

Input:
print(fix_zero_terminal_snr([0.81, 0.36, 0.04]))
Output:
[0.81, 0.26449, 0.0]
Reasoning:
  • Compute the square roots of the input values to work in the αˉ\sqrt{\bar{\alpha}} domain: 0.81=0.9\sqrt{0.81} = 0.9, 0.36=0.6\sqrt{0.36} = 0.6, and 0.04=0.2\sqrt{0.04} = 0.2.
  • Identify the first (s0=0.9s_0 = 0.9) and last (sT=0.2s_T = 0.2) values to determine the linear rescaling range, which is s0−sT=0.9−0.2=0.7s_0 - s_T = 0.9 - 0.2 = 0.7.
  • Apply the linear transformation s−sTs0−sTâ‹…s0\frac{s - s_T}{s_0 - s_T} \cdot s_0 to each element to shift the curve so the last value becomes zero while keeping the first value unchanged:
    • For the first element: 0.9−0.20.7â‹…0.9=1â‹…0.9=0.9\frac{0.9 - 0.2}{0.7} \cdot 0.9 = 1 \cdot 0.9 = 0.9
    • For the second element: 0.6−0.20.7â‹…0.9=0.40.7â‹…0.9≈0.514286\frac{0.6 - 0.2}{0.7} \cdot 0.9 = \frac{0.4}{0.7} \cdot 0.9 \approx 0.514286
    • For the last element: 0.2−0.20.7â‹…0.9=0\frac{0.2 - 0.2}{0.7} \cdot 0.9 = 0
  • Square the rescaled values to return to the αˉ\bar{\alpha} domain and round to 6 decimal places:
    • 0.92=0.810.9^2 = 0.81
    • (0.514286)2≈0.26449(0.514286)^2 \approx 0.26449
    • 02=0.00^2 = 0.0
  • The final output is [0.81, 0.26449, 0.0]

Constraints:

  • 2 <= T <= 100000.
  • Rescale the sqrt(alpha_bar) curve so the first value is preserved and the last hits 0.
  • Square back; the final value is exactly 0.0; round to 6 decimals.
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.