Skip to content

Commit 65097ca

Browse files
[Doc] Add model development API Reference (#11884)
Signed-off-by: DarkLight1337 <[email protected]>
1 parent 1d967ac commit 65097ca

File tree

9 files changed

+54
-9
lines changed

9 files changed

+54
-9
lines changed

.buildkite/test-pipeline.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ steps:
3838
- pip install -r requirements-docs.txt
3939
- SPHINXOPTS=\"-W\" make html
4040
# Check API reference (if it fails, you may have missing mock imports)
41-
- grep \"sig sig-object py\" build/html/api/params.html
41+
- grep \"sig sig-object py\" build/html/api/inference_params.html
4242

4343
- label: Async Engine, Inputs, Utils, Worker Test # 24min
4444
fast_check: true

docs/source/api/params.md renamed to docs/source/api/inference_params.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Optional Parameters
1+
# Inference Parameters
22

3-
Optional parameters for vLLM APIs.
3+
Inference parameters for vLLM APIs.
44

55
(sampling-params)=
66

@@ -19,4 +19,3 @@ Optional parameters for vLLM APIs.
1919
.. autoclass:: vllm.PoolingParams
2020
:members:
2121
```
22-

docs/source/api/model/adapters.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Model Adapters
2+
3+
## Module Contents
4+
5+
```{eval-rst}
6+
.. automodule:: vllm.model_executor.models.adapters
7+
:members:
8+
:member-order: bysource
9+
```

docs/source/api/model/index.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Model Development
2+
3+
## Submodules
4+
5+
```{toctree}
6+
:maxdepth: 1
7+
8+
interfaces_base
9+
interfaces
10+
adapters
11+
```
12+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Optional Interfaces
2+
3+
## Module Contents
4+
5+
```{eval-rst}
6+
.. automodule:: vllm.model_executor.models.interfaces
7+
:members:
8+
:member-order: bysource
9+
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Base Model Interfaces
2+
3+
## Module Contents
4+
5+
```{eval-rst}
6+
.. automodule:: vllm.model_executor.models.interfaces_base
7+
:members:
8+
:member-order: bysource
9+
```

docs/source/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ community/sponsors
139139
140140
api/offline_inference/index
141141
api/engine/index
142+
api/inference_params
142143
api/multimodal/index
143-
api/params
144+
api/model/index
144145
```
145146

146147
% Design Documents: Details about vLLM internals

vllm/model_executor/models/interfaces.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ def get_multimodal_embeddings(self, **kwargs) -> Optional[T]:
3838
to be merged with text embeddings.
3939
4040
The output embeddings must be one of the following formats:
41+
4142
- A list or tuple of 2D tensors, where each tensor corresponds to
42-
each input multimodal data item (e.g, image).
43+
each input multimodal data item (e.g, image).
4344
- A single 3D tensor, with the batch dimension grouping the 2D tensors.
4445
45-
NOTE: The returned multimodal embeddings must be in the same order as
46-
the appearances of their corresponding multimodal data item in the
47-
input prompt.
46+
Note:
47+
The returned multimodal embeddings must be in the same order as
48+
the appearances of their corresponding multimodal data item in the
49+
input prompt.
4850
"""
4951
...
5052

@@ -59,6 +61,7 @@ def get_input_embeddings(
5961
) -> torch.Tensor:
6062
...
6163

64+
@overload
6265
def get_input_embeddings(
6366
self,
6467
input_ids: torch.Tensor,

vllm/model_executor/models/interfaces_base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
@runtime_checkable
3737
class VllmModel(Protocol[C_co, T_co]):
38+
"""The interface required for all models in vLLM."""
3839

3940
def __init__(
4041
self,
@@ -97,6 +98,7 @@ def is_vllm_model(
9798

9899
@runtime_checkable
99100
class VllmModelForTextGeneration(VllmModel[C_co, T], Protocol[C_co, T]):
101+
"""The interface required for all generative models in vLLM."""
100102

101103
def compute_logits(
102104
self,
@@ -142,6 +144,7 @@ def is_text_generation_model(
142144

143145
@runtime_checkable
144146
class VllmModelForPooling(VllmModel[C_co, T], Protocol[C_co, T]):
147+
"""The interface required for all pooling models in vLLM."""
145148

146149
def pooler(
147150
self,

0 commit comments

Comments
 (0)