Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions megatron/core/ssm/gated_delta_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,19 @@ def sharded_state_dict(self, prefix="", sharded_offsets=(), metadata=None, tp_gr

return sharded_state_dict

def backward_dw(self):
"""Execute weight gradient computation for all linear layers."""
self._backward_in_proj()
self._backward_out_proj()

def _backward_in_proj(self):
"""Computes weight gradients of input projection layer."""
self.in_proj.backward_dw()

def _backward_out_proj(self):
"""Computes weight gradients of output projection layer."""
self.out_proj.backward_dw()


def _split_tensor_factory(
orig_sh_ten: ShardedTensor, split_sections: List[int], split_names: List[str], split_dim: int
Expand Down
Loading