Skip to content

CPU EC Connector Usage Guide

ECCPUConnector extends the GPU-based encoder cache with a CPU tier: it offloads encoder outputs (encoder_cache[mm_hash]) to a shared /dev/shm mmap region so later steps and later requests reuse them instead of recomputing. GPU↔CPU copies run on pooled CUDA streams via swap_blocks_batch, asynchronously with model compute.

Setting ec_enable_p2p: true in ec_connector_extra_config additionally enables peer-to-peer (P2P) transfer: a consumer instance pulls an encoding directly out of a producer instance's CPU tier over RDMA instead of recomputing it locally — for E/PD disaggregation or encoder/decoder-instance sharing.

Two settings work together:

  • ec_enable_p2p is the P2P on/off switch for every transport. Its former name, ec_enable_nixl, is still accepted and used when ec_enable_p2p is absent.
  • ec_transport picks the data plane that moves the bytes: "nixl" (default) or "moriio" (AMD MoRI-IO). With "moriio" NIXL is neither needed nor loaded.

Prerequisites

  • Local CPU-tier offload (ec_enable_p2p unset or false) needs no extra packages — the gate-off code path (cpu/connector.py, cpu/scheduler/, cpu/worker/, cpu/common.py) imports neither nixl nor the P2P transport modules, enforced by a repo test (tests/v1/ec_connector/unit/test_no_nixl_imports.py).
  • P2P with ec_transport: "nixl" (the default) requires the nixl package: uv pip install nixl (pinned to nixl==1.3.2 in requirements/kv_connectors.txt, shared with NixlConnector). Refer to the NIXL repository for platform-specific installation. If nixl isn't importable, the connector raises RuntimeError: ec_transport='nixl' (the default) requires NIXL; install the nixl package or set ec_transport to another transport.
  • P2P with ec_transport: "moriio" requires the amd-mori package and RDMA devices in the container, and does not need nixl. If mori isn't importable, the connector raises RuntimeError: ec_transport=moriio requires MoRI-IO; install amd-mori ….

Basic Usage

Local CPU-tier offload only, within a single engine instance:

vllm serve <model> --ec-transfer-config '{
  "ec_connector": "ECCPUConnector",
  "ec_role": "ec_both",
  "ec_connector_extra_config": {"ec_cpu_bytes": 1073741824}
}'
  • ec_role="ec_both": the same process offloads to and reloads from the CPU tier.
  • The tier is one mmap region (/dev/shm/vllm_ec_{instance_id}_dp{dp_rank}.mmap) shared by every TP/PCP worker of the instance; only TP rank 0 / PCP rank 0 writes on save, since all ranks hold identical encoder output.
  • Entries are keyed by mm_hash; EmbeddingCache evicts ready+unpinned entries FIFO when space is needed.
  • The runner cache and CPU tier can evict independently. When a scheduled chunk uses a runner-cached output that is missing from the CPU tier, the producer saves the existing tensor again without rerunning the encoder. The scheduler pins the step's CPU loads before reserving blocks for these saves. If no blocks are available, the existing missing-entry behavior still applies.
  • Each batched save/load runs on a pooled CUDA stream; completion is reported to the scheduler once the transfer's end event fires (ECCPUWorker.build_connector_worker_meta → ECCPUScheduler.update_connector_output), which marks saved entries ready and unpins loaded ones.
  • The region is unlinked from /dev/shm in shutdown().

Usage With P2P NIXL

Producer — offloads to its CPU tier and serves reads from consumers:

vllm serve <model> --ec-transfer-config '{
  "ec_connector": "ECCPUConnector",
  "ec_role": "ec_producer",
  "ec_connector_extra_config": {"ec_enable_p2p": true, "ec_cpu_bytes": 1073741824}
}'

ec_role="ec_producer" alone already enables mm_encoder_only on the multimodal config, so vllm_config.is_mm_encoder_only is True (skips the language model, sampler, and pooler); add --mm-encoder-only only if you need encoder-only execution independent of ec_transfer_config.

Consumer — pulls encodings named in a request's ec_transfer_params before falling back to local encoding:

vllm serve <model> --ec-transfer-config '{
  "ec_connector": "ECCPUConnector",
  "ec_role": "ec_consumer",
  "ec_connector_extra_config": {"ec_enable_p2p": true, "ec_cpu_bytes": 1073741824}
}'

Usage With P2P MoRI-IO

On AMD GPUs the data plane can run over MoRI-IO instead of NIXL. Add "ec_transport": "moriio" to ec_connector_extra_config on both the producer and the consumer. The MoRI-IO engine and the completion-notification socket bind to VLLM_EC_SIDE_CHANNEL_HOST (or the detected host IP when unset) on OS-assigned ports, so that address must be reachable from the peer on both sides:

vllm serve <model> --ec-transfer-config '{
  "ec_connector": "ECCPUConnector",
  "ec_role": "ec_consumer",
  "ec_connector_extra_config": {"ec_enable_p2p": true, "ec_transport": "moriio", "ec_cpu_bytes": 1073741824}
}'

ec_enable_p2p is still required: it turns P2P on for any transport, and ec_transport picks the data plane. With "moriio" the embeddings never touch NIXL or UCX. The control plane, protocol and fallback behaviour are the same for both transports. Set ec_transport identically on the producer and the consumer.

Orchestration flow

  1. A request finishes on the producer. ECCPUConnector.request_finished() returns, for each mm_hash still resident in its CPU tier:
{mm_hash: {"metadata": {...}, "peer_host": str, "peer_port": int, "size_bytes": int}}

surfaced to the caller as ec_transfer_params (RequestOutput.ec_transfer_params / EngineCoreOutput.ec_transfer_params). metadata carries the placeholder fields the model declares for the modality, for an orchestrator that rewrites the media into a metadata-only reference; the remaining keys are the connector's own handle on the published encoding.

The two halves are published together or not at all. An mm_hash the producer cannot serve — never saved because the region was full, or evicted since — is reported with empty metadata and no address, so an orchestrator leaves the media on the request and the consumer encodes it locally. 2. The orchestrator issues a follow-up request with the same mm_hash to a consumer instance, passing the producer's ec_transfer_params through SamplingParams.extra_args["ec_transfer_params"]. 3. On the consumer, ECCPUScheduler.ensure_cache_available() checks request.ec_transfer_params. A ready CPU-tier entry or a runner encoder-cache entry with a matching embedding count avoids a remote transfer. For each announced mm_hash without either cache hit, it opens a ZMQ session to (peer_host, peer_port), sends an XferReq, and on an OK XferAck issues a NIXL READ that pulls the blocks straight from the producer's mmap into its own. The request is deferred until the READ completes. 4. A NACK_NOT_READY means the producer announced the encoding but its GPU→mmap save has not landed yet. The consumer releases the in-flight entry without recording a failure and re-requests the read on a later step, so a save that lands a few steps late costs latency rather than a recompute. 5. On any other NACK (NACK_MISSING, NACK_INCOMPAT, NACK_VERSION, NACK_INTERNAL), ack timeout, read timeout, or peer disconnect, the consumer discards the in-flight entry and falls back to local encoding for that mm_hash — a P2P failure never blocks the request indefinitely.

Protocol

  • Control plane: ZMQ. By default, each producer binds a ROUTER socket on the local IP returned by vLLM's get_ip() with an OS-assigned port and advertises the bound port through ec_transfer_params.peer_port. Optional host and port overrides are listed below. Each consumer opens one DEALER connection per producer peer, with ZMQ heartbeating (2s interval, 4s timeout, 8s TTL) to detect a dead peer. XferReq/XferAck are msgspec msgpack structs, versioned by EC_CONNECTOR_VERSION (currently 1) — a version mismatch is NACKed.
  • Compatibility check: every XferReq carries a SHA-256 hash over (vllm_version, model, dtype, block_size_bytes); the producer NACKs (NACK_INCOMPAT) any peer whose hash differs.
  • Ack statuses: OK, NACK_MISSING (the producer no longer holds the encoding), NACK_NOT_READY (held, but its save has not landed), NACK_INCOMPAT, NACK_VERSION, NACK_INTERNAL. Only NACK_NOT_READY is retryable — RETRYABLE_NACKS in cpu/protocol.py is what both ends consult, so the classification lives with the wire vocabulary rather than at each call site.
  • Data plane: NIXL (UCX backend) or MoRI-IO (RDMA backend), chosen by ec_transport; consumer-initiated READ either way — the consumer pulls bytes directly out of the producer's registered mmap region; the producer never pushes. MoRI-IO has no per-transfer notification equivalent to NIXL's, so the MoRI-IO transport tells the producer a READ finished over a ZMQ PUSH→PULL pair; the producer's PULL endpoint travels in its agent metadata.
  • Producer restart recovery: the XferAck carries the producer's NIXL agent metadata, so a consumer can recover a READ against a restarted producer without a fresh handshake round-trip.
  • Timeouts: consumer XferAck wait 2s; NIXL read 20s (then quarantined — not evicted — for up to 60s to let an unabortable DMA settle); the producer releases an unclaimed pinned grant after a 30s pin lease.

Configuration

EC transfer is configured via --ec-transfer-config (CLI) or the ec_transfer_config field of VllmConfig (ECTransferConfig, vllm/config/ec_transfer.py):

Field Type Default Description
ec_connector str \| None None Connector class name. Use "ECCPUConnector".
ec_role "ec_producer" \| "ec_consumer" \| "ec_both" \| None None Required whenever ec_connector is set. ec_producer offloads GPU→CPU only, ec_consumer reloads CPU→GPU only, ec_both does both in the same process.
ec_connector_extra_config dict[str, Any] {} Connector-specific settings, including ec_enable_p2p — see ec_connector_extra_config Reference.
engine_id str \| None random UUID4 Names this instance's P2P agent (the NIXL agent or the MoRI-IO engine) when ec_enable_p2p=True.
ec_connector_module_path str \| None None Python module path to load an out-of-tree connector from, when ec_connector isn't in the built-in registry (ECExampleConnector, ECCPUConnector).

ec_connector_extra_config Reference

Key Type Required Description
ec_enable_p2p bool No (default false) Enables P2P transfer in addition to local CPU offload, whichever ec_transport is used. ec_enable_nixl is accepted as its former name and used when ec_enable_p2p is absent. Omitted or false imports no NIXL/MoRI-IO/ZMQ. Extra config is not type coerced, so a string value is parsed: "true", "1", "yes" enable it, anything else does not.
ec_transport "nixl" \| "moriio" No (default "nixl") P2P data plane, used only when ec_enable_p2p is true. "nixl" needs the nixl package; "moriio" needs the mori package (AMD MoRI-IO) and RDMA devices in the container, and does not use NIXL. Any other value raises ValueError. Use the same value on producer and consumer.
consumer_ack_timeout_s float No (default 30.0, the producer's pin lease) How long a consumer waits for an XferAck before giving up on a read. The producer answers XferReqs from its own scheduler step, so its reply latency scales with the encoder's --max-num-batched-tokens: a loaded encoder whose steps run longer than this makes consumers abandon reads the producer is about to grant. Raise it for large encoder batches.
ec_cpu_bytes int Yes Total size, in bytes, of the shared CPU mmap region. ECCPUConnector raises ValueError if unset. Block count = ec_cpu_bytes // block_size_bytes, where each block holds one LLM input-embedding vector. Entries allocate enough blocks for their modality-specific output shape, including visual DeepStack features.

The control address uses vLLM's standard IP discovery. Set VLLM_HOST_IP to select a specific network interface when automatic discovery is unsuitable.

Environment variable Default Description
VLLM_EC_SIDE_CHANNEL_HOST Unset Override the EC control host instead of using get_ip(). Must be reachable by consumers; wildcard addresses are rejected.
VLLM_EC_SIDE_CHANNEL_PORT 0 0 selects an OS-assigned port per producer. A nonzero value binds base_port + data_parallel_index; an occupied port fails startup.

For fixed ports, assign non-overlapping ranges to independent instances sharing a host. Consumers use the advertised address and do not need matching port configuration.

Limitations

  • No mechanism to notify an orchestrator or peer instance when an encoding is evicted from the CPU tier before it's consumed. A consumer only discovers a miss when its XferReq is NACKed (NACK_MISSING) and falls back to local recompute.
  • At the moment, Mmap cleanup on process shutdown is best-effort: if the creating process is SIGKILLed before ECSharedRegion.cleanup() runs, the /dev/shm/vllm_ec_*.mmap file leaks and must be removed manually.
  • NixlDataTransport hardcodes the UCX backend.
  • A retried read releases its destination blocks and re-allocates them on the next step, so a producer whose save is slow to land makes the consumer evict ready entries to win the same blocks back, once per engine step.
  • Falling back to local encoding requires the media to still be on the request. Announcing an encoding only when it can be served keeps an orchestrator from rewriting the media away for one that cannot, but an encoding lost after it was announced — evicted between the announcement and the consumer's read — leaves a rewritten request with nothing to embed, and it fails in the worker's sanity_check_mm_encoder_outputs. ensure_cache_available() can only defer a request, not fail it, so reporting this cleanly needs a scheduler-side failure path.