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
14147f6f
Commit
14147f6f
authored
Jul 14, 2025
by
Matthew Douglas
Browse files
Test fix
parent
941681da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
1 deletion
+5
-1
tests/helpers.py
tests/helpers.py
+2
-1
tests/test_optim.py
tests/test_optim.py
+3
-0
No files found.
tests/helpers.py
View file @
14147f6f
...
...
@@ -21,7 +21,8 @@ BOOLEAN_TUPLES = list(product(TRUE_FALSE, repeat=2)) # all combinations of (boo
def
get_available_devices
(
no_cpu
=
False
):
if
"BNB_TEST_DEVICE"
in
os
.
environ
:
# If the environment variable is set, use it directly.
return
[
d
for
d
in
os
.
environ
[
"BNB_TEST_DEVICE"
]
if
d
.
lower
()
!=
"cpu"
]
device
=
os
.
environ
[
"BNB_TEST_DEVICE"
]
return
[]
if
no_cpu
and
device
==
"cpu"
else
[
device
]
devices
=
[]
if
HIP_ENVIRONMENT
else
[
"cpu"
]
if
not
no_cpu
else
[]
...
...
tests/test_optim.py
View file @
14147f6f
...
...
@@ -170,6 +170,7 @@ optimizer_names_32bit = [
@
pytest
.
mark
.
parametrize
(
"dim1"
,
[
1024
],
ids
=
id_formatter
(
"dim1"
))
@
pytest
.
mark
.
parametrize
(
"dim2"
,
[
32
,
1024
,
4097
,
1
],
ids
=
id_formatter
(
"dim2"
))
@
pytest
.
mark
.
parametrize
(
"device"
,
get_available_devices
(
no_cpu
=
True
),
ids
=
id_formatter
(
"device"
))
@
pytest
.
mark
.
skipif
(
not
get_available_devices
(
no_cpu
=
True
),
reason
=
"No device"
)
def
test_optimizer32bit
(
dim1
,
dim2
,
gtype
,
optim_name
,
device
):
if
optim_name
.
startswith
(
"paged_"
)
and
sys
.
platform
==
"win32"
:
pytest
.
skip
(
"Paged optimizers can have issues on Windows."
)
...
...
@@ -250,6 +251,7 @@ def test_optimizer32bit(dim1, dim2, gtype, optim_name, device):
@
pytest
.
mark
.
parametrize
(
"dim2"
,
[
32
,
1024
,
4097
],
ids
=
id_formatter
(
"dim2"
))
@
pytest
.
mark
.
parametrize
(
"gtype"
,
[
torch
.
float32
,
torch
.
float16
],
ids
=
describe_dtype
)
@
pytest
.
mark
.
parametrize
(
"device"
,
get_available_devices
(
no_cpu
=
True
))
@
pytest
.
mark
.
skipif
(
not
get_available_devices
(
no_cpu
=
True
),
reason
=
"No device"
)
def
test_global_config
(
dim1
,
dim2
,
gtype
,
device
):
if
dim1
==
1
and
dim2
==
1
:
return
...
...
@@ -306,6 +308,7 @@ optimizer_names_8bit = [
@
pytest
.
mark
.
parametrize
(
"dim2"
,
[
32
,
1024
,
4097
],
ids
=
id_formatter
(
"dim2"
))
@
pytest
.
mark
.
parametrize
(
"dim1"
,
[
1024
],
ids
=
id_formatter
(
"dim1"
))
@
pytest
.
mark
.
parametrize
(
"device"
,
get_available_devices
(
no_cpu
=
True
))
@
pytest
.
mark
.
skipif
(
not
get_available_devices
(
no_cpu
=
True
),
reason
=
"No device"
)
def
test_optimizer8bit
(
dim1
,
dim2
,
gtype
,
optim_name
,
device
):
torch
.
set_printoptions
(
precision
=
6
)
...
...
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