Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
bitsandbytes
Commits
097b1cc5
Commit
097b1cc5
authored
Jul 13, 2023
by
Tim Dettmers
Browse files
Fixed bug caused by undefined default type of absmax. #553
parent
7b6cfe17
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
CHANGELOG.md
CHANGELOG.md
+3
-0
bitsandbytes/functional.py
bitsandbytes/functional.py
+6
-2
No files found.
CHANGELOG.md
View file @
097b1cc5
...
@@ -264,3 +264,6 @@ Deprecated:
...
@@ -264,3 +264,6 @@ Deprecated:
Features:
Features:
-
Added precompiled CUDA 11.8 binaries to support H100 GPUs without compilation #571
-
Added precompiled CUDA 11.8 binaries to support H100 GPUs without compilation #571
Bug fixes:
-
Fixed a bug where the default type of absmax was undefined which leads to errors if the default type is different than torch.float32. # 553
bitsandbytes/functional.py
View file @
097b1cc5
...
@@ -604,7 +604,7 @@ def quantize_blockwise(A: Tensor, code: Tensor = None, absmax: Tensor = None, ou
...
@@ -604,7 +604,7 @@ def quantize_blockwise(A: Tensor, code: Tensor = None, absmax: Tensor = None, ou
n
=
A
.
numel
()
n
=
A
.
numel
()
blocks
=
n
//
blocksize
blocks
=
n
//
blocksize
blocks
+=
1
if
n
%
blocksize
>
0
else
0
blocks
+=
1
if
n
%
blocksize
>
0
else
0
absmax
=
torch
.
zeros
((
blocks
,),
device
=
A
.
device
)
absmax
=
torch
.
zeros
((
blocks
,),
device
=
A
.
device
,
dtype
=
torch
.
float32
)
if
out
is
None
:
if
out
is
None
:
out
=
torch
.
zeros_like
(
A
,
dtype
=
torch
.
uint8
)
out
=
torch
.
zeros_like
(
A
,
dtype
=
torch
.
uint8
)
...
@@ -684,6 +684,8 @@ def dequantize_blockwise(
...
@@ -684,6 +684,8 @@ def dequantize_blockwise(
quant_state
=
(
absmax
,
code
,
blocksize
,
False
,
torch
.
float32
,
None
,
None
)
quant_state
=
(
absmax
,
code
,
blocksize
,
False
,
torch
.
float32
,
None
,
None
)
absmax
,
code
,
blocksize
,
nested
,
dtype
,
offset
,
state2
=
quant_state
absmax
,
code
,
blocksize
,
nested
,
dtype
,
offset
,
state2
=
quant_state
if
absmax
.
dtype
!=
torch
.
float32
:
absmax
=
absmax
.
float
()
if
nested
:
if
nested
:
absmax
=
dequantize_blockwise
(
absmax
,
state2
)
absmax
=
dequantize_blockwise
(
absmax
,
state2
)
absmax
+=
offset
absmax
+=
offset
...
@@ -796,7 +798,7 @@ def quantize_4bit(A: Tensor, absmax: Tensor = None, out: Tensor = None, blocksiz
...
@@ -796,7 +798,7 @@ def quantize_4bit(A: Tensor, absmax: Tensor = None, out: Tensor = None, blocksiz
if
absmax
is
None
:
if
absmax
is
None
:
blocks
=
n
//
blocksize
blocks
=
n
//
blocksize
blocks
+=
1
if
n
%
blocksize
>
0
else
0
blocks
+=
1
if
n
%
blocksize
>
0
else
0
absmax
=
torch
.
zeros
((
blocks
,),
device
=
A
.
device
)
absmax
=
torch
.
zeros
((
blocks
,),
device
=
A
.
device
,
dtype
=
torch
.
float32
)
if
out
is
None
:
if
out
is
None
:
...
@@ -886,6 +888,7 @@ def dequantize_4bit(A: Tensor,quant_state: Tuple[Tensor, Tensor] = None, absmax:
...
@@ -886,6 +888,7 @@ def dequantize_4bit(A: Tensor,quant_state: Tuple[Tensor, Tensor] = None, absmax:
if
compressed_stats
is
not
None
:
if
compressed_stats
is
not
None
:
if
absmax
.
dtype
!=
torch
.
float32
:
absmax
=
absmax
.
float
()
offset
,
state2
=
compressed_stats
offset
,
state2
=
compressed_stats
absmax
=
dequantize_blockwise
(
absmax
,
state2
)
absmax
=
dequantize_blockwise
(
absmax
,
state2
)
absmax
+=
offset
absmax
+=
offset
...
@@ -930,6 +933,7 @@ def quantize(A: Tensor, code: Tensor = None, out: Tensor = None) -> Tensor:
...
@@ -930,6 +933,7 @@ def quantize(A: Tensor, code: Tensor = None, out: Tensor = None) -> Tensor:
code
=
code
.
to
(
A
.
device
)
code
=
code
.
to
(
A
.
device
)
absmax
=
torch
.
abs
(
A
).
max
()
absmax
=
torch
.
abs
(
A
).
max
()
if
absmax
.
dtype
!=
torch
.
float32
:
absmax
=
absmax
.
float
()
inp
=
A
/
absmax
inp
=
A
/
absmax
out
=
quantize_no_absmax
(
inp
,
code
,
out
)
out
=
quantize_no_absmax
(
inp
,
code
,
out
)
return
out
,
(
absmax
,
code
)
return
out
,
(
absmax
,
code
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment