Skip to content

Commit c35bfe8

Browse files
fix ds-inference without policy (#2247)
Co-authored-by: Jeff Rasley <[email protected]>
1 parent fae896e commit c35bfe8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

deepspeed/module_inject/replace_module.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -653,11 +653,10 @@ def _replace(child, name, conv_linear_layer):
653653
new_bias = torch.empty((weight_shape[0]),
654654
device=child.weight.device,
655655
dtype=child.weight.dtype)
656-
657656
if z_inference:
658657
with deepspeed.zero.GatheredParameters(child.bias, modifier_rank=0):
659658
new_bias.data.copy_(child.bias.data)
660-
else:
659+
elif child.bias:
661660
new_bias.data.copy_(child.bias.data)
662661
return LinearAllreduce(data, child.bias if child.bias is None else \
663662
torch.nn.parameter.Parameter(new_bias.to(torch.cuda.current_device())), mp_group)
@@ -704,7 +703,9 @@ def _slice_embedding(child, name, conv_linear_layer):
704703
child.weight.shape[1] // mp_size),
705704
device=child.weight.device,
706705
dtype=child.weight.dtype)
707-
data = mp_replace.copy(new_weight, child.weight.ds_tensor.data)
706+
data = mp_replace.copy(new_weight,
707+
child.weight.ds_tensor.data if hasattr(child.weight, 'ds_tensor') else \
708+
child.weight.data)
708709
new_embedding = nn.Embedding(child.weight.shape[0],
709710
child.weight.shape[1] // mp_size)
710711
new_embedding.weight.data.copy_(data)

0 commit comments

Comments
 (0)