Skip to content

Commit

Permalink
Don't require scipy for regular use
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Jan 24, 2024
1 parent 1e64210 commit edc83e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion bitsandbytes/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,15 @@ def create_linear_map(signed=True, total_bits=8, add_zero=True):
l = values.numel()//2
return torch.Tensor(values[:l].tolist() + [0]*gap + values[l:].tolist())


def create_normal_map(offset=0.9677083, use_extra_value=True):
from scipy.stats import norm
try:
from scipy.stats import norm
except ImportError as ie:
raise ImportError(
"Scipy is required for `create_normal_map`. "
"Install `bitsandbytes` with the `[test]` extra."
) from ie

if use_extra_value:
# one more positive value, this is an asymmetric type
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ def read(fname):
license="MIT",
keywords="gpu optimizers optimization 8-bit quantization compression",
url="https://github.com/TimDettmers/bitsandbytes",
install_requires=['scipy'],
install_requires=[],
extras_require={
'test': ['scipy'],
},
packages=find_packages(),
package_data={"": libs},
install_requires=['torch', 'numpy', 'scipy'],
Expand Down

0 comments on commit edc83e2

Please sign in to comment.