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
cc39768c
Commit
cc39768c
authored
Aug 29, 2025
by
zhuwenwen
Browse files
优化 block_tables 的生成逻辑,增加对混合情况的检测,确保在存在空和非空块时正确计算最大块长度
parent
5d891ae1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
6 deletions
+26
-6
vllm/attention/backends/utils.py
vllm/attention/backends/utils.py
+26
-6
No files found.
vllm/attention/backends/utils.py
View file @
cc39768c
...
@@ -245,6 +245,26 @@ class CommonMetadataBuilder(AttentionMetadataBuilder[TAttentionMetadata]):
...
@@ -245,6 +245,26 @@ class CommonMetadataBuilder(AttentionMetadataBuilder[TAttentionMetadata]):
block_tables
=
torch
.
from_numpy
(
input_block_tables
).
pin_memory
().
to
(
block_tables
=
torch
.
from_numpy
(
input_block_tables
).
pin_memory
().
to
(
device
,
non_blocking
=
True
)
device
,
non_blocking
=
True
)
else
:
has_empty
:
bool
=
any
(
len
(
bt
)
==
0
for
bt
in
self
.
block_tables
)
has_non_empty
=
any
(
len
(
bt
)
>
0
for
bt
in
self
.
block_tables
)
max_block_length
=
0
if
has_empty
and
has_non_empty
:
for
inter_data
in
self
.
input_builder
.
inter_data_list
:
block_tables
=
inter_data
.
block_tables
if
block_tables
:
for
seq_id
in
inter_data
.
seq_ids
:
if
seq_id
in
block_tables
:
block_table
=
block_tables
[
seq_id
]
max_block_length
=
max
(
max_block_length
,
len
(
block_table
))
if
max_block_length
>
0
:
block_tables
=
make_tensor_with_pad
(
self
.
block_tables
,
pad
=
0
,
dtype
=
torch
.
int
,
device
=
device
,
max_len
=
max_block_length
,
)
else
:
else
:
block_tables
=
make_tensor_with_pad
(
block_tables
=
make_tensor_with_pad
(
self
.
block_tables
,
self
.
block_tables
,
...
...
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