Skip to content

[Bugfix][Frontend] Honor --enable-log-outputs on /v1/completions - #62205

Merged
DarkLight1337 merged 4 commits into
vllm-project:mainfrom
surajm20061998:fix/completions-log-outputs
Oct 19, 2026
Merged

DarkLight1337 merged 4 commits into
vllm-project:mainfrom
surajm20061998:fix/completions-log-outputs

Conversation

@surajm20061998

@surajm20061998 surajm20061998 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Overview

--enable-log-outputs is silently ignored by /v1/completions. The handler never accepted the flag or logged generated text, while chat, Responses, Anthropic (#60982), Cohere (#61089) and /inference/v1/generate all do. This adds output logging to completions, mirroring chat.

Claims

  • With --enable-log-requests --enable-log-outputs, /v1/completions logs generated text: one line per output when not streaming; when streaming, one line per delta (respects --enable-log-deltas) plus the full text when the stream ends.
  • Output lines reuse the per-prompt request id from the input log (cmpl-<id>-<i>), so the two can be correlated.
  • Nothing changes when the flag is off (the default).

Validation

End-to-end, vllm serve Qwen/Qwen2.5-0.5B-Instruct --enable-log-requests --enable-log-outputs (CPU backend). For each request, the counts of Received request / Generated response log lines:

Request main This PR
/v1/completions, non-streaming 1 / 0 1 / 1
/v1/completions, streaming, 8 tokens 1 / 0 1 / 9 (8 deltas + complete)
/v1/chat/completions (control) 1 / 1 1 / 1
Log lines with this PR
Generated response cmpl-e2e-cmpl-nonstream-0: output: ' Paris. It was founded in 7', finish_reason: length
Generated response cmpl-e2e-cmpl-stream-0 (streaming delta): output: ' Paris', finish_reason: None
Generated response cmpl-e2e-cmpl-stream-0 (streaming delta): output: '.', finish_reason: None
...
Generated response cmpl-e2e-cmpl-stream-0 (streaming delta): output: '7', finish_reason: length
Generated response cmpl-e2e-cmpl-stream-0 (streaming complete): output: ' Paris. It was founded in 7', finish_reason: streaming_complete
Generated response chatcmpl-e2e-chat-nonstream: output: 'Hello! How can I assist you today', finish_reason: length

Tests: test_completion_logs_outputs_when_enabled[stream=False|True] drives create_completion with a mock engine and checks the logged text, token ids, finish reason, delta/complete lines, and that every line uses the input log's request id.

$ pytest tests/entrypoints/openai/completion/test_completion_error.py tests/entrypoints/openai/completion/test_completion_text_offset.py
main:    2 failed, 51 passed  (TypeError: ... unexpected keyword argument 'enable_log_outputs')
this PR: 53 passed

Regression: pytest tests/entrypoints/openai/completion/{test_completion_error,test_completion_text_offset,test_lora_resolvers}.py tests/entrypoints/openai/chat_completion/test_serving_chat.py tests/entrypoints/serve/utils: main 279 passed, this PR 281 passed. Both have the same 19 environment-only failures (GPT-OSS/Harmony tokenizers unavailable offline). pre-commit ruff and mypy are clean.

Validated on macOS (Apple Silicon, CPU backend), Python 3.12, torch 2.14.0, rebased on main @ e744eacf6. No model evaluation: logging only.

Details

The original --enable-log-outputs PR (#20707) implemented logging for chat and Responses only. Later endpoints that inherit from the chat handler only needed the flag forwarded (#60982, #61089). Completions has its own handler, so it needs the logging itself:

  • OpenAIServingCompletion takes enable_log_outputs / enable_log_deltas, and init_generate_state passes them, as for chat.
  • Non-streaming: after the response is built, log each output's generated text, token ids and finish reason.
  • Streaming: log each non-empty delta, accumulate text only when logging is on, and log each choice's full text after the stream, with finish_reason="streaming_complete" as chat does.
  • The generated text is logged, not the echoed prompt (echo=true); log_inputs already logs the prompt.

The batch chat endpoint and speech-to-text have the same gap. I'll follow up separately to keep this one small.

Duplicate check: searched issues/PRs for enable-log-outputs, enable_log_outputs, and log outputs + completions, and inspected every open PR touching vllm/entrypoints/openai/completion/serving.py and vllm/entrypoints/generate/api_router.py. #45634 adds request arrival/completion lifecycle logs, a different feature. #40155 is about prompt log levels. None add output logging to completions.

AI assistance: Claude (Anthropic) helped find, reproduce and write this change. I reviewed every changed line and ran the tests and the end-to-end check above myself.


Pull Request Checklist
  • I used vLLM's /pr-checklist skill. (Mandatory for agents, optional for humans).

  • AI assistance was used during the creation of this PR.

  • Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.

  • Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.

  • Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.

  • Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.

--enable-log-outputs is server-wide, but /v1/completions never logged
generated text: OpenAIServingCompletion did not accept the flag, and
init_generate_state did not pass it. Chat, Responses, Anthropic, Cohere
and /inference/v1/generate all log outputs.

Log completion outputs the way chat does: one line per output for
non-streaming requests; for streaming requests, one line per delta
(unless --enable-log-deltas is off) and the full text once the stream
ends. Lines use the same per-prompt request id as the input log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: surajm20061998 <surajm20061998@gmail.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify mergify Bot added frontend bug Something isn't working labels Oct 17, 2026
Comment thread vllm/entrypoints/openai/completion/serving.py Outdated
Comment thread vllm/entrypoints/openai/completion/serving.py Outdated
Signed-off-by: surajm20061998 <surajm20061998@gmail.com>
Signed-off-by: surajm20061998 <surajm20061998@gmail.com>
@DarkLight1337

Copy link
Copy Markdown
Member

@claude review

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code review found no issues

No high-confidence issues detected in this change.

@DarkLight1337 DarkLight1337 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thx

@DarkLight1337
DarkLight1337 enabled auto-merge (squash) October 19, 2026 01:11
@DarkLight1337

Copy link
Copy Markdown
Member

/ci run

@github-actions github-actions Bot added the ready ONLY add when PR is ready to merge/full CI is needed label Oct 19, 2026
@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #95761 for commit 38ae9fd214e8.

@surajm20061998

Copy link
Copy Markdown
Contributor Author

/ci retry

@github-actions

Copy link
Copy Markdown

✅ Queued 1 failed job(s) for retry in Buildkite CI #95761.

@surajm20061998

Copy link
Copy Markdown
Contributor Author

The /ci retry hit the same single failure: H200 LM Eval KV-Offload, simple-nemotron-h-8b GSM8K run 2 = 0.395, i.e. 79/200 vs the 80/200 bar (0.45 − 0.05). The other 3 checks in that job and the remaining 124 jobs passed.

I don't think it's related to this PR:

Happy to retry again or rebase if you'd prefer. @DarkLight1337, let me know what works best for merging.

@DarkLight1337

Copy link
Copy Markdown
Member

Retrying

@DarkLight1337
DarkLight1337 merged commit 6af1e0a into vllm-project:main Oct 19, 2026
127 checks passed
bantianyue pushed a commit to bantianyue/vllm that referenced this pull request Oct 28, 2026
…m-project#62205)

Signed-off-by: surajm20061998 <surajm20061998@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.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 frontend 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.

2 participants