vllm - 💡(How to fix) Fix [Bug]: Endless generation [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vllm-project/vllm#38521Fetched 2026-04-08 01:53:35
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

Code Example

Your output of `python collect_env.py` here
RAW_BUFFERClick to expand / collapse

Your current environment

<details> <summary>The output of <code>python collect_env.py</code></summary>
Your output of `python collect_env.py` here
</details>

🐛 Describe the bug

After upgrading to vllm 0.18.0, we got an endless generation. When asking for a chat completions on the endpoint: /v1/chat/completions, vllm include in response <user> inputs. When we authorize bigger prompt length, vllm never stop generating new tokens and start a solo conversation.

We tried loading 2 different models as gguf files:

  • devstral small 2505
  • tinyllama

We got no special parameters but tried --enable-prefix-caching and --enable-chunked-prefill without any sucess.

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

extent analysis

Fix Plan

To address the endless generation issue, we need to adjust the model's configuration to prevent it from including user inputs in the response and to stop generating new tokens when a certain limit is reached.

Steps to Fix

  • Set a maximum sequence length to prevent endless generation:
    • Use the --max-sequence-length parameter when loading the model.
  • Exclude user inputs from the response:
    • Use the --exclude-inputs parameter when generating chat completions.

Example Code

import torch
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer

# Load the model and tokenizer
model = AutoModelForSeq2SeqLM.from_pretrained("devstral/small-2505")
tokenizer = AutoTokenizer.from_pretrained("devstral/small-2505")

# Set the maximum sequence length
max_sequence_length = 512

# Generate chat completions with the specified parameters
def generate_chat_completions(user_input, model, tokenizer, max_sequence_length):
    inputs = tokenizer(user_input, return_tensors="pt")
    outputs = model.generate(**inputs, max_length=max_sequence_length)
    response = tokenizer.decode(outputs[0], skip_special_tokens=True)
    return response

# Test the function
user_input = "Hello, how are you?"
response = generate_chat_completions(user_input, model, tokenizer, max_sequence_length)
print(response)

Verification

To verify that the fix worked, test the generate_chat_completions function with different user inputs and check that the response does not include the user input and does not exceed the specified maximum sequence length.

Extra Tips

  • Make sure to adjust the max_sequence_length parameter according to your specific use case to prevent the model from generating excessively long responses.
  • Consider implementing additional logic to handle cases where the user input is longer than the maximum sequence length.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING