Skip to content

Fix WanVAE_.encode() to return both mu and log_var - #574

Closed
Mr-Neutr0n wants to merge 1 commit into
Wan-Video:mainfrom
Mr-Neutr0n:fix/encode-return-value
Closed

Fix WanVAE_.encode() to return both mu and log_var#574
Mr-Neutr0n wants to merge 1 commit into
Wan-Video:mainfrom
Mr-Neutr0n:fix/encode-return-value

Conversation

@Mr-Neutr0n

Copy link
Copy Markdown

Summary

  • Fixed WanVAE_.encode() to return both mu and log_var as expected by forward()
  • Made scale parameter optional (defaults to None) in both encode() and decode() methods

Problem

The forward() method calls self.encode(x) expecting two return values (mu, log_var):

mu, log_var = self.encode(x)

However, encode() was only returning mu, causing a ValueError: not enough values to unpack.

Additionally, encode(x, scale) required the scale parameter, but forward() didn't pass it.

Changes

  1. Modified encode() to return (mu, log_var) tuple
  2. Made scale parameter optional with scale=None default
  3. Made scale parameter optional in decode() as well for consistency
  4. Updated WanVAE.encode() wrapper to extract only mu with [0] index

Related Issue

Fixes #556

Test Plan

  • forward() now works without passing scale (uses no scaling when scale=None)
  • Explicit scale parameter still works as before
  • WanVAE wrapper continues to work unchanged

@Mr-Neutr0n

Copy link
Copy Markdown
Author

bump on this — the encode() method was only returning mu and dropping log_var, which breaks anyone trying to use the VAE's full latent distribution. would appreciate a review

@Mr-Neutr0n

Copy link
Copy Markdown
Author

Hi! Quick status: this still applies cleanly to the latest main as of today, and the PR is still mergeable. Re-requesting a review. If this looks good now, I would be happy to see it merged; if the repo has moved on, I am just as happy to close it.

@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.

关于 line 483: WanVAE_ 中 encode 返回值缺失 问题

1 participant