Skip to content

How were the VAE latent mean/std values obtained, and why are they used for latent scaling? #1536

Description

@Van23Li

Hi DiffSynth-Studio team,

Thank you for open-sourcing this project.

I noticed that the Qwen-Image/Wan pipeline applies fixed channel-wise normalization to the VAE latent:

latents = (latents - mean) / std

Could you clarify:

How were these mean and std values calculated?
Were they computed by encoding the training data, taking the posterior mean for each sample, and then calculating channel-wise statistics over all samples and spatial-temporal positions?
Why is this scaling necessary?

My guess is that the raw latent channels have different means and variances, so this normalization makes their scales more balanced, better matches the scale of Gaussian noise, and prevents high-variance channels from dominating the flow-matching loss.

It would be very helpful if you could confirm this or share the statistics-collection method. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions