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
46442b03
Unverified
Commit
46442b03
authored
Apr 28, 2025
by
Matthew Douglas
Committed by
GitHub
Apr 28, 2025
Browse files
Support 4bit torch.compile fullgraph with PyTorch nightly (#1616)
parent
c244e983
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
bitsandbytes/nn/modules.py
bitsandbytes/nn/modules.py
+8
-1
No files found.
bitsandbytes/nn/modules.py
View file @
46442b03
...
@@ -290,6 +290,13 @@ class Params4bit(torch.nn.Parameter):
...
@@ -290,6 +290,13 @@ class Params4bit(torch.nn.Parameter):
return
self
return
self
@
classmethod
def
__torch_function__
(
cls
,
func
,
types
,
args
=
(),
kwargs
=
None
):
if
kwargs
is
None
:
kwargs
=
{}
with
torch
.
_C
.
DisableTorchFunctionSubclass
():
return
func
(
*
args
,
**
kwargs
)
def
_quantize
(
self
,
device
):
def
_quantize
(
self
,
device
):
w
=
self
.
data
.
contiguous
().
to
(
device
)
w
=
self
.
data
.
contiguous
().
to
(
device
)
w_4bit
,
quant_state
=
bnb
.
functional
.
quantize_4bit
(
w_4bit
,
quant_state
=
bnb
.
functional
.
quantize_4bit
(
...
@@ -486,7 +493,7 @@ class Linear4bit(nn.Linear):
...
@@ -486,7 +493,7 @@ class Linear4bit(nn.Linear):
bias
=
None
if
self
.
bias
is
None
else
self
.
bias
.
to
(
self
.
compute_dtype
)
bias
=
None
if
self
.
bias
is
None
else
self
.
bias
.
to
(
self
.
compute_dtype
)
return
bnb
.
matmul_4bit
(
x
,
self
.
weight
.
t
(),
bias
=
bias
,
quant_state
=
self
.
weight
.
quant_state
).
to
(
inp_dtype
)
return
bnb
.
matmul_4bit
(
x
,
self
.
weight
.
data
.
t
(),
bias
=
bias
,
quant_state
=
self
.
weight
.
quant_state
).
to
(
inp_dtype
)
class
LinearFP4
(
Linear4bit
):
class
LinearFP4
(
Linear4bit
):
...
...
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