Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
4a19cdf5
"vscode:/vscode.git/clone" did not exist on "c051bfe4eb77b82eba90504360bbd4e61d9e489a"
Commit
4a19cdf5
authored
Apr 14, 2025
by
zhuwenwen
Browse files
update vdim padding strategy
parent
155d41d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
18 deletions
+32
-18
vllm/attention/backends/mla/utils.py
vllm/attention/backends/mla/utils.py
+32
-18
No files found.
vllm/attention/backends/mla/utils.py
View file @
4a19cdf5
...
...
@@ -511,23 +511,37 @@ class MLACommonImpl(MLAAttentionImpl[T], Generic[T]):
# v with 0s to match the qk head dim
# v_padded = torch.nn.functional.pad(v, [0, q.shape[-1] - v.shape[-1]],
# value=0)
attn_output
=
self
.
flash_attn_varlen_func
(
q
=
q
,
k
=
k
,
# v=v_padded,
v
=
v
,
cu_seqlens_q
=
seq_start_loc
,
cu_seqlens_k
=
seq_start_loc
,
max_seqlen_q
=
max_prefill_seq_len
,
max_seqlen_k
=
max_prefill_seq_len
,
softmax_scale
=
self
.
scale
,
causal
=
True
,
)
# attn_output = attn_output\
# .view(-1, self.num_heads, q.shape[-1])[..., :v.shape[-1]]\
# .reshape(-1, self.num_heads * v.shape[-1])
attn_output
=
attn_output
\
.
reshape
(
-
1
,
self
.
num_heads
*
v
.
shape
[
-
1
])
v_padded
=
torch
.
nn
.
functional
.
pad
(
v
,
[
0
,
(
q
.
shape
[
-
1
]
-
v
.
shape
[
-
1
]
-
32
)],
value
=
0
)
if
torch
.
cuda
.
get_device_properties
(
torch
.
cuda
.
current_device
()).
multi_processor_count
==
120
:
attn_output
=
flash_attn_varlen_func
(
q
=
q
,
k
=
k
,
v
=
v_padded
,
cu_seqlens_q
=
seq_start_loc
,
cu_seqlens_k
=
seq_start_loc
,
max_seqlen_q
=
max_prefill_seq_len
,
max_seqlen_k
=
max_prefill_seq_len
,
softmax_scale
=
self
.
scale
,
causal
=
True
,
)
attn_output
=
attn_output
\
.
view
(
-
1
,
self
.
num_heads
,
q
.
shape
[
-
1
])[...,
:
v
.
shape
[
-
1
]]
\
.
reshape
(
-
1
,
self
.
num_heads
*
v
.
shape
[
-
1
])
else
:
attn_output
=
flash_attn_varlen_func
(
q
=
q
,
k
=
k
,
v
=
v
,
cu_seqlens_q
=
seq_start_loc
,
cu_seqlens_k
=
seq_start_loc
,
max_seqlen_q
=
max_prefill_seq_len
,
max_seqlen_k
=
max_prefill_seq_len
,
softmax_scale
=
self
.
scale
,
causal
=
True
,
)
attn_output
=
attn_output
\
.
reshape
(
-
1
,
self
.
num_heads
*
v
.
shape
[
-
1
])
return
self
.
o_proj
(
attn_output
)[
0
]
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