Skip to content

[BugFix][Graph] fix: handle empty sym_shape_indices in PiecewiseBackend.#39395

Merged
ProExpertProg merged 3 commits into
vllm-project:mainfrom
chaunceyjiang:fix/piecewise-backend-sym-shape_indices-empty-handling
Apr 15, 2026
Merged

[BugFix][Graph] fix: handle empty sym_shape_indices in PiecewiseBackend.#39395
ProExpertProg merged 3 commits into
vllm-project:mainfrom
chaunceyjiang:fix/piecewise-backend-sym-shape_indices-empty-handling

Conversation

@chaunceyjiang
Copy link
Copy Markdown
Collaborator

@chaunceyjiang chaunceyjiang commented Apr 9, 2026

Purpose

FIx #39341

Test Plan

generating_prompts = [prefix + prompt for prompt in prompts]
llm = LLM(
    model="/mnt/data4/models/Qwen/Qwen3-0.6B",
    max_model_len=512,
    max_num_batched_tokens=1,
)
sampling_params = SamplingParams(temperature=0, top_p=0.95, max_tokens=10)

outputs = llm.generate(generating_prompts, sampling_params)
print(outputs)

Test Result

[RequestOutput(request_id=0, prompt="You are an expert school principal, skilled in effectively managing faculty and staff. Draft 10-15 questions for a potential first grade Head Teacher for my K-12, all-girls', independent school that emphasizes community, joyful discovery, and life-long learning. The candidate is coming in for a first-round panel interview for a 8th grade Math teaching role. They have 5 years of previous teaching experience as an assistant teacher at a co-ed, public school with experience in middle school math teaching. Based on these information, fulfill the following paragraph: Hello, my name is", prompt_token_ids=[2610, 525, 458, 6203, 2906, 12435, 11, 25530, 304, 13444, 18150, 21564, 323, 5570, 13, 28564, 220, 16, 15, 12, 16, 20, 4755, 369, 264, 4650, 1156, 11972, 11203, 29069, 369, 847, 730, 12, 16, 17, 11, 678, 62870, 82, 516, 9489, 2906, 429, 65059, 3942, 11, 82112, 18335, 11, 323, 2272, 23791, 6832, 13, 576, 9144, 374, 5001, 304, 369, 264, 1156, 21015, 6945, 7128, 369, 264, 220, 23, 339, 11972, 4149, 12629, 3476, 13, 2379, 614, 220, 20, 1635, 315, 3681, 12629, 3139, 438, 458, 17847, 11079, 518, 264, 1062, 34435, 11, 584, 2906, 448, 3139, 304, 6149, 2906, 6888, 12629, 13, 20205, 389, 1493, 1995, 11, 20423, 279, 2701, 14311, 25, 21927, 11, 847, 829, 374], encoder_prompt=None, encoder_prompt_token_ids=None, prompt_logprobs=None, outputs=[CompletionOutput(index=0, text=' [Name], and I am a [Position]', token_ids=[508, 675, 1125, 323, 358, 1079, 264, 508, 3812, 60], routed_experts=None, cumulative_logprob=None, logprobs=None, finish_reason=length, stop_reason=None)], finished=True, metrics=None, lora_request=None, num_cached_tokens=0), RequestOutput(request_id=1, prompt="You are an expert school principal, skilled in effectively managing faculty and staff. Draft 10-15 questions for a potential first grade Head Teacher for my K-12, all-girls', independent school that emphasizes community, joyful discovery, and life-long learning. The candidate is coming in for a first-round panel interview for a 8th grade Math teaching role. They have 5 years of previous teaching experience as an assistant teacher at a co-ed, public school with experience in middle school math teaching. Based on these information, fulfill the following paragraph: The president of the United States is", prompt_token_ids=[2610, 525, 458, 6203, 2906, 12435, 11, 25530, 304, 13444, 18150, 21564, 323, 5570, 13, 28564, 220, 16, 15, 12, 16, 20, 4755, 369, 264, 4650, 1156, 11972, 11203, 29069, 369, 847, 730, 12, 16, 17, 11, 678, 62870, 82, 516, 9489, 2906, 429, 65059, 3942, 11, 82112, 18335, 11, 323, 2272, 23791, 6832, 13, 576, 9144, 374, 5001, 304, 369, 264, 1156, 21015, 6945, 7128, 369, 264, 220, 23, 339, 11972, 4149, 12629, 3476, 13, 2379, 614, 220, 20, 1635, 315, 3681, 12629, 3139, 438, 458, 17847, 11079, 518, 264, 1062, 34435, 11, 584, 2906, 448, 3139, 304, 6149, 2906, 6888, 12629, 13, 20205, 389, 1493, 1995, 11, 20423, 279, 2701, 14311, 25, 576, 4767, 315, 279, 3639, 4180, 374], encoder_prompt=None, encoder_prompt_token_ids=None, prompt_logprobs=None, outputs=[CompletionOutput(index=0, text=' a woman, and the president is a woman.', token_ids=[264, 5220, 11, 323, 279, 4767, 374, 264, 5220, 13], routed_experts=None, cumulative_logprob=None, logprobs=None, finish_reason=length, stop_reason=None)], finished=True, metrics=None, lora_request=None, num_cached_tokens=112), RequestOutput(request_id=2, prompt="You are an expert school principal, skilled in effectively managing faculty and staff. Draft 10-15 questions for a potential first grade Head Teacher for my K-12, all-girls', independent school that emphasizes community, joyful discovery, and life-long learning. The candidate is coming in for a first-round panel interview for a 8th grade Math teaching role. They have 5 years of previous teaching experience as an assistant teacher at a co-ed, public school with experience in middle school math teaching. Based on these information, fulfill the following paragraph: The capital of France is", prompt_token_ids=[2610, 525, 458, 6203, 2906, 12435, 11, 25530, 304, 13444, 18150, 21564, 323, 5570, 13, 28564, 220, 16, 15, 12, 16, 20, 4755, 369, 264, 4650, 1156, 11972, 11203, 29069, 369, 847, 730, 12, 16, 17, 11, 678, 62870, 82, 516, 9489, 2906, 429, 65059, 3942, 11, 82112, 18335, 11, 323, 2272, 23791, 6832, 13, 576, 9144, 374, 5001, 304, 369, 264, 1156, 21015, 6945, 7128, 369, 264, 220, 23, 339, 11972, 4149, 12629, 3476, 13, 2379, 614, 220, 20, 1635, 315, 3681, 12629, 3139, 438, 458, 17847, 11079, 518, 264, 1062, 34435, 11, 584, 2906, 448, 3139, 304, 6149, 2906, 6888, 12629, 13, 20205, 389, 1493, 1995, 11, 20423, 279, 2701, 14311, 25, 576, 6722, 315, 9625, 374], encoder_prompt=None, encoder_prompt_token_ids=None, prompt_logprobs=None, outputs=[CompletionOutput(index=0, text=' Paris, and the capital of Italy is Rome.', token_ids=[12095, 11, 323, 279, 6722, 315, 15344, 374, 21718, 13], routed_experts=None, cumulative_logprob=None, logprobs=None, finish_reason=length, stop_reason=None)], finished=True, metrics=None, lora_request=None, num_cached_tokens=112), RequestOutput(request_id=3, prompt="You are an expert school principal, skilled in effectively managing faculty and staff. Draft 10-15 questions for a potential first grade Head Teacher for my K-12, all-girls', independent school that emphasizes community, joyful discovery, and life-long learning. The candidate is coming in for a first-round panel interview for a 8th grade Math teaching role. They have 5 years of previous teaching experience as an assistant teacher at a co-ed, public school with experience in middle school math teaching. Based on these information, fulfill the following paragraph: The future of AI is", prompt_token_ids=[2610, 525, 458, 6203, 2906, 12435, 11, 25530, 304, 13444, 18150, 21564, 323, 5570, 13, 28564, 220, 16, 15, 12, 16, 20, 4755, 369, 264, 4650, 1156, 11972, 11203, 29069, 369, 847, 730, 12, 16, 17, 11, 678, 62870, 82, 516, 9489, 2906, 429, 65059, 3942, 11, 82112, 18335, 11, 323, 2272, 23791, 6832, 13, 576, 9144, 374, 5001, 304, 369, 264, 1156, 21015, 6945, 7128, 369, 264, 220, 23, 339, 11972, 4149, 12629, 3476, 13, 2379, 614, 220, 20, 1635, 315, 3681, 12629, 3139, 438, 458, 17847, 11079, 518, 264, 1062, 34435, 11, 584, 2906, 448, 3139, 304, 6149, 2906, 6888, 12629, 13, 20205, 389, 1493, 1995, 11, 20423, 279, 2701, 14311, 25, 576, 3853, 315, 15235, 374], encoder_prompt=None, encoder_prompt_token_ids=None, prompt_logprobs=None, outputs=[CompletionOutput(index=0, text=' not just about the technology itself, but about how', token_ids=[537, 1101, 911, 279, 5440, 5086, 11, 714, 911, 1246], routed_experts=None, cumulative_logprob=None, logprobs=None, finish_reason=length, stop_reason=None)], finished=True, metrics=None, lora_request=None, num_cached_tokens=112)]

Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

@mergify mergify Bot added the bug Something isn't working label Apr 9, 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 modifies the __call__ method in vllm/compilation/piecewise_backend.py to introduce conditional logic. It now differentiates between dynamic and static input shapes based on self.sym_shape_indices. For static shapes, the method directly retrieves the first compiled range_entry from self.range_entries rather than attempting to derive a runtime shape from the arguments. This change improves the backend's flexibility to handle both dynamic and static input shape scenarios. There is no feedback to provide.

@chaunceyjiang
Copy link
Copy Markdown
Collaborator Author

/cc @ProExpertProg @zou3519 PTAL.

@DarkLight1337
Copy link
Copy Markdown
Member

Can you add a regression test?

@chaunceyjiang
Copy link
Copy Markdown
Collaborator Author

Can you add a regression test?

Done.

@youkaichao
Copy link
Copy Markdown
Member

cc @zou3519 is it possible to ask Dynamo just not to specialize on the size 1? I feel ideally this should be fixed by Dynamo.

@ProExpertProg
Copy link
Copy Markdown
Collaborator

cc @zou3519 is it possible to ask Dynamo just not to specialize on the size 1? I feel ideally this should be fixed by Dynamo.

I think this is possible with unbacked ints. @laithsakka is working on this I believe - faith anything to add?

@ProExpertProg ProExpertProg added the ready ONLY add when PR is ready to merge/full CI is needed label Apr 13, 2026
@ProExpertProg
Copy link
Copy Markdown
Collaborator

Richard is away this week but it'd be good to wait for @laithsakka or @BoyuanFeng to take a look before merging

Comment thread vllm/compilation/piecewise_backend.py Outdated
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
@chaunceyjiang chaunceyjiang force-pushed the fix/piecewise-backend-sym-shape_indices-empty-handling branch from 4600a06 to fc20832 Compare April 14, 2026 02:51
@ProExpertProg ProExpertProg merged commit db8d4a4 into vllm-project:main Apr 15, 2026
59 checks passed
Natfii pushed a commit to Navi-AI-Lab/nvllm that referenced this pull request Apr 17, 2026
…nd. (vllm-project#39395)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
(cherry picked from commit db8d4a4)
Natfii pushed a commit to Navi-AI-Lab/nvllm that referenced this pull request Apr 17, 2026
…nd. (vllm-project#39395)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
(cherry picked from commit db8d4a4)
whk-lab pushed a commit to whk-lab/vllm that referenced this pull request Apr 23, 2026
…nd. (vllm-project#39395)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
avinashsingh77 pushed a commit to avinashsingh77/vllm that referenced this pull request Apr 27, 2026
…nd. (vllm-project#39395)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Signed-off-by: Avinash Singh <avinashsingh.rcoem@gmail.com>
mystous pushed a commit to mystous/vllm_hybrid that referenced this pull request May 10, 2026
…nd. (vllm-project#39395)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: max_num_batched_tokens=1 raises unhandled IndexError

5 participants