Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions convert_hf_to_gguf.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,6 @@ def prepare_tensors(self):
# data = data_torch.squeeze().numpy()
data = data_torch.numpy()

# if data ends up empty, it means data_torch was a scalar tensor -> restore
if len(data.shape) == 0:
data = data_torch.numpy()

Comment on lines -305 to -308
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the intention here was to have the shape be non-zero for scalars, in which case

data = data.reshape(1)

might be more appropriate in that otherwise redundant if condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @compilade for the comments.

Is there a case that data.reshape(1) is needed when converting gguf models?
If not, there might be some risk adding data.reshape(1) here.

I would suggest removing the code at the moment which doesn't change the logic.
And we can still add data.reshape(1) in the future if it really matters.

What do you think?
Thanks.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a case that data.reshape(1) is needed when converting gguf models?

Yes, and it's exactly when len(data.shape) == 0 (aka when the shape is an empty tuple ()).

It doesn't really happen in practice because most models don't have scalar tensors.

I would suggest removing the code at the moment which doesn't change the logic.
And we can still add data.reshape(1) in the future if it really matters.

Agreed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ggerganov and @compilade for your approval.

n_dims = len(data.shape)
data_qtype: gguf.GGMLQuantizationType | bool = self.tensor_force_quant(name, new_name, bid, n_dims)

Expand Down