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

Bug: gradient_accumulate_contexts function #275

Open
spnova12 opened this issue Aug 4, 2022 · 1 comment
Open

Bug: gradient_accumulate_contexts function #275

spnova12 opened this issue Aug 4, 2022 · 1 comment

Comments

@spnova12
Copy link

spnova12 commented Aug 4, 2022

With ref to :

def gradient_accumulate_contexts(gradient_accumulate_every, is_ddp, ddps):
if is_ddp:
num_no_syncs = gradient_accumulate_every - 1
head = [combine_contexts(map(lambda ddp: ddp.no_sync, ddps))] * num_no_syncs
tail = [null_context]
contexts = head + tail
else:
contexts = [null_context] * gradient_accumulate_every
for context in contexts:
with context():
yield

I think "map(lambda ddp: ddp.no_sync, ddps)" should be changed to "list(map(lambda ddp: ddp.no_sync, ddps))"
Otherwise, since map is an iterator, it can be used only once, and then the function of gradient_accumulate cannot work well.

@lucidrains
Copy link
Owner

it is iterated over within the combine contexts function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants