[MRV2] Enable mm prefix bidi attention support on MRV2 (#46942)
Signed-off-by: Isotr0py <mozf@mail2.sysu.edu.cn> Signed-off-by: Isotr0py <2037008807@qq.com> Co-authored-by: Nick Hill <nickhill123@gmail.com>
This commit is contained in:
@@ -9,7 +9,10 @@ from vllm.config import VllmConfig
|
||||
from vllm.config.compilation import CUDAGraphMode
|
||||
from vllm.v1.core.sched.output import NewRequestData
|
||||
from vllm.v1.kv_cache_interface import KVCacheConfig
|
||||
from vllm.v1.worker.gpu.attn_utils import build_attn_metadata
|
||||
from vllm.v1.worker.gpu.attn_utils import (
|
||||
build_attn_metadata,
|
||||
compute_mm_prefix_ranges,
|
||||
)
|
||||
from vllm.v1.worker.gpu.input_batch import InputBatch
|
||||
from vllm.v1.worker.gpu.mm.encoder_cache import EncoderCache
|
||||
from vllm.v1.worker.gpu.mm.rope import get_rope_state
|
||||
@@ -152,6 +155,17 @@ class DefaultModelState(ModelState):
|
||||
max_seq_len = self.max_model_len
|
||||
else:
|
||||
max_seq_len = seq_lens_cpu_upper_bound[:num_reqs].max().item()
|
||||
req_doc_ranges: dict[int, list[tuple[int, int]]] | None = None
|
||||
if (
|
||||
self.supports_mm_inputs
|
||||
and self.encoder_cache is not None
|
||||
and self.model_config.is_mm_prefix_lm
|
||||
):
|
||||
req_doc_ranges = compute_mm_prefix_ranges(
|
||||
req_ids=input_batch.req_ids,
|
||||
mm_features=self.encoder_cache.mm_features,
|
||||
sliding_window=self.model_config.get_sliding_window(),
|
||||
)
|
||||
attn_metadata = build_attn_metadata(
|
||||
attn_groups=attn_groups,
|
||||
num_reqs=num_reqs,
|
||||
@@ -167,6 +181,7 @@ class DefaultModelState(ModelState):
|
||||
seq_lens_cpu_upper_bound=seq_lens_cpu_upper_bound,
|
||||
dcp_local_seq_lens=input_batch.dcp_local_seq_lens,
|
||||
positions=input_batch.positions,
|
||||
mm_req_doc_ranges=req_doc_ranges,
|
||||
for_cudagraph_capture=for_capture,
|
||||
rswa_prefix_lens=input_batch.prompt_lens,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user