File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 11[project ]
22name = " vector-quantize-pytorch"
3- version = " 1.23.1 "
3+ version = " 1.23.2 "
44description = " Vector Quantization - Pytorch"
55authors = [
66 { name = " Phil Wang" , email = " lucidrains@gmail.com" }
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments