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

Bugfix: Initialize grad_input, grad_weight to None #68

Merged
merged 2 commits into from
Mar 6, 2024
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
4 changes: 4 additions & 0 deletions axonn/intra_layer/fully_connected.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def backward(ctx, grad_output):
if dist.get_world_size(ctx.backward_all_reduce_group) > 1 or (
not overlap_reduce_scatter
):
grad_input, grad_weight = None, None

if ctx.needs_input_grad[0]:
grad_input = grad_output.matmul(weight)
handle = dist.all_reduce(
Expand Down Expand Up @@ -135,6 +137,8 @@ def backward(ctx, grad_output):
grad_weight = None # weight gradients are not ready yet
return grad_input, grad_weight, None, None, None, None, None, None, None
else:
grad_input, grad_weight = None, None

if ctx.needs_input_grad[1]:
grad_weight = (
grad_output.reshape(-1, grad_output.shape[-1])
Expand Down
Loading