Skip to content
Merged
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
49d76a1
[Draft] EPD
Sep 8, 2025
00d1185
[Fix] Runable for non EPD mode
Sep 9, 2025
3031ea0
[Fix] Remove hard code path in share storage connector
Sep 9, 2025
c2ea7db
[Misc] Clean code and docs
Sep 9, 2025
7448888
[Misc] Clean code
Sep 9, 2025
bc00658
[Fix] Enable start Encoder Instance without KVC and fix PD instance s…
Sep 10, 2025
946bfb4
[Minor] Fix EC update state after encoder cache allocation
Sep 10, 2025
e1ecb30
[Bug] Check actualy tensor file for EC Cache exist in ECSharedStorage…
Sep 10, 2025
d20c0f8
[Bugfix] Encoder Instance does not return Output to client
Sep 10, 2025
a290dda
[Bugfix] Fix try scheduler encoder inputs return when there is no enc…
knlnguyen1802 Sep 11, 2025
668125d
[Fix] Fix typo and move all hardcode to launch config
knlnguyen1802 Sep 12, 2025
62d4a2a
[Fix] Fix typo in docs
knlnguyen1802 Sep 12, 2025
a0735ce
[Misc] Add example for disaggregate encoder
knlnguyen1802 Sep 15, 2025
bc1f9ba
[Fix] Clean code
knlnguyen1802 Sep 15, 2025
bcf5286
[Bugfix] Fix bug when request there is no encoder input
knlnguyen1802 Sep 15, 2025
250d9e3
[Misc] Optimize disaggregate encoder proxy
knlnguyen1802 Sep 16, 2025
f5ba236
[Minor] Remove some comments and update docs
knlnguyen1802 Sep 16, 2025
c5514d6
[Minor] Remove unused logging
knlnguyen1802 Sep 16, 2025
f470d17
[Misc] Add docs for disaggregate encoder
knlnguyen1802 Sep 16, 2025
756663c
[Feature] E+P+D disagg with proxy & example
herotai214 Sep 16, 2025
3613ecc
[Misc] Proxy support E+P+D & E+PD / Update docs & examples
herotai214 Sep 17, 2025
23c4902
Update vllm/config/__init__.py
knlnguyen1802 Sep 22, 2025
7ef47ad
[Misc] Resolve comments
herotai214 Oct 8, 2025
1b79908
Update examples/online_serving/disaggregated_encoder/README.md
knlnguyen1802 Oct 8, 2025
e4c9174
[Misc] resolve comment and fix example script
khuonglmhw Oct 8, 2025
7ba00e3
[Misc] Resolve comment
knlnguyen1802 Oct 9, 2025
99b34e3
[Misc] Resolve comment
knlnguyen1802 Oct 9, 2025
dc9e2a9
[CI/Build] Unit test for ECSharedStorageConnector
herotai214 Oct 10, 2025
2169531
[Fix] remove v1 check for create_connector and update docs
knlnguyen1802 Oct 10, 2025
a2221ea
[Misc] Clean code to pass pre-commit rules
khuonglmhw Oct 14, 2025
a08d1d5
[Bugfix] Fix ec_connector_output for non multimodal model
knlnguyen1802 Oct 17, 2025
ef73fd8
[Fix] Rebase
knlnguyen1802 Oct 21, 2025
3f86218
[Fix] Rebase
knlnguyen1802 Oct 21, 2025
ff050c7
Fix pre-commit
knlnguyen1802 Oct 21, 2025
1e4c7ad
Merge branch 'main' into epd_draft
knlnguyen1802 Oct 21, 2025
7968f61
[Misc] Fix/add documentation
khuonglmhw Oct 21, 2025
ec4e701
Fix docs
knlnguyen1802 Oct 22, 2025
3cc166f
Fix test and clean code
knlnguyen1802 Oct 22, 2025
67b502e
Fix docs
knlnguyen1802 Oct 22, 2025
84d99c7
Fix docs
knlnguyen1802 Oct 22, 2025
a5fc6fe
Fix docs again
knlnguyen1802 Oct 22, 2025
7ecb6f5
Merge branch 'main' into epd_draft
khuonglm Oct 22, 2025
30888ba
[Misc] Script to verify EPD correctness
herotai214 Oct 22, 2025
90d40fe
Merge branch 'epd_draft' of https://github.com/fake0fan/vllm into epd…
knlnguyen1802 Oct 23, 2025
eabfe7e
Fix pre-commit
knlnguyen1802 Oct 23, 2025
5120f76
Fix pre-commit
knlnguyen1802 Oct 23, 2025
7e7a269
Fix pre-commit
knlnguyen1802 Oct 23, 2025
37545ef
[Fix] fix pre-commit
khuonglm Oct 23, 2025
f1ee67c
Fix docs
knlnguyen1802 Oct 23, 2025
a8f5dad
Fix whisper bug
knlnguyen1802 Oct 24, 2025
45d7724
Rebase with main
knlnguyen1802 Oct 24, 2025
42f43fb
Fix pre-commit
knlnguyen1802 Oct 24, 2025
c3050fc
Merge branch 'main' into epd_draft
knlnguyen1802 Oct 24, 2025
12880b9
Rebase with main
knlnguyen1802 Oct 27, 2025
563cdd4
[CI/Build] Fix test_scheduler disable_hybrid_kv_cache_manager flag
herotai214 Oct 27, 2025
92a5222
Merge branch 'main' into epd_draft
knlnguyen1802 Oct 27, 2025
bda8f49
Merge branch 'main' into epd_draft
fake0fan Oct 27, 2025
1c76328
[CI/Build][Bugfix] Fix and add test ensure init ECConnector before KV…
herotai214 Oct 28, 2025
d772f81
Rebase with main
knlnguyen1802 Oct 30, 2025
cc31385
Merge branch 'main' into epd_draft
knlnguyen1802 Oct 30, 2025
604f94d
Merge branch 'main' into epd_draft
knlnguyen1802 Oct 30, 2025
3e75764
Merge branch 'main' into epd_draft & Add ec_connector_output to Exect…
herotai214 Nov 4, 2025
5e79b0b
Fix scheduler pre-commit
herotai214 Nov 4, 2025
2665ff6
[Bugfix] Fix num_tokens_to_schedule & Add unit test
herotai214 Nov 5, 2025
8e04ca9
Fix pre-commit
herotai214 Nov 6, 2025
2353348
[Bugfix] Add logs to EPD proxy at during runtime
herotai214 Nov 6, 2025
69515d8
Edit Readme & comments
herotai214 Nov 6, 2025
cabee08
Merge branch 'main' into epd_draft; Revert HMA related changes
herotai214 Nov 6, 2025
9f71ddf
fix pre-commit
herotai214 Nov 6, 2025
1659fc4
[Misc] Support local mm, Increase encoder budget in test & better err…
herotai214 Nov 7, 2025
66efd95
Merge branch 'main' into epd_draft; no conflict
herotai214 Nov 7, 2025
dc6a0bc
[Misc] Add single request example
herotai214 Nov 10, 2025
d5ab465
Merge branch 'main' into epd_draft; no conflicts
herotai214 Nov 10, 2025
c8215d9
Revert num_new_tokens bug handling changes in scheduler
herotai214 Nov 10, 2025
535c031
[Doc] Update docs for EPD & increase budget in scripts
herotai214 Nov 11, 2025
4ef546e
Fix pre-commit
herotai214 Nov 11, 2025
e834bc3
Merge branch 'main' into epd_draft
herotai214 Nov 11, 2025
bdf5bfa
Merge branch 'main' into epd_draft
ywang96 Nov 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions docs/features/disagg_encoder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Disaggregated Encoder

A **disaggregated encoder** runs the vision-encoder stage of a multimodal LLM in a process that is separate from the pre-fill / decoder stage. Deploying these two stages in independent vLLM instances brings three practical benefits:

1. **Independent, fine-grained scaling**
2. **Lower time-to-first-token (TTFT)**
3. **Cross-process reuse and caching of encoder outputs**

Design doc: <https://docs.google.com/document/d/1aed8KtC6XkXtdoV87pWT0a8OJlZ-CpnuLLzmR8l9BAE>

---

## 1 Motivation

### 1. Independent, fine-grained scaling

* Vision encoders are lightweight, while language models are orders of magnitude larger.
* The language model can be parallelised without affecting the encoder fleet.
* Encoder nodes can be added or removed independently.

### 2. Lower time-to-first-token (TTFT)

* Language-only requests bypass the vision encoder entirely.
* Encoder output is injected only at required attention layers, shortening the pre-fill critical path.

### 3. Cross-process reuse and caching

* In-process encoders confine reuse to a single worker.
* A remote, shared cache lets any worker retrieve existing embeddings, eliminating redundant computation.

---

## 2 Usage Example

The current reference pathway is **SharedStorageConnector**.
Below ready-to-run scripts shows the workflow:

1 Encoder instance + 1 PD instance:
`examples/online_serving/disaggregated_encoder/shared_storage_connector/disagg_encoder_example.sh`

1 Encoder instance + 1 Prefill instance + 1 Decode instance:
`examples/online_serving/disaggregated_encoder/shared_storage_connector/disagg_epd_example.sh`

---

## 3 Test Script

Please refer to the directories `tests/v1/ec_connector`

## 4 Development

Disaggregated encoding is implemented by running two parts:

* **Encoder instance** – a vLLM instance to performs vision encoding.
* **Prefill/Decode (PD) instance(s)** – runs language pre-fill and decode.
* PD can be in either a single normal instance with `disagg_encoder_example.sh` (E->PD) or in disaggregated instances with `disagg_epd_example.sh` (E->P->D)

A connector transfers encoder-cache (EC) embeddings from the encoder instance to the PD instance.
All related code is under `vllm/distributed/ec_transfer`.

### Key abstractions

* **ECConnector** – interface for retrieving EC caches produced by the encoder.
* *Scheduler role* – checks cache existence and schedules loads.
* *Worker role* – loads the embeddings into memory.

Here is a figure illustrating disaggregate encoder flow:

![Disaggregated Encoder Flow](../assets/features/disagg_encoder/disagg_encoder_flow.png)

For the PD disaggregation part, the Prefill instance receive cache exactly the same as the disaggregate encoder flow above. Prefill instance executes 1 step (prefill -> 1 token output) and then transfer KV cache to the Decode instance for the remaining execution. The KV transfer part purely happens after the execute of the PDinstance.

`docs/features/disagg_prefill.md` shows the brief idea about the disaggregated prefill (v0)

We create the example setup with the **NixlConnector** from `vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py` and referred to the `tests/v1/kv_connector/nixl_integration/toy_proxy_server.py` to facilitate the kv transfer between P and D;
119 changes: 119 additions & 0 deletions examples/online_serving/disaggregated_encoder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Disaggregated Encoder

These example scripts that demonstrate the disaggregated encoder (EPD) features of vLLM.

For a detailed explanation of the EPD features, please refer to the [Disaggregated Encoder Feature Documentation](../../../docs/features/disagg_encoder.md).

## Files

- `disagg_epd_proxy.py` - Proxy script that demonstrates the XeYpZd setup (X encode instances, Y prefill instances, Z decode instances). Currently stable for the 1e1p1d configuration.

- `disagg_1e1p1d_example.sh` - Sets up the 1e1p1d configuration, runs the VisionArena benchmark, and processes a single request with a local image.

- `disagg_1e1pd_example.sh` - Sets up the 1e1pd configuration, runs the VisionArena benchmark, and processes a single request with a local image.

### Custom Configuration

```bash
# Use specific GPUs
GPU_E=0 GPU_PD=1 GPU_P=1 GPU_D=2 bash disagg_1e1p1d_example.sh

# Use specific ports
ENDPOINT_PORT=10001 bash disagg_1e1p1d_example.sh

# Use specific model
MODEL="Qwen/Qwen2.5-VL-3B-Instruct" bash disagg_1e1p1d_example.sh

# Use specific storage path
EC_SHARED_STORAGE_PATH="/tmp/my_ec_cache" bash disagg_1e1p1d_example.sh
```

## Encoder Instances

Encoder engines should be launched with the following flags:

- `--enforce-eager` **(required)** – The current EPD implementation is only compatible with encoder instances running in this mode.

- `--no-enable-prefix-caching` **(required)** – Encoder instances do not consume KV cache; prefix caching is disabled to avoid conflicts with other features.

- `--max-num-batched-tokens=<large value>` **(default: 2048)** – This flag controls the token scheduling budget per decoding step and is irrelevant to encoder-only instances. **Set it to a very high value (effectively unlimited) to bypass scheduler limitations.** The actual token budget is managed by the encoder cache manager.

## Local media inputs

To support local image inputs (from your ```MEDIA_PATH``` directory), add the following flag to the encoder instance:

```bash
--allowed-local-media-path $MEDIA_PATH
```

The vllm instances and `disagg_encoder_proxy` supports local URIs with ```{"url": "file://'"$MEDIA_PATH_FILENAME"'}``` as multimodal inputs. Each URI is passed unchanged from the `disagg_encoder_proxy` to the encoder instance so that the encoder can load the media locally.

## EC connector and KV transfer

The `ECSharedStorageConnector` is used to store the encoder cache on local disk and facilitate transfer. To enable the encoder disaggregation feature, add the following configuration:

```bash
# Add to encoder instance:
--ec-transfer-config '{
"ec_connector": "ECSharedStorageConnector",
"ec_role": "ec_producer",
"ec_connector_extra_config": {
"shared_storage_path": "'"$EC_SHARED_STORAGE_PATH"'"
}
}'

# Add to prefill/prefill+decode instance:
--ec-transfer-config '{
"ec_connector": "ECSharedStorageConnector",
"ec_role": "ec_consumer",
"ec_connector_extra_config": {
"shared_storage_path": "'"$EC_SHARED_STORAGE_PATH"'"
}
}'
```

`$EC_SHARED_STORAGE_PATH` is the path where the EC connector temporarily stores the cache.

If you enable prefill instance (`--prefill-servers-urls` not disabled), you will need --kv-transfer-config to facilitate the PD disaggregation. Currently, we use the `NixlConnector` for this purpose. Refer to `tests/v1/kv_connector/nixl_integration` for more example codes on PD disaggregation with Nixl.

```bash
# Add to prefill instance:
--kv-transfer-config '{
"kv_connector": "NixlConnector",
"kv_role": "kv_producer"
}'

# Add to decode instance:
--kv-transfer-config '{
"kv_connector": "NixlConnector",
"kv_role": "kv_consumer"
}'
```

## Proxy Instance Flags (`disagg_epd_proxy.py`)

| Flag | Description |
|------|-------------|
| `--encode-servers-urls` | Comma-separated list of encoder endpoints. Every multimodal item extracted from the request is fanned out to one of these URLs in a round-robin fashion. |
| `--prefill-servers-urls` | Comma-separated list of prefill endpoints. Set to `disable`, `none`, or `""` to skip the dedicated prefill phase and run E+PD (encoder + combined prefill/decode). |
| `--decode-servers-urls` | Comma-separated list of decode endpoints. Non-stream and stream paths both round-robin over this list. |
| `--host`, `--port` | Bind address for the proxy itself (defaults: `0.0.0.0:8000`). |

Example usage:
For E + PD setup:

```bash
$ python disagg_encoder_proxy.py \
--encode-servers-urls "http://e1:8001,http://e2:8002" \
--prefill-servers-urls "disable" \
--decode-servers-urls "http://pd1:8003,http://pd2:8004"
```

For E + P + D setup:

```bash
$ python disagg_encoder_proxy.py \
--encode-servers-urls "http://e1:8001,http://e2:8001" \
--prefill-servers-urls "http://p1:8003,http://p2:8004" \
--decode-servers-urls "http://d1:8005,http://d2:8006"
```
Loading