Skip to content

Add Python inference benchmark CLI#694

Open
RitwijParmar wants to merge 3 commits into
cactus-compute:mainfrom
RitwijParmar:codex/cactus-inference-benchmark-cli
Open

Add Python inference benchmark CLI#694
RitwijParmar wants to merge 3 commits into
cactus-compute:mainfrom
RitwijParmar:codex/cactus-inference-benchmark-cli

Conversation

@RitwijParmar

Copy link
Copy Markdown

Adds a cactus benchmark command for repeatable local inference measurements from the Python CLI.

Why this felt useful: the Python API already returns TTFT, prefill throughput, decode throughput, RAM, and token counts, but there was not a small built-in way to run the same prompt profiles repeatedly and save artifacts for comparing runtime, quantization, or long-context changes.

What changed:

  • adds built-in benchmark profiles for short chat, long prefill, and JSON-shaped output
  • supports custom profile files so a PR or device run can publish exact prompt shapes
  • writes per-run JSONL plus grouped summary JSON with mean, p50, p95, min, and max
  • resets the KV cache between runs by default, with --keep-cache when cache reuse is intentional
  • documents the workflow in the Python README

I used Codex to help implement and test this, and reviewed the code locally before opening the PR.

Tests:

  • /Users/ritwij/Documents/oss-work/cactus/.venv-codex/bin/python -m pytest python/tests/test_cli_benchmark.py python/tests/test_cli_run.py -q
  • /Users/ritwij/Documents/oss-work/cactus/.venv-codex/bin/python -m pytest python/tests/test_bindings.py::TestCliParser python/tests/test_cli_benchmark.py -q

Both passed locally before I removed the temporary test venv.

@RitwijParmar

RitwijParmar commented Jun 7, 2026

Copy link
Copy Markdown
Author

I pushed a follow-up that turns this into more of a regression harness rather than just a runner.

New pieces:

  • synthetic context sweep profiles via --sweep-token-counts
  • environment metadata in summaries so runs are easier to compare later
  • Markdown reports for benchmark artifacts
  • --compare base.json candidate.json with thresholded regression checks for TTFT, total latency, prefill TPS, and decode TPS
  • compare mode avoids importing the native binding, so it can run anywhere the summary artifacts are available

I also added tests around the sweep generation, comparison logic, Markdown output, and parser paths.

@RitwijParmar
RitwijParmar force-pushed the codex/cactus-inference-benchmark-cli branch from fb04db1 to c688914 Compare June 9, 2026 22:03
@RitwijParmar

Copy link
Copy Markdown
Author

Rebased this on current main and resolved the CLI conflicts. The benchmark command now sits next to the newer run/list/test CLI changes instead of replacing them. I also checked the touched Python files with Python 3.11 compile. Local pytest is not available in this environment, so I could not run the focused pytest here.

@RitwijParmar
RitwijParmar force-pushed the codex/cactus-inference-benchmark-cli branch from c688914 to 1b9d74a Compare June 10, 2026 16:16
Signed-off-by: Ritwij Aryan Parmar <ritwij.aryan.parmar@gmail.com>
Signed-off-by: Ritwij Aryan Parmar <ritwij.aryan.parmar@gmail.com>
Signed-off-by: Ritwij Aryan Parmar <ritwij.aryan.parmar@gmail.com>
@RitwijParmar
RitwijParmar force-pushed the codex/cactus-inference-benchmark-cli branch from 96ae88f to b54ff28 Compare June 10, 2026 17:13
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