Skip to content

Commit

Permalink
fixing lint
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Apr 30, 2024
1 parent cae33c3 commit da53f39
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions bitsandbytes/archive_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ def get_instance(cls):
dtype2bytes[torch.int8] = 1


def get_paged(*shape, dtype=torch.float32, device=torch.device("cuda", index=0)):
def get_paged(*shape, dtype=torch.float32, device=None):
if device is None:
torch.device("cuda", index=0)
num_bytes = dtype2bytes[dtype] * prod(shape)
cuda_ptr = lib.cget_managed_ptr(ct.c_size_t(num_bytes))
c_ptr = ct.cast(cuda_ptr, ct.POINTER(ct.c_int))
Expand Down Expand Up @@ -246,8 +248,8 @@ def create_linear_map(signed=True, total_bits=8, add_zero=True):
if gap == 0:
return values
else:
l = values.numel() // 2
return torch.Tensor(values[:l].tolist() + [0] * gap + values[l:].tolist())
l_var = values.numel() // 2
return torch.Tensor(values[:l_var].tolist() + [0] * gap + values[l_var:].tolist())


def create_normal_map(offset=0.9677083, use_extra_value=True):
Expand Down Expand Up @@ -679,7 +681,7 @@ def quantize_blockwise(

def dequantize_blockwise(
A: Tensor,
quant_state: Tuple[Tensor, Tensor] = None,
quant_state: Optional[Tuple[Tensor, Tensor]] = None,

Check failure on line 684 in bitsandbytes/archive_functional.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (F821)

bitsandbytes/archive_functional.py:684:18: F821 Undefined name `Optional`
absmax: Tensor = None,
code: Tensor = None,
out: Tensor = None,
Expand Down Expand Up @@ -857,7 +859,7 @@ def quantize_4bit(

def dequantize_fp4(
A: Tensor,
quant_state: Tuple[Tensor, Tensor] = None,
quant_state: Optional[Tuple[Tensor, Tensor]] = None,

Check failure on line 862 in bitsandbytes/archive_functional.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (F821)

bitsandbytes/archive_functional.py:862:18: F821 Undefined name `Optional`
absmax: Tensor = None,
out: Tensor = None,
blocksize: int = 64,
Expand All @@ -867,7 +869,7 @@ def dequantize_fp4(

def dequantize_nf4(
A: Tensor,
quant_state: Tuple[Tensor, Tensor] = None,
quant_state: Optional[Tuple[Tensor, Tensor]] = None,

Check failure on line 872 in bitsandbytes/archive_functional.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (F821)

bitsandbytes/archive_functional.py:872:18: F821 Undefined name `Optional`
absmax: Tensor = None,
out: Tensor = None,
blocksize: int = 64,
Expand All @@ -877,7 +879,7 @@ def dequantize_nf4(

def dequantize_4bit(
A: Tensor,
quant_state: Tuple[Tensor, Tensor] = None,
quant_state: Optional[Tuple[Tensor, Tensor]] = None,

Check failure on line 882 in bitsandbytes/archive_functional.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (F821)

bitsandbytes/archive_functional.py:882:18: F821 Undefined name `Optional`
absmax: Tensor = None,
out: Tensor = None,
blocksize: int = 64,
Expand Down Expand Up @@ -979,7 +981,7 @@ def quantize(A: Tensor, code: Tensor = None, out: Tensor = None) -> Tensor:

def dequantize(
A: Tensor,
quant_state: Tuple[Tensor, Tensor] = None,
quant_state: Optional[Tuple[Tensor, Tensor]] = None,

Check failure on line 984 in bitsandbytes/archive_functional.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (F821)

bitsandbytes/archive_functional.py:984:18: F821 Undefined name `Optional`
absmax: Tensor = None,
code: Tensor = None,
out: Tensor = None,
Expand Down

0 comments on commit da53f39

Please sign in to comment.