[OpenAI] Propagate PD routing metadata through /v1/responses (#35503)

This commit is contained in:
Jeremy Zhang
2026-09-12 01:33:38 +08:00
committed by GitHub
parent ddf02a4f58
commit f69d6fc28a
4 changed files with 73 additions and 2 deletions
@@ -1652,6 +1652,18 @@ class ResponsesRequest(BaseModel):
default=None, description="Cache salt for request caching"
)
# For PD disaggregation
bootstrap_host: Optional[Union[List[str], str]] = None
bootstrap_port: Optional[Union[List[Optional[int]], int]] = None
bootstrap_room: Optional[Union[List[int], int]] = None
# For DP routing — external router assigns a specific DP worker
routed_dp_rank: Optional[int] = None
# For PD disagg — hint telling decode which prefill DP worker has the KV cache
disagg_prefill_dp_rank: Optional[int] = None
# Deprecated: use routed_dp_rank instead
data_parallel_rank: Optional[int] = None
# SGLang sampling extras. ``None`` defers to ``--preferred-sampling-params``.
frequency_penalty: float = 0.0
presence_penalty: float = 0.0
@@ -1669,6 +1681,11 @@ class ResponsesRequest(BaseModel):
"repetition_penalty": 1.0,
}
@model_validator(mode="before")
@classmethod
def _handle_deprecated_dp_rank(cls, values):
return _migrate_deprecated_dp_rank(values)
@model_validator(mode="before")
@classmethod
def normalize_reasoning_to_thinking(cls, values):
@@ -435,6 +435,10 @@ class OpenAIServingResponses(OpenAIServingChat):
else {}
)
effective_routed_dp_rank = self.extract_routed_dp_rank_from_header(
raw_request, request.routed_dp_rank
)
adapted_request = GenerateReqInput(
**prompt_kwargs,
**logprob_kwargs,
@@ -464,6 +468,11 @@ class OpenAIServingResponses(OpenAIServingChat):
session_id=request.session_id,
extra_key=request.extra_key,
cache_salt=request.cache_salt,
bootstrap_host=request.bootstrap_host,
bootstrap_port=request.bootstrap_port,
bootstrap_room=request.bootstrap_room,
routed_dp_rank=effective_routed_dp_rank,
disagg_prefill_dp_rank=request.disagg_prefill_dp_rank,
# background+stream streams on this connection, so don't detach.
background=request.background and not request.stream,
require_reasoning=require_reasoning,