Skip to content

Commit 2b367e5

Browse files
committed
address #222
1 parent 54e228e commit 2b367e5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "vector-quantize-pytorch"
3-
version = "1.23.1"
3+
version = "1.23.2"
44
description = "Vector Quantization - Pytorch"
55
authors = [
66
{ name = "Phil Wang", email = "[email protected]" }

vector_quantize_pytorch/vector_quantize_pytorch.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,19 @@ def update_in_place_optimizer(self):
10631063
if not exists(self.in_place_codebook_optimizer):
10641064
return
10651065

1066+
# handle ddp, thanks to @gdoras
1067+
1068+
if self._codebook.use_ddp:
1069+
1070+
for param in self._codebook.parameters():
1071+
if not exists(param.grad):
1072+
continue
1073+
1074+
distributed.all_reduce(param.grad)
1075+
param.grad /= distributed.get_world_size()
1076+
1077+
# optimizer step
1078+
10661079
self.in_place_codebook_optimizer.step()
10671080
self.in_place_codebook_optimizer.zero_grad()
10681081

0 commit comments

Comments
 (0)