Repository navigation
[3/N][Sync sglang-miles] TITO Support - #23751
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e02a19bc79
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for i in range(batch_size): | ||
| tmp_obj = obj[i] | ||
| state = self.rid_to_state[tmp_obj.rid] | ||
| if getattr(tmp_obj, "return_prompt_token_ids", False): |
There was a problem hiding this comment.
Preserve prompt-token-id flag in batched subrequests
This condition reads return_prompt_token_ids from tmp_obj, but in batched/parallel paths tmp_obj is produced by GenerateReqInput.__getitem__, which does not copy the new field and leaves it at the default False. That means requests with n > 1 (or true batched requests) never set state.prompt_token_ids, so prompt_token_ids is silently omitted from non-streaming chat responses even when callers set return_prompt_token_ids=true.
Useful? React with 👍 / 👎.
| # only stop tokens and tool_call_constraint are needed. | ||
| if request.input_ids is not None: | ||
| result = MessageProcessingResult( | ||
| prompt=self.tokenizer_manager.tokenizer.decode(request.input_ids), |
There was a problem hiding this comment.
Avoid tokenizer decode in pretokenized input_ids path
The pre-tokenized input_ids branch unconditionally calls self.tokenizer_manager.tokenizer.decode(...). In deployments with skip_tokenizer_init=True, the tokenizer can be None while input_ids requests are still valid, so this path crashes before generation. This breaks the new TITO flow for tokenizer-less configurations that should otherwise accept raw token IDs.
Useful? React with 👍 / 👎.
| message=ChatMessage( | ||
| role="assistant", | ||
| content=text if text else None, | ||
| content=text if text else "", |
There was a problem hiding this comment.
Not sure whether this is acceptable. Cuz many chat template will treat None as None string... It will be weird.
There was a problem hiding this comment.
Sorry my previous word is confusing. I mean whether it should be modified to ""? Cuz original impl, we insert None instead of "", then the text will be <|assistant|> None, which is weird.
|
/tag-run-ci-label |
|
|
||
| # Handle single vs multiple requests | ||
| if is_multimodal: | ||
| prompt_kwargs = {"text": processed_messages.prompt} |
There was a problem hiding this comment.
Prioritize request.input_ids here before the multimodal text branch. The input_ids path sets processed_messages.prompt to "", but this branch still sends text="" whenever model_config.is_multimodal is true, so TITO requests on multimodal model servers silently generate from an empty prompt instead of the supplied token IDs. Add an is_multimodal=True regression test for the pre-tokenized path.
There was a problem hiding this comment.
I temporarily leave the last else for the existing non-multimodal path, but do you think it's better to do a different factoring like
if request.input_ids is not None or (
not is_multimodal and not isinstance(processed_messages.prompt_ids, str)
):
to avoid the repeated prompt_kwargs = {"input_ids": processed_messages.prompt_ids}?
| message=ChatMessage( | ||
| role="assistant", | ||
| content=text if text else None, | ||
| content=text if text else "", |
JustinTong0323
left a comment
There was a problem hiding this comment.
Looks good to me.
|
/rerun-failed-ci |
Chat-side TITO is native in the 0.5.13 release, not main-only: sgl-project/sglang#23751 merged 2026-06-04 and v0.5.13 was cut 2026-06-13, so the tag contains it. Stock 0.5.13 exposes `return_prompt_token_ids` / `return_meta_info` on the request and `prompt_token_ids` / `meta_info` on each choice. No patched build or fork is required -- ProRL's `patch_sglang_0513_token_metadata.sh` only makes `logprobs=true` imply those flags, which this server sets explicitly. `transport: chat` (new default) therefore inherits everything from VLLMModel and overrides only `_attach_token_id_information`. Prompt templating, tool-call parsing, sampling params, auth and context-overflow handling all move server-side, which removes -- rather than patches -- the local-tokenizer drift, the missing Authorization header, the client-side `cap_to_context` truncation, the dropped sampling params, and the event-loop blocking of local tokenization. `transport: generate` keeps the native `/generate` path for builds that predate chat-side TITO (e.g. forks serving diffusion LLMs), with fixes: merged `chat_template_kwargs` so per-request overrides are honored, `tools` rendered into the prompt, an Authorization header, expanded sampling params plus a loud warning for ones it cannot honor, and an overflowing prompt returning a filterable empty `finish_reason="length"` instead of a head-truncated prompt. In both transports a generation SGLang reports as `finish_reason="abort"` now raises, so a server-cancelled partial rollout cannot enter a training batch looking like a normal completion. Also: `trust_remote_code` defaults to false, `transformers` is pinned and imported lazily, the cross-server import uses a plain import (matching local_vllm_model_proxy), and `cap_to_context` rejects a context too small to generate instead of POSTing a negative `max_new_tokens`. Tests are rebuilt on the vllm_model convention -- a real SGLangModel with a mocked ServerClient -- so the real inherited preprocess runs rather than being stubbed, and all patching goes through `monkeypatch` so module globals cannot leak between tests. 27 pure-logic tests pass (up from 19). The on-policy guarantee is documented as single-turn and AR-mode: under block diffusion the per-token logprob is an estimator, not the logprob of an AR draw. The obsolete vllm-vs-sglang diagnostic is dropped; its finding (the version boundary) is now stated in the README. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: linnan wang <[email protected]>
Chat-side TITO is native in the 0.5.13 release, not main-only: sgl-project/sglang#23751 merged 2026-06-04 and v0.5.13 was cut 2026-06-13, so the tag contains it. Stock 0.5.13 exposes `return_prompt_token_ids` / `return_meta_info` on the request and `prompt_token_ids` / `meta_info` on each choice. No patched build or fork is required -- ProRL's `patch_sglang_0513_token_metadata.sh` only makes `logprobs=true` imply those flags, which this server sets explicitly. `transport: chat` (new default) therefore inherits everything from VLLMModel and overrides only `_attach_token_id_information`. Prompt templating, tool-call parsing, sampling params, auth and context-overflow handling all move server-side, which removes -- rather than patches -- the local-tokenizer drift, the missing Authorization header, the client-side `cap_to_context` truncation, the dropped sampling params, and the event-loop blocking of local tokenization. `transport: generate` keeps the native `/generate` path for builds that predate chat-side TITO (e.g. forks serving diffusion LLMs), with fixes: merged `chat_template_kwargs` so per-request overrides are honored, `tools` rendered into the prompt, an Authorization header, expanded sampling params plus a loud warning for ones it cannot honor, and an overflowing prompt returning a filterable empty `finish_reason="length"` instead of a head-truncated prompt. In both transports a generation SGLang reports as `finish_reason="abort"` now raises, so a server-cancelled partial rollout cannot enter a training batch looking like a normal completion. Also: `trust_remote_code` defaults to false, `transformers` is pinned and imported lazily, the cross-server import uses a plain import (matching local_vllm_model_proxy), and `cap_to_context` rejects a context too small to generate instead of POSTing a negative `max_new_tokens`. Tests are rebuilt on the vllm_model convention -- a real SGLangModel with a mocked ServerClient -- so the real inherited preprocess runs rather than being stubbed, and all patching goes through `monkeypatch` so module globals cannot leak between tests. 27 pure-logic tests pass (up from 19). The on-policy guarantee is documented as single-turn and AR-mode: under block diffusion the per-token logprob is an estimator, not the logprob of an AR draw. The obsolete vllm-vs-sglang diagnostic is dropped; its finding (the version boundary) is now stated in the README. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: linnan wang <[email protected]>
Co-authored-by: Jiajun Li <[email protected]>
Motivation
Synced from 69018ba and 3606aec.
Modifications
input_ids.prompt_token_idsand optionalmeta_info.Accuracy Tests
Speed Tests and Profiling
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ✅ Run #26835556808
Latest PR Test (Extra): ❌ Run #26835555924