MCPcopy
hub / github.com/deepspeedai/DeepSpeedExamples / update_master_grads

Method update_master_grads

Megatron-LM/fp16/fp16.py:556–567  ·  view source on GitHub ↗

Copy the ``.grad`` attribute from stored references to fp16 parameters to the ``.grad`` attribute of the fp32 master parameters that are directly updated by the optimizer. :attr:`update_master_grads` only needs to be called if ``fp16_optimizer_obj.backward`` was c

(self)

Source from the content-addressed store, hash-verified

554 self.update_master_grads()
555
556 def update_master_grads(self):
557 """
558 Copy the ``.grad`` attribute from stored references to fp16 parameters to
559 the ``.grad`` attribute of the fp32 master parameters that are directly
560 updated by the optimizer. :attr:`update_master_grads` only needs to be called if
561 ``fp16_optimizer_obj.backward`` was called with ``update_master_grads=False``.
562 """
563 if self.dynamic_loss_scale:
564 self._check_overflow()
565 if self.overflow: return
566 self._model_grads_to_master_grads()
567 self._downscale_master()
568
569 def inspect_master_grad_data(self):
570 """

Callers 3

backwardMethod · 0.95
backward_stepFunction · 0.80
backward_stepFunction · 0.80

Calls 3

_check_overflowMethod · 0.95
_downscale_masterMethod · 0.95

Tested by

no test coverage detected