Skip to content

Switch vllm_rollout endpoint /v1/completions to /inference/v1/generate - #16

Merged
aoshen02 merged 5 commits into
mainfrom
vllm-generate-endpoint
May 22, 2026
Merged

Switch vllm_rollout endpoint /v1/completions to /inference/v1/generate#16
aoshen02 merged 5 commits into
mainfrom
vllm-generate-endpoint

Conversation

@andakai

@andakai andakai commented May 19, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR switches the vLLM text-only rollout path from the OpenAI-compatible /v1/completions endpoint to the SkyRL style token-only /inference/v1/generate endpoint.

The new path tokenizes prompts on the rollout client side, sends token_ids to vLLM, and parses generated token ids and per-token logprobs directly from the /inference/v1/generate response. This also aligns the vLLM rollout behavior with the existing SGLang text-only rollout style, where the rollout client owns tokenization and the server receives token ids.

More reasons about why use inference/v1/generate instead of /v1/completions:

Changes

  • Replace text-only vLLM rollout request URL from /v1/completions to /inference/v1/generate.
  • Delete all related to /v1/completions.

Note:

This PR only targets the text-only vLLM rollout path. Multimodal rollout is not part of this change. The existing multimodal flow still uses: /v1/chat/completions/render -> /inference/v1/generate in SkyRL.

Routed experts support is currently not supported in /inference/v1/generate in v0.20.2. So please don't merge this pr currently. It is in vllm-project/vllm#39568. Once it is released in next version. I will keep doing this pr.

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

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.

Code Review

This pull request migrates the vLLM rollout implementation from the /v1/completions endpoint to the /inference/v1/generate endpoint. The changes include updating request payload construction, simplifying response parsing for tokens and logprobs, and renaming internal functions to reflect the new API. Additionally, a validation check was added to prevent the use of rollout routing replay, as it is currently unsupported. Feedback suggests refining the error message for this validation check to be more descriptive and professional.

Comment thread slime/utils/arguments.py Outdated
Comment on lines +1825 to +1827
raise ValueError(
"TODO: add https://github.com/vllm-project/vllm/pull/39568 to support rollout routing replay in /inference/v1/generate. "
)

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.

medium

The error message contains a 'TODO' and a raw URL, which is a bit informal for a user-facing ValueError. It would be better to state clearly that the feature is currently unsupported and provide the reference as a note.

Suggested change
raise ValueError(
"TODO: add https://github.com/vllm-project/vllm/pull/39568 to support rollout routing replay in /inference/v1/generate. "
)
raise ValueError(
"Rollout routing replay is not yet supported for vLLM when using the /inference/v1/generate endpoint. "
"Support is planned (see https://github.com/vllm-project/vllm/pull/39568)."
)

Comment thread slime/rollout/vllm_rollout.py Outdated
@aoshen02

Copy link
Copy Markdown
Collaborator

Please add some tests.

@andakai

andakai commented May 22, 2026

Copy link
Copy Markdown
Collaborator Author

Added a new test covered: Qwen3-0.6B, Qwen3-30B-A3B, Qwen3-30B-A3B-R3.

@andakai

andakai commented May 22, 2026

Copy link
Copy Markdown
Collaborator Author

Note that currently vllm v0.21.0 will fail at the test_qwen3_30b_a3b_r3_vllm_inference_generate_endpoint test.

@aoshen02
aoshen02 merged commit 4c74767 into main May 22, 2026
10 of 17 checks passed
aoshen02 added a commit that referenced this pull request May 26, 2026
Aligns all 5 example rollout functions to the same /inference/v1/generate
(token-in/token-out) path that slime/rollout/vllm_rollout.py:387 has used
since PR #16. Previously each example had its own ad-hoc shape: 4 of them
on /v1/completions (OpenAI completions, with `prompt` + token-id field and
parallel `logprobs.token_logprobs` / `token_ids` arrays), and the VLM
example on /v1/chat/completions (image_url message content).

Migration pattern (text token-in/out):
- POST /inference/v1/generate with {model, token_ids, sampling_params}
- Map rollout sampling params via _build_inference_sampling_params
- Parse choices[0] via _inference_generate_tokens_and_logprobs
- finish_reason is the scalar choices[0].finish_reason (no more
  meta_info.finish_reason.type wrapper)

VLM (geo3k_vlm_multi_turn): switched to canonical two-stage flow —
POST /v1/chat/completions/render to get token_ids+features, forward to
/inference/v1/generate. The example now maintains a messages list across
turns (env.format_observation already returns chat-style content with
image objects) and re-renders each turn; train-side multimodal features
are still produced locally by the HF processor.

Side effects:
- retool / search-r1: postprocess_responses (string truncation at
  </tool_call> / </code> / </answer>) was a workaround for SGLang's
  return_logprob=False path that re-tokenized truncated strings. It's
  unsound under token-precise tracking, so it's removed; both branches
  (logprobs on/off) now share the engine's token output verbatim.
- tau-bench: call_to_action_sglang stays for backward compat; docstring
  clarified that it's engine-agnostic.

Also finishes the consistent_hash / x-session-id rename inside
docs/{en,zh}/advanced/vllm-config.md — the file was renamed in 8b3d1e3
but its body still pointed at `consistent_hashing` / `X-SMG-Routing-Key`
from the SGLang-router era.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
momo609 pushed a commit that referenced this pull request May 26, 2026
#16)

* change vllm_rollout endpoint /v1/completions to /inference/v1/generate

* update with vllm latest main commit: 4f940896a32c9e2a0eba7f50d521bf5f6b4de458

* test vllm inference generate endpoint

* test config aligns with the latest main
@aoshen02
aoshen02 deleted the vllm-generate-endpoint branch June 8, 2026 14:17
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.

2 participants