Skip to content

Bug: gradient_accumulate_contexts function #275

Open
@spnova12

Description

@spnova12

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions