diff --git a/src/transformers/generation/continuous_batching/model_runner.py b/src/transformers/generation/continuous_batching/model_runner.py index e6799724d04b..05f07ef12dd5 100644 --- a/src/transformers/generation/continuous_batching/model_runner.py +++ b/src/transformers/generation/continuous_batching/model_runner.py @@ -334,6 +334,9 @@ def run_one_warmup(self, model: nn.Module, num_q_tokens: int, max_kv_read: int | batch_data["max_length_k"][allocator.layer_type] = max_length_k io.max_length_k[allocator.layer_type] = max_length_k self.compute_batch(model, batch_data) + # The next warmup rewrites the static inputs this forward reads, so wait for it to finish + if self.inputs_and_outputs.compute_stream is not None: + self.inputs_and_outputs.compute_stream.synchronize() duration = time.perf_counter() - start logger.debug(f"Warmup completed in {duration:.2f}s")