Skip to content

Commit

Permalink
add check
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi-databricks committed Jan 2, 2024
1 parent 1ac5c4b commit a41581c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions llmfoundry/utils/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ def process_init_device(model_cfg: DictConfig, fsdp_config: Optional[Dict]):
# Set defaults for mixed initialization
fsdp_config.setdefault('use_orig_params', False)
fsdp_config.setdefault('load_monolith_rank0_only', True)
# Always set `sync_module_states` to True when using hybrid sharding
if fsdp_config.get('sharding_strategy', 'FULL_SHARD') in ['HYBRID_SHARD', '_HYBRID_SHARD_ZERO2'] \
and not fsdp_config.get('sync_module_states', False):
warnings.warn((
'Setting `sync_module_states = True` for FSDP. This is required '
'when using hybrid sharding.'))
fsdp_config['sync_module_states'] = True

# no mixed precision needed for weights when they're already 16 bits
master_dtype = model_cfg.get('master_weights_dtype')
Expand Down

0 comments on commit a41581c

Please sign in to comment.