Skip to content

Commit

Permalink
[checkpointio] fix save hf config
Browse files Browse the repository at this point in the history
  • Loading branch information
ver217 committed Sep 7, 2023
1 parent 5190ac0 commit c3aa9b4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions colossalai/checkpoint_io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import torch
import torch.nn as nn
from torch.optim import Optimizer
from transformers.modeling_utils import PreTrainedModel, get_parameter_dtype
from transformers.modeling_utils import unwrap_model as unwrap_huggingface_model

from colossalai.interface import ModelWrapper, OptimizerWrapper
from colossalai.nn.optimizer import ColossalaiOptimizer
Expand Down Expand Up @@ -383,6 +381,11 @@ def save_config_file(model: nn.Module, checkpoint_path: str, is_master: bool = T
checkpoint_path (str): Path to the checkpoint directory.
is_master (bool): Whether current rank is main process.
"""
try:
from transformers.modeling_utils import PreTrainedModel, get_parameter_dtype
from transformers.modeling_utils import unwrap_model as unwrap_huggingface_model
except ImportError:
return
if not isinstance(model, PreTrainedModel):
return

Expand Down

0 comments on commit c3aa9b4

Please sign in to comment.