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
55ebaac7
Commit
55ebaac7
authored
Jun 03, 2025
by
Matthew Douglas
Browse files
Tests: don't require grad on weights for test_kbit_backprop
parent
318a86e3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
4 deletions
+2
-4
tests/test_modules.py
tests/test_modules.py
+2
-4
No files found.
tests/test_modules.py
View file @
55ebaac7
...
@@ -285,9 +285,6 @@ module_dict = {
...
@@ -285,9 +285,6 @@ module_dict = {
@
pytest
.
mark
.
parametrize
(
"device"
,
get_available_devices
())
@
pytest
.
mark
.
parametrize
(
"device"
,
get_available_devices
())
@
pytest
.
mark
.
parametrize
(
"module"
,
module_dict
.
values
(),
ids
=
module_dict
.
keys
())
@
pytest
.
mark
.
parametrize
(
"module"
,
module_dict
.
values
(),
ids
=
module_dict
.
keys
())
def
test_kbit_backprop
(
device
,
module
):
def
test_kbit_backprop
(
device
,
module
):
if
device
==
"cpu"
:
pytest
.
xfail
(
"Test is not yet supported on CPU"
)
b
=
16
b
=
16
dim1
=
36
dim1
=
36
dim2
=
84
dim2
=
84
...
@@ -295,14 +292,15 @@ def test_kbit_backprop(device, module):
...
@@ -295,14 +292,15 @@ def test_kbit_backprop(device, module):
# dim2 = 83
# dim2 = 83
ref
=
nn
.
Sequential
(
*
[
torch
.
nn
.
Linear
(
dim1
,
dim2
),
torch
.
nn
.
Linear
(
dim2
,
128
)])
ref
=
nn
.
Sequential
(
*
[
torch
.
nn
.
Linear
(
dim1
,
dim2
),
torch
.
nn
.
Linear
(
dim2
,
128
)])
# ref[1].weight.requires_grad = False
torch
.
nn
.
init
.
kaiming_normal_
(
ref
[
0
].
weight
)
torch
.
nn
.
init
.
kaiming_normal_
(
ref
[
0
].
weight
)
torch
.
nn
.
init
.
kaiming_normal_
(
ref
[
1
].
weight
)
torch
.
nn
.
init
.
kaiming_normal_
(
ref
[
1
].
weight
)
ref
[
1
].
weight
.
requires_grad_
(
False
)
kbit
=
nn
.
Sequential
(
*
[
torch
.
nn
.
Linear
(
dim1
,
dim2
),
module
(
dim2
,
128
)])
kbit
=
nn
.
Sequential
(
*
[
torch
.
nn
.
Linear
(
dim1
,
dim2
),
module
(
dim2
,
128
)])
kbit
[
0
].
weight
.
detach
().
copy_
(
ref
[
0
].
weight
)
kbit
[
0
].
weight
.
detach
().
copy_
(
ref
[
0
].
weight
)
kbit
[
1
].
weight
.
detach
().
copy_
(
ref
[
1
].
weight
)
kbit
[
1
].
weight
.
detach
().
copy_
(
ref
[
1
].
weight
)
kbit
[
0
].
bias
.
detach
().
copy_
(
ref
[
0
].
bias
)
kbit
[
0
].
bias
.
detach
().
copy_
(
ref
[
0
].
bias
)
kbit
[
1
].
bias
.
detach
().
copy_
(
ref
[
1
].
bias
)
kbit
[
1
].
bias
.
detach
().
copy_
(
ref
[
1
].
bias
)
kbit
[
1
].
weight
.
requires_grad_
(
False
)
ref
=
ref
.
half
().
to
(
device
)
ref
=
ref
.
half
().
to
(
device
)
kbit
=
kbit
.
half
().
to
(
device
)
kbit
=
kbit
.
half
().
to
(
device
)
kbit
=
kbit
.
half
().
to
(
device
)
kbit
=
kbit
.
half
().
to
(
device
)
...
...
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