trainloop 0.5.0__tar.gz → 0.5.2__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.5.0 → trainloop-0.5.2}/PKG-INFO +3 -3
- {trainloop-0.5.0 → trainloop-0.5.2}/pyproject.toml +2 -2
- {trainloop-0.5.0 → trainloop-0.5.2}/src/trainloop/hooks.py +9 -6
- {trainloop-0.5.0 → trainloop-0.5.2}/src/trainloop/trainer.py +10 -4
- {trainloop-0.5.0 → trainloop-0.5.2}/README.md +0 -0
- {trainloop-0.5.0 → trainloop-0.5.2}/src/trainloop/__init__.py +0 -0
- {trainloop-0.5.0 → trainloop-0.5.2}/src/trainloop/py.typed +0 -0
- {trainloop-0.5.0 → trainloop-0.5.2}/src/trainloop/utils.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: trainloop
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.2
|
|
4
4
|
Summary: Minimal PyTorch training loop with hooks and checkpointing.
|
|
5
|
-
Author: Karim
|
|
6
|
-
Author-email: Karim
|
|
5
|
+
Author: Karim Knaebel
|
|
6
|
+
Author-email: Karim Knaebel <contact@knaebel.dev>
|
|
7
7
|
Requires-Dist: pillow>=11.3.0
|
|
8
8
|
Requires-Dist: torch>=2.0.0
|
|
9
9
|
Requires-Python: >=3.10
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "trainloop"
|
|
3
|
-
version = "0.5.
|
|
3
|
+
version = "0.5.2"
|
|
4
4
|
description = "Minimal PyTorch training loop with hooks and checkpointing."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
7
|
-
{ name = "Karim
|
|
7
|
+
{ name = "Karim Knaebel", email = "contact@knaebel.dev" }
|
|
8
8
|
]
|
|
9
9
|
requires-python = ">=3.10"
|
|
10
10
|
dependencies = [
|
|
@@ -269,7 +269,7 @@ class ProgressHook(_StatsHook):
|
|
|
269
269
|
):
|
|
270
270
|
eta = self.eta_tracker.get_eta(trainer.max_steps - trainer.step)
|
|
271
271
|
trainer.logger.info(
|
|
272
|
-
f"Step {trainer.step
|
|
272
|
+
f"Step {trainer.step}/{trainer.max_steps}:"
|
|
273
273
|
+ f" step {step_time:.4f}{'s' if self.show_units else ''} data {data_time:.4f}{'s' if self.show_units else ''}"
|
|
274
274
|
+ (f" eta {eta}" if eta is not None else "")
|
|
275
275
|
+ (
|
|
@@ -309,6 +309,13 @@ class LoggingHook(_StatsHook):
|
|
|
309
309
|
):
|
|
310
310
|
super().__init__(interval, sync)
|
|
311
311
|
|
|
312
|
+
def on_before_step(self, trainer: BaseTrainer):
|
|
313
|
+
super().on_before_step(trainer)
|
|
314
|
+
self.lrs = [
|
|
315
|
+
(param_group.get("name", f"group_{i}"), param_group["lr"])
|
|
316
|
+
for i, param_group in enumerate(trainer.optimizer.param_groups)
|
|
317
|
+
] # record the LR before the scheduler steps
|
|
318
|
+
|
|
312
319
|
def process_stats(
|
|
313
320
|
self,
|
|
314
321
|
trainer: BaseTrainer,
|
|
@@ -320,10 +327,6 @@ class LoggingHook(_StatsHook):
|
|
|
320
327
|
max_memory: float | None,
|
|
321
328
|
records: Records,
|
|
322
329
|
):
|
|
323
|
-
lrs = [
|
|
324
|
-
(param_group.get("name", f"group_{i}"), param_group["lr"])
|
|
325
|
-
for i, param_group in enumerate(trainer.optimizer.param_groups)
|
|
326
|
-
]
|
|
327
330
|
trainer.log(
|
|
328
331
|
{
|
|
329
332
|
"train": records
|
|
@@ -334,7 +337,7 @@ class LoggingHook(_StatsHook):
|
|
|
334
337
|
"data_time": data_time,
|
|
335
338
|
"step_time": step_time,
|
|
336
339
|
"non_finite_grad_retry_count": non_finite_grad_retry_count,
|
|
337
|
-
"lr": {name: lr for name, lr in lrs},
|
|
340
|
+
"lr": {name: lr for name, lr in self.lrs},
|
|
338
341
|
}
|
|
339
342
|
}
|
|
340
343
|
)
|
|
@@ -266,10 +266,16 @@ class BaseTrainer:
|
|
|
266
266
|
if not is_accumulating:
|
|
267
267
|
if not self.grad_scaler.is_enabled():
|
|
268
268
|
# only skip non-finite grads if the scaler is disabled (the scaler needs to process non-finite grads to adjust the scale)
|
|
269
|
-
if
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
269
|
+
if not torch.isfinite(
|
|
270
|
+
# Infinity norm is finite iff every gradient element is finite. Uses efficient foreach kernels and only one host sync.
|
|
271
|
+
torch.nn.utils.get_total_norm(
|
|
272
|
+
(
|
|
273
|
+
p.grad
|
|
274
|
+
for p in self.model.parameters()
|
|
275
|
+
if p.grad is not None
|
|
276
|
+
),
|
|
277
|
+
norm_type=float("inf"),
|
|
278
|
+
)
|
|
273
279
|
):
|
|
274
280
|
if self.max_non_finite_grad_retries is None or (
|
|
275
281
|
non_finite_grad_retry_count
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|