Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tensorrt_llm/serve/openai_disagg_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ def _rewrite_usage_sse_event_from_ctx(
event: bytes,
ctx_response: Optional[UCompletionResponse],
) -> bytes:
# Only the final chunk has a top-level `usage` to rewrite, but this ran
# json.loads on every relayed chunk. A usage field can't exist unless the
# bytes contain `"usage"`, so skip the parse when they don't.
if b'"usage"' not in event:
return event
separator_match = self._sse_separator_index(event)
separator = separator_match[1] if separator_match else b""
event_body = event[: -len(separator)] if separator else event
Expand Down
Loading