Skip to content

Fix --local-rank argument compatibility with torchrun - #165

Closed
Mr-Neutr0n wants to merge 1 commit into
SysCV:mainfrom
Mr-Neutr0n:fix-local-rank-arg
Closed

Fix --local-rank argument compatibility with torchrun#165
Mr-Neutr0n wants to merge 1 commit into
SysCV:mainfrom
Mr-Neutr0n:fix-local-rank-arg

Conversation

@Mr-Neutr0n

Copy link
Copy Markdown

Summary

  • Accept both --local-rank (hyphen) and --local_rank (underscore) for the distributed training argument
  • Fixes compatibility with PyTorch's torchrun which passes --local-rank instead of --local_rank

Problem

When using torchrun for distributed training:

torchrun --nproc_per_node=6 train.py ...

The script fails with:

HQ-SAM: error: unrecognized arguments: --local-rank=5

This happens because torchrun passes --local-rank (with hyphen), but the script only accepted --local_rank (with underscore).

Solution

Changed the argument definition to accept both forms using argparse's multiple option names feature.

Test plan

  • Run distributed training with torchrun --nproc_per_node=N train.py
  • Verify backward compatibility with torch.distributed.launch (deprecated)

Fixes #153

Accept both --local-rank and --local_rank for distributed training.
PyTorch's torchrun uses --local-rank (with hyphen), but the script
only accepted --local_rank (with underscore), causing the error:
"unrecognized arguments: --local-rank=5"

Fixes #153
@Mr-Neutr0n

Copy link
Copy Markdown
Author

bump — this fixes the --local-rank argument to work with torchrun's --local_rank convention. otherwise it crashes on launch. lmk if anything needs changing

@Mr-Neutr0n

Copy link
Copy Markdown
Author

Friendly ping -- this one-line fix in train/train.py resolves the --local-rank vs --local_rank mismatch that causes torchrun to crash on launch. Would appreciate a review when you get a chance.

@Mr-Neutr0n

Copy link
Copy Markdown
Author

Closing this one to tidy up my open pull requests.

It's been open around five months with no review activity, and I'd rather withdraw it than leave it sitting in your queue. Nothing needed from you, and no hard feelings at all.

If the fix is still wanted, this can be reopened, or I'm happy to redo it properly against current main. Apologies for the noise.

@Mr-Neutr0n Mr-Neutr0n closed this Jul 28, 2026
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.

local-rank argument issue

1 participant