Skip to content

Commit

Permalink
Fix fused_qkv print model ValueError (#7109)
Browse files Browse the repository at this point in the history
Suppose qkv_linear_weight_shape = [in_features, out_features].
The qkv linear weight shape is [3, in_features, out_features] if using
fued_qkv gemm optimization. It will cause "ValueError: too many values
to unpack (expected 2)" issue when printing the model.

Solution: Take the last two weight dimensions shapes as in_features and
out_features.

Signed-off-by: Lai, Yejing <[email protected]>
Co-authored-by: Hongwei Chen <[email protected]>
Co-authored-by: Logan Adams <[email protected]>
  • Loading branch information
3 people authored Mar 4, 2025
1 parent 17c6595 commit 71807bc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion deepspeed/module_inject/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def __deepcopy__(self, memo):

def extra_repr(self):
if self.weight is not None:
out_features, in_features = self.weight.shape if self.weight is not None else (None, None)
out_features, in_features = self.weight.shape[-2:] if self.weight is not None else (None, None)
dtype = self.weight.dtype if self.weight is not None else None
extra_repr_str = "in_features={}, out_features={}, bias={}, dtype={}".format(
in_features, out_features, self.bias is not None, dtype)
Expand Down

0 comments on commit 71807bc

Please sign in to comment.