starling.samplers.plms_sampler.dynamic_thresholding_fn

dynamic_thresholding_fn(x0: Tensor, p: float = 0.995, max_val: float = 1.0) Tensor[source]

Applies dynamic thresholding to VAE latent predictions.

Args:

x0: Tensor of shape (B, C, H, W) — predicted x_0 in latent space p: Quantile threshold, e.g., 0.995 max_val: Absolute minimum threshold cap to avoid over-compression

Returns:

Clamped and rescaled tensor.