Skip to content

Commit

Permalink
simplify launcher (#3398)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvpatel2000 authored Jun 17, 2024
1 parent cca51e2 commit 6023fe5
Showing 1 changed file with 7 additions and 5 deletions.
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']:
# 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

0 comments on commit 6023fe5

Please sign in to comment.