Skip to content

fix(distributed): call destroy_process_group() on exit to prevent NCC…#1391

Open
mandanajignesh-byte wants to merge 1 commit into
EvolvingLMMs-Lab:mainfrom
mandanajignesh-byte:fix/nccl-destroy-process-group-on-exit
Open

fix(distributed): call destroy_process_group() on exit to prevent NCC…#1391
mandanajignesh-byte wants to merge 1 commit into
EvolvingLMMs-Lab:mainfrom
mandanajignesh-byte:fix/nccl-destroy-process-group-on-exit

Conversation

@mandanajignesh-byte

Copy link
Copy Markdown

…L resource leak

In distributed runs (accelerate launch / multi-GPU), when evaluation hits an exception, process shutdown emits:

WARNING: destroy_process_group() was not called before program exit,
which can leak resources.

Root cause: Accelerator registers no atexit handler, so distributed teardown never happens on error paths.

Fix: wrap the evaluation loop and result printing in a try/finally block. The finally block calls accelerator.state.destroy_process_group() when Accelerator is active, or torch.distributed.destroy_process_group() directly when running in a pre-initialized distributed context. wandb logging runs inside try before finally to preserve correct ordering.

Fixes #1240

Summary

In scope

Out of scope

Validation

Risk / Compatibility

Type of Change

  • Bug fix (non-breaking change)
  • New feature
  • New benchmark/task
  • New model integration
  • Breaking change
  • Documentation update
  • Refactoring (no functional changes)

…L resource leak

In distributed runs (accelerate launch / multi-GPU), when evaluation
hits an exception, process shutdown emits:

  WARNING: destroy_process_group() was not called before program exit,
  which can leak resources.

Root cause: Accelerator registers no atexit handler, so distributed
teardown never happens on error paths.

Fix: wrap the evaluation loop and result printing in a try/finally block.
The finally block calls accelerator.state.destroy_process_group() when
Accelerator is active, or torch.distributed.destroy_process_group()
directly when running in a pre-initialized distributed context.
wandb logging runs inside try before finally to preserve correct ordering.

Fixes EvolvingLMMs-Lab#1240
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.

[Bug] NCCL warning on error path: destroy_process_group() not called

2 participants