summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Dettmers <tim.dettmers@gmail.com>2022-08-08 05:20:36 -0700
committerTim Dettmers <tim.dettmers@gmail.com>2022-08-08 05:20:36 -0700
commit62441815bc733c9e75d32dd65305a16aaebd317a (patch)
tree017454ff35e0fa94c3b29369551d465e063bcf18
parent26efb154c8d77b4ede2cfc0dbd2381dd385f33e7 (diff)
Removed prod for Python <= 3.7 compatibility.
-rw-r--r--bitsandbytes/autograd/_functions.py14
-rw-r--r--setup.py2
2 files changed, 9 insertions, 7 deletions
diff --git a/bitsandbytes/autograd/_functions.py b/bitsandbytes/autograd/_functions.py
index 14f2660..a5446b7 100644
--- a/bitsandbytes/autograd/_functions.py
+++ b/bitsandbytes/autograd/_functions.py
@@ -1,10 +1,14 @@
-from dataclasses import dataclass
-
+import operator
import torch
-import math
import bitsandbytes as bnb
import bitsandbytes.functional as F
+from dataclasses import dataclass
+from functools import reduce # Required in Python 3
+
+def prod(iterable):
+ return reduce(operator.mul, iterable, 1)
+
tensor = torch.Tensor
"""
@@ -12,8 +16,6 @@ tensor = torch.Tensor
This is particularly important for small models where outlier features
are less systematic and occur with low frequency.
"""
-
-
class GlobalOutlierPooler(object):
_instance = None
@@ -201,7 +203,7 @@ class MatMul8bitLt(torch.autograd.Function):
def forward(ctx, A, B, out=None, state=MatmulLtState()):
# default to pytorch behavior if inputs are empty
ctx.is_empty = False
- if math.prod(A.shape) == 0:
+ if prod(A.shape) == 0:
ctx.is_empty = True
ctx.A = A
ctx.B = B
diff --git a/setup.py b/setup.py
index 67b655d..c425ca7 100644
--- a/setup.py
+++ b/setup.py
@@ -18,7 +18,7 @@ def read(fname):
setup(
name=f"bitsandbytes",
- version=f"0.31.4",
+ version=f"0.31.5",
author="Tim Dettmers",
author_email="dettmers@cs.washington.edu",
description="8-bit optimizers and matrix multiplication routines.",