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
1d9f0f2a
Commit
1d9f0f2a
authored
Sep 20, 2023
by
Ruslan Svirschevski
Browse files
add QuantState.__get_item__() for compatibility
parent
0a0b531f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
bitsandbytes/functional.py
bitsandbytes/functional.py
+14
-1
No files found.
bitsandbytes/functional.py
View file @
1d9f0f2a
...
@@ -579,7 +579,20 @@ class QuantState:
...
@@ -579,7 +579,20 @@ class QuantState:
self
.
offset
=
offset
self
.
offset
=
offset
self
.
state2
=
state2
self
.
state2
=
state2
self
.
nested
=
state2
is
not
None
self
.
nested
=
state2
is
not
None
def
__get_item__
(
self
,
idx
):
"""
ensures compatibility with older quant state scheme with nested lists.
assumes the following layout:
state = [qabsmax, input_shape, A.dtype, blocksize, [offset, state2], quant_type]
state2 = [absmax, input_shape, A.dtype, blocksize, None, quant_type]
"""
if
self
.
nested
:
list_repr
=
[
self
.
absmax
,
self
.
shape
,
self
.
dtype
,
self
.
blocksize
,
[
self
.
offset
,
self
.
state2
],
self
.
quant_type
]
else
:
list_repr
=
[
self
.
absmax
,
self
.
shape
,
self
.
dtype
,
self
.
blocksize
,
None
,
self
.
quant_type
]
return
list_repr
[
idx
]
@
classmethod
@
classmethod
def
from_dict
(
cls
,
qs_dict
:
dict
[
str
,
Any
],
device
:
torch
.
device
)
->
'QuantState'
:
def
from_dict
(
cls
,
qs_dict
:
dict
[
str
,
Any
],
device
:
torch
.
device
)
->
'QuantState'
:
"""
"""
...
...
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