Skip to content

fix(infer): exit instead of blocking in destroy_process_group when a rank fails - #1712

Open
klin-amd wants to merge 1 commit into
ModelTC:mainfrom
klin-amd:dev/klin/infer-exit-on-rank-error
Open

klin-amd wants to merge 1 commit into
ModelTC:mainfrom
klin-amd:dev/klin/infer-exit-on-rank-error

Conversation

@klin-amd

@klin-amd klin-amd commented Nov 14, 2026 •

Copy link
Copy Markdown

Problem

When one rank raises during torchrun ... -m lightx2v.infer (for example an OOM, or a cusolverDnCreate failure in the UniPC corrector), main() still calls dist.destroy_process_group() in its finally block. The other ranks are still waiting in a collective that the failed rank will never join, such as the per-step check_stop broadcast. So destroy_process_group() blocks, the failed rank never exits, and torchrun cannot detect the failure. The job hangs until the NCCL watchdog timeout (10 min by default), and the original traceback does not appear until then.

Fix

Call destroy_process_group() only when the request succeeded. On failure, let the exception propagate and the process exit. Under torchrun, the launcher then reports the failing rank and terminates its peers.

This complements #1685, which covers restart-required device errors. This change covers ordinary exceptions (OOM, etc.) in the CLI entry point.

Test

Wan2.1-T2V-1.3B, 4-GPU ring sequence parallel, with GPU memory constrained so that one rank fails in step 3:

Before After
Time from error to job exit hung until the 600 s NCCL watchdog timeout about 13 s
Error shown only after the timeout immediately, with the failing rank

A successful 4-GPU Ulysses run still destroys the process group on every rank and exits with code 0.

pre-commit run --all-files passes.

…rank fails

When one rank raises, its peers may still be blocked in a collective it
will never join (e.g. the per-step check_stop broadcast), so
destroy_process_group() in the finally block hangs, the failed rank never
exits, and the job waits for the NCCL watchdog timeout.

Only destroy the process group after a successful request; on failure
let the process exit so torchrun reports the error and stops the peers.

Signed-off-by: Lin, KuanTing <Kuanting.Lin@amd.com>
@klin-amd
klin-amd marked this pull request as draft November 14, 2026 13:48
@klin-amd
klin-amd marked this pull request as ready for review November 14, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant