Skip to content

Commit

Permalink
update RequestOutput.__init__() to take multi_modal_placeholders as…
Browse files Browse the repository at this point in the history
… optional argument

also require it to be passed as kwargs, to avoid breaking existing code.

Signed-off-by: Linkun Chen <[email protected]>
  • Loading branch information
Linkun Chen committed Nov 18, 2024
1 parent bf6b671 commit 8c5fdf8
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions vllm/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def __init__(
request_id: str,
prompt: Optional[str],
prompt_token_ids: Optional[List[int]],
multi_modal_placeholders: MultiModalPlaceholderDict,
prompt_logprobs: Optional[PromptLogprobs],
outputs: List[CompletionOutput],
finished: bool,
Expand All @@ -105,11 +104,13 @@ def __init__(
encoder_prompt: Optional[str] = None,
encoder_prompt_token_ids: Optional[List[int]] = None,
num_cached_tokens: Optional[int] = None,
*,
multi_modal_placeholders: Optional[MultiModalPlaceholderDict] = None,
) -> None:
self.request_id = request_id
self.prompt = prompt
self.prompt_token_ids = prompt_token_ids
self.multi_modal_placeholders = multi_modal_placeholders
self.multi_modal_placeholders = multi_modal_placeholders or {}
self.prompt_logprobs = prompt_logprobs
self.outputs = outputs
self.finished = finished
Expand Down Expand Up @@ -144,7 +145,6 @@ def new(
request_id=request_id,
prompt=prompt,
prompt_token_ids=prompt_token_ids,
multi_modal_placeholders={},
prompt_logprobs=None, # TODO
outputs=[completion_output],
finished=finished,
Expand All @@ -158,8 +158,7 @@ def from_seq_group(
finished = seq_group.is_finished()

if seq_group.request_id in seq_id_to_seq_group:
group: SequenceGroupBase = seq_id_to_seq_group[
seq_group.request_id]
group: SequenceGroupBase = seq_id_to_seq_group[seq_group.request_id]
if finished:
group.finish_seq(seq_group)
assembled_seq_group = group.maybe_assemble_group(seq_group)
Expand Down Expand Up @@ -202,8 +201,8 @@ def from_seq_group(
# num_cached_tokens should be the same for all the sequences
num_cached_tokens = None
for i, seq in enumerate(top_n_seqs):
output_text = seq.get_output_text_to_return(
text_buffer_length, delta)
output_text = seq.get_output_text_to_return(text_buffer_length,
delta)

output_token_ids = seq.get_output_token_ids_to_return(delta)
num_output_tokens = 1 if isinstance(output_token_ids,
Expand Down Expand Up @@ -280,33 +279,33 @@ def from_seq_group(
seq_group.set_finished_time(finished_time)

init_args = (seq_group.request_id, prompt, prompt_token_ids,
seq_group.multi_modal_placeholders, prompt_logprobs,
outputs, finished, seq_group.metrics,
prompt_logprobs, outputs, finished, seq_group.metrics,
seq_group.lora_request, encoder_prompt,
encoder_prompt_token_ids, num_cached_tokens)
init_kwargs = {"multi_modal_placeholders": seq_group.multi_modal_placeholders}

Check failure on line 285 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / ruff (3.12)

Ruff (E501)

vllm/outputs.py:285:81: E501 Line too long (86 > 80)

if use_cache:
request_output = seq_group.cached_request_output
request_output.__init__(*init_args) # type: ignore
request_output.__init__(*init_args, **init_kwargs) # type: ignore

else:
request_output = cls(*init_args)
request_output = cls(*init_args, **init_kwargs)

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.9)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "str" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.9)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "Optional[str]" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.9)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "Optional[list[int]]" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.9)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "Optional[list[Optional[dict[int, Logprob]]]]" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.9)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "list[CompletionOutput]" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.9)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "bool" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.9)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "Optional[RequestMetrics]" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.9)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "Optional[LoRARequest]" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.9)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "Optional[int]" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.10)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "str" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.10)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "str | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.10)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "list[int] | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.10)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "list[dict[int, Logprob] | None] | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.10)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "list[CompletionOutput]" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.10)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "bool" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.10)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "RequestMetrics | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.10)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "LoRARequest | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.10)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "int | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.11)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "str" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.11)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "str | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.11)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "list[int] | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.11)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "list[dict[int, Logprob] | None] | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.11)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "list[CompletionOutput]" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.11)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "bool" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.11)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "RequestMetrics | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.11)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "LoRARequest | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.11)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "int | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.12)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "str" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.12)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "str | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.12)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "list[int] | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.12)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "list[dict[int, Logprob] | None] | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.12)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "list[CompletionOutput]" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.12)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "bool" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.12)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "RequestMetrics | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.12)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "LoRARequest | None" [arg-type]

Check failure on line 292 in vllm/outputs.py

View workflow job for this annotation

GitHub Actions / mypy (3.12)

Argument 2 to "RequestOutput" has incompatible type "**dict[str, Mapping[str, Sequence[PlaceholderRange]]]"; expected "int | None" [arg-type]

return request_output

def __repr__(self) -> str:
return (f"RequestOutput(request_id={self.request_id}, "
f"prompt={self.prompt!r}, "
f"prompt_token_ids={self.prompt_token_ids}, "
f"multi_modal_placeholders={self.multi_modal_placeholders}, "
f"encoder_prompt={self.encoder_prompt!r}, "
f"encoder_prompt_token_ids={self.encoder_prompt_token_ids}, "
f"prompt_logprobs={self.prompt_logprobs}, "
f"outputs={self.outputs}, "
f"finished={self.finished}, "
f"metrics={self.metrics}, "
f"lora_request={self.lora_request}, "
f"num_cached_tokens={self.num_cached_tokens})")
f"num_cached_tokens={self.num_cached_tokens}, "
f"multi_modal_placeholders={self.multi_modal_placeholders})")


class EmbeddingRequestOutput:
Expand Down

0 comments on commit 8c5fdf8

Please sign in to comment.