huggingface / huggingface/diffusers

Combined loss term for VQ-VAE (`diffusers.VQModel`)

Open
#7,787 3 comments 0 reactions 0 assignees View on GitHub
stale
Dominant language
Python
Stars
34.5k
Forks
7.3k
Avg merge
3d 3h
Merged PRs (30d)
91

Description

For training the VQ-VAE component of a latent diffusion model a la `CompVis/ldm-celebahq-256` (which uses `diffusers.VQModel`), is there a combined loss term for each of the losses as described by the authors: reconstruction loss, vq loss, and commitment loss?

I see the vq loss term is collected in `VectorQuantizer`, but it does not seem to be used anywhere else.
https://github.com/huggingface/diffusers/blob/ebc99a77aad647c5d33eb36a33c23f7b3949cb40/src/diffusers/models/autoencoders/vae.py#L726-L730

I'm also open to alternatives to `VQModel` like `AutoEncoderKL`, if they can collect the loss terms more easily.

Thank you!

Contributor guide

Open the contributing guide

Research direction

Start with the linked lines in src/diffusers/models/autoencoders/vae.py and trace how VectorQuantizer's VQ loss is handled by VQModel. Determine whether reconstruction, VQ, and commitment losses can be collected together, and verify that the resulting loss terms are available for the stated VQ-VAE training use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.