Skip to content

Commit e7e77cd

Browse files
committed
docs: class migration from sphinx to mkdocs (inputs)
Signed-off-by: Zerohertz <[email protected]>
1 parent 45ab403 commit e7e77cd

File tree

5 files changed

+87
-54
lines changed

5 files changed

+87
-54
lines changed

vllm/inputs/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
INPUT_REGISTRY = InputRegistry()
1212
"""
13-
The global {class}`~InputRegistry` which is used by {class}`~vllm.LLMEngine`
14-
to dispatch data processing according to the target model.
13+
The global [`InputRegistry`][vllm.inputs.registry.InputRegistry] which is used
14+
by [`LLMEngine`][vllm.LLMEngine] to dispatch data processing according to the
15+
target model.
1516
"""
1617

1718
__all__ = [

vllm/inputs/data.py

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,24 @@ class EmbedsPrompt(TypedDict):
8080
"""
8181
Set of possible schemas for a single prompt:
8282
83-
- A text prompt ({class}`str` or {class}`TextPrompt`)
84-
- A tokenized prompt ({class}`TokensPrompt`)
85-
- An embeddings prompt ({class}`EmbedsPrompt`)
83+
- A text prompt ([`str`][] or [`TextPrompt`][vllm.inputs.data.TextPrompt])
84+
- A tokenized prompt ([`TokensPrompt`][vllm.inputs.data.TokensPrompt])
85+
- An embeddings prompt ([`EmbedsPrompt`][vllm.inputs.data.EmbedsPrompt])
8686
8787
Note that "singleton" is as opposed to a data structure
8888
which encapsulates multiple prompts, i.e. of the sort
8989
which may be utilized for encoder/decoder models when
9090
the user desires to express both the encoder & decoder
91-
prompts explicitly, i.e. {class}`ExplicitEncoderDecoderPrompt`
91+
prompts explicitly, i.e.
92+
[`ExplicitEncoderDecoderPrompt`][vllm.inputs.data.ExplicitEncoderDecoderPrompt]
9293
93-
A prompt of type {class}`SingletonPrompt` may be employed
94-
as (1) input to a decoder-only model, (2) input to
94+
A prompt of type [`SingletonPrompt`][vllm.inputs.data.SingletonPrompt] may be
95+
employed as (1) input to a decoder-only model, (2) input to
9596
the encoder of an encoder/decoder model, in the scenario
9697
where the decoder-prompt is not specified explicitly, or
9798
(3) as a member of a larger data structure encapsulating
98-
more than one prompt, i.e. {class}`ExplicitEncoderDecoderPrompt`
99+
more than one prompt, i.e.
100+
[`ExplicitEncoderDecoderPrompt`][vllm.inputs.data.ExplicitEncoderDecoderPrompt]
99101
"""
100102

101103

@@ -126,18 +128,20 @@ class ExplicitEncoderDecoderPrompt(TypedDict, Generic[_T1_co, _T2_co]):
126128
comprising an explicit encoder prompt and a decoder prompt.
127129
128130
The encoder and decoder prompts, respectively, may be formatted
129-
according to any of the {class}`SingletonPrompt` schemas,
131+
according to any of the
132+
[`SingletonPrompt`][vllm.inputs.data.SingletonPrompt] schemas,
130133
and are not required to have the same schema.
131134
132135
Only the encoder prompt may have multi-modal data. mm_processor_kwargs
133136
should be at the top-level, and should not be set in the encoder/decoder
134137
prompts, since they are agnostic to the encoder/decoder.
135138
136-
Note that an {class}`ExplicitEncoderDecoderPrompt` may not
137-
be used as an input to a decoder-only model,
139+
Note that an
140+
[`ExplicitEncoderDecoderPrompt`][vllm.inputs.data.ExplicitEncoderDecoderPrompt]
141+
may not be used as an input to a decoder-only model,
138142
and that the `encoder_prompt` and `decoder_prompt`
139143
fields of this data structure themselves must be
140-
{class}`SingletonPrompt` instances.
144+
[`SingletonPrompt`][vllm.inputs.data.SingletonPrompt] instances.
141145
"""
142146

143147
encoder_prompt: _T1_co
@@ -152,11 +156,11 @@ class ExplicitEncoderDecoderPrompt(TypedDict, Generic[_T1_co, _T2_co]):
152156
Set of possible schemas for an LLM input, including
153157
both decoder-only and encoder/decoder input types:
154158
155-
- A text prompt ({class}`str` or {class}`TextPrompt`)
156-
- A tokenized prompt ({class}`TokensPrompt`)
157-
- An embeddings prompt ({class}`EmbedsPrompt`)
159+
- A text prompt ([`str`][] or [`TextPrompt`][vllm.inputs.data.TextPrompt])
160+
- A tokenized prompt ([`TokensPrompt`][vllm.inputs.data.TokensPrompt])
161+
- An embeddings prompt ([`EmbedsPrompt`][vllm.inputs.data.EmbedsPrompt])
158162
- A single data structure containing both an encoder and a decoder prompt
159-
({class}`ExplicitEncoderDecoderPrompt`)
163+
([`ExplicitEncoderDecoderPrompt`][vllm.inputs.data.ExplicitEncoderDecoderPrompt])
160164
"""
161165

162166

@@ -189,7 +193,8 @@ def token_inputs(
189193
prompt: Optional[str] = None,
190194
cache_salt: Optional[str] = None,
191195
) -> TokenInputs:
192-
"""Construct {class}`TokenInputs` from optional values."""
196+
"""Construct [`TokenInputs`][vllm.inputs.data.TokenInputs] from optional
197+
values."""
193198
inputs = TokenInputs(type="token", prompt_token_ids=prompt_token_ids)
194199

195200
if prompt is not None:
@@ -221,7 +226,8 @@ def embeds_inputs(
221226
prompt_embeds: torch.Tensor,
222227
cache_salt: Optional[str] = None,
223228
) -> EmbedsInputs:
224-
"""Construct :class:`EmbedsInputs` from optional values."""
229+
"""Construct [`EmbedsInputs`][vllm.inputs.data.EmbedsInputs] from optional
230+
values."""
225231
inputs = EmbedsInputs(type="embeds", prompt_embeds=prompt_embeds)
226232

227233
if cache_salt is not None:
@@ -232,19 +238,20 @@ def embeds_inputs(
232238

233239
DecoderOnlyInputs = Union[TokenInputs, EmbedsInputs, "MultiModalInputs"]
234240
"""
235-
The inputs in {class}`~vllm.LLMEngine` before they are
241+
The inputs in [`LLMEngine`][vllm.engine.llm_engine.LLMEngine] before they are
236242
passed to the model executor.
237243
This specifies the data required for decoder-only models.
238244
"""
239245

240246

241247
class EncoderDecoderInputs(TypedDict):
242248
"""
243-
The inputs in {class}`~vllm.LLMEngine` before they are
244-
passed to the model executor.
249+
The inputs in [`LLMEngine`][vllm.engine.llm_engine.LLMEngine] before they
250+
are passed to the model executor.
245251
246252
This specifies the required data for encoder-decoder models.
247253
"""
254+
248255
encoder: Union[TokenInputs, "MultiModalInputs"]
249256
"""The inputs for the encoder portion."""
250257

@@ -254,13 +261,13 @@ class EncoderDecoderInputs(TypedDict):
254261

255262
SingletonInputs = Union[TokenInputs, EmbedsInputs, "MultiModalInputs"]
256263
"""
257-
A processed {class}`SingletonPrompt` which can be passed to
258-
{class}`vllm.sequence.Sequence`.
264+
A processed [`SingletonPrompt`][vllm.inputs.data.SingletonPrompt] which can be
265+
passed to [`vllm.sequence.Sequence`][].
259266
"""
260267

261268
ProcessorInputs = Union[DecoderOnlyInputs, EncoderDecoderInputs]
262269
"""
263-
The inputs to {data}`vllm.inputs.InputProcessor`.
270+
The outputs from [`vllm.inputs.preprocess.InputPreprocessor`][].
264271
"""
265272

266273
_T1 = TypeVar("_T1", bound=SingletonPrompt, default=SingletonPrompt)
@@ -277,7 +284,8 @@ def build_explicit_enc_dec_prompt(
277284
return ExplicitEncoderDecoderPrompt(
278285
encoder_prompt=encoder_prompt,
279286
decoder_prompt=decoder_prompt,
280-
mm_processor_kwargs=mm_processor_kwargs)
287+
mm_processor_kwargs=mm_processor_kwargs,
288+
)
281289

282290

283291
def zip_enc_dec_prompts(
@@ -288,7 +296,8 @@ def zip_enc_dec_prompts(
288296
) -> list[ExplicitEncoderDecoderPrompt[_T1, _T2]]:
289297
"""
290298
Zip encoder and decoder prompts together into a list of
291-
{class}`ExplicitEncoderDecoderPrompt` instances.
299+
[`ExplicitEncoderDecoderPrompt`][vllm.inputs.data.ExplicitEncoderDecoderPrompt]
300+
instances.
292301
293302
``mm_processor_kwargs`` may also be provided; if a dict is passed, the same
294303
dictionary will be used for every encoder/decoder prompt. If an iterable is
@@ -299,10 +308,11 @@ def zip_enc_dec_prompts(
299308
if isinstance(mm_processor_kwargs, dict):
300309
return [
301310
build_explicit_enc_dec_prompt(
302-
encoder_prompt, decoder_prompt,
303-
cast(dict[str, Any], mm_processor_kwargs))
304-
for (encoder_prompt,
305-
decoder_prompt) in zip(enc_prompts, dec_prompts)
311+
encoder_prompt,
312+
decoder_prompt,
313+
cast(dict[str, Any], mm_processor_kwargs),
314+
) for (encoder_prompt,
315+
decoder_prompt) in zip(enc_prompts, dec_prompts)
306316
]
307317
return [
308318
build_explicit_enc_dec_prompt(encoder_prompt, decoder_prompt,

vllm/inputs/parse.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ class ParsedTokens(TypedDict):
2323

2424
@overload
2525
def parse_and_batch_prompt(
26-
prompt: Union[str, list[str]]) -> Sequence[ParsedText]:
26+
prompt: Union[str, list[str]], ) -> Sequence[ParsedText]:
2727
...
2828

2929

3030
@overload
3131
def parse_and_batch_prompt(
32-
prompt: Union[list[int], list[list[int]]]) -> Sequence[ParsedTokens]:
32+
prompt: Union[list[int], list[list[int]]], ) -> Sequence[ParsedTokens]:
3333
...
3434

3535

@@ -86,7 +86,7 @@ class ParsedTokensPrompt(TypedDict):
8686

8787

8888
class ParsedEmbedsPrompt(TypedDict):
89-
type: Literal['embeds']
89+
type: Literal["embeds"]
9090
content: EmbedsPrompt
9191

9292

@@ -133,7 +133,7 @@ def parse_singleton_prompt(prompt: SingletonPrompt) -> ParsedSingletonPrompt:
133133

134134

135135
def is_explicit_encoder_decoder_prompt(
136-
prompt: PromptType) -> TypeIs[ExplicitEncoderDecoderPrompt]:
136+
prompt: PromptType, ) -> TypeIs[ExplicitEncoderDecoderPrompt]:
137137
return isinstance(prompt, dict) and "encoder_prompt" in prompt
138138

139139

vllm/inputs/preprocess.py

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,26 @@ def get_eos_token_id(self,
6767
return self.tokenizer.get_lora_tokenizer(lora_request).eos_token_id
6868

6969
def get_decoder_start_token_id(self) -> Optional[int]:
70-
'''
70+
"""
7171
Obtain the decoder start token id employed by an encoder/decoder
7272
model. Returns None for non-encoder/decoder models or if the
7373
model config is unavailable.
74-
'''
74+
"""
7575

7676
if not self.model_config.is_encoder_decoder:
7777
logger.warning_once(
7878
"Using None for decoder start token id because "
7979
"this is not an encoder/decoder model.")
8080
return None
8181

82-
if (self.model_config is None or self.model_config.hf_config is None):
82+
if self.model_config is None or self.model_config.hf_config is None:
8383
logger.warning_once(
8484
"Using None for decoder start token id because "
8585
"model config is not available.")
8686
return None
8787

8888
dec_start_token_id = getattr(self.model_config.hf_config,
89-
'decoder_start_token_id', None)
89+
"decoder_start_token_id", None)
9090
if dec_start_token_id is None:
9191
logger.warning_once(
9292
"Falling back on <BOS> for decoder start token "
@@ -97,7 +97,7 @@ def get_decoder_start_token_id(self) -> Optional[int]:
9797
return dec_start_token_id
9898

9999
def _get_default_enc_dec_decoder_prompt(self) -> list[int]:
100-
'''
100+
"""
101101
Specifically for encoder/decoder models:
102102
generate a default decoder prompt for when
103103
the user specifies only the encoder prompt.
@@ -126,7 +126,7 @@ def _get_default_enc_dec_decoder_prompt(self) -> list[int]:
126126
Returns:
127127
128128
* prompt_token_ids
129-
'''
129+
"""
130130

131131
bos_token_id = self.get_bos_token_id()
132132
assert bos_token_id is not None
@@ -224,7 +224,10 @@ async def _tokenize_prompt_async(
224224
lora_request: Optional[LoRARequest],
225225
tokenization_kwargs: Optional[dict[str, Any]] = None,
226226
) -> list[int]:
227-
"""Async version of {meth}`_tokenize_prompt`."""
227+
"""
228+
Async version of
229+
[`_tokenize_prompt`][vllm.inputs.preprocess.InputPreprocessor._tokenize_prompt].
230+
"""
228231
tokenizer = self.get_tokenizer_group()
229232
tokenization_kwargs = self._get_tokenization_kw(tokenization_kwargs)
230233

@@ -287,7 +290,10 @@ async def _process_multimodal_async(
287290
lora_request: Optional[LoRARequest],
288291
return_mm_hashes: bool = False,
289292
) -> MultiModalInputs:
290-
"""Async version of {meth}`_process_multimodal`."""
293+
"""
294+
Async version of
295+
[`_process_multimodal`][vllm.inputs.preprocess.InputPreprocessor._process_multimodal].
296+
"""
291297
tokenizer = await self._get_mm_tokenizer_async(lora_request)
292298

293299
mm_processor = self.mm_registry.create_processor(self.model_config,
@@ -472,7 +478,7 @@ def _prompt_to_llm_inputs(
472478
473479
Returns:
474480
475-
* {class}`SingletonInputs` instance
481+
* [`SingletonInputs`][vllm.inputs.data.SingletonInputs] instance
476482
"""
477483
parsed = parse_singleton_prompt(prompt)
478484

@@ -508,7 +514,10 @@ async def _prompt_to_llm_inputs_async(
508514
lora_request: Optional[LoRARequest] = None,
509515
return_mm_hashes: bool = False,
510516
) -> SingletonInputs:
511-
"""Async version of {meth}`_prompt_to_llm_inputs`."""
517+
"""
518+
Async version of
519+
[`_prompt_to_llm_inputs`][vllm.inputs.preprocess.InputPreprocessor._prompt_to_llm_inputs].
520+
"""
512521
parsed = parse_singleton_prompt(prompt)
513522

514523
if parsed["type"] == "embeds":
@@ -644,7 +653,9 @@ def _process_encoder_decoder_prompt(
644653
) -> EncoderDecoderInputs:
645654
"""
646655
For encoder/decoder models only:
647-
Process an input prompt into an {class}`EncoderDecoderInputs` instance.
656+
Process an input prompt into an
657+
[`EncoderDecoderInputs`][vllm.inputs.data.EncoderDecoderInputs]
658+
instance.
648659
649660
There are two types of input prompts:
650661
singleton prompts which carry only the
@@ -670,7 +681,8 @@ def _process_encoder_decoder_prompt(
670681
671682
Returns:
672683
673-
* {class}`EncoderDecoderInputs` instance
684+
* [`EncoderDecoderInputs`][vllm.inputs.data.EncoderDecoderInputs]
685+
instance
674686
"""
675687
encoder_inputs: SingletonInputs
676688
decoder_inputs: Optional[SingletonInputs]
@@ -710,7 +722,10 @@ async def _process_encoder_decoder_prompt_async(
710722
prompt: PromptType,
711723
tokenization_kwargs: Optional[dict[str, Any]] = None,
712724
) -> EncoderDecoderInputs:
713-
"""Async version of {meth}`_process_encoder_decoder_prompt`."""
725+
"""
726+
Async version of
727+
[`_process_encoder_decoder_prompt`][vllm.inputs.preprocess.InputPreprocessor._process_encoder_decoder_prompt].
728+
"""
714729
encoder_inputs: SingletonInputs
715730
decoder_inputs: Optional[SingletonInputs]
716731

@@ -778,7 +793,8 @@ def _process_decoder_only_prompt(
778793
) -> DecoderOnlyInputs:
779794
"""
780795
For decoder-only models:
781-
Process an input prompt into an {class}`DecoderOnlyInputs` instance.
796+
Process an input prompt into a
797+
[`DecoderOnlyInputs`][vllm.inputs.data.DecoderOnlyInputs] instance.
782798
783799
Arguments:
784800
@@ -789,7 +805,7 @@ def _process_decoder_only_prompt(
789805
790806
Returns:
791807
792-
* {class}`DecoderOnlyInputs` instance
808+
* [`DecoderOnlyInputs`][vllm.inputs.data.DecoderOnlyInputs] instance
793809
"""
794810

795811
prompt_comps = self._prompt_to_llm_inputs(
@@ -812,7 +828,10 @@ async def _process_decoder_only_prompt_async(
812828
prompt_adapter_request: Optional[PromptAdapterRequest] = None,
813829
return_mm_hashes: bool = False,
814830
) -> DecoderOnlyInputs:
815-
"""Async version of {meth}`_process_decoder_only_prompt`."""
831+
"""
832+
Async version of
833+
[`_process_decoder_only_prompt`][vllm.inputs.preprocess.InputPreprocessor._process_decoder_only_prompt].
834+
"""
816835
prompt_comps = await self._prompt_to_llm_inputs_async(
817836
prompt,
818837
tokenization_kwargs=tokenization_kwargs,
@@ -863,7 +882,10 @@ async def preprocess_async(
863882
prompt_adapter_request: Optional[PromptAdapterRequest] = None,
864883
return_mm_hashes: bool = False,
865884
) -> ProcessorInputs:
866-
"""Async version of {meth}`preprocess`."""
885+
"""
886+
Async version of
887+
[`preprocess`][vllm.inputs.preprocess.InputPreprocessor.preprocess].
888+
"""
867889
if self.model_config.is_encoder_decoder:
868890
assert not return_mm_hashes, (
869891
"Multimodal hashes for encoder-decoder models should not be ",

0 commit comments

Comments
 (0)