Unified Deep Learning Benchmark Library for PyTorch and TensorFlow
Project description
torchbenchx — Unified Deep Learning Benchmark Library
Benchmark. Compare. Visualize.
torchbenchx is a framework-agnostic deep learning benchmarking library that measures latency, throughput, memory usage, and parameter count of models from both PyTorch and TensorFlow — all inside your Jupyter Notebook, with no servers or dashboards required.
It’s designed for researchers, developers, and AI enthusiasts who want quick, reliable model comparisons with interactive visualizations.
⚙️ Key Features
- Dual Framework Support: Benchmark models from both PyTorch and TensorFlow using one unified API.
- Latency & Throughput Measurement: Calculates per-inference latency and samples-per-second throughput.
- Model Parameters & Memory Usage: Automatically estimates memory footprint and parameter count.
- Device Awareness: Detects and runs on CPU or GPU automatically.
- Notebook-native Visualization: Generates Plotly scatter plots of performance metrics directly in Jupyter/Colab.
- Minimal Dependencies: Lightweight and ready to use.
Installation
pip install torchbenchx
# Backends and viz libs
pip install torch torchvision tensorflow plotly pandas psutil
Optional: install notebook or jupyterlab if using outside Colab.
Quick Start
from torchbenchx import BenchX
import torchvision.models as tv_models
import tensorflow as tf
bench = BenchX(batch_size=16, runs=30)
bench.benchmark(tv_models.resnet18(weights=None), "ResNet18", framework="pytorch")
bench.benchmark(tf.keras.applications.MobileNetV3Small(), "MobileNetV3", framework="tensorflow")
bench.summary() # Styled table
bench.visualize() # Plotly scatter
Core Class: BenchX
BenchX(device=None, batch_size=16, runs=30, warmup=10)
- device: "cuda" or "cpu" — auto-detected if not set (for PyTorch)
- batch_size: Number of samples per inference
- runs: Number of repeated runs for averaging
- warmup: Initial runs ignored to stabilize measurements
Methods
benchmark(model, name, input_shape=(3, 224, 224), framework="pytorch")
Returns a dict with:
{Model, Framework, Device, Latency_ms, Throughput_sps, Memory_MB, Params_M}
summary() # Styled pandas DataFrame (stronger colors on white bg)
visualize(metric_x="Latency_ms", metric_y="Throughput_sps") # Scatter with improved legend/layout
visualize_all() # Returns dict of figures: scatter, throughput_bar, latency_bar, memory_bar
Dependencies
- torch: PyTorch backend
- tensorflow: TensorFlow backend
- plotly: Interactive plotting
- pandas: Data handling and summary display
- psutil: Memory usage monitoring
Internal Workflow
- Warmup phase to stabilize performance
- Timed inference loop across
runs - Metrics: latency (ms/inference), throughput (samples/sec)
- Memory estimation (GPU peak or process RSS)
- Results aggregated into a DataFrame and visualized
- Memory estimation: reports
Memory_Bytes,Memory_MB, and a humanizedMemory
Use Cases
- Research: Compare architectures across frameworks
- Development: Optimize inference pipelines
- Education: Demonstrate benchmarking concepts
- Model Selection: Speed vs efficiency trade-offs
Roadmap
- FLOPs estimation
- Power consumption metrics
- JAX and ONNX Runtime support
- Export results to CSV/JSON
- Leaderboard UI for reproducibility
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file torchbenchx-0.1.0.tar.gz.
File metadata
- Download URL: torchbenchx-0.1.0.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bcb95cf093cf264916ecc4728df44986d7525af0df50c1211994e8014fe43bc
|
|
| MD5 |
d69976b33a2cedd228731d053a75215d
|
|
| BLAKE2b-256 |
bfd96ae7f2b7b705d0d883aaf4512701d4055c95d826842d2ae1d008c240b3ea
|
File details
Details for the file torchbenchx-0.1.0-py3-none-any.whl.
File metadata
- Download URL: torchbenchx-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73d6fe2cf86033fb5c9315e396f7a71efd1b43a97af12d2e7c1878f3cdeb10ee
|
|
| MD5 |
4728c3b4d6caea29ca658fa43c80d320
|
|
| BLAKE2b-256 |
8e993c77541c47cd78280265464adef73c0ed4da0f3785afcfd274e66bd30ff5
|