Skip to content

fix: correct operator precedence in lvlb_weights calculation#907

Open
Mr-Neutr0n wants to merge 1 commit into
CompVis:mainfrom
Mr-Neutr0n:fix/lvlb-weights-operator-precedence
Open

fix: correct operator precedence in lvlb_weights calculation#907
Mr-Neutr0n wants to merge 1 commit into
CompVis:mainfrom
Mr-Neutr0n:fix/lvlb-weights-operator-precedence

Conversation

@Mr-Neutr0n

Copy link
Copy Markdown

Bug

In the lvlb_weights calculation, the expression 1 - alphas_cumprod_prev / 1. - alphas_cumprod is parsed as 1 - (alphas_cumprod_prev / 1.) - alphas_cumprod due to Python operator precedence, instead of the intended (1 - alphas_cumprod_prev) / (1 - alphas_cumprod).

Fix

Added parentheses to ensure correct precedence matching the DDPM paper's posterior variance formula.

@Mr-Neutr0n

Copy link
Copy Markdown
Author

This single-line fix corrects the operator precedence in the x0 parameterization branch of lvlb_weights. Without the parentheses around 1. - torch.Tensor(alphas_cumprod), the subtraction is evaluated after the multiplication, producing (2. * 1) - alphas_cumprod instead of the intended 2. * (1. - alphas_cumprod). The fix is clearly correct and has been open for about three months with no activity. Would a maintainer be able to take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant