Skip to content

Support usage.input_tokens and output_tokens fallback - #131

Merged
davanstrien merged 1 commit into
mainfrom
feat/usage-input-output-tokens
Nov 30, 2026
Merged

davanstrien merged 1 commit into
mainfrom
feat/usage-input-output-tokens

Conversation

@davanstrien

Copy link
Copy Markdown
Owner

Summary

  • Fall back to usage.input_tokens and usage.output_tokens in saturate.transport.usage_tokens() when prompt_tokens / completion_tokens are absent or null.
  • Endpoints that use the input_tokens / output_tokens naming convention — including OpenAI's /v1/responses, Anthropic's /v1/messages, and Flide's /v1/systemone — now populate Stats.prompt_tokens, Stats.completion_tokens, Stats.tokens_per_sec, and controller tok_s observations instead of reporting 0.
  • prompt_tokens / completion_tokens keep precedence (including explicit 0), and malformed non-None primary values still clamp to 0 without falling back.

Testing

  • Unit tests in tests/test_transport_retry.py covering input_tokens/output_tokens, precedence, explicit 0, None fallback, and malformed values.
  • End-to-end test in tests/test_run_stats.py verifying Stats totals, tokens_per_sec, and persisted telemetry tok_s > 0.
  • Full fast suite (764 passed), ruff check, ruff format --check, and ty check green.
  • Live HF Jobs GPU smoke test against OmniJev/Flide (/v1/systemone) running now (results will be added in a comment).

@davanstrien

Copy link
Copy Markdown
Owner Author

Live GPU smoke test on HF Jobs (OmniJev/Flide /v1/systemone)

Ran OmniJev/OneJev1.6-0.8B (flide==0.2.1 + this PR branch @48815d1) on l4x1 over 1,000 SetFit/enron_spam emails × 8 typed questions (noul/choice/score) via Engine(cmd=["flide", "serve", ...], ready_route="/models", ready_method="GET") + pump(..., route="/systemone", signal_source="none", window=Auto()) → HF Bucket:

  • Job: davanstrien/6b0da15754072e8b7172ef4f (completed, exit 0)
  • Readiness: engine ready (health x3 + trial 200) in 43 s (including model download + CUDA graph capture)
  • Run 1: 1000 ok, 0 failed, 30.86 rows/s, 32,127.6 tok/s, final window 256 (32.4 s, bound_by={"engine": 16}, retries=0, breaker_opens=0, hints=[])
  • Usage accounting verified: prompt_tokens=1,032,933 (from usage.input_tokens), completion_tokens=8,000 (exact 1,000 × 8 from usage.output_tokens), and 16/16 controller telemetry ticks recorded tok_s > 0 (driving Auto() from 64 → 256)
  • Resume & read-back: immediate resume skipped 1000/1000 in 0.59 s (0 new requests); read_output() verified 1000 durable rows; server shut down cleanly with no SIGKILL sweep.

@davanstrien
davanstrien merged commit 0c35d49 into main Nov 30, 2026
18 checks passed
@davanstrien
davanstrien deleted the feat/usage-input-output-tokens branch November 30, 2026 18:00
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