Skip to content

Commit

Permalink
try getting the generation config on local rank 0
Browse files Browse the repository at this point in the history
  • Loading branch information
irenedea committed Aug 9, 2024
1 parent e01bbba commit 9ddc38e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion llmfoundry/models/hf/hf_causal_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def build_inner_model(

# Hugging Face copies the modules into the
# transformers modules cache. On particular systems, this operation seems to cause contention between
# the different processes. To avoid this contention, we first create the config on local rank
# the different processes. To avoid this contention, we first create the config and generation config on local rank
# zero. This will set up the transformers module cache and avoid the future contention.
if dist.get_local_rank() == 0:
AutoConfig.from_pretrained(
Expand All @@ -244,6 +244,13 @@ def build_inner_model(
use_cache=
False, # Necessary due to https://github.com/huggingface/transformers/issues/28056
)
try:
GenerationConfig.from_pretrained(
pretrained_model_name_or_path,
use_auth_token=use_auth_token,
)
except OSError:
pass

dist.barrier()

Expand Down

0 comments on commit 9ddc38e

Please sign in to comment.