Communication library for distributed AI infrastructure: endpoint mobility primitives that let replicas join, leave, fail over and migrate with traffic in flight (PD/AF disaggregation, pipeline parallelism, elastic serving)
pip install connex-ai==0.1.1 Copy PIP instructions
Endpoint mobility primitives for dynamic LLM serving communication endpoints that join, leave, fail and migrate with traffic in flight
Connex is a communication library for distributed AI infrastructure, built on endpoint mobility primitives: communication endpoints that join, leave, fail and migrate while traffic to them is in flight. Its target is distributed and heterogeneous LLM serving in which many replicas of a distributed model run side by side (several pipeline chains, pools of prefill and decode instances, attention and FFN workers) on mixed hardware and transports, and the set of endpoints changes all the time. Every endpoint has a stable logical identity that a control plane resolves to its current address; senders keep in-flight work correct when the endpoint behind an identity changes, so requests hand over to another replica on failure or scale-down and new replicas take traffic as soon as they join.
Tensor bytes move through a pluggable data plane. On RDMA hosts the default is connex-rs, Connex's own Rust data plane over UCX: GPUDirect one-sided transfers as fast as Mooncake Transfer Engine, plus peer-death events within milliseconds and same-identity rejoin, which bring handover after a killed stage from 2-3 s to well under 1 s (comparison). Mooncake Transfer Engine, UCX and ZeroMQ remain available.
Connex is the system described in Connex: Endpoint Mobility Primitives for Dynamic LLM Serving (SIGCOMM 2026, see Citation).
Collective communication libraries assume that the set of peers is fixed at start-up: a rank is an address, and a lost rank ends the job. Production serving breaks that assumption. Replicas are added and removed with load, fail and are replaced, move to other nodes or hardware, and one request is increasingly served by several role-specialised instances (pipeline stages, prefill and decode, attention and FFN) that talk over the network. In all of these, the peer of a running request can change while its data is in flight. Restarting the whole replica, or dropping its requests, turns every scale or failure event into user-visible errors. Connex treats this as a communication problem: it gives the application a mobile endpoint and a delivery contract that survives the endpoint moving. The design rationale is in docs/design/overview.md.
A small example, CPU only and not tied to any serving scenario: a sender talks to two replicas of one logical group, survives one of them dying with a step in flight, sees it rejoin, follows a migration to a new address and a scale-down. The group could be a decode pool, FFN workers or one stage of several pipeline replicas. Full script: examples/mobile_endpoints.py.
from connex.directory import DirectoryClient from connex.directory_server import DirectoryServer from connex.elastic import ElasticPeerSet directory = DirectoryServer("127.0.0.1:7000", "127.0.0.1:7001") # routes, leases, events directory.start() # each replica JOINs under LID ("demo", group=1, shard=0, replica=r) a = DirectoryClient(directory.bind_addr, "demo", stage_idx=1, replica_idx=0, local_addresses=[addr_a]); a.start(); a.register() b = DirectoryClient(directory.bind_addr, "demo", stage_idx=1, replica_idx=1, local_addresses=[addr_b]); b.start(); b.register() # the sender resolves the group through the directory, not fixed ranks owner = DirectoryClient(directory.bind_addr, "demo", stage_idx=0); owner.start() peers = ElasticPeerSet(owner, transport, stage_idx=1) peers.start(); peers.wait_ready(2) peers.send(peers.pick(), b"step") peers.mark_failed(("demo", 1, 0, 1)) # replica 1 died: evicted for every sender peers.send(peers.pick(), b"step-42") # in-flight step handed over to replica 0 b.register() # replica 1 rejoins (scale up) a.register(addresses=[new_addr_a]) # replica 0 migrates, same LID b.deregister() # scale down Output $ python examples/mobile_endpoints.py replicas: [('demo', 1, 0, 0), ('demo', 1, 0, 1)] received: b'step' b'step' handover: [('demo', 1, 0, 0)] b'step-42' rejoin: [('demo', 1, 0, 0), ('demo', 1, 0, 1)] migrate: b'after-migrate' scale-down: [('demo', 1, 0, 0)] examples/two_stage_pipeline.py shows directory discovery plus a tensor transfer, and make cpu-demo the resume proxy surviving a backend kill.
The primitives are generic; how far each scenario is integrated with an inference engine differs, and this table says so plainly. Multi-replica pipeline parallelism is the first scenario that is fully integrated and validated end to end on GPUs (vLLM, Llama-3-8B, 4 stages, replicas joining and leaving, see docs/results.md). A single pipeline chain is only the building block; the interesting cases are several replica chains whose stages fail over to each other.
Connex separates who talks to whom, and what happens when that changes from how the bytes move. Connex owns the first part. The second part is a pluggable data plane. On RDMA hosts the default is connex-rs (HeterInfra/connex-rs, pip install "connex-ai[rs]"), Connex's own data plane in Rust over UCX; the Mooncake Transfer Engine remains supported (CONNEX_PP_BACKEND=mooncake) and is the default where no RDMA device is present. "ConnexTE" names the combination of Connex control with a transfer-engine data plane.
One step from a sender to its peer works like this. The sender copies the tensors into a send ring it registered with the data plane (GPU memory when GPUDirect is on, CONNEXTE_GDR=1, the default; host memory otherwise) and sends a small ZeroMQ signal with the correlation id, the tensor layout and the ring offset. The receiver pulls the payload with one one-sided RDMA read into its own registered buffer and acknowledges, which frees the ring slot. Everything around that read is Connex: which peer the step goes to, what a timeout or a dead peer means, retrying without executing a step twice, dropping late replies, re-sending all in-flight steps to another replica, and asking the engine to recompute state the new peer does not hold.
The data plane is an interface, not a dependency. connex.pp uses only seven methods of a transfer engine (register_memory, unregister_memory, transfer_sync_read, managed-buffer allocation and copies; see the TransferEngine protocol in connex/pp/transports.py), and the unit tests run the whole step protocol, failover included, against an in-memory fake. Another RDMA library can be plugged in by implementing that protocol. CONNEX_PP_BACKEND selects it: auto (default: connex-rs when installed and an RDMA device is present, else Mooncake, else ZeroMQ), connex-rs, mooncake or zmq. None of the mobility logic lives in the data plane, and Connex does not modify Mooncake.
What connex-rs adds over a plain transfer engine is that the transport itself reports peers: a process that dies is reported to every stage linked to it within milliseconds (its kernel tears down the UCX connections), and connections are keyed by logical endpoint id, so a single stage restarted under the same identity rejoins without restarting its chain. connex.pp uses these events as its primary failure signal and keeps the router lease and the TCP probe for hung or partitioned peers (a heartbeat on the transport's own progress thread, 1 s / 3 s, only raises a suspicion). With the same 4-stage, 2-replica Llama-3-8B layout, killing a stage resumes its in-flight requests 0.01-0.9 s after the kill (K=4) instead of 2-3 s, and steady-state latency and throughput match Mooncake (docs/results.md).
An engine implements a small contract: send and receive a tensor dict at step boundaries, report per request what state it holds, release finished requests, and recompute requests reported missing (docs/design/engine-contract.md). import connex and import connex.pp need no inference engine.
Each pipeline stage runs as its own vLLM process and registers as a LID (model, stage, 0, replica). Several replica chains share one front-router; a stage-0 replica keeps its traffic on its own chain and, when a downstream stage dies, hands its in-flight steps to the same stage of another replica (re-prefilling requests whose KV died with it). Stage-0 deaths are covered by the resume proxy.
Clients reach stage 0 of either replica directly or through the optional resume proxy; every stage registers, heartbeats and receives membership events through the Connex front-router (routes, leases, health).
It needs a vLLM fork with an external pipeline mode (--pipeline-stage-mode external, one process per stage); upstream vLLM has neither the mode nor a plugin hook for pipeline communicators. The image build (docker/Dockerfile) installs the fork, copies the communicators and applies the engine patches (K steps in flight, re-prefill, downstream CUDA graphs and external-PP fixes); see integrations/vllm/README.md.
About VLLM_FORK_REPO. The external-PP vLLM fork is not part of this repository and is not yet published, so the image build has no default for it: VLLM_FORK_REPO is a placeholder for the git URL of a copy of that fork you can access (the integration is validated at fork commit 380186d57, the default VLLM_FORK_REF). The library, the CPU-only demo and the test suite need neither the fork nor a GPU.
Quick start on one host with GPUs (two replicas of a 2-stage Llama-3-8B pipeline; four GPUs, or two GPUs of 40 GB or more with GPU2=0 GPU3=1 GPU_MEM_UTIL=0.4, started one replica after the other as in docs/deploy.md):
make image IMAGE=connex-vllm:dev VLLM_FORK_REPO= export CONNEX_IMAGE=connex-vllm:dev HF_TOKEN=hf_... docker compose -f docker/docker-compose.yml --profile proxy up -d docker/smoke_test.sh # replica 0 docker/smoke_test.sh http://127.0.0.1:8010 # replica 1 docker/smoke_test.sh http://127.0.0.1:5199 # through the resume proxy docker compose -f docker/docker-compose.yml kill stage1-r1 # replica 1's requests hand over to replica 0's stage 1 docs/deploy.md covers every tier with copy-pasteable commands: CPU-only demo, one GPU box (docker compose), several hosts with RDMA or TCP, and Kubernetes (deploy/k8s/manifests.py).
The chart compares the two RDMA data planes on the same deployment (numbers from docs/results.md, section 6; regenerate with python docs/assets/src/results_chart.py). The results below are on a 4-stage Llama-3-8B pipeline on A40 nodes with InfiniBand (Mooncake TE over RDMA); full tables and reproduction commands are in docs/results.md:
Python 3.10 or newer. The distribution on PyPI is connex-ai; the import name is connex.
pip install connex-ai # core: torch, pyzmq, msgpack, numpy, safetensors pip install "connex-ai[proxy]" # + aiohttp, for connex.serving.proxy pip install "connex-ai[rs]" # + connex-rs data plane (connex-rs>=0.1,<0.2) pip install "connex-ai[mooncake]" # + Mooncake Transfer Engine pip install "connex-ai[ucx]" # + ucx-py (CUDA 12 build) pip install "connex-ai[vllm,rs]" # vLLM: PD connector for upstream vLLM (PP needs the fork) pip install "connex-ai[sglang,rs]" # SGLang: PD transfer backend plugin (PP adapter is a prototype) pip install "connex-ai[rs,proxy,mooncake]" # extras combine From a checkout (development, tests, examples, deployment files):
pip install -e ".[test]" # + pytest, pyflakes, aiohttp python -m pytest -q tests # CPU only Optional dependencies degrade gracefully: without ucx-py, UCXTransport logs a warning and uses ZeroMQ; connex.pp uses connex-rs, else Mooncake, else a ZeroMQ-only data path. connex-rs is its own package and repository (HeterInfra/connex-rs). For RDMA and GPUDirect, build its wheel against a UCX with verbs/rdmacm and CUDA support from the third_party/connex-rs submodule (Rust toolchain, maturin; see CONTRIBUTING.md); the image build does this.
Every component is configured through environment variables or flags: the stage entrypoint, front-router and control plane, the ConnexTE and UCX data planes, the vLLM engine patches and the resume proxy. All of them, and the benchmark tools, are listed in docs/configuration.md. Image build arguments are in docs/deploy.md.
See CONTRIBUTING.md. Changes are listed in CHANGELOG.md.
If you use Connex in your research, please cite our paper:
@inproceedings{lin2026connex, title={Connex: Endpoint Mobility Primitives for Dynamic LLM Serving}, author={Lin, Yanying and Liu, Vincent and Luo, Tao and Xu, Chengzhong and Ye, Kejiang}, booktitle={Proceedings of the ACM SIGCOMM 2026 Conference}, pages={46--59}, year={2026} } License Apache-2.0, see LICENSE.
ucx rs mooncake proxy bench vllm sglang test dev
llm serving distributed inference endpoint mobility pipeline parallelism prefill-decode disaggregation attention-ffn disaggregation multi-replica elastic serving heterogeneous inference failover rdma mooncake ucx vllm
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




