trainloop 0.9.0__tar.gz → 0.10.0__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.
- {trainloop-0.9.0 → trainloop-0.10.0}/PKG-INFO +1 -1
- {trainloop-0.9.0 → trainloop-0.10.0}/pyproject.toml +1 -1
- {trainloop-0.9.0 → trainloop-0.10.0}/pyproject.toml.orig +1 -1
- {trainloop-0.9.0 → trainloop-0.10.0}/src/trainloop/hooks.py +16 -3
- {trainloop-0.9.0 → trainloop-0.10.0}/src/trainloop/trainer.py +10 -5
- {trainloop-0.9.0 → trainloop-0.10.0}/README.md +0 -0
- {trainloop-0.9.0 → trainloop-0.10.0}/src/trainloop/__init__.py +0 -0
- {trainloop-0.9.0 → trainloop-0.10.0}/src/trainloop/py.typed +0 -0
- {trainloop-0.9.0 → trainloop-0.10.0}/src/trainloop/utils.py +0 -0
|
@@ -83,7 +83,9 @@ class BaseHook:
|
|
|
83
83
|
def on_after_train(self, trainer: BaseTrainer):
|
|
84
84
|
pass
|
|
85
85
|
|
|
86
|
-
def
|
|
86
|
+
def on_log_scalars(
|
|
87
|
+
self, trainer: BaseTrainer, records: dict, dry_run: bool = False
|
|
88
|
+
):
|
|
87
89
|
pass
|
|
88
90
|
|
|
89
91
|
def on_log_images(self, trainer: BaseTrainer, records: dict, dry_run: bool = False):
|
|
@@ -627,6 +629,9 @@ class EMAHook(BaseHook):
|
|
|
627
629
|
class WandbHook(BaseHook):
|
|
628
630
|
"""Log metrics and images to Weights & Biases (rank 0 only).
|
|
629
631
|
|
|
632
|
+
Nested scalar key components are joined with ``/``. Avoid ``/`` within an
|
|
633
|
+
individual component because it is also W&B's panel namespace separator.
|
|
634
|
+
|
|
630
635
|
Args:
|
|
631
636
|
project: W&B project name.
|
|
632
637
|
config: Optional config dict or JSON file path to log.
|
|
@@ -678,7 +683,9 @@ class WandbHook(BaseHook):
|
|
|
678
683
|
if _dist_rank() == 0:
|
|
679
684
|
self.wandb.finish()
|
|
680
685
|
|
|
681
|
-
def
|
|
686
|
+
def on_log_scalars(
|
|
687
|
+
self, trainer: BaseTrainer, records: dict, dry_run: bool = False
|
|
688
|
+
):
|
|
682
689
|
if _dist_rank() == 0:
|
|
683
690
|
data = {"/".join(k): v for k, v in flatten_nested_dict(records).items()}
|
|
684
691
|
if not dry_run:
|
|
@@ -748,6 +755,10 @@ class WandbHook(BaseHook):
|
|
|
748
755
|
class TensorBoardHook(BaseHook):
|
|
749
756
|
"""Log metrics and images to TensorBoard (rank 0 only).
|
|
750
757
|
|
|
758
|
+
Nested namespace components are joined with ``namespace_separator`` and
|
|
759
|
+
the final name is separated with ``/``. Avoid these separators within
|
|
760
|
+
individual keys because TensorBoard uses them to organize tags.
|
|
761
|
+
|
|
751
762
|
Args:
|
|
752
763
|
texts: Optional text values to log when training starts.
|
|
753
764
|
namespace_separator: Separator for nested tag prefixes; the final TensorBoard
|
|
@@ -784,7 +795,9 @@ class TensorBoardHook(BaseHook):
|
|
|
784
795
|
self.writer.close()
|
|
785
796
|
self.writer = None
|
|
786
797
|
|
|
787
|
-
def
|
|
798
|
+
def on_log_scalars(
|
|
799
|
+
self, trainer: BaseTrainer, records: dict, dry_run: bool = False
|
|
800
|
+
):
|
|
788
801
|
if self.writer is None:
|
|
789
802
|
return
|
|
790
803
|
|
|
@@ -349,17 +349,22 @@ class BaseTrainer:
|
|
|
349
349
|
def unwrapped_model(self):
|
|
350
350
|
return self.unwrap(self.model)
|
|
351
351
|
|
|
352
|
-
def
|
|
352
|
+
def log_scalars(self, records: dict[str, Any], dry_run: bool = False):
|
|
353
353
|
"""
|
|
354
|
-
Dispatch
|
|
354
|
+
Dispatch nested scalar records to logging hooks.
|
|
355
|
+
|
|
356
|
+
Dictionary keys are treated as path components. Logging hooks may join
|
|
357
|
+
nested components with backend-specific namespace separators, such as
|
|
358
|
+
``/``. Avoid those separators within individual keys because distinct
|
|
359
|
+
nested paths may otherwise map to the same backend metric name.
|
|
355
360
|
|
|
356
361
|
Args:
|
|
357
|
-
records: Nested dict of
|
|
362
|
+
records: Nested dict of scalar metrics to log.
|
|
358
363
|
dry_run: If True, hooks should avoid side effects and only report intent.
|
|
359
364
|
"""
|
|
360
|
-
self.logger.debug("
|
|
365
|
+
self.logger.debug("log_scalars()")
|
|
361
366
|
for h in self.hooks:
|
|
362
|
-
h.
|
|
367
|
+
h.on_log_scalars(self, records, dry_run=dry_run)
|
|
363
368
|
|
|
364
369
|
def log_images(self, records: dict[str, Any], dry_run: bool = False):
|
|
365
370
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|