Skip to content

Fix: Add None check in step_with_batch_queue for async scheduling#31600

Closed
ricky-chaoju wants to merge 1 commit intovllm-project:mainfrom
ricky-chaoju:fix/v1-engine-batch-queue-none-check
Closed

Fix: Add None check in step_with_batch_queue for async scheduling#31600
ricky-chaoju wants to merge 1 commit intovllm-project:mainfrom
ricky-chaoju:fix/v1-engine-batch-queue-none-check

Conversation

@ricky-chaoju
Copy link
Copy Markdown
Contributor

@ricky-chaoju ricky-chaoju commented Jan 1, 2026

Summary

Fix AttributeError: 'NoneType' object has no attribute 'sampled_token_ids' crash in V1 engine when async scheduling is enabled (default).

Root Cause

In step_with_batch_queue() method, execute_model() can return None to signal async scheduling, but there was no None check before passing model_output to scheduler.update_from_output().

The step() method already handles this correctly (line 364-366), but step_with_batch_queue() was missing the same check.

Fix

Added None check in step_with_batch_queue() to call sample_tokens() when model_output is None, mirroring the existing pattern in step().

Environment

  • GPU: NVIDIA GB10 (SM 12.1 / Blackwell)
  • PyTorch: 2.9.1+cu130

Relates to: #31588

@mergify mergify bot added the v1 label Jan 1, 2026
Copy link
Copy Markdown
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 addresses a critical AttributeError that occurs when using asynchronous scheduling. The root cause, a missing None check for the result of execute_model in step_with_batch_queue, has been accurately identified. The fix, which involves adding a None check and calling sample_tokens to generate a valid model output, mirrors the existing logic in the step method and is a robust solution to prevent the crash. The implementation is clean, concise, and directly resolves the reported issue.

@ricky-chaoju ricky-chaoju marked this pull request as ready for review January 1, 2026 06:06
- Handle None return from execute_model() in step_with_batch_queue()
- Mirrors existing pattern in step() method
- Fixes AttributeError: 'NoneType' object has no attribute 'sampled_token_ids'
- Affects V1 engine with async scheduling enabled (default)

Relates to: vllm-project#31588

Signed-off-by: vllm-dev <ricky.chen@infinirc.com>
@ricky-chaoju ricky-chaoju force-pushed the fix/v1-engine-batch-queue-none-check branch from 1c84725 to 68825b6 Compare January 1, 2026 06:10
@njhill
Copy link
Copy Markdown
Member

njhill commented Jan 2, 2026

Thanks @rickychen-infinirc. But this should only ever happen as a secondary error after the execute_model method already raised an exception. Please share the whole log, you should see an earlier root cause error/traceback.

I agree that this is still a bug though since the secondary error is misleading. I've opened #31611 to address this.

@njhill
Copy link
Copy Markdown
Member

njhill commented Jan 4, 2026

Closing now that #31611 is merged.

@njhill njhill closed this Jan 4, 2026
@ricky-chaoju ricky-chaoju deleted the fix/v1-engine-batch-queue-none-check branch January 5, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants