Skip to main content

HF Inference Benchmark

CI Pipeline PyPI Python Code Style License

Production-grade benchmarking infrastructure for HuggingFace inference workloads.

hf-inference-benchmark is a reproducible, device-agnostic benchmarking system that measures the real operational cost of running LLMs — latency, throughput, and memory — under production-like conditions.

It answers one critical question:

“Will this model crash my server — and how fast can it actually run?”


Why This Tool Exists

Most public HuggingFace benchmarking scripts:

• Measure only a single forward pass
• Ignore warmup behavior
• Ignore GPU synchronization
• Ignore memory allocator behavior
• Produce misleading results

This tool implements the same benchmarking discipline used by real ML infrastructure teams.


Benchmarking Pipeline

Model Load
   ↓
Warmup Passes
   ↓
Synchronized Execution
   ↓
Latency Profiling (P50 / P95 / Avg)
   ↓
Token Counting
   ↓
Throughput Calculation (tokens/sec)
   ↓
Peak Memory Tracking
   ↓
Structured JSON Export

Metric Definitions

Metric Meaning
latency_p50 Median inference latency
throughput Real generation speed in tokens/sec
memory_mb Peak RAM/VRAM usage
warmup Kernel stabilization
synchronization Accurate GPU timing

User Installation

# From PyPI
pip install hf-inference-benchmark

# From Source (for Developers)
git clone https://github.com/rgb-99/hf-inference-benchmark.git
cd hf-inference-benchmark
pip install -e .

Basic Usage

# Run on CPU/GPU (Auto-detected)
hf-bench facebook/opt-125m

# Export results for the Reporting Suite
hf-bench gpt2 --tokens 64 --out results/gpt2_perf.json

Persisting Results

hf-bench facebook/opt-125m --tokens 64 --out results/opt125m.json

Example:

{
  "model": "facebook/opt-125m",
  "throughput": 54.36,
  "latency_p50": 878.83,
  "memory_mb": 797.56
}

Reproducible Benchmarking

For fair comparison:

• Fix prompt
• Fix token count
• Fix device
• Use warmup runs
• Compare structured JSON outputs


Platform Integration

This tool is part of the unified NLP infrastructure platform:

nlp-tool benchmark facebook/opt-125m
nlp-tool report results/opt125m.json

Roadmap

• Batch-size profiling
• Streaming generation benchmarks
• Multi-GPU scaling
• Energy-cost estimation
• CI-based regression tracking


Metadata

Release files for hf-inference-benchmark 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hf-inference-benchmark 0.1.4
File Size Uploaded Provenance
hf_inference_benchmark-0.1.4.tar.gz 5.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for hf-inference-benchmark 0.1.4
File Interpreter ABI Platform
hf_inference_benchmark-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 13.4 kB

Release files / hf_inference_benchmark-0.1.4.tar.gz

Download URL hf_inference_benchmark-0.1.4.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6a4aa6df006af05ae95e5e3ec24ca938a30756dc53cacc3d42f26d75f2fcdf19
BLAKE2b-256 checksum
How to use checksums
16b909e34412e50566c355e5ec2e2f4050fdecedfa2f3036878949e35ad88424
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / hf_inference_benchmark-0.1.4-py3-none-any.whl

Download URL hf_inference_benchmark-0.1.4-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b363243566460ad37cbdde74386d5bd9e9ecf7762a36554c2b6b0e2a750ac17
BLAKE2b-256 checksum
How to use checksums
e2fbe6d9cbf9d4ac051d8097c7503d1584c956a01d72298dc49a8bde8a2be2e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for hf-inference-benchmark 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page