Skip to content

Add Endpoint Picker Protocol Proposal #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Changes from 3 commits
Commits
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
87 changes: 87 additions & 0 deletions docs/proposals/003-model-server-protocol/protocol.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Endpoint Picker Protocol

The Endpoint Picker, or EPP, is a core component of the inference extension. Ultimately it's
responsible for picking an endpoint from the `InferencePool`. A reference implementation can be
found [here](../../../pkg/ext-proc/).

## Proxy Protocol

This is the protocol between the EPP and the proxy (e.g, Envoy).

The EPP MUST implement the Envoy
[external processing service](https://www.envoyproxy.io/docs/envoy/latest/api-v3/service/ext_proc/v3/external_processor)protocol.

For each HTTP request, the EPP MUST communicate to the proxy the picked model server endpoint, via
adding the `target-pod` HTTP header in the request, or otherwise return an error.

## Model Server Protocol

This is the protocol between the EPP and the model servers.

### Inference API Protocol

The model server MUST implement OpenAI’s [Completions](https://platform.openai.com/docs/api-reference/completions)
and [Chat](https://platform.openai.com/docs/api-reference/chat) APIs.

### Metrics Reporting

The inference extension scrapes metrics from the model servers to make optimal request scheduling
decisions. The model servers MUST provide the following metrics via a Prometheus endpoint. The exact
metric names don't necessarily need to be the same as the recommended names here, however the
metric types and semantics MUST follow this doc.

Note the requirements here are aligned with the
[model server metrics standardization](https://docs.google.com/document/d/1SpSp1E6moa4HSrJnS4x3NpLuj88sMXr2tbofKlzTZpk)
effort.

The corresponding metrics in vLLM are also shown in the table below, as vLLM is already integrated
into the reference endpoint picker implementation.

| Metric | Type | Description | vLLM metric |
| ----- | ---- | ---- | ---- |
| TotalQueuedRequests | Gauge | The current total number of requests in the queue.| `vllm:num_requests_waiting`|
| KVCacheUtilization| Gauge | The current KV cache utilization in percentage.| `vllm:gpu_cache_usage_perc`|


### LoRA Adapter Serving

Model servers that support dynamic LoRA serving can benefit from the LoRA affinity algorithm. Note
the current algorithm in the reference EPP is highly biased towards vLLM's current dynamic LoRA
implementation.

The model servers MUST support serving a LoRA adapter specified in the `model` argument of the
request, provided the requested adapter is valid.

The model server MUST expose the following LoRA adapter information via a RESTful API with response
in JSON :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the current EPP implementation support this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it does not. It uses the current vLLM metrics implementation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The protocol is part of the release, and so i think we should remove this until the next release when we actually implement it and only spec the metrics based approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can document the current metrics approach for vllm, but I don't want to make it a "protocol", because it's really awkward. It's not something we should recommend for the next model server to implement.

The purpose of the protocol is to set up a contract for any new model server integration to follow. So I think we should document this here, and with a note that the current vllm workaround should converge too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that is why we have versioning, it doesn't make sense to document a contract that the EPP doesn't implement. Once we have EPP implements it, we update the protocol and create a new release. @robscott @smarterclayton for opinions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this is just a short-term workaround and we don't need a protocol to document it - the code speaks for itself. I think the protocol should be something reasonably stable based on our best knowledge, and we are willing to take to integrate with another model server.

One option is to just not document this at all, until we have some implementation to support it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not documenting anything is an option, but documenting a protocol and make it part of a release that doesn't implement it is I think not what we should do here. Remember that we are versioning the protocol with the EPP image.

I would still lean towards documenting what we implemented and released, and we can change that in the next release, that is what versioning allows us to do. It is expected that the initial iterations will include more frequent changes, and the protocol will stabilize after that.

Copy link
Contributor

@smarterclayton smarterclayton Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably align to abdullah here - the goal is to spec what is currently required, so that you don't read things that don't exist. There will be people using 0.1 for quite a while, so be accurate to 0.1. Anything that is to be removed can simply be moved to a separate PR which is "draft for 0.2 proposed changes" and not lost.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback, I updated the doc


* `Config`
* `LoRAEnabled`: boolean, whether dynamic LoRA serving is enabled.
* `MaxActiveAdapter`: integer, the maximum number of adapters that can be loaded to GPU memory to
serve a batch. Requests will be queued if the model server has reached MaxActiveAdapter and cannot
load the requested adapter.
* `State`
* `ActiveAdapters`: List[string], a list of adapters that are currently loaded in GPU memory and
ready to serve requests.

This is an example API endpoint and response:
```
GET ${server_endpoint}/adapters/info
```

```
{
"config": {
"enabled": true,
"maxActiveAdapters": 4,
},
"state": {
"activeAdapters": ["adapter1", "adapter2"]
}
}
```

NOTE: Currently in vLLM v0.6.6, LoRA info is exposed in the `vllm:lora_requests_info` metric, where
`MaxActiveAdapters` is exposed as a string label `max_lora`, and `ActiveAdapters` as a comma
separated string label `running_lora_adapters`. We will use [this issue](https://github.com/vllm-project/vllm/issues/10086)
to track integration efforts with vLLM.