Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.
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
5 changes: 5 additions & 0 deletions src/sparseml/pytorch/image_classification/utils/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
default_device,
is_parallel_model,
)
from sparsezoo import Zoo


_LOGGER = logging.getLogger(__file__)
Expand Down Expand Up @@ -327,6 +328,10 @@ def _run_train_epoch(
)

def _setup_checkpoint_manager(self):
if self.checkpoint_path and self.checkpoint_path.startswith("zoo"):
self.checkpoint_path = Zoo.load_model_from_stub(
self.checkpoint_path
).download_framework_files(extensions=[".pth"])[0]
checkpoint_state = torch.load(self.checkpoint_path)
checkpoint_manager = None
checkpoint_recipe = checkpoint_state.get("recipe")
Expand Down
3 changes: 2 additions & 1 deletion src/sparseml/transformers/sparsification/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,10 @@ def create_optimizer(self):
if torch.distributed.is_initialized()
else self.args._n_gpu
)
n_device = n_gpu if n_gpu > 0 else 1
total_batch_size = (
self.args.per_device_train_batch_size
* n_gpu
* n_device
* self.args.gradient_accumulation_steps
)
self.manager_steps_per_epoch = math.ceil(
Expand Down