[bugfix] fix TBO crashes when attn_tp_size > 1 (#13730)

Co-authored-by: Cheng Wan <54331508+ch-wan@users.noreply.github.com>
This commit is contained in:
Yuhao Yao
2025-12-12 10:18:40 +08:00
committed by GitHub
parent 0aa3dec5c7
commit e9e7f15eb5
20 changed files with 285 additions and 16 deletions

View File

@@ -376,6 +376,7 @@ class ForwardBatch:
# For two-batch overlap
tbo_split_seq_index: Optional[int] = None
tbo_parent_token_range: Optional[Tuple[int, int]] = None
tbo_padded_len: Optional[int] = None
tbo_children: Optional[List[ForwardBatch]] = None
# For matryoshka embeddings
@@ -852,6 +853,14 @@ class ForwardBatch:
TboForwardBatchPreparer.prepare(
batch=self, is_draft_worker=model_runner.is_draft_worker
)
# TODO: The following is added to make sure sub-batch input_ids are padded
# to the multiple of attn_tp_size. It can likely be removed after this
# function is refactored and merged into the Scheduler.
if self.tbo_children:
for child in self.tbo_children:
child._pad_inputs_to_size(
model_runner, child.tbo_padded_len, child.batch_size
)
def _pad_inputs_to_size(self, model_runner: ModelRunner, num_tokens, bs):
# padding