MCPcopy Create free account
hub / github.com/eric-mitchell/direct-preference-optimization / clip_gradient

Method clip_gradient

trainers.py:493–495  ·  view source on GitHub ↗

Clip the gradient norm of the parameters of an FSDP policy, gathering the gradients across all GPUs.

(self)

Source from the content-addressed store, hash-verified

491 dist.barrier()
492
493 def clip_gradient(self):
494 """Clip the gradient norm of the parameters of an FSDP policy, gathering the gradients across all GPUs."""
495 return self.policy.clip_grad_norm_(self.config.max_grad_norm).item()
496
497 def save(self, output_dir=None, metrics=None):
498 """Save policy, optimizer, and scheduler state to disk, gathering from all processes and saving only on the rank 0 process."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected