Skip to content

fix: skip debug TPS on short streams#849

Merged
7Sageer merged 1 commit into
MoonshotAI:mainfrom
7Sageer:fix/debug-tps-gate
Jun 17, 2026
Merged

fix: skip debug TPS on short streams#849
7Sageer merged 1 commit into
MoonshotAI:mainfrom
7Sageer:fix/debug-tps-gate

Conversation

@7Sageer

@7Sageer 7Sageer commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue. Supersedes #848 with an alternative fix that preserves decode-TPS semantics.

Problem

Debug mode computes TPS as output tokens / stream duration. For short or single-chunk tool-call turns the streamed window drains in ~1ms, so dividing by a timer-quantized duration reports inflated rates like tens of thousands of tok/s, e.g. TPS: 44000.0 tok/s (44 tokens in 1ms).

What changed

Only compute debug TPS when the streamed window reaches 50ms, which keeps the existing decode-TPS semantics for normal turns. Below that threshold the line shows the raw token count and duration (44 tokens in 1ms (stream too short for TPS)) instead of a meaningless ratio, rather than redefining TPS over the full response window (TTFT + stream) as #848 did. Added regression tests and a patch changeset.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Decode TPS is meaningless when the streamed window is only ~1ms
(short / single-chunk tool-call turns), since dividing output tokens
by a timer-quantized duration reports inflated rates like tens of
thousands of tok/s. Only compute TPS when the stream window reaches
50ms; otherwise show the raw token count and duration.
@changeset-bot

changeset-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: be7f33b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@7Sageer 7Sageer mentioned this pull request Jun 17, 2026
5 tasks
@pkg-pr-new

pkg-pr-new Bot commented Jun 17, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@be7f33b
npx https://pkg.pr.new/@moonshot-ai/kimi-code@be7f33b

commit: be7f33b

@7Sageer 7Sageer merged commit 254f946 into MoonshotAI:main Jun 17, 2026
9 checks passed
This was referenced Jun 17, 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