MCPcopy Create free account
hub / github.com/bitsandbytes-foundation/bitsandbytes / _quantize

Method _quantize

bitsandbytes/nn/modules.py:737–748  ·  view source on GitHub ↗
(self, device)

Source from the content-addressed store, hash-verified

735 return obj
736
737 def _quantize(self, device):
738 if self.has_fp16_weights:
739 return super().to(device)
740
741 # We quantize the weight and store in 8bit row-major
742 B = self.data.contiguous().to(device=device, dtype=torch.float16)
743 CB, SCB, _ = bnb.functional.int8_vectorwise_quant(B)
744 self.data = CB
745 self.CB = CB
746 self.SCB = SCB
747
748 return self
749
750 def cpu(self):
751 return self.to(device="cpu")

Callers 1

toMethod · 0.95

Calls 1

toMethod · 0.45

Tested by

no test coverage detected