[Bugfix] Fix O(n²) multimodal string prompt processing by mertunsall · Pull Request #29667 · vllm-project/vllm (original) (raw)

[gemini-code-assist[bot]](/apps/gemini-code-assist)

@mertunsall

_apply_matches() had O(n²) complexity when processing multimodal prompts. When no match was found, the loop incremented start_idx but _find_matches() used prev_end_idx (unchanged), re-scanning the entire prompt each iteration.

Fix: Exit loop when no matches remain instead of incrementing uselessly.

Impact: InternVL 5k token prompt: 2.6s → <10ms for processing. Signed-off-by: mertunsall mertunsal1905@gmail.com

@mertunsall

Signed-off-by: mertunsall mertunsal1905@gmail.com

DarkLight1337

@mertunsall

Signed-off-by: mertunsall mertunsal1905@gmail.com

@mertunsall

Signed-off-by: mertunsall mertunsal1905@gmail.com

@mertunsall

@mertunsall

Signed-off-by: mertunsall mertunsal1905@gmail.com

@DarkLight1337 DarkLight1337 changed the title[Bugfix] Fix O(n²) multimodal prompt processin [Bugfix] Fix O(n²) multimodal prompt processing

Nov 28, 2025

DarkLight1337

@mertunsall

Signed-off-by: mertunsall mertunsal1905@gmail.com

@mertunsall

@mertunsall

@mertunsall

Signed-off-by: mertunsall mertunsal1905@gmail.com

@ywang96

@ywang96 ywang96 added the ready

ONLY add when PR is ready to merge/full CI is needed

label

Nov 28, 2025

@ywang96

@ywang96 ywang96 changed the title[Bugfix] Fix O(n²) multimodal prompt processing [Bugfix] Fix O(n²) multimodal string prompt processing

Nov 28, 2025

kitaekatt pushed a commit to kitaekatt/vllm that referenced this pull request

Dec 1, 2025

…29667)

Signed-off-by: mertunsall mertunsal1905@gmail.com Co-authored-by: Roger Wang hey@rogerw.io

amd-hhashemi pushed a commit to amd-hhashemi/vllm that referenced this pull request

Dec 2, 2025

…29667)

Signed-off-by: mertunsall mertunsal1905@gmail.com Co-authored-by: Roger Wang hey@rogerw.io Signed-off-by: Hashem Hashemi hashem.hashemi@amd.com

mystous pushed a commit to mystous/vllm_hybrid that referenced this pull request

May 10, 2026

@mertunsall @ywang96

…29667)

Signed-off-by: mertunsall mertunsal1905@gmail.com Co-authored-by: Roger Wang hey@rogerw.io

my-other-github-account pushed a commit to my-other-github-account/vllm that referenced this pull request

May 15, 2026

@mertunsall @ywang96

…29667)

Signed-off-by: mertunsall mertunsal1905@gmail.com Co-authored-by: Roger Wang hey@rogerw.io

my-other-github-account pushed a commit to my-other-github-account/vllm that referenced this pull request

May 15, 2026

@mertunsall @ywang96

…29667)

Signed-off-by: mertunsall mertunsal1905@gmail.com Co-authored-by: Roger Wang hey@rogerw.io

0826joyce pushed a commit to 0826joyce/vllm-serving-optimization that referenced this pull request

May 19, 2026

@mertunsall @ywang96

…29667)

Signed-off-by: mertunsall mertunsal1905@gmail.com Co-authored-by: Roger Wang hey@rogerw.io

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})