Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit e054e12

Browse files
corey-nmnatuan
authored andcommitted
Saving both original and final recipes in torchvision train script (#1337)
* Saving both original and final recipes in torchvision train script * Style Co-authored-by: Tuan Nguyen <tuan@neuralmagic.com>
1 parent d1303cc commit e054e12

File tree

1 file changed

+9
-1
lines changed
  • src/sparseml/pytorch/torchvision

1 file changed

+9
-1
lines changed

src/sparseml/pytorch/torchvision/train.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from torchvision.transforms.functional import InterpolationMode
3434

3535
import click
36+
from sparseml.optim.helpers import load_recipe_yaml_str
3637
from sparseml.pytorch.models.registry import ModelRegistry
3738
from sparseml.pytorch.optim import ScheduledModifierManager
3839
from sparseml.pytorch.torchvision import presets, transforms, utils
@@ -558,7 +559,14 @@ def collate_fn(batch):
558559
logger = LoggerManager(log_python=False)
559560

560561
if args.recipe is not None:
561-
logger.save(args.recipe)
562+
base_path = os.path.join(args.output_dir, "original_recipe.yaml")
563+
with open(base_path, "w") as fp:
564+
fp.write(load_recipe_yaml_str(args.recipe))
565+
logger.save(base_path)
566+
567+
full_path = os.path.join(args.output_dir, "final_recipe.yaml")
568+
manager.save(full_path)
569+
logger.save(full_path)
562570

563571
steps_per_epoch = len(data_loader) / args.gradient_accum_steps
564572

0 commit comments

Comments
 (0)