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
14048a3c
Commit
14048a3c
authored
Sep 18, 2022
by
justheuristic
Browse files
safer cast
parent
5b169f18
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
bitsandbytes/autograd/_functions.py
bitsandbytes/autograd/_functions.py
+2
-1
No files found.
bitsandbytes/autograd/_functions.py
View file @
14048a3c
...
@@ -371,7 +371,7 @@ class MatMul8bitLt(torch.autograd.Function):
...
@@ -371,7 +371,7 @@ class MatMul8bitLt(torch.autograd.Function):
gradB32
,
SgradB32
=
F
.
igemmlt
(
C32grad
,
CxAt
,
Sgrad
,
SAt
)
gradB32
,
SgradB32
=
F
.
igemmlt
(
C32grad
,
CxAt
,
Sgrad
,
SAt
)
grad_B
=
F
.
mm_dequant
(
gradB32
,
SgradB32
,
SCgradt
,
SCAt
).
to
(
ctx
.
dtype_B
)
grad_B
=
F
.
mm_dequant
(
gradB32
,
SgradB32
,
SCgradt
,
SCAt
).
to
(
ctx
.
dtype_B
)
if
state
.
threshold
>
0.0
and
subA
is
not
None
:
if
state
.
threshold
>
0.0
and
subA
is
not
None
:
grad_B
[:,
idx
]
.
add
mm
_
(
grad_output
.
t
(),
subA
)
grad_B
[:,
idx
]
+=
torch
.
mm
(
grad_output
.
t
(),
subA
)
if
req_gradA
:
if
req_gradA
:
if
state
.
CBt
is
not
None
:
if
state
.
CBt
is
not
None
:
...
@@ -384,6 +384,7 @@ class MatMul8bitLt(torch.autograd.Function):
...
@@ -384,6 +384,7 @@ class MatMul8bitLt(torch.autograd.Function):
grad_A
=
F
.
mm_dequant
(
gradA32
,
SgradA32
,
SCgrad
,
state
.
SCBt
).
view
(
ctx
.
grad_shape
).
to
(
ctx
.
dtype_A
)
grad_A
=
F
.
mm_dequant
(
gradA32
,
SgradA32
,
SCgrad
,
state
.
SCBt
).
view
(
ctx
.
grad_shape
).
to
(
ctx
.
dtype_A
)
elif
state
.
CB
is
not
None
:
elif
state
.
CB
is
not
None
:
raise
NotImplementedError
(
"WIP"
)
CB
=
state
.
CB
.
to
(
ctx
.
dtype_B
)
CB
=
state
.
CB
.
to
(
ctx
.
dtype_B
)
CB
.
mul_
(
state
.
SCB
.
unsqueeze
(
1
).
div_
(
127.0
).
to
(
CB
.
dtype
))
CB
.
mul_
(
state
.
SCB
.
unsqueeze
(
1
).
div_
(
127.0
).
to
(
CB
.
dtype
))
grad_A
=
torch
.
matmul
(
grad_output
,
CB
).
view
(
ctx
.
grad_shape
).
to
(
ctx
.
dtype_A
)
grad_A
=
torch
.
matmul
(
grad_output
,
CB
).
view
(
ctx
.
grad_shape
).
to
(
ctx
.
dtype_A
)
...
...
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