Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
bitsandbytes
Commits
cef519c8
"vscode:/vscode.git/clone" did not exist on "d11b5068dd74de6694cea0cce350bc86eb2ba5b2"
Commit
cef519c8
authored
Jul 09, 2023
by
Tim Dettmers
Browse files
Added test for Param4bit.to() and fixed double quant behavior.
parent
6a905be5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
5 deletions
+4
-5
bitsandbytes/functional.py
bitsandbytes/functional.py
+0
-2
bitsandbytes/nn/modules.py
bitsandbytes/nn/modules.py
+3
-3
tests/test_modules.py
tests/test_modules.py
+1
-0
No files found.
bitsandbytes/functional.py
View file @
cef519c8
...
@@ -831,8 +831,6 @@ def quantize_4bit(A: Tensor, absmax: Tensor = None, out: Tensor = None, blocksiz
...
@@ -831,8 +831,6 @@ def quantize_4bit(A: Tensor, absmax: Tensor = None, out: Tensor = None, blocksiz
if
compress_statistics
:
if
compress_statistics
:
offset
=
absmax
.
mean
()
offset
=
absmax
.
mean
()
absmax
-=
offset
absmax
-=
offset
#code = create_custom_map().to(absmax.device)
#qabsmax, state2 = quantize_blockwise(absmax, code=code, blocksize=256)
qabsmax
,
state2
=
quantize_blockwise
(
absmax
,
blocksize
=
256
)
qabsmax
,
state2
=
quantize_blockwise
(
absmax
,
blocksize
=
256
)
del
absmax
del
absmax
state
=
[
qabsmax
,
input_shape
,
A
.
dtype
,
blocksize
,
[
offset
,
state2
],
quant_type
,
datatype
]
state
=
[
qabsmax
,
input_shape
,
A
.
dtype
,
blocksize
,
[
offset
,
state2
],
quant_type
,
datatype
]
...
...
bitsandbytes/nn/modules.py
View file @
cef519c8
...
@@ -188,9 +188,9 @@ class Params4bit(torch.nn.Parameter):
...
@@ -188,9 +188,9 @@ class Params4bit(torch.nn.Parameter):
#s[-2][1][0] = s[-2][1][0].to(device) # nested absmax
#s[-2][1][0] = s[-2][1][0].to(device) # nested absmax
# for 8-bit
# for 8-bit
s
[
-
2
][
0
]
=
s
[
-
2
][
0
].
to
(
device
)
# offset
s
[
-
3
][
0
]
=
s
[
-
3
][
0
].
to
(
device
)
# offset
s
[
-
2
][
1
][
0
]
=
s
[
-
2
][
1
][
0
].
to
(
device
)
# nested quantiation state statitics
s
[
-
3
][
1
][
0
]
=
s
[
-
3
][
1
][
0
].
to
(
device
)
# nested quantiation state statitics
s
[
-
2
][
1
][
1
]
=
s
[
-
2
][
1
][
1
].
to
(
device
)
# nested quantiation codebook
s
[
-
3
][
1
][
1
]
=
s
[
-
3
][
1
][
1
].
to
(
device
)
# nested quantiation codebook
new_param
=
Params4bit
(
super
().
to
(
device
=
device
,
dtype
=
dtype
,
non_blocking
=
non_blocking
),
new_param
=
Params4bit
(
super
().
to
(
device
=
device
,
dtype
=
dtype
,
non_blocking
=
non_blocking
),
requires_grad
=
self
.
requires_grad
,
quant_state
=
self
.
quant_state
,
requires_grad
=
self
.
requires_grad
,
quant_state
=
self
.
quant_state
,
blocksize
=
self
.
blocksize
,
compress_statistics
=
self
.
compress_statistics
,
blocksize
=
self
.
blocksize
,
compress_statistics
=
self
.
compress_statistics
,
...
...
tests/test_modules.py
View file @
cef519c8
...
@@ -535,6 +535,7 @@ def test_kbit_backprop(module):
...
@@ -535,6 +535,7 @@ def test_kbit_backprop(module):
kbit
[
1
].
bias
.
detach
().
copy_
(
ref
[
1
].
bias
)
kbit
[
1
].
bias
.
detach
().
copy_
(
ref
[
1
].
bias
)
ref
=
ref
.
half
().
cuda
()
ref
=
ref
.
half
().
cuda
()
kbit
=
kbit
.
half
().
cuda
()
kbit
=
kbit
.
half
().
cuda
()
kbit
=
kbit
.
half
().
to
(
'cuda'
)
errs1
=
[]
errs1
=
[]
errs2
=
[]
errs2
=
[]
...
...
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