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 996f23f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 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
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ def read(fname):
license="MIT",
keywords="gpu optimizers optimization 8-bit quantization compression",
url="https://github.com/TimDettmers/bitsandbytes",
install_requires=['scipy'],
packages=find_packages(),
package_data={"": libs},
install_requires=['torch', 'numpy', 'scipy'],
extras_require={'benchmark': ['pandas', 'matplotlib']},
install_requires=['torch', 'numpy'],
extras_require={
'benchmark': ['pandas', 'matplotlib'],
'test': ['scipy'],
},
long_description=read("README.md"),
long_description_content_type="text/markdown",
classifiers=[
Expand Down

0 comments on commit 996f23f

Please sign in to comment.