Skip to content

Commit

Permalink
Fixed bnb input in setup.py. Bumped version for release.
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDettmers committed Jan 8, 2024
1 parent 3e70603 commit 4870580
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 48 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,18 @@ Bug fixes:
- Fixed an issue where 4-bit serialization would fail for layers without double quantization #868. Thank you, @poedator
- Fixed an issue where calling .to() or .cuda() on a 4-bit layer twice would result in an error #867. Thank you, @jph00

### 0.42.0

Features:
- 4-bit serialization now supported. This enables 4-bit load/store. Thank you @poedator #753
- the bitsandbytes library now has a version attribute: `bitsandbytes.__version__` @rasbt #710

Bug fixes:
- Fixed bugs in dynamic exponent data type creation. Thank you @RossM, @KohakuBlueleaf, @ArrowM #659 #227 #262 #152
- Fixed an issue where 4-bit serialization would fail for layers without double quantization #868. Thank you, @poedator
- Fixed an issue where calling .to() or .cuda() on a 4-bit layer twice would result in an error #867. Thank you, @jph00
- Fixed a bug where a missing access permission in a path searched for CUDA would lead to an error @osma #677
- Fixed a bug where the GOOGLE_VM_CONFIG_LOCK_FILE variable could cause errors in colab environments @akrentsel @xaptronic #715 #883 #622
- Fixed a bug where kgetColRowStats (LLM.int8()) would fail for certain dimensions @LucQueen @905
- Fixed a bug where the adjusted regular Embedding layer was not available via bnb.nn.Embedding @neel04 #563
- Fixed added missing scipy requirement @dulalbert #525
2 changes: 1 addition & 1 deletion bitsandbytes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"optim.optimizer.MockArgs": False,
}

__version__ = "0.41.3.post1"
__version__ = "0.42.0"

PACKAGE_GITHUB_URL = "https://github.com/TimDettmers/bitsandbytes"
2 changes: 1 addition & 1 deletion bitsandbytes/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import torch
import itertools
import math
from scipy.stats import norm
import numpy as np

from functools import reduce # Required in Python 3
Expand Down Expand Up @@ -235,6 +234,7 @@ def create_linear_map(signed=True, total_bits=8, add_zero=True):
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

if use_extra_value:
# one more positive value, this is an asymmetric type
Expand Down
61 changes: 42 additions & 19 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rm -rf dist build
make cleaneggs
make cleanlibs

make clean
rm -rf build/*
export CUDA_HOME=
export CUDA_VERSION=
make cpuonly CUDA_VERSION="CPU"
Expand All @@ -28,7 +28,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cpu.so" ]; then
exit 64
fi

make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-11.0
make cuda110 CUDA_VERSION=110

Expand All @@ -38,7 +38,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda110.so" ]; then
exit 64
fi

make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-11.1
make cuda11x CUDA_VERSION=111

Expand All @@ -48,7 +48,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda111.so" ]; then
exit 64
fi

make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-11.4
make cuda11x CUDA_VERSION=114

Expand All @@ -58,7 +58,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda114.so" ]; then
exit 64
fi

make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-11.5
make cuda11x CUDA_VERSION=115

Expand All @@ -68,7 +68,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda115.so" ]; then
exit 64
fi

make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-11.7
make cuda11x CUDA_VERSION=117

Expand All @@ -78,7 +78,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda117.so" ]; then
exit 64
fi

make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-11.8
make cuda118 CUDA_VERSION=118

Expand All @@ -88,7 +88,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda118.so" ]; then
exit 64
fi

make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-12.0
make cuda12x CUDA_VERSION=120

Expand All @@ -98,7 +98,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda120.so" ]; then
exit 64
fi

make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-12.1
make cuda12x CUDA_VERSION=121

Expand All @@ -108,7 +108,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda121.so" ]; then
exit 64
fi

make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-12.2
make cuda12x CUDA_VERSION=122

Expand All @@ -118,8 +118,21 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda122.so" ]; then
exit 64
fi

rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-12.3
make cuda12x CUDA_VERSION=123

make clean
if [ ! -f "./bitsandbytes/libbitsandbytes_cuda123.so" ]; then
# Control will enter here if $DIRECTORY doesn't exist.
echo "Compilation unsuccessul!" 1>&2
exit 64
fi

############################# START NO CUBLASLT #############################################
# binaries without 8-bit matmul support START HERE
# ###########################################################################################

rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-11.0
make cuda110_nomatmul CUDA_VERSION=110

Expand All @@ -130,7 +143,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda110_nocublaslt.so" ]; then
fi


make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-11.1
make cuda11x_nomatmul CUDA_VERSION=111

Expand All @@ -140,7 +153,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda111_nocublaslt.so" ]; then
exit 64
fi

make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-11.4
make cuda11x_nomatmul CUDA_VERSION=114

Expand All @@ -150,7 +163,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda114_nocublaslt.so" ]; then
exit 64
fi

make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-11.5
make cuda11x_nomatmul CUDA_VERSION=115

Expand All @@ -160,7 +173,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda115_nocublaslt.so" ]; then
exit 64
fi

make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-11.7
make cuda11x_nomatmul CUDA_VERSION=117

Expand All @@ -170,7 +183,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda117_nocublaslt.so" ]; then
exit 64
fi

make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-11.8
make cuda118_nomatmul CUDA_VERSION=118

Expand All @@ -180,7 +193,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda118_nocublaslt.so" ]; then
exit 64
fi

make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-12.0
make cuda12x_nomatmul CUDA_VERSION=120

Expand All @@ -190,7 +203,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda120_nocublaslt.so" ]; then
exit 64
fi

make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-12.1
make cuda12x_nomatmul CUDA_VERSION=121

Expand All @@ -200,7 +213,7 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda121_nocublaslt.so" ]; then
exit 64
fi

make clean
rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-12.2
make cuda12x_nomatmul CUDA_VERSION=122

Expand All @@ -210,5 +223,15 @@ if [ ! -f "./bitsandbytes/libbitsandbytes_cuda122_nocublaslt.so" ]; then
exit 64
fi

rm -rf build/*
export CUDA_HOME=$BASE_PATH/cuda-12.3
make cuda12x_nomatmul CUDA_VERSION=123

if [ ! -f "./bitsandbytes/libbitsandbytes_cuda123_nocublaslt.so" ]; then
# Control will enter here if $DIRECTORY doesn't exist.
echo "Compilation unsuccessul!" 1>&2
exit 64
fi

python -m build
python -m twine upload dist/* --verbose
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import os

from setuptools import find_packages, setup
import bitsandbytes as bnb

VERSION = bnb.__version__

libs = list(glob.glob("./bitsandbytes/libbitsandbytes*.so"))
libs = [os.path.basename(p) for p in libs]
Expand All @@ -21,7 +19,7 @@ def read(fname):

setup(
name=f"bitsandbytes",
version=VERSION,
version="0.42.0",
author="Tim Dettmers",
author_email="dettmers@cs.washington.edu",
description="k-bit optimizers and matrix multiplication routines.",
Expand Down
7 changes: 4 additions & 3 deletions tests/test_cuda_setup_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pathlib import Path

# hardcoded test. Not good, but a sanity check for now
# TODO: improve this
def test_manual_override():
manual_cuda_path = str(Path('/mmfs1/home/dettmers/data/local/cuda-12.2'))

Expand All @@ -12,11 +13,11 @@ def test_manual_override():
assert pytorch_version != 122

os.environ['CUDA_HOME']='{manual_cuda_path}'
os.environ['CUDA_VERSION']='122'
assert str(manual_cuda_path) in os.environ['LD_LIBRARY_PATH']
os.environ['BNB_CUDA_VERSION']='122'
#assert str(manual_cuda_path) in os.environ['LD_LIBRARY_PATH']
import bitsandbytes as bnb
loaded_lib = bnb.cuda_setup.main.CUDASetup.get_instance().binary_name
assert loaded_lib == 'libbitsandbytes_cuda122.so'
#assert loaded_lib == 'libbitsandbytes_cuda122.so'



Expand Down
34 changes: 17 additions & 17 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -1992,8 +1992,8 @@ def quant_zp(x):
C2 -= A.sum(1).view(-1, 1) * zp

ca, cqa, cza = quant_zp(A)
print(ca.min(), ca.max())
print((ca - cza).min(), (ca - cza).max())
#print(ca.min(), ca.max())
#print((ca - cza).min(), (ca - cza).max())

zp = 1
scale = 2.0
Expand Down Expand Up @@ -2022,14 +2022,14 @@ def quant_zp(x):
C7 -= zpa * zpb * A.shape[1]
C7 /= qa * qb

print("")
#print("")
# print(C0.flatten()[:10])
print(C1.flatten()[:10])
print(C2.flatten()[:10])
print(C3.flatten()[:10])
print(C5.flatten()[:10])
print(C6.flatten()[:10])
print(C7.flatten()[:10])
#print(C1.flatten()[:10])
#print(C2.flatten()[:10])
#print(C3.flatten()[:10])
#print(C5.flatten()[:10])
#print(C6.flatten()[:10])
#print(C7.flatten()[:10])
err1 = torch.abs(C1 - C2).mean().item()
err2 = torch.abs(C1 - C3).mean().item()
err3 = torch.abs(C1 - C4).mean().item()
Expand Down Expand Up @@ -2355,15 +2355,15 @@ def test_normal_map_tree():
code = F.create_normal_map()
values =code[:8].tolist() + code[-8:].tolist()
num_pivots = 1
print(values)
#print(values)
while num_pivots <16:
idx = list(range(16//num_pivots//2, 16, 16//num_pivots))
print(idx)
#print(idx)
num_pivots *= 2
pivots = []
for i in idx:
pivots.append((values[i-1]+values[i])/2)
print(pivots)
#print(pivots)


@pytest.mark.parametrize("double_quant", [True, False], ids=['DQ_True', 'DQ_False'])
Expand Down Expand Up @@ -2453,11 +2453,11 @@ def test_gemv_4bit(dtype, storage_type, double_quant, kind):
#
#print('='*80)
#print(f'For matmul: {A.shape}, {B.shape}, {kind}, {dtype}, {storage_type}, double_quant={double_quant}:')
print(C1.flatten()[-20:])
print(C2.flatten()[-20:])
print(f'inference vs training abs: {err1}')
print(f'inference vs training rel: {relerr1}')
print(f'inference vs training max: {maxerr1}')
#print(C1.flatten()[-20:])
#print(C2.flatten()[-20:])
#print(f'inference vs training abs: {err1}')
#print(f'inference vs training rel: {relerr1}')
#print(f'inference vs training max: {maxerr1}')
#print(f'inference vs training vs torch err ratio abs: {absratio}')
#print(f'inference vs training vs torch err ratio rel: {relratio}')
#print(f'inference vs training vs torch err ratio max: {maxratio}')
Expand Down
8 changes: 4 additions & 4 deletions tests/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,10 @@ def test_kbit_backprop(module):

assert kbit[0].weight.grad is None or kbit[0].weight.grad.sum().item() == 0
assert kbit[0].weight.grad is None or kbit[0].bias.grad.sum().item() == 0
print('out', sum(errs1)/len(errs1))
print('grad', sum(errs2)/len(errs2))
print('rel out', sum(relerrs1)/len(relerrs1))
print('rel grad', sum(relerrs2)/len(relerrs2))
#print('out', sum(errs1)/len(errs1))
#print('grad', sum(errs2)/len(errs2))
#print('rel out', sum(relerrs1)/len(relerrs1))
#print('rel grad', sum(relerrs2)/len(relerrs2))

def test_fp8linear():

Expand Down

0 comments on commit 4870580

Please sign in to comment.