Repository navigation
feat: per-model client-side renderers for RL rollouts (+ /v1/generate) #2278
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
Changes from 12 commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
ab9dc79
feat: add renderers support for RL — rendering proxy + /v1/generate e…
hallerite 63b61e9
feat: remove token-client training path
hallerite b489632
fix: restore serving chat type imports
hallerite f34982a
feat: forward lora adapters through generate
hallerite 600348b
fix: preserve renderer proxy client routing
hallerite 82e929b
fix: restore external rollout model routing
hallerite 82fcbeb
refactor: use direct renderer rollout clients
hallerite 4efa271
feat: add new renderer options to config docstring
hallerite 7a7dcc6
fix: point verifiers dep at renderers branch instead of local path
hallerite 84c3852
merge: origin/main into hallerite/renderers-v2
hallerite d1506f5
chore: remove debug smoke configs
hallerite b532428
fix: remove old TITO endpoint, fix merge import gaps
hallerite 67ffcb5
refactor: remove OpenAIServingChatWithRoutedExperts
hallerite c26a0ae
merge: origin/main into hallerite/renderers-v2
hallerite 753d616
fix: update tests for new train/eval client type split
hallerite 9f84ce3
feat: default train_client_type to renderer
hallerite 920f381
fix: elastic test uses train_clients instead of removed clients property
hallerite 208a9b3
chore: pin verifiers renderer revision
hallerite bcbdbb3
Merge remote-tracking branch 'origin/main' into hallerite/renderers-v2
hallerite 55d44d0
chore: bump verifiers to c4e50e4 (Qwen3-VL image-pad fix)
hallerite e9cb682
chore: bump verifiers to 2d8cc29 (trainer/vLLM image-pad fix)
hallerite e781e9c
fix(vlm): expand <|image_pad|> in trainer samples in sync with parall…
hallerite 160d4c9
refactor(vlm): model-agnostic image-pad expansion + overlap preproces…
hallerite 03865c6
feat(vlm): route VLMs to MITO, keep renderers for plain LMs
hallerite fd9d0f5
chore(orchestrator): bump verifiers to pool-size-1 default
hallerite ca3dcdd
perf(serving_generate): stop polling is_disconnected per decode step
hallerite 5093054
fix(serving_generate): default max_tokens to context room, not 4096
hallerite 9cf49b0
fix(serving_generate): use engine model_config attr, not async getter
hallerite b1843b4
refactor(renderer): drop VLM residue from renderer path
hallerite d54ff30
fix(serving_generate): use TokensInput shape to silence vLLM deprecation
hallerite 05a3516
feat(config): pluggable tool_parser / reasoning_parser
hallerite 10d3d98
feat(config): expose model.renderer_pool_size
hallerite fcaa834
chore: bump verifiers to f47ba32 (gated synthesize-close bridge)
hallerite 858aa45
chore: bump verifiers to fb6ecb9 (bridge anchor fix + synth-close knob)
hallerite cd56374
chore: bump verifiers to 891da50 (per-renderer bridge_to_next_turn)
hallerite c06a0af
chore: bump verifiers to 9020f70 (kimi/gpt-oss parse fixes + wider ro…
hallerite 6e99c2e
chore: bump verifiers to 7d2f7f7 (full render parity across the matrix)
hallerite 4aee0c6
chore: bump verifiers to 6f89c38 (hand-coded per-renderer bridges)
hallerite 62946a7
fix(serving_generate): plumb cache_salt through /v1/generate
hallerite 67f9e54
chore: bump verifiers to c499099 (cache_salt forwarding on /v1/generate)
hallerite 889d15e
chore: bump verifiers to fafea87 (exact-name model→renderer map)
hallerite 7bbf985
fix(ring_attn): adapt FA3 varlen wrappers to flash_attn_3 3.0.0 kwargs
hallerite e099a9f
chore: bump verifiers to c58da4a
hallerite 9641871
chore: bump verifiers to 7136de5
hallerite 8e7b68f
chore: bump verifiers to 7b86d14 (merge of main into renderers)
hallerite 3ba3dcd
[fix] patch gdn with varlen for qwen (#2346)
Jackmin801 8089985
chore(deps): bump verifiers to 17358ee
hallerite 01f9453
chore(inference): restore /v1/chat/completions/tokens (TITO) alongsid…
hallerite 5d96a3e
Merge origin/main into hallerite/renderers-v2 + add use_renderer toggle
hallerite 515c48f
chore(orchestrator): cleanup-review fixes + bump verifiers
hallerite c61d842
chore(deps): bump verifiers to ee6cdb5
hallerite 519f61e
chore(deps): bump verifiers to b7dd85f (renderers merged to main)
hallerite 76c8590
test(orchestrator): set use_renderer/tool_parser/reasoning_parser/ren…
hallerite 540500d
revert: restore docs/on_policy_distillation.md and skills/entrypoints…
hallerite 717c6e0
address reviews
hallerite 5b6f42b
fix(config): drop orphan renderer fields from SharedModelConfig
hallerite d5ea636
fix(server): validate /v1/generate body via FastAPI
hallerite c97ecfd
style: ruff isort
hallerite 3ece39f
Merge remote-tracking branch 'origin/main' into hallerite/renderers-v2
hallerite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/prime_rl/inference/vllm/serving_chat_with_routed_experts.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import base64 | ||
| from collections.abc import AsyncGenerator, AsyncIterator | ||
|
|
||
| import numpy as np | ||
| from vllm.entrypoints.openai.chat_completion.protocol import ChatCompletionRequest, ChatCompletionResponse | ||
| from vllm.entrypoints.openai.chat_completion.serving import OpenAIServingChat | ||
| from vllm.entrypoints.openai.engine.protocol import ErrorResponse, RequestResponseMetadata | ||
| from vllm.logger import init_logger | ||
| from vllm.outputs import RequestOutput | ||
| from vllm.reasoning import ReasoningParser | ||
|
|
||
| logger = init_logger(__name__) | ||
|
|
||
|
|
||
| class _RoutedExpertsCapture: | ||
| def __init__(self, generator: AsyncGenerator[RequestOutput, None]): | ||
| self._generator = generator | ||
| self.routed_experts: dict[int, dict] = {} | ||
|
|
||
| def _encode_routed_experts(self, arr: np.ndarray) -> dict: | ||
| return { | ||
| "data": base64.b85encode(arr.tobytes()).decode("ascii"), | ||
| "shape": list(arr.shape), | ||
| } | ||
|
|
||
| async def __aiter__(self): | ||
| async for request_output in self._generator: | ||
| for output in request_output.outputs: | ||
| if output.routed_experts is not None: | ||
| self.routed_experts[output.index] = self._encode_routed_experts(output.routed_experts) | ||
| yield request_output | ||
|
|
||
| def post_process(self, response: ChatCompletionResponse): | ||
| for choice in response.choices: | ||
| if choice.index in self.routed_experts: | ||
| choice.routed_experts = self.routed_experts[choice.index] | ||
|
|
||
|
|
||
| class OpenAIServingChatWithRoutedExperts(OpenAIServingChat): | ||
| """OpenAI chat serving wrapper that preserves routed expert metadata.""" | ||
|
|
||
| async def chat_completion_full_generator( | ||
| self, | ||
| request: ChatCompletionRequest, | ||
| result_generator: AsyncIterator[RequestOutput], | ||
| request_id: str, | ||
| model_name: str, | ||
| conversation, | ||
| tokenizer, | ||
| request_metadata: RequestResponseMetadata, | ||
| reasoning_parser: ReasoningParser | None = None, | ||
| ) -> ErrorResponse | ChatCompletionResponse: | ||
| if self.model_config.enable_return_routed_experts: | ||
| capture = _RoutedExpertsCapture(result_generator) | ||
| result_generator = capture | ||
| else: | ||
| capture = None | ||
|
|
||
| response = await super().chat_completion_full_generator( | ||
| request, | ||
| result_generator, | ||
| request_id, | ||
| model_name, | ||
| conversation, | ||
| tokenizer, | ||
| request_metadata, | ||
| reasoning_parser, | ||
| ) | ||
|
|
||
| if capture and isinstance(response, ChatCompletionResponse): | ||
| capture.post_process(response) | ||
|
|
||
| return response |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this function ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's just FastAPI-style Dependency Injection, same as
chat_with_tokens()