fix(io_struct): index extra_key per sub-request in batched GenerateReqInput (#26971)

This commit is contained in:
Humphrey
2026-06-14 00:50:38 -07:00
committed by GitHub
parent 1456eb612d
commit 8c334e2224
2 changed files with 68 additions and 1 deletions
+17 -1
View File
@@ -428,6 +428,7 @@ class GenerateReqInput(BaseReq):
self._normalize_sampling_params(num)
self._normalize_logprob_params(num)
self._normalize_custom_logit_processor(num)
self._normalize_extra_key(num)
self._normalize_bootstrap_params(num)
def _expand_inputs(self, num):
@@ -597,6 +598,21 @@ class GenerateReqInput(BaseReq):
"Cannot use list custom_logit_processor with parallel_sample_num > 1"
)
def _normalize_extra_key(self, num):
"""Normalize extra_key for batch processing."""
if self.extra_key is None:
return
if isinstance(self.extra_key, str):
self.extra_key = [self.extra_key] * num
elif isinstance(self.extra_key, list):
if len(self.extra_key) != self.batch_size:
raise ValueError(
"The length of extra_key should be equal to the batch size."
)
self.extra_key = self.extra_key * self.parallel_sample_num
else:
raise ValueError("extra_key should be a list or a string.")
def _normalize_bootstrap_params(self, num):
"""Normalize bootstrap parameters for batch processing."""
# Normalize bootstrap_host
@@ -713,7 +729,7 @@ class GenerateReqInput(BaseReq):
disagg_prefill_dp_rank=self.disagg_prefill_dp_rank,
conversation_id=self.conversation_id,
priority=self.priority,
extra_key=self.extra_key,
extra_key=self.extra_key[i] if self.extra_key is not None else None,
no_logs=self.no_logs,
custom_labels=self.custom_labels,
return_bytes=self.return_bytes,