Add optional SyncBatchNorm support to ImageNet example by snehasonkusare-tech · Pull Request #1406 · pytorch/examples · GitHub
Skip to content

Add optional SyncBatchNorm support to ImageNet example#1406

Open
snehasonkusare-tech wants to merge 1 commit into
pytorch:mainfrom
snehasonkusare-tech:add-syncbn
Open

Add optional SyncBatchNorm support to ImageNet example#1406
snehasonkusare-tech wants to merge 1 commit into
pytorch:mainfrom
snehasonkusare-tech:add-syncbn

Conversation

@snehasonkusare-tech

Copy link
Copy Markdown

This PR adds optional SyncBatchNorm support to the ImageNet training script.

What’s included:

  • Added new CLI argument: --sync-bn

  • If both (a) distributed training is enabled and (b) --sync-bn is passed,
    BatchNorm layers are converted to SyncBatchNorm using:

    nn.SyncBatchNorm.convert_sync_batchnorm(model)

  • Conversion happens before DistributedDataParallel wrapping, as required.

Why this is useful:

SyncBatchNorm improves performance and stability in multi-GPU distributed training
and is commonly used in ImageNet training recipes. Adding this option makes the
example more complete and aligned with standard training practices.

Testing:

  • Verified that the script runs correctly with dummy data on CPU.
  • Ensured that normal execution is unchanged unless --sync-bn is passed.

Addresses Issue #793.

@meta-cla

meta-cla Bot commented Dec 8, 2025

Copy link
Copy Markdown

@netlify

netlify Bot commented Dec 8, 2025

Copy link
Copy Markdown

Deploy Preview for pytorch-examples-preview canceled.

Name Link
🔨 Latest commit 2e72653
🔍 Latest deploy log https://app.netlify.com/projects/pytorch-examples-preview/deploys/6937480016d9c20008cdbb3c

@snehasonkusare-tech

Copy link
Copy Markdown
Author

Hi, this is my first contribution to PyTorch. Please let me know if any changes are needed.
Thanks!

@meta-cla meta-cla Bot added the cla signed label Dec 8, 2025
@meta-cla

meta-cla Bot commented Dec 8, 2025

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant