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
d9333aa9
Unverified
Commit
d9333aa9
authored
Jun 08, 2025
by
Matthew Douglas
Committed by
GitHub
Jun 08, 2025
Browse files
Improvement for torch.compile support on Params4bit (#1673)
parent
11df723f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
11 deletions
+1
-11
bitsandbytes/nn/modules.py
bitsandbytes/nn/modules.py
+0
-7
tests/test_linear4bit.py
tests/test_linear4bit.py
+1
-4
No files found.
bitsandbytes/nn/modules.py
View file @
d9333aa9
...
@@ -291,13 +291,6 @@ class Params4bit(torch.nn.Parameter):
...
@@ -291,13 +291,6 @@ 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
(
...
...
tests/test_linear4bit.py
View file @
d9333aa9
...
@@ -270,10 +270,7 @@ def test_params4bit_real_serialization(device, quant_type, blocksize, compress_s
...
@@ -270,10 +270,7 @@ def test_params4bit_real_serialization(device, quant_type, blocksize, compress_s
@
pytest
.
mark
.
parametrize
(
"mode"
,
[
"default"
,
"reduce-overhead"
],
ids
=
id_formatter
(
"mode"
))
@
pytest
.
mark
.
parametrize
(
"mode"
,
[
"default"
,
"reduce-overhead"
],
ids
=
id_formatter
(
"mode"
))
@
pytest
.
mark
.
skipif
(
torch
.
__version__
<
(
2
,
4
),
reason
=
"Not supported in torch < 2.4"
)
@
pytest
.
mark
.
skipif
(
torch
.
__version__
<
(
2
,
4
),
reason
=
"Not supported in torch < 2.4"
)
def
test_linear4bit_torch_compile
(
device
,
quant_type
,
compute_dtype
,
compress_statistics
,
bias
,
fullgraph
,
mode
):
def
test_linear4bit_torch_compile
(
device
,
quant_type
,
compute_dtype
,
compress_statistics
,
bias
,
fullgraph
,
mode
):
if
device
==
"cpu"
and
quant_type
==
"fp4"
:
if
fullgraph
and
torch
.
__version__
<
(
2
,
8
,
0
,
"dev"
):
pytest
.
skip
(
"FP4 is not supported for CPU"
)
if
fullgraph
and
torch
.
__version__
<
(
2
,
8
):
pytest
.
skip
(
"fullgraph mode requires torch 2.8 or higher"
)
pytest
.
skip
(
"fullgraph mode requires torch 2.8 or higher"
)
if
device
==
"cuda"
and
platform
.
system
()
==
"Windows"
:
if
device
==
"cuda"
and
platform
.
system
()
==
"Windows"
:
...
...
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