Skip to content
Merged
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
15 changes: 11 additions & 4 deletions megatron/core/dist_checkpointing/strategies/zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ class ZarrSaveShardedStrategy(SaveShardedStrategy):

def __init__(self, backend: str, version: int):
super().__init__(backend, version)
logger.warning(
f"`zarr` distributed checkpoint backend is deprecated."
" Please switch to PyTorch Distributed format (`torch_dist`)."
raise CheckpointingException(
"`zarr` distributed checkpoint backend is no longer supported. "
"Please switch to PyTorch Distributed format (`torch_dist`)."
)

def save(self, sharded_state_dict: ShardedStateDict, checkpoint_dir: Union[str, Path]):
Expand Down Expand Up @@ -197,6 +197,13 @@ def _create_zarr_array(sharded_tensor: ShardedTensor, checkpoint_dir: Path):
class ZarrLoadShardedStrategy(LoadShardedStrategy):
"""Load strategy for the Zarr backend."""

def __init__(self, backend: str, version: int):
super().__init__(backend, version)
raise CheckpointingException(
"`zarr` distributed checkpoint backend is no longer supported. "
"Please switch to PyTorch Distributed format (`torch_dist`)."
)

def load(self, sharded_state_dict: ShardedStateDict, checkpoint_dir: Union[str, Path]):
if isinstance(checkpoint_dir, str):
checkpoint_dir = Path(checkpoint_dir)
Expand Down Expand Up @@ -310,7 +317,7 @@ def pad_to_expected_shape(x: torch.Tensor, expected_sharded_ten: ShardedTensor):
return torch.nn.functional.pad(x, pad_args)

# unsqueeze and squeeze to get shapes supported by cudnn
print(f"Replicating last row for {expected_sharded_ten.key}")
logger.info(f"Replicating last row for {expected_sharded_ten.key}")
if x.dtype == torch.bfloat16:
return (
torch.nn.functional.pad(x.float().unsqueeze(0), pad_args, mode="replicate")
Expand Down
Loading