Skip to content

Conversation

@22quinn
Copy link
Collaborator

@22quinn 22quinn commented Aug 18, 2025

Purpose

Currently most RL frameworks interact with vLLM via LLM or AsyncLLM class, like the example here:

handle = llm.collective_rpc.remote(

In order for RL framework to interact with vLLM via the API server, a /collective_rpc endpoint is needed.

This endpoint accepts a json body with the following fields. For security reason, we do not handle (de-)serialization but accepts only strings.

  • method: str
  • args: list[str]
  • kwargs: dict[str, str]
  • timeout: Optional[float]

Test Plan

PYTHONPATH="/data/users/user/gitrepos/vllm" pytest tests/entrypoints/openai/test_collective_rpc.py

Test Result

  • test_get_model_name passed
  • test_return_none passed
  • test_echo_args_kwargs passed

(Optional) Documentation Update


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
@github-actions
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@mergify mergify bot added the frontend label Aug 18, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new /collective_rpc API endpoint. The changes include adding an abstract collective_rpc method to the EngineClient protocol and implementing the corresponding endpoint in the API server.

My review has identified a few issues:

  1. A critical issue where the new abstract method collective_rpc appears to be unimplemented in the concrete engine classes provided in the context, which would lead to runtime errors.
  2. A high-severity issue in the API endpoint implementation related to unsafe access to the request body, which could cause unhandled exceptions.
  3. Another high-severity issue with how the results from the RPC call are serialized into the JSON response, which would lead to incorrect output for structured data.

Please see the detailed comments for suggestions on how to address these points.

elif isinstance(result, pydantic.BaseModel):
response.append(result.model_dump())
else:
response.append(str(result))
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Using str(result) for serialization is problematic for structured data types like dictionaries or lists. It converts them into a string representation (e.g., "{'a': 1}") instead of a proper JSON object. This can lead to unexpected behavior on the client side. It's better to append the result directly and let JSONResponse handle the serialization. This will correctly serialize JSON-compatible types and raise an error for non-serializable types, which is more explicit.

Suggested change
response.append(str(result))
response.append(result)

Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
@22quinn 22quinn added the rl Related to RL workflows label Aug 18, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
@mgoin
Copy link
Member

mgoin commented Aug 18, 2025

I think we should make the /collective_rpc endpoint only added if a CLI argument is set. I worry about the concern of security-conscious users seeing an "rpc" endpoint by default. Then we could also expand the support of the endpoint if it is opt-in

@22quinn
Copy link
Collaborator Author

22quinn commented Aug 18, 2025

I think we should make the /collective_rpc endpoint only added if a CLI argument is set. I worry about the concern of security-conscious users seeing an "rpc" endpoint by default. Then we could also expand the support of the endpoint if it is opt-in

This endpoint is currently gated behind VLLM_SERVER_DEV_MODE=1, similar to /reset_prefix_cache, /sleep, /wake_up. What kind of extra support you're thinking of?

@mgoin
Copy link
Member

mgoin commented Aug 18, 2025

Ah I wasn't aware of that gate, that sounds sufficient to me.

Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
@22quinn 22quinn requested a review from youkaichao August 18, 2025 20:50
@22quinn 22quinn marked this pull request as ready for review August 18, 2025 20:51
Copy link
Member

@DarkLight1337 DarkLight1337 left a comment

Choose a reason for hiding this comment

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

LGTM

@DarkLight1337
Copy link
Member

Please fix the failing tests though

Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
@mergify mergify bot added the ci/build label Aug 19, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
@22quinn 22quinn added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 19, 2025
@DarkLight1337 DarkLight1337 enabled auto-merge (squash) August 19, 2025 09:21
@22quinn
Copy link
Collaborator Author

22quinn commented Aug 19, 2025

@DarkLight1337 The full version of entrypoints-test-api-server passed (only the fastcheck version failed) before your rebase. Same goes for openai-api-correctness. Probably safe to force merge?

@DarkLight1337
Copy link
Member

I'll just retry the tests

@DarkLight1337 DarkLight1337 merged commit f7cf5b5 into vllm-project:main Aug 19, 2025
71 checks passed
princepride pushed a commit to princepride/vllm that referenced this pull request Aug 20, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
divakar-amd pushed a commit to divakar-amd/vllm_upstream that referenced this pull request Aug 20, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
cyang49 pushed a commit to cyang49/vllm that referenced this pull request Aug 20, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
djmmoss pushed a commit to djmmoss/vllm that referenced this pull request Aug 21, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
Signed-off-by: Duncan Moss <djm.moss@gmail.com>
epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
xiao-llm pushed a commit to xiao-llm/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
Signed-off-by: Xiao Yu <xiao.yu@amd.com>
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
mengxingkongzhouhan pushed a commit to mengxingkongzhouhan/vllm that referenced this pull request Aug 30, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Sep 3, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
FeiDaLI pushed a commit to FeiDaLI/vllm that referenced this pull request Sep 25, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
@22quinn 22quinn deleted the http-rpc branch November 16, 2025 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/build frontend ready ONLY add when PR is ready to merge/full CI is needed rl Related to RL workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants