Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions flagai/model/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ def from_pretrain(cls,
config_path = os.path.join(download_path, "config.json")
checkpoint_path = os.path.join(download_path, "pytorch_model.bin")

def load_local(checkpoint_path):
def load_local(checkpoint_path, only_download_config=False):
model = cls.init_from_json(config_path, **kwargs)
model.to(device)
if only_download_config:
return model
if os.getenv('ENV_TYPE') != 'deepspeed+mpu':
if os.path.exists(checkpoint_path):
model.load_weights(checkpoint_path)
Expand Down Expand Up @@ -146,7 +148,7 @@ def load_diffusion_local(yaml_path, only_download_config=False, **kwargs):
It is fine when checkpoint_path does not exist, for the case that only_download_config=True
At that time the model will not be loaded.
"""
return load_local(checkpoint_path)
return load_local(checkpoint_path, only_download_config=only_download_config)

try:
model_id = _get_model_id(model_name)
Expand Down
4 changes: 2 additions & 2 deletions flagai/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ def get_dataloader(self, dataset, collate_fn, shuffle=False):
shuffle=shuffle)
else:
if self.env_type == 'deepspeed+mpu':
rank = mpu.get_model_parallel_src_rank()
rank = mpu.get_data_parallel_rank()
print("*"*80)
print("local rank",self.rank, "model rank", rank)
print("local rank",self.rank, "data parallel rank", rank)
print("*"*80)
sampler = torch.utils.data.distributed.DistributedSampler(
dataset,
Expand Down