kostyl-toolkit 0.1.14__tar.gz → 0.1.16__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/PKG-INFO +1 -1
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/clearml/pulling_utils.py +19 -4
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/configs/training_settings.py +1 -1
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/lightning/callbacks/registry_uploading.py +23 -31
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/pyproject.toml +1 -1
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/README.md +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/__init__.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/__init__.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/clearml/__init__.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/clearml/dataset_utils.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/clearml/logging_utils.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/configs/__init__.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/configs/base_model.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/configs/hyperparams.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/dist_utils.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/lightning/__init__.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/lightning/callbacks/__init__.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/lightning/callbacks/checkpoint.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/lightning/callbacks/early_stopping.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/lightning/extenstions/__init__.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/lightning/extenstions/custom_module.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/lightning/extenstions/pretrained_model.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/lightning/loggers/__init__.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/lightning/loggers/tb_logger.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/lightning/steps_estimation.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/metrics_formatting.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/params_groups.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/schedulers/__init__.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/schedulers/base.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/schedulers/composite.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/schedulers/cosine.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/utils/__init__.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/utils/dict_manipulations.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/utils/fs.py +0 -0
- {kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/utils/logging.py +0 -0
|
@@ -15,7 +15,10 @@ from kostyl.ml.lightning.extenstions.pretrained_model import (
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
def get_tokenizer_from_clearml(
|
|
18
|
-
model_id: str,
|
|
18
|
+
model_id: str,
|
|
19
|
+
task: Task | None = None,
|
|
20
|
+
ignore_remote_overrides: bool = True,
|
|
21
|
+
name: str | None = None,
|
|
19
22
|
) -> PreTrainedTokenizerBase:
|
|
20
23
|
"""
|
|
21
24
|
Retrieve a Hugging Face tokenizer stored in a ClearML.
|
|
@@ -26,6 +29,8 @@ def get_tokenizer_from_clearml(
|
|
|
26
29
|
the model. Defaults to None.
|
|
27
30
|
ignore_remote_overrides (bool, optional): Whether to ignore remote hyperparameter
|
|
28
31
|
overrides when connecting the ClearML task. Defaults to True.
|
|
32
|
+
name: The model name to be stored on the Task
|
|
33
|
+
(default to filename of the model weights, without the file extension, or to Input Model if that is not found)
|
|
29
34
|
|
|
30
35
|
Returns:
|
|
31
36
|
PreTrainedTokenizerBase: The instantiated tokenizer loaded from the local copy
|
|
@@ -34,7 +39,9 @@ def get_tokenizer_from_clearml(
|
|
|
34
39
|
"""
|
|
35
40
|
clearml_tokenizer = InputModel(model_id=model_id)
|
|
36
41
|
if task is not None:
|
|
37
|
-
clearml_tokenizer.connect(
|
|
42
|
+
clearml_tokenizer.connect(
|
|
43
|
+
task, ignore_remote_overrides=ignore_remote_overrides, name=name
|
|
44
|
+
)
|
|
38
45
|
|
|
39
46
|
tokenizer = AutoTokenizer.from_pretrained(
|
|
40
47
|
clearml_tokenizer.get_local_copy(raise_on_error=True)
|
|
@@ -49,6 +56,7 @@ def get_model_from_clearml[
|
|
|
49
56
|
model: type[TModel],
|
|
50
57
|
task: Task | None = None,
|
|
51
58
|
ignore_remote_overrides: bool = True,
|
|
59
|
+
name: str | None = None,
|
|
52
60
|
**kwargs: Any,
|
|
53
61
|
) -> TModel:
|
|
54
62
|
"""
|
|
@@ -59,8 +67,11 @@ def get_model_from_clearml[
|
|
|
59
67
|
model: The model class that implements either PreTrainedModel or LightningCheckpointLoaderMixin.
|
|
60
68
|
task: Optional ClearML task used to resolve the input model reference. If provided, the input model
|
|
61
69
|
will be connected to this task, with remote overrides optionally ignored.
|
|
62
|
-
ignore_remote_overrides: When connecting the input model to the provided task,
|
|
70
|
+
ignore_remote_overrides: When connecting the input model to the provided task,
|
|
71
|
+
determines whether
|
|
63
72
|
remote configuration overrides should be ignored.
|
|
73
|
+
name: The model name to be stored on the Task
|
|
74
|
+
(default to filename of the model weights, without the file extension, or to Input Model if that is not found)
|
|
64
75
|
**kwargs: Additional keyword arguments to pass to the model loading method.
|
|
65
76
|
|
|
66
77
|
Returns:
|
|
@@ -70,7 +81,11 @@ def get_model_from_clearml[
|
|
|
70
81
|
input_model = InputModel(model_id=model_id)
|
|
71
82
|
|
|
72
83
|
if task is not None:
|
|
73
|
-
input_model.connect(
|
|
84
|
+
input_model.connect(
|
|
85
|
+
task,
|
|
86
|
+
ignore_remote_overrides=ignore_remote_overrides,
|
|
87
|
+
name=name,
|
|
88
|
+
)
|
|
74
89
|
|
|
75
90
|
local_path = Path(input_model.get_local_copy(raise_on_error=True))
|
|
76
91
|
|
{kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/lightning/callbacks/registry_uploading.py
RENAMED
|
@@ -78,49 +78,41 @@ class ClearMLRegistryUploaderCallback(Callback):
|
|
|
78
78
|
)
|
|
79
79
|
return output_model
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
def on_validation_epoch_end(
|
|
83
|
-
self, trainer: Trainer, pl_module: KostylLightningModule
|
|
84
|
-
) -> None:
|
|
85
|
-
if (not trainer.is_global_zero) or (
|
|
86
|
-
self.uploading_frequency != "after-every-eval"
|
|
87
|
-
):
|
|
88
|
-
return
|
|
81
|
+
def _upload_best_checkpoint(self, pl_module: KostylLightningModule) -> None:
|
|
89
82
|
if self._output_model is None:
|
|
90
83
|
self._output_model = self._create_output_model(pl_module)
|
|
91
84
|
|
|
92
|
-
if self.ckpt_callback.best_model_path
|
|
85
|
+
if self.ckpt_callback.best_model_path == self._last_best_model_path:
|
|
86
|
+
if self.verbose and (self._last_best_model_path != ""):
|
|
87
|
+
logger.info("Best model unchanged since last upload")
|
|
88
|
+
elif self.verbose:
|
|
89
|
+
logger.info("No best model found yet to upload")
|
|
90
|
+
else:
|
|
93
91
|
if self.verbose:
|
|
94
|
-
logger.info(
|
|
92
|
+
logger.info(
|
|
93
|
+
f"Uploading best model from {self.ckpt_callback.best_model_path}"
|
|
94
|
+
)
|
|
95
95
|
self._output_model.update_weights(
|
|
96
96
|
self.ckpt_callback.best_model_path,
|
|
97
97
|
auto_delete_file=False,
|
|
98
|
-
async_enable=
|
|
98
|
+
async_enable=False,
|
|
99
99
|
)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
return
|
|
101
|
+
|
|
102
|
+
@override
|
|
103
|
+
def on_validation_epoch_end(
|
|
104
|
+
self, trainer: Trainer, pl_module: KostylLightningModule
|
|
105
|
+
) -> None:
|
|
106
|
+
if (not trainer.is_global_zero) or (
|
|
107
|
+
self.uploading_frequency != "after-every-eval"
|
|
108
|
+
):
|
|
109
|
+
return
|
|
110
|
+
self._upload_best_checkpoint(pl_module)
|
|
103
111
|
return
|
|
104
112
|
|
|
105
113
|
@override
|
|
106
114
|
def on_train_end(self, trainer: Trainer, pl_module: KostylLightningModule) -> None:
|
|
107
115
|
if not trainer.is_global_zero:
|
|
108
116
|
return
|
|
109
|
-
|
|
110
|
-
self._output_model = self._create_output_model(pl_module)
|
|
111
|
-
|
|
112
|
-
if self.ckpt_callback.best_model_path != self._last_best_model_path:
|
|
113
|
-
if self.verbose:
|
|
114
|
-
logger.info(
|
|
115
|
-
f"Best model path at the end of training: {self.ckpt_callback.best_model_path}"
|
|
116
|
-
)
|
|
117
|
-
self._output_model.update_weights(
|
|
118
|
-
self.ckpt_callback.best_model_path,
|
|
119
|
-
auto_delete_file=False,
|
|
120
|
-
async_enable=False,
|
|
121
|
-
)
|
|
122
|
-
elif self.verbose:
|
|
123
|
-
logger.info(
|
|
124
|
-
"Best model path at the end of training: unchanged since last upload, skipping..."
|
|
125
|
-
)
|
|
117
|
+
self._upload_best_checkpoint(pl_module)
|
|
126
118
|
return
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/lightning/callbacks/early_stopping.py
RENAMED
|
File without changes
|
|
File without changes
|
{kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/lightning/extenstions/custom_module.py
RENAMED
|
File without changes
|
{kostyl_toolkit-0.1.14 → kostyl_toolkit-0.1.16}/kostyl/ml/lightning/extenstions/pretrained_model.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|