trainloop 0.5.1__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.1 → trainloop-0.5.2}/PKG-INFO +1 -1
- {trainloop-0.5.1 → trainloop-0.5.2}/pyproject.toml +1 -1
- {trainloop-0.5.1 → trainloop-0.5.2}/src/trainloop/trainer.py +10 -4
- {trainloop-0.5.1 → trainloop-0.5.2}/README.md +0 -0
- {trainloop-0.5.1 → trainloop-0.5.2}/src/trainloop/__init__.py +0 -0
- {trainloop-0.5.1 → trainloop-0.5.2}/src/trainloop/hooks.py +0 -0
- {trainloop-0.5.1 → trainloop-0.5.2}/src/trainloop/py.typed +0 -0
- {trainloop-0.5.1 → trainloop-0.5.2}/src/trainloop/utils.py +0 -0
|
@@ -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
|
|
File without changes
|