Skip to content

fix(stargate-bench): measure validated stream output - #1826

Open
barrygreengus wants to merge 8 commits into
codex/stargate-maintenance/registrationfrom
codex/stargate-maintenance/benchmarks
Open

barrygreengus wants to merge 8 commits into
codex/stargate-maintenance/registrationfrom
codex/stargate-maintenance/benchmarks

Conversation

@barrygreengus

@barrygreengus barrygreengus commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Why

The benchmark counted empty or truncated HTTP 200 responses as successful inference and credited requested token limits as generated output. Its native mock omitted streamed usage, leaving no reliable output count for the scorer.

Examples

  • Empty or truncated success: HTTP 200 with an empty body, or an SSE body ending before data: [DONE], previously counted as success. These responses now fail validation.
  • Requested versus generated: a request allows 100 output tokens, but a five-token context with a two-token prompt leaves room for three generated tokens. The mock-to-driver test records requested output_tokens: 100 and observed_output_tokens: 3. Scoring uses three.
  • Backend shares: two backends receive 100-token requests but generate two and eight tokens. Their output shares are 20% and 80%, instead of the 50% split implied by requested limits.
  • Missing usage: a completed external stream can be successful without providing a count. Aggregate output throughput and shares remain unavailable in that case. Older result files remain readable, and a reported zero remains distinct from an absent count.
  • First output: keepalive comments and empty role chunks do not establish the first-output timestamp. Content, reasoning, and refusal text do. A refusal-only completion with three generated tokens must have a first-output timestamp; ignoring refusal text leaves that measurement missing.

What changed

  • Use the public sse-core decoder for SSE framing and payload limits. The benchmark driver handles completion markers, application errors, output timing, and token usage.
  • Keep requested workload tokens separate from observed completion-token counts, and finish the request when the completion marker arrives.
  • Honor stream_options.include_usage in mock-dynamo, reporting actual bounded output before [DONE] and preserving the existing response shape when usage is not requested.
  • Report throughput and output shares as unavailable when successful external or legacy responses have no usable count.
  • Expose benchmark tests through Bazel and test the actual mock and driver executables together.

Customer Release Notes

Stargate benchmarks report validated output usage and reject incomplete success responses. Native mock streams provide actual token counts when requested; missing external usage is shown as unavailable.

Plan Summary

Not applicable.

Usage

Request results include observed_output_tokens. Existing output_tokens fields retain the requested workload limit. The driver requests streamed usage automatically; mock-dynamo also accepts stream_options.include_usage on direct chat-completion requests.

Testing

The YAGNI follow-up passed all 160 benchmark tests and 36 mock-dynamo tests, plus all-target Clippy for both packages with warnings denied. It replaces internal missing-usage counters with boolean flags; existing behavioral tests cover scoring, legacy results, and streamed usage. No runtime schema or dependency changed in this follow-up.

Earlier combined-stack validation passed 1,611 Cargo workspace tests, with 3 existing performance tests ignored, workspace Clippy, and 6 scoped Bazel targets. The native mock-to-driver integration recorded three observed tokens for a request allowing 100. A refusal-only stream recorded first-output timing and three observed tokens; a separate real-driver reproduction verified that later uncounted refusal text invalidates an earlier cumulative count. The full workspace and Bazel suites were not rerun for this internal state simplification. No GPU or live-cluster performance campaign was run.

Notes

The decoder limits each buffered SSE data, event-name, or ID field to 1 MiB. Discarded comments do not consume that buffer budget. Network requests remain owned by the existing HTTP client; decoding does not retry them.

Final layer of the Stargate maintenance stack. Earlier layers fix protocol handling, proxy and relay lifetime, and registration recovery. The streaming deadline finding was already fixed by #1452.

Issues

Closes #1817

References

sse-core decoder

Chat streamed usage

Related Pull Requests

Depends on #1823. Stack, bottom to top: #1818, #1820, #1823, #1826.

Dependencies

Added sse-core 0.2.3 with default features disabled and only std enabled. Its enabled dependencies were already present; no other package versions changed. The crate is dual-licensed MIT OR Apache-2.0. Apache-2.0 was selected and verified against the repository allowlist and the published source revision. Added benchmark attribution, regenerated the root NOTICE index, and refreshed Cargo and Bazel lockfiles, and updated the generated dependency inventory.

@barrygreengus
barrygreengus added this pull request to stack #1821 September 11, 2026 21:49
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

🛡️ CodeQL Analysis

🚨 Found 5 issue(s)

Severity Breakdown:

  • 🔴 Errors: 0
  • 🟡 Warnings: 0
  • 🔵 Notes: 0
📋 Top Issues

🔗 View full details in Security tab

🕐 Last updated: 2026-09-11 22:27:38 UTC | Commit: 54b3e6e

@barrygreengus
barrygreengus force-pushed the codex/stargate-maintenance/benchmarks branch 2 times, most recently from b3e0b9f to 6f1913e Compare September 14, 2026 16:46
@barrygreengus
barrygreengus force-pushed the codex/stargate-maintenance/benchmarks branch from 4264894 to a10bd5a Compare September 14, 2026 17:01
@barrygreengus
barrygreengus force-pushed the codex/stargate-maintenance/benchmarks branch from a10bd5a to 59bb253 Compare September 14, 2026 21:22
@barrygreengus
barrygreengus removed this pull request from stack #1821 September 15, 2026 16:28
@barrygreengus
barrygreengus added this pull request to stack #1906 September 15, 2026 16:29
@barrygreengus
barrygreengus force-pushed the codex/stargate-maintenance/benchmarks branch from fa89124 to 7858489 Compare September 15, 2026 16:29
@barrygreengus
barrygreengus force-pushed the codex/stargate-maintenance/benchmarks branch from ec6dc77 to 4e0ef82 Compare September 15, 2026 21:00
@barrygreengus
barrygreengus force-pushed the codex/stargate-maintenance/benchmarks branch 4 times, most recently from 3a44d14 to 98e62e7 Compare September 16, 2026 03:04
@barrygreengus
barrygreengus force-pushed the codex/stargate-maintenance/benchmarks branch from 98e62e7 to a73c543 Compare September 16, 2026 04:41
@barrygreengus
barrygreengus force-pushed the codex/stargate-maintenance/benchmarks branch from a73c543 to 80cd387 Compare September 16, 2026 04:52
Validate SSE completion and parse reported output usage instead of crediting requested tokens. Preserve requested workload fields, mark missing usage as unknown, and run benchmark regressions through Bazel.

Refs: #1817
Resolve benchmark scenarios from declared runfiles so the full benchmark test suite runs in a clean Bazel sandbox.

Refs: #1817
Normalize CR, LF, and split CRLF boundaries and strip a single initial UTF-8 BOM across chunks. Bound buffered events, discard empty events promptly, and keep UTF-8 fixtures in ASCII source.

Refs: #1817
Honor include_usage with final generated-token counts and preserve the existing stream shape when usage is not requested. Verify the real mock-to-driver path with a Bazel test using declared executable inputs.

Refs: #1817
Add sse-core 0.2.3 under its Apache-2.0 license with only the std feature.
Replace custom SSE framing with its bounded decoder and keep completion,
usage, and output timing checks in the benchmark driver.

Relates to #1817
@barrygreengus
barrygreengus force-pushed the codex/stargate-maintenance/benchmarks branch from 80cd387 to d27482c Compare September 16, 2026 05:17
Only the presence of missing output usage affects scoring. Replace the
unused numeric counts with boolean latches while preserving separate
successful-request and per-group coverage.

Relates to #1817
@barrygreengus
barrygreengus marked this pull request as ready for review September 16, 2026 16:29
@barrygreengus
barrygreengus requested review from a team as code owners September 16, 2026 16:29
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.

fix(stargate): address protocol, lifecycle, recovery, and benchmark audit findings

1 participant