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

Method __init__

bitsandbytes/nn/modules.py:901–928  ·  view source on GitHub ↗
(
        self,
        num_embeddings,
        embedding_dim,
        dtype=None,
        quant_type="fp4",
        quant_storage=torch.uint8,
        device=None,
    )

Source from the content-addressed store, hash-verified

899 """
900
901 def __init__(
902 self,
903 num_embeddings,
904 embedding_dim,
905 dtype=None,
906 quant_type="fp4",
907 quant_storage=torch.uint8,
908 device=None,
909 ):
910 super().__init__(num_embeddings, embedding_dim, device=device, dtype=dtype)
911 self.dtype = self.weight.data.dtype
912
913 self.weight = Params4bit(
914 self.weight.data,
915 requires_grad=False,
916 compress_statistics=None,
917 quant_type=quant_type,
918 quant_storage=quant_storage,
919 module=self,
920 )
921
922 blocksize = self.weight.blocksize
923
924 if embedding_dim % blocksize != 0:
925 logger.warning(
926 f"Embedding size {embedding_dim} is not divisible by block size {blocksize}. "
927 "This will lead to slow inference.",
928 )
929
930 def _forward_with_partial_dequantize(self, input: Tensor):
931 assert self.embedding_dim % self.weight.quant_state.blocksize == 0

Callers

nothing calls this directly

Calls 2

Params4bitClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected