Skip to content

fix: correct operator precedence in lvlb_weights calculation - #907

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

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?

@Mr-Neutr0n

Copy link
Copy Markdown
Author

Closing this one to tidy up my open pull requests.

It's been open around five months with no review activity, and I'd rather withdraw it than leave it sitting in your queue. Nothing needed from you, and no hard feelings at all.

If the fix is still wanted, this can be reopened, or I'm happy to redo it properly against current main. Apologies for the noise.

@Mr-Neutr0n Mr-Neutr0n closed this Jul 28, 2026
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