Skip to content
Closed
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions dequant.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def dequantize_tensor(tensor, dtype=None, dequant_dtype=None):

if qtype in TORCH_COMPATIBLE_QTYPES:
return tensor.to(dtype)
elif qtype == gguf.GGMLQuantizationType.BF16:
tensor = torch.Tensor(tensor.data.view(torch.bfloat16).reshape(oshape))
return tensor if dtype is None or dtype == torch.bfloat16 else tensor.to(dtype)
elif qtype in dequantize_functions:
dequant_dtype = dtype if dequant_dtype == "target" else dequant_dtype
return dequantize(tensor.data, qtype, oshape, dtype=dequant_dtype).to(dtype)
Expand Down
Loading