Skip to content

KVOutputAggregator: Fix handling of empty output#22899

Closed
orozery wants to merge 0 commit intovllm-project:mainfrom
orozery:empty-kv-connector-output-bug
Closed

KVOutputAggregator: Fix handling of empty output#22899
orozery wants to merge 0 commit intovllm-project:mainfrom
orozery:empty-kv-connector-output-bug

Conversation

@orozery
Copy link
Collaborator

@orozery orozery commented Aug 14, 2025

This PR fixes KVOutputAggregator to correctly handle the case where ModelRunnerOutput.kv_connector_output is None.

Example trace of bug when loading a single request from KV connector, which yields EmptyModelRunnerOutput for a couple of engine steps:

(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701] EngineCore encountered a fatal error.
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701] Traceback (most recent call last):
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]   File "/workspace/vllm/vllm/v1/engine/core.py", line 692, in run_engine_core
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]     engine_core.run_busy_loop()
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]   File "/workspace/vllm/vllm/v1/engine/core.py", line 719, in run_busy_loop
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]     self._process_engine_step()
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]   File "/workspace/vllm/vllm/v1/engine/core.py", line 744, in _process_engine_step
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]     outputs, model_executed = self.step_fn()
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]                               ^^^^^^^^^^^^^^
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]   File "/workspace/vllm/vllm/v1/engine/core.py", line 288, in step
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]     model_output = self.execute_model_with_error_logging(
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]   File "/workspace/vllm/vllm/v1/engine/core.py", line 274, in execute_model_with_error_logging
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]     raise err
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]   File "/workspace/vllm/vllm/v1/engine/core.py", line 265, in execute_model_with_error_logging
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]     return model_fn(scheduler_output)
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]            ^^^^^^^^^^^^^^^^^^^^^^^^^^
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]   File "/workspace/vllm/vllm/v1/executor/multiproc_executor.py", line 192, in execute_model
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]     return self.kv_output_aggregator.aggregate(outputs, self.output_rank)
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]   File "/workspace/vllm/vllm/distributed/kv_transfer/kv_connector/utils.py", line 146, in aggregate
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]     update_finished_set(output.finished_sending,
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701]                         ^^^^^^^^^^^^^^^^^^^^^^^
(EngineCore_0 pid=75768) ERROR 08-14 08:46:12 [core.py:701] AttributeError: 'NoneType' object has no attribute 'finished_sending'

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes a critical AttributeError in KVOutputAggregator when kv_connector_output is None. The added check is a good solution. However, I found another critical issue in the same aggregate method: it will crash with an IndexError if the input outputs list is empty. This can occur if async_aggregate receives an empty list of futures. Since the goal is to handle empty outputs robustly, I strongly recommend adding a check for an empty outputs list at the start of the aggregate method. As this is outside the changed lines, I'm mentioning it in this general feedback.

@github-actions
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@orozery
Copy link
Collaborator Author

orozery commented Aug 14, 2025

@njhill

@orozery orozery closed this Aug 14, 2025
@orozery orozery force-pushed the empty-kv-connector-output-bug branch from 0e14e86 to 540d54c Compare August 14, 2025 13:31
@orozery
Copy link
Collaborator Author

orozery commented Aug 14, 2025

Already fixed in #22663

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant