Skip to content

Conversation

lavinal712
Copy link
Contributor

What does this PR do?

  • Add discriminator optimizer optimization.
  • Add SyncBatchNorm for discriminator

Fix bug report #10605 (comment)

@sayakpaul

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