Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Ghost Clipping with Batch Memory Manager #707

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 3 additions & 2 deletions opacus/optimizers/optimizer_fast_gradient_clipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from __future__ import annotations

import copy
import logging
from typing import Callable, Optional

Expand Down Expand Up @@ -112,9 +113,9 @@ def accumulate(self):
"""
for p in self.params:
if p.summed_grad is not None:
p.summed_grad += p.grad
p.summed_grad.add_(p.grad.data)
else:
p.summed_grad = p.grad
p.summed_grad = copy.deepcopy(p.grad.data)

def zero_grad(self, set_to_none: bool = False):
"""
Expand Down
Loading