vllm.multimodal ¶
Modules:
-
audio– -
cache– -
encoder_budget– -
gpu_ipc_memory–Admission control for frontend GPU-side multimodal work.
-
hasher– -
image– -
inputs– -
media– -
parse– -
processing– -
registry– -
utils– -
video– -
video_decoders– -
video_prune–
Classes:
-
MultiModalHasher–Derives multi-modal cache keys.
-
MultiModalKwargsItems–A dictionary of processed multi-modal inputs by modality.
-
MultiModalRegistry–A registry that dispatches data processing according to the model.
Attributes:
-
BatchedTensorInputs(TypeAlias) –A dictionary containing nested tensors which have been batched via
-
MULTIMODAL_REGISTRY–The global
MultiModalRegistry -
NestedTensors(TypeAlias) –Uses a list instead of a tensor if the dimensions of each element do not match.
BatchedTensorInputs = dict[str, NestedTensors] module-attribute ¶
A dictionary containing nested tensors which have been batched via MultiModalKwargsItems.get_data.
MULTIMODAL_REGISTRY = MultiModalRegistry() module-attribute ¶
The global MultiModalRegistry is used by model runners to dispatch data processing according to the target model.
Info
NestedTensors = Union[list['NestedTensors'], list['torch.Tensor'], 'torch.Tensor', tuple['torch.Tensor', ...]] module-attribute ¶
Uses a list instead of a tensor if the dimensions of each element do not match.
MultiModalHasher ¶
Derives multi-modal cache keys.
Every method here yields framed chunks: each chunk is preceded by its length and each container by its kind, so that the concatenation fed to the digest is uniquely decodable and distinct inputs cannot share a key.
Methods:
-
iter_item_to_bytes–Yield the digest input for a single
key/objpair. -
iter_value_to_bytes–Yield the digest input for a value, tagged by its container kind.
Source code in vllm/multimodal/hasher.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
iter_item_to_bytes(key, obj) classmethod ¶
Yield the digest input for a single key/obj pair.
Source code in vllm/multimodal/hasher.py
iter_value_to_bytes(obj) classmethod ¶
Yield the digest input for a value, tagged by its container kind.
Containers carry their kind and length so that a nested structure can never serialize to the same bytes as a differently shaped one (a list and a mapping keyed by stringified indices, for example).
Source code in vllm/multimodal/hasher.py
MultiModalKwargsItems ¶
Bases: UserDict[str, Sequence[_I]]
A dictionary of processed multi-modal inputs by modality.
For example, given a processor that processes images into pixel_values and image_grid_thw, and audios into input_audio_features, a prompt with 2 images and 1 audio will be processed into a MultiModalKwargsItems with the following structure:
MultiModalKwargsItems(
{
"image": [
# For the first image
MultiModalKwargsItem({"pixel_values": ..., "image_grid_thw": ...}),
# For the second imgae
MultiModalKwargsItem({"pixel_values": ..., "image_grid_thw": ...}),
],
"audio": [
# For the first audio
MultiModalKwargsItem({"input_audio_features": ...}),
],
}
)
Unlike HF processing which returns all items in a single dictionary with batched keyword arguments, we split up the items because some of them may already be cached. Also, items from multiple requests may be batched together to improve throughput, using the logic defined by the BaseMultiModalField for each keyword argument.
Methods:
-
get_data–Construct a dictionary of keyword arguments to pass to the model.
Source code in vllm/multimodal/inputs.py
897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 | |
get_data(*, device=None, pin_memory=False) ¶
Construct a dictionary of keyword arguments to pass to the model.
Source code in vllm/multimodal/inputs.py
MultiModalRegistry ¶
A registry that dispatches data processing according to the model.
Methods:
-
create_processor–Create a multi-modal processor for a specific model and tokenizer.
-
register_processor–Register a multi-modal processor to a model class. The processor
Source code in vllm/multimodal/registry.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
create_processor(model_config, *, tokenizer=None) ¶
Create a multi-modal processor for a specific model and tokenizer.
Source code in vllm/multimodal/registry.py
register_processor(processor, *, info, dummy_inputs) ¶
Register a multi-modal processor to a model class. The processor is constructed lazily, hence a factory method should be passed.
When the model receives multi-modal data, the provided function is invoked to transform the data into a dictionary of model inputs.