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
AutoAWQ
Commits
bc4f93c2
Commit
bc4f93c2
authored
Sep 12, 2023
by
Casper Hansen
Browse files
xq view key
parent
ba4da393
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
awq/modules/fused/attn.py
awq/modules/fused/attn.py
+3
-1
No files found.
awq/modules/fused/attn.py
View file @
bc4f93c2
...
...
@@ -134,6 +134,7 @@ class QuantAttentionFused(nn.Module):
"xk_slice"
:
lambda
xqkv
:
xqkv
[:,
:,
1
],
"xv_slice"
:
lambda
xqkv
:
xqkv
[:,
:,
2
],
"xk_reshape"
:
(
self
.
n_local_heads
,
self
.
head_dim
//
8
,
8
),
"xq_view"
:
(
self
.
n_local_heads
,
self
.
head_dim
),
"xk_view"
:
(
self
.
n_local_heads
,
self
.
head_dim
),
"xv_view"
:
(
self
.
n_local_heads
,
self
.
head_dim
),
"single_xq_view"
:
(
self
.
n_local_heads
,
self
.
head_dim
),
...
...
@@ -171,12 +172,13 @@ class QuantAttentionFused(nn.Module):
bsz
,
seqlen
,
_
=
hidden_states
.
shape
xqkv
=
self
.
qkv_proj
(
hidden_states
)
xqkv
=
xqkv
.
view
((
bsz
,
seqlen
)
+
self
.
attention_shapes
[
"xqkv_view"
])
xq
=
self
.
attention_shapes
[
"xq_slice"
](
xqkv
)
xk
=
self
.
attention_shapes
[
"xk_slice"
](
xqkv
)
xv
=
self
.
attention_shapes
[
"xv_slice"
](
xqkv
)
if
seqlen
>
1
:
xq
=
xq
.
view
(
bsz
,
seqlen
,
self
.
n_local_heads
,
self
.
head_dim
)
xq
=
xq
.
view
(
(
bsz
,
seqlen
)
+
self
.
attention_shapes
[
"xq_view"
]
)
xk
=
xk
.
view
((
bsz
,
seqlen
)
+
self
.
attention_shapes
[
"xk_view"
])
xv
=
xv
.
view
((
bsz
,
seqlen
)
+
self
.
attention_shapes
[
"xv_view"
])
...
...
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