Skip to content

vllm.distributed.ec_transfer.ec_connector.example_connector

Classes:

ECExampleConnector

Bases: ECConnectorBase

Methods:

_found_match_for_mm_data(mm_hash)

Check if the cache is hit for the request.

_generate_filename_debug(mm_hash, create_folder=True)

Return the full path of the safetensors file for this mm_hash. If create_folder is True (default) the parent directory is created.

_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.

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.

has_cache_item(identifier)

Check if cache exist externally for the media.

Parameters:

  • identifier

    (str) –

    the identifier of the media.

Returns:

  • bool –

    Bool indicate that media exists in cache or not

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.

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.

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.

update_state_after_alloc(request, index)

Update ECConnector state after encoder cache allocation.