Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Fix Autoencoderkl train script #11113

Merged
merged 3 commits into from
Mar 19, 2025

Conversation

lavinal712
Copy link
Contributor

What does this PR do?

  • Add discriminator optimizer optimization.
  • Add SyncBatchNorm for discriminator

Fix bug report #10605 (comment)

@sayakpaul

@@ -627,6 +627,7 @@ def main(args):
ema_vae = EMAModel(vae.parameters(), model_cls=AutoencoderKL, model_config=vae.config)
perceptual_loss = lpips.LPIPS(net="vgg").eval()
discriminator = NLayerDiscriminator(input_nc=3, n_layers=3, use_actnorm=False).apply(weights_init)
discriminator = torch.nn.SyncBatchNorm.convert_sync_batchnorm(discriminator)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to version-guard torch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. As far as I know, this method first appeared in PyTorch 1.1.0 and is still valid in 2.6.0.

https://pytorch.org/docs/1.1.0/nn.html?highlight=syncbatchnorm#torch.nn.SyncBatchNorm

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@sayakpaul sayakpaul merged commit fc28791 into huggingface:main Mar 19, 2025
8 of 9 checks passed
@sayakpaul
Copy link
Member

Thanks for your contributions!

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.

3 participants