Skip to content

[Infer] Fix transformers streaming logprobs - #9866

Draft
taking-lying-flat wants to merge 1 commit into
modelscope:mainfrom
taking-lying-flat:agent/fix-transformers-stream-logprobs
Draft

[Infer] Fix transformers streaming logprobs#9866
taking-lying-flat wants to merge 1 commit into
modelscope:mainfrom
taking-lying-flat:agent/fix-transformers-stream-logprobs

Conversation

@taking-lying-flat

@taking-lying-flat taking-lying-flat commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • retain the LogitsStreamer instance used by PT/Transformers generation so streaming responses can consume its logits

Root cause

The PT streaming path constructed LogitsStreamer() inline inside LogitsProcessorList, while the local logits_streamer variable remained None. The collection path therefore returned early for every streamed chunk, and logprobs was serialized as null.

Impact

Requests using the Transformers backend with both stream=true and logprobs=true now return populated logprobs. Non-streaming inference and streaming requests without logprobs are unchanged.

Validation

  • python -m py_compile swift/infer_engine/transformers_engine.py
  • git diff --check upstream/main...HEAD

@taking-lying-flat
taking-lying-flat force-pushed the agent/fix-transformers-stream-logprobs branch from da50411 to f254d61 Compare August 6, 2026 14:16
@taking-lying-flat taking-lying-flat changed the title [Infer] Fix transformers streaming logprobs [Infer] Fix and optimize Transformers logprobs Aug 7, 2026
@taking-lying-flat
taking-lying-flat force-pushed the agent/fix-transformers-stream-logprobs branch from 84912a9 to f254d61 Compare August 7, 2026 00:32
@taking-lying-flat taking-lying-flat changed the title [Infer] Fix and optimize Transformers logprobs [Infer] Fix transformers streaming logprobs Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant