Skip to content

Commit

Permalink
precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
dakinggg committed Sep 30, 2023
1 parent 53ba514 commit 95c93cd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions llmfoundry/callbacks/hf_checkpointer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from composer.loggers.remote_uploader_downloader import RemoteUploaderDownloader
from composer.models import HuggingFaceModel
from composer.utils import dist, format_name_with_dist_and_time, parse_uri
from transformers import PreTrainedModel, PreTrainedTokenizerBase
from transformers import PreTrainedModel, PreTrainedTokenizerBase, PretrainedConfig

from llmfoundry.models.mpt import MPTConfig, MPTForCausalLM
from llmfoundry.utils.huggingface_hub_utils import \
Expand Down Expand Up @@ -158,7 +158,7 @@ def _save_checkpoint(self, state: State, logger: Logger):
original_tokenizer = state.model.tokenizer
else:
original_model = state.model.model
original_tokenizer = state.model.tokenizers
original_tokenizer = state.model.tokenizer

assert isinstance(original_model, PreTrainedModel)
assert isinstance(original_tokenizer, PreTrainedTokenizerBase)
Expand All @@ -179,7 +179,8 @@ def _save_checkpoint(self, state: State, logger: Logger):
log.debug('Saving Hugging Face checkpoint to disk')

copied_config = copy.deepcopy(original_model.config)
if original_model.config.model_type == 'mpt':
assert isinstance(copied_config, PretrainedConfig)
if copied_config.model_type == 'mpt':
copied_config.attn_config['attn_impl'] = 'torch'
copied_config.init_device = 'cpu'

Expand Down

0 comments on commit 95c93cd

Please sign in to comment.