Skip to content

Commit ab99334

Browse files
hack to make v13 and v16 work together
Signed-off-by: Alex Brooks <albrooks@redhat.com>
1 parent 99c4683 commit ab99334

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

vllm_bart_plugin/bart.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@
4242
from vllm.model_executor.layers.attention.cross_attention import CrossAttention
4343
from vllm.model_executor.layers.attention.mm_encoder_attention import MMEncoderAttention
4444
from vllm.multimodal.processing.dummy_inputs import BaseDummyInputsBuilder
45+
IS_LEGACY=False
4546
except ImportError:
4647
# These were moved after vLLM 0.13; try the legacy path
4748
from vllm.attention.backends.abstract import AttentionType
4849
from vllm.attention.layer import Attention
4950
from vllm.attention.layers.cross_attention import CrossAttention
5051
from vllm.attention.layers.mm_encoder_attention import MMEncoderAttention
5152
from vllm.multimodal.profiling import BaseDummyInputsBuilder
53+
IS_LEGACY=True
5254

5355
from vllm.model_executor.layers.linear import (
5456
ColumnParallelLinear,
@@ -1014,6 +1016,15 @@ def _get_subparsers(self) -> Mapping[str, ModalityDataParser]:
10141016
class BartMultiModalProcessor(EncDecMultiModalProcessor[BartProcessingInfo]):
10151017
"""Multimodal processor for BART encoder-decoder models."""
10161018

1019+
def __init__(self, *args, **kwargs):
1020+
# HACK: v13 needs to define _get_data_parser, but v16 throws in __init__
1021+
# if this class has _get_data_parser as an attribute, so for now,
1022+
# we conditionally ist based on which import path was taken, since
1023+
# those are also changes that were needed for v13.
1024+
if IS_LEGACY:
1025+
self._get_data_parser = self.build_data_parser
1026+
super().__init__(*args, **kwargs)
1027+
10171028
def create_encoder_prompt(
10181029
self,
10191030
prompt: str | list[int],
@@ -1124,9 +1135,6 @@ def _get_prompt_updates(
11241135
def build_data_parser(self) -> MultiModalDataParser:
11251136
return TextDataParser()
11261137

1127-
# Needed for compatibility with v13
1128-
def _get_data_parser(self) -> MultiModalDataParser:
1129-
return self.build_data_parser()
11301138

11311139
@MULTIMODAL_REGISTRY.register_processor(
11321140
BartMultiModalProcessor,

0 commit comments

Comments
 (0)