fix GradBucket.is_last() logic (#63768)
authorNima Elyasi <nimaelyasi@fb.com>
Wed, 1 Sep 2021 15:47:44 +0000 (08:47 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 1 Sep 2021 16:29:13 +0000 (09:29 -0700)
commitd1f3d85fd80de2166114af1b5e16070a6d33a898
treeb1d3592d0d24c4d98465c3829582418fca9dffde
parent92b31b59aff908fcecb76e5baff5bb52ce62608a
fix GradBucket.is_last() logic (#63768)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/63768

passed number of buckets to GradBucket constructor, to check if index is equal to num_buckets - 1 in the .is_last() function.

Test Plan:
buck test mode/dev-nosan //caffe2/test/distributed/algorithms/ddp_comm_hooks:test_ddp_hooks

test output: https://www.internalfb.com/intern/testinfra/testconsole/testrun/8162774375985873/

Reviewed By: SciPioneer, mrshenli

Differential Revision: D30455913

fbshipit-source-id: 8c67ca69cbf191d6e189e09248407eb167bb24b6
test/distributed/algorithms/ddp_comm_hooks/test_ddp_hooks.py
torch/csrc/distributed/c10d/comm.hpp
torch/csrc/distributed/c10d/reducer.cpp