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
d9ca0ed9
Commit
d9ca0ed9
authored
Sep 17, 2022
by
justheuristic
Browse files
un-fuse bias
parent
7facedda
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
bitsandbytes/autograd/_functions.py
bitsandbytes/autograd/_functions.py
+5
-3
tests/test_autograd.py
tests/test_autograd.py
+1
-1
No files found.
bitsandbytes/autograd/_functions.py
View file @
d9ca0ed9
...
@@ -234,8 +234,6 @@ class MatMul8bitLt(torch.autograd.Function):
...
@@ -234,8 +234,6 @@ class MatMul8bitLt(torch.autograd.Function):
if
A_dtype
!=
torch
.
float16
:
if
A_dtype
!=
torch
.
float16
:
warnings
.
warn
(
f
"MatMul8bitLt: input matrix will be converted from
{
A_dtype
}
to float16"
)
warnings
.
warn
(
f
"MatMul8bitLt: input matrix will be converted from
{
A_dtype
}
to float16"
)
A
=
A
.
to
(
torch
.
float16
)
A
=
A
.
to
(
torch
.
float16
)
if
bias
is
not
None
:
bias
=
bias
.
to
(
torch
.
float16
)
# 1. Quantize A
# 1. Quantize A
if
len
(
A
.
shape
)
==
3
:
if
len
(
A
.
shape
)
==
3
:
...
@@ -315,7 +313,11 @@ class MatMul8bitLt(torch.autograd.Function):
...
@@ -315,7 +313,11 @@ class MatMul8bitLt(torch.autograd.Function):
C32A
,
SA
=
F
.
transform
(
CA
,
"col32"
)
C32A
,
SA
=
F
.
transform
(
CA
,
"col32"
)
out32
,
Sout32
=
F
.
igemmlt
(
C32A
,
state
.
CxB
,
SA
,
state
.
SB
)
out32
,
Sout32
=
F
.
igemmlt
(
C32A
,
state
.
CxB
,
SA
,
state
.
SB
)
# we apply the fused bias here
# we apply the fused bias here
output
=
F
.
mm_dequant
(
out32
,
Sout32
,
SCA
,
state
.
SCB
,
bias
=
bias
)
fused_bias
=
bias
if
bias
.
dtype
==
torch
.
float16
else
None
output
=
F
.
mm_dequant
(
out32
,
Sout32
,
SCA
,
state
.
SCB
,
bias
=
fused_bias
)
if
fused_bias
is
None
and
bias
is
not
None
:
output
.
add_
(
bias
.
to
(
output
.
dtype
))
# 4. Mixed-precision decomposition matmul
# 4. Mixed-precision decomposition matmul
if
coo_tensorA
is
not
None
and
subA
is
not
None
:
if
coo_tensorA
is
not
None
and
subA
is
not
None
:
...
...
tests/test_autograd.py
View file @
d9ca0ed9
...
@@ -427,4 +427,4 @@ def test_matmullt(
...
@@ -427,4 +427,4 @@ def test_matmullt(
)
)
if
req_grad
[
2
]:
if
req_grad
[
2
]:
torch
.
testing
.
assert_allclose
(
gradBias1
,
gradBias2
,
atol
=
0.18
,
rtol
=
0.3
)
torch
.
testing
.
assert_allclose
(
gradBias1
,
gradBias2
)
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