MCPcopy Create free account
hub / github.com/andrewkchan/deepseek.cpp / quantize

Function quantize

convert.py:326–335  ·  view source on GitHub ↗
(t: torch.Tensor)

Source from the content-addressed store, hash-verified

324 return t
325
326 def quantize(t: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
327 if dtype not in [torch.float32, torch.float16]:
328 if isinstance(metadata.quant, KQuant):
329 t = k_quantize(t.to(torch.float32), metadata.quant.name)
330 elif metadata.quant.block_size is None:
331 return per_tensor_quantize(t, dtype)
332 else:
333 quant_block_size = torch.tensor(metadata.quant.block_size)
334 return blockwise_quantize(t, quant_block_size, dtype)
335 return t.to(dtype), None
336
337 def conv(weight_name: str, scale_name: str) -> Tuple[torch.Tensor, torch.Tensor]:
338 nonlocal progress

Callers 2

convFunction · 0.85
load_weightsFunction · 0.85

Calls 3

k_quantizeFunction · 0.90
per_tensor_quantizeFunction · 0.85
blockwise_quantizeFunction · 0.85

Tested by

no test coverage detected