vllm.distributed.ec_transfer.ec_connector.example_connector ¶
Classes:
ECExampleConnector ¶
Bases: ECConnectorBase
Methods:
-
build_connector_meta–Build the connector metadata for this step.
-
has_cache_item–Check if cache exist externally for the media
-
request_finished–Report each item's cache key and grid so a consumer can skip the
-
save_caches–Save the encoder cache to the connector.
-
start_load_caches–Start loading the cache from the connector into vLLM's encoder cache.
-
update_state_after_alloc–Update ECConnector state after encoder cache allocation.
Source code in vllm/distributed/ec_transfer/ec_connector/example_connector.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 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 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
_found_match_for_mm_data(mm_hash) ¶
Check if the cache is hit for the request.
_generate_filename_debug(mm_hash) ¶
Return the full path of the safetensors file for this mm_hash. Ensures the parent directory exists because _generate_foldername_debug is called with its default (create_folder=True).
Source code in vllm/distributed/ec_transfer/ec_connector/example_connector.py
_generate_foldername_debug(mm_hash, create_folder=True) ¶
Return the folder in which the cache for this mm_hash lives. If create_folder is True (default) the directory is created recursively the first time it is needed.
Source code in vllm/distributed/ec_transfer/ec_connector/example_connector.py
_placeholder_metadata_fields(modality) ¶
Which processed keys this model needs published for modality.
Read from MultiModalDataParser.embedding_fields, the same declaration the consumer's parser requires, so the two cannot drift. An empty set means the modality cannot be delivered out of band, and the consumer will process the media itself.
Source code in vllm/distributed/ec_transfer/ec_connector/example_connector.py
build_connector_meta(scheduler_output) ¶
Build the connector metadata for this step.
This function should NOT modify any fields in the scheduler_output. Also, calling this function will reset the state of the connector. This only build for load mm_data only Args: scheduler_output (SchedulerOutput): the scheduler output object.
Source code in vllm/distributed/ec_transfer/ec_connector/example_connector.py
has_cache_item(identifier) ¶
Check if cache exist externally for the media
Parameters:
Returns:
-
bool–Bool indicate that media exists in cache or not
Source code in vllm/distributed/ec_transfer/ec_connector/example_connector.py
request_finished(request) ¶
Report each item's cache key and grid so a consumer can skip the image transform.
A consumer only needs the grid to size the prompt's placeholder range; the embedding itself arrives through this connector. Reporting the grid the producer actually computed keeps the two sides in agreement without the caller re-deriving it from the raw media.
Source code in vllm/distributed/ec_transfer/ec_connector/example_connector.py
save_caches(encoder_cache, mm_hash, **kwargs) ¶
Save the encoder cache to the connector.
This method saves the encoder cache from the worker's local storage to shared storage or another external connector.
Parameters:
-
(encoder_cache¶dict[str, Tensor]) –A dictionary mapping multimodal data hashes (
mm_hash) to encoder cache tensors. -
(mm_hash¶str) –The hash of the multimodal data whose cache is being saved.
-
(kwargs¶dict, default:{}) –Additional keyword arguments for the connector.
Source code in vllm/distributed/ec_transfer/ec_connector/example_connector.py
start_load_caches(encoder_cache, **kwargs) ¶
Start loading the cache from the connector into vLLM's encoder cache.
This method loads the encoder cache based on metadata provided by the scheduler. It is called before _gather_mm_embeddings for the EC Connector. For EC, the encoder_cache and mm_hash are stored in kwargs.
Parameters:
-
(encoder_cache¶dict[str, Tensor]) –A dictionary mapping multimodal data hashes (
mm_hash) to encoder cache tensors. -
(kwargs¶dict, default:{}) –Additional keyword arguments for the connector.
Source code in vllm/distributed/ec_transfer/ec_connector/example_connector.py
update_state_after_alloc(request, index) ¶
Update ECConnector state after encoder cache allocation.