Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify launcher world size parsing #3398

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions composer/cli/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,13 @@ def _parse_args():
if args.nproc < 1:
raise ValueError('The nproc must be 1 or greater')

if args.world_size is None and 'WORLD_SIZE' in os.environ:
args.world_size = int(os.environ['WORLD_SIZE'])
if args.world_size is None:
if 'WORLD_SIZE' in os.environ and os.environ.get('LOCAL_WORLD_SIZE') != os.environ['WORLD_SIZE']:
mvpatel2000 marked this conversation as resolved.
Show resolved Hide resolved
# Use WORLD_SIZE env var if set and running multinode. Otherwise, default to nproc
# to enable easy overriding of number of processes when on a single node.
args.world_size = int(os.environ['WORLD_SIZE'])
else:
args.world_size = args.nproc

if args.base_rank is None and 'BASE_RANK' in os.environ:
args.base_rank = int(os.environ['BASE_RANK'])
Expand All @@ -212,9 +217,6 @@ def _parse_args():
if args.master_port is None and 'MASTER_PORT' in os.environ:
args.master_port = int(os.environ['MASTER_PORT'])

if args.world_size is None:
args.world_size = args.nproc

if args.world_size < args.nproc:
raise ValueError(f'world_size({args.world_size}) cannot be less than nproc({args.nproc})')

Expand Down
Loading