@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 0037b5746a
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 12, 06:00 UTC

[Core] Eliminate redundant is_encoder_decoder lookups (20-40us/step) (#29800)

Signed-off-by: Wushi Dong <dongws@meta.com>

Wushi Dong committed Dec 1, 2025 at 23:08 UTC 0037b5746a4319c851eed2bc0b24912e179a851c
1 file changed +3 -9
vllm/v1/worker/gpu_model_runner.py
+3 -9
@@ -2439,16 +2439,13 @@ class GPUModelRunner(
2439 ]:
2440 num_scheduled_tokens = scheduler_output.total_num_scheduled_tokens
2441 is_first_rank = get_pp_group().is_first_rank
2442 + is_encoder_decoder = self.model_config.is_encoder_decoder
2443
2444 # _prepare_inputs may reorder the batch, so we must gather multi
2445 # modal outputs after that to ensure the correct order
2446 ec_connector_output = None
2447
2447 - if (
2448 - self.supports_mm_inputs
2449 - and is_first_rank
2450 - and not self.model_config.is_encoder_decoder
2451 - ):
2448 + if self.supports_mm_inputs and is_first_rank and not is_encoder_decoder:
2449 # Run the multimodal encoder if any.
2450 with self.maybe_get_ec_connector_output(
2451 scheduler_output,
@@ -2526,10 +2523,7 @@ class GPUModelRunner(
2523 num_input_tokens, intermediate_tensors, True
2524 )
2525
2529 - if (
2530 - self.model_config.is_encoder_decoder
2531 - and scheduler_output.scheduled_encoder_inputs
2532 - ):
2526 + if is_encoder_decoder and scheduler_output.scheduled_encoder_inputs:
2527 # Run the encoder, just like we do with other multimodal inputs.
2528 # For an encoder-decoder model, our processing here is a bit
2529 # simpler, because the outputs are just passed to the decoder.