Skip to content

Adding support to route a request to a specific engine instance#438

Merged
YuhanLiu11 merged 1 commit into
vllm-project:mainfrom
dumb0002:sleep-aware-routing
Jun 2, 2025
Merged

Adding support to route a request to a specific engine instance#438
YuhanLiu11 merged 1 commit into
vllm-project:mainfrom
dumb0002:sleep-aware-routing

Conversation

@dumb0002

@dumb0002 dumb0002 commented May 19, 2025

Copy link
Copy Markdown
Contributor

This PR adds support to route a request to a specific engine instance., e.g., vLLM v1 sleep and wake_up for a specific vLLM engine.

To achieve that we added the following features:
a) Add a end route to return the list of available engines and their serving models: /engines, Methods: POST - For example:

$ curl -o- http://localhost:30080/engines | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   225  100   225    0     0   1303      0 --:--:-- --:--:-- --:--:--  1308
[
  {
    "engine_id": "b1450413-a704-56d6-a95f-ea0e4bb21ada",
    "serving_model": "facebook/opt-125m",
    "created": 1747669342
  },
  {
    "engine_id": "03dc3c14-fea9-527b-a715-da92ac7ebce6",
    "serving_model": "openai-community/gpt2",
    "created": 1747669342
  }
]

b) Add a route to send a inference to a specific engine instance based on the ID returned in (a) above. The engine ID is provided using a query string:

$ curl -X POST http://localhost:30080/v1/completions?id=b1450413-a704-56d6-a95f-ea0e4bb21ada \
>   -H "Content-Type: application/json" \
>   -d '{
>     "model": "facebook/opt-125m",
>     "prompt": "The capital of France is,",
>     "max_tokens": 10
>   }' \
>   | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   488  100   385  100   103   1738    465 --:--:-- --:--:-- --:--:--  2208
{
  "id": "cmpl-8e9948646f0d45e3b26291f944430f3f",
  "object": "text_completion",
  "created": 1747669434,
  "model": "facebook/opt-125m",
  "choices": [
    {
      "index": 0,
      "text": " surprisingly, a French swim pool. Seriously, no",
      "logprobs": null,
      "finish_reason": "length",
      "stop_reason": null,
      "prompt_logprobs": null
    }
  ],
  "usage": {
    "prompt_tokens": 7,
    "total_tokens": 17,
    "completion_tokens": 10,
    "prompt_tokens_details": null
  }
}

First PR for FIX to issue #391

BEFORE SUBMITTING, PLEASE READ THE CHECKLIST BELOW AND FILL IN THE DESCRIPTION ABOVE


  • Make sure the code changes pass the pre-commit checks.
  • Sign-off your commit by using -s when doing git commit
  • Try to classify PRs for easy understanding of the type of changes, such as [Bugfix], [Feat], and [CI].
Detailed Checklist (Click to Expand)

Thank you for your contribution to production-stack! Before submitting the pull request, please ensure the PR meets the following criteria. This helps us maintain the code quality and improve the efficiency of the review process.

PR Title and Classification

Please try to classify PRs for easy understanding of the type of changes. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:

  • [Bugfix] for bug fixes.
  • [CI/Build] for build or continuous integration improvements.
  • [Doc] for documentation fixes and improvements.
  • [Feat] for new features in the cluster (e.g., autoscaling, disaggregated prefill, etc.).
  • [Router] for changes to the vllm_router (e.g., routing algorithm, router observability, etc.).
  • [Misc] for PRs that do not fit the above categories. Please use this sparingly.

Note: If the PR spans more than one category, please include all relevant prefixes.

Code Quality

The PR need to meet the following code quality standards:

  • Pass all linter checks. Please use pre-commit to format your code. See README.md for installation.
  • The code need to be well-documented to ensure future contributors can easily understand the code.
  • Please include sufficient tests to ensure the change is stay correct and robust. This includes both unit tests and integration tests.

DCO and Signed-off-by

When contributing changes to this project, you must agree to the DCO. Commits must include a Signed-off-by: header which certifies agreement with the terms of the DCO.

Using -s with git commit will automatically add this header.

What to Expect for the Reviews

We aim to address all PRs in a timely manner. If no one reviews your PR within 5 days, please @-mention one of YuhanLiu11
, Shaoting-Feng or ApostaC.

@dumb0002 dumb0002 force-pushed the sleep-aware-routing branch 2 times, most recently from 55073b2 to 9de9244 Compare May 19, 2025 16:37
@dumb0002 dumb0002 force-pushed the sleep-aware-routing branch from 0f693d4 to 9de9244 Compare May 20, 2025 04:12
@max-wittig

Copy link
Copy Markdown
Contributor

Hi! Would it be possible to add some tests to this feature?

Comment thread src/vllm_router/routers/main_router.py Outdated
existing_engines = set()
engines_cards = []
for endpoint in endpoints:
if endpoint.model_name in existing_engines:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will it be better to check endpoint.Id (engine_id) instead of model_name?
If there are multiple replicas for the same model, only one of them will be considered.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes! replaced with endpoint.Id

@YuhanLiu11

Copy link
Copy Markdown
Collaborator

@dumb0002 Thanks! This is great! can you resolve the conflict?

@dumb0002 dumb0002 force-pushed the sleep-aware-routing branch 2 times, most recently from ffe2417 to bed1529 Compare May 29, 2025 23:18
@dumb0002

Copy link
Copy Markdown
Contributor Author

@dumb0002 Thanks! This is great! can you resolve the conflict?

Done!

Signed-off-by: Braulio Dumba <Braulio.Dumba@ibm.com>
@dumb0002 dumb0002 force-pushed the sleep-aware-routing branch from bed1529 to 979d106 Compare May 30, 2025 20:02

@YuhanLiu11 YuhanLiu11 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! Thanks for your contribution!

@YuhanLiu11 YuhanLiu11 merged commit bd1a59b into vllm-project:main Jun 2, 2025
11 checks passed
JustinDuy pushed a commit to JustinDuy/production-stack-1 that referenced this pull request Jun 13, 2025
…-project#438)

Signed-off-by: Braulio Dumba <Braulio.Dumba@ibm.com>
Co-authored-by: Braulio Dumba <Braulio.Dumba@ibm.com>
davidgao7 pushed a commit to davidgao7/production-stack that referenced this pull request Jun 26, 2025
…-project#438)

Signed-off-by: Braulio Dumba <Braulio.Dumba@ibm.com>
Co-authored-by: Braulio Dumba <Braulio.Dumba@ibm.com>
Signed-off-by: David Gao <davidgao313@outlook.com>
Senne-Mennes pushed a commit to Senne-Mennes/production-stack that referenced this pull request Oct 22, 2025
…-project#438)

Signed-off-by: Braulio Dumba <Braulio.Dumba@ibm.com>
Co-authored-by: Braulio Dumba <Braulio.Dumba@ibm.com>
Signed-off-by: senne.mennes@capgemini.com <senne.mennes@capgemini.com>
emanuelecassese pushed a commit to emanuelecassese/production-stack that referenced this pull request Jan 30, 2026
…-project#438)

Signed-off-by: Braulio Dumba <Braulio.Dumba@ibm.com>
Co-authored-by: Braulio Dumba <Braulio.Dumba@ibm.com>
BadLord1st pushed a commit to BadLord1st/vllm-production-stack that referenced this pull request Feb 1, 2026
…-project#438)

Signed-off-by: Braulio Dumba <Braulio.Dumba@ibm.com>
Co-authored-by: Braulio Dumba <Braulio.Dumba@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants