AI cost control Research-backed Python

parallel-inference-tunerFind the fastest, most energy-efficient threads, workers and batching for model serving

parallel-inference-tuner measures XGBoost, LightGBM, CatBoost, scikit-learn, ONNX Runtime or PyTorch models on your own machine and recommends the threads, processes and micro-batching that give the lowest latency or the least energy, including inside containers with CPU limits.

PyPI pip install parallel-inference-tuner

Free · MIT license · runs on your machine · no signup PyPI ↗GitHub ↗

How parallel-inference-tuner works

Most model servers run with whatever threading the library picked: all logical cores for every prediction, more workers than CPUs, or a container that thinks it has 64 cores when it has 2. The result is slower responses and more energy per prediction than the hardware needs.

parallel-inference-tuner measures your model on the machine it will run on. It times every combination of thread count and batch size, runs several worker processes together to see how they compete for the CPU, and then simulates your real request rate against your latency target. You get the settings to use, the environment variables to set, and the predicted latency and energy per request.

It works with XGBoost, LightGBM, CatBoost, scikit-learn, ONNX Runtime and PyTorch models.

Try it

pip install parallel-inference-tuner
parallel-inference-tuner model.json --data rows.csv --rate 300 --slo-ms 20

Free and open source under the MIT license. Serving models on CPUs and paying too much for it? Book a call.

Agent skill included

Let your AI coding agent run parallel-inference-tuner for you

The parallel-inference-tuner skill works with Claude Code, Codex, Cursor, Gemini CLI and other agents that read SKILL.md files. It runs the tool, explains each finding in plain words and helps you fix it.

npx skills add MuhammadAhmadZia/parallel-inference-tuner --skill parallel-inference-tuner

Using the Claude or ChatGPT apps instead? Download the skill ZIP from the GitHub releases page and upload it under Skills.

See all 30 agent skills →

Questions about parallel-inference-tuner

Why not just use all cores for every prediction?

For one row, starting and syncing threads usually costs more than the work itself. Several single-threaded workers often serve more requests than one worker with many threads, at lower energy per prediction. The tool measures which is true for your model and machine.

Does it work in Docker and Kubernetes?

Yes, and that is where it helps most. It reads the container's CPU quota, which os.cpu_count() does not report, and warns when libraries would start more threads than the container can run.

Do I need to test every setting live?

No. It measures how long each batch size takes, measures the workers running together, and then simulates your traffic for every combination of workers, batch size and wait time. The simulator is checked against queueing theory.

How is energy measured?

With the CPU's RAPL counters where Linux allows reading them (bare metal, usually as root), with idle power removed. Elsewhere it uses the Green Algorithms estimate from CPU time, and says so.

UN Sustainable Development Goals

How each tool maps to SDG targets →

Want this set up and tuned for your store?

The tools are free. If you would rather have the checks run, the findings fixed and the results measured for you, that is what I do for clients.