Measure the true cost with FLOPpy

A hardware-agnostic Python library to monitor the computational cost (FLOPs and BOPs) of Machine and Deep Learning algorithms. Full support for PyTorch and Scikit-learn.

$
pip install floppy-tracker

Available on PyPI

Why choose FLOPpy?

In the era of Green AI, execution time or energy consumption are not enough: they depend heavily on the hardware. FLOPpy measures the true intrinsic complexity of your model.

Fair Comparisons

Compare the efficiency of different architectures regardless of whether you are using a CPU, a T4 GPU, or an A100. FLOPs and BOPs don't lie.

Bit-Operations (BOPs)

FLOPs alone do not capture the savings of quantization. FLOPpy natively tracks BOPs to quantify the real benefits of FP16, INT8, and INT4.

Full Pipeline Tracking

Don't stop at inference. FLOPpy analyzes the entire training loop: Forward and Backward passes, Loss functions, optimizers, and even tokenization.

Built for Research and Production

  • Cross-Framework Support

    Profile `torch` (including Hugging Face) and `scikit-learn` models using a single, consistent API.

  • "Zero-Boilerplate" Architecture

    No need to modify your model's code. Transparent integration via patching and low-level hooks (ATen dispatch).

  • The "Escape Hatch"

    Native support for quantized layers and fused optimizers (e.g., BitsAndBytes, DeepSpeed, Apex) that usually bypass standard profilers.

  • Weights & Biases Integration

    Seamless synchronization with WandB for real-time visualization of metrics during training.

floppy_report.txt
FLOPpyTracker Summary "experiment_name"
===================================================
System Environment:
- OS      : Linux (x86_64) | 2016 GB RAM
- CPU     : AMD EPYC 7742 64-Core
- GPU     : 1x NVIDIA A100-SXM4-80GB
- Libs    : PyTorch 2.2.2+cu121 | Scikit-learn 1.6

Computational Workload Breakdown:
- Model (Forward)   : 414.72 KFLOPs |  13.27 MBOPs
- Model (Backward)  : 500.22 KFLOPs |  16.01 MBOPs
- Loss (Forward)    :  11.52 KFLOPs | 368.64 KBOPs
- Optimizer (Update): 136.44 KFLOPs |   4.37 MBOPs
---------------------------------------------------
OVERALL TOTAL       :   1.06 MFLOPs |  34.01 MBOPs
===================================================

How It Works

FLOPpy employs high-precision, transparent strategies across different frameworks to ensure maximum accuracy without requiring any changes to your original code.

PyTorch Backend

  • Unified Dispatch: Uses TorchDispatchMode to intercept underlying C++ ATen dispatch calls in real-time, capturing operations even outside standard nn.Module objects.
  • Transparent Backward Tracking: Safely monkey-patches torch.Tensor.backward to encapsulate the entire Autograd graph execution.
  • Optimizer Hooks: Specialized fallback logic accurately estimates fused or quantized optimizers (e.g., 8-bit Adam) bypassing standard dispatchers.

Scikit-learn Backend

  • Dynamic API Wrapping: Automatically wraps standard methods (fit, predict, transform) to extract input/output array dimensions at runtime.
  • Semantic Mapping: fit() operations are mapped as Model (Backward) training phase, while predict() is reported as Model (Forward) inference.
  • Algorithmic Complexity: Applies targeted mathematical formulas (e.g., matrix multiplications, tree depths) based on input shapes and model hyperparameters.

Seamless Integration

Add FLOPpy to your existing code with just a few lines of code.

import torch.nn as nn
from floppy import FLOPpyTracker, WandbConfiguration
from transformers import AutoModel

wandb_config = WandbConfiguration(
  project_name="your_experiment",
  group_name="your_group", 
  reporter_key="your_wandb_key_here"
)

# 1. Define your model, loss and optimizer
model = nn.Sequential(nn.Linear(10, 10), nn.ReLU())
loss_fn = nn.CrossEntropyLoss()
optimizer = torch.optim.Adam(model.parameters())
num_epochs = 10

# 2. Initialize the tracker
tracker = FLOPpyTracker(run_name="pytorch_experiment")

# 3. Run monitoring
tracker.run(model=model, optimizer=optimizer, loss_fn=loss_fn)

# 4. Do something with the model
for _ in range(num_epochs):
    for xb, yb in your_data_loader:
        optimizer.zero_grad()
        y_hat = model(xb)
        loss = loss_fn(y_hat, yb)
        loss.backward()
        optimizer.step()
        tracker.batch() # Optional: track metrics per batch

    tracker.epoch() # Optional: track metrics per epoch
    
# 5. Access the report
report = tracker.report()
print(report)

Research & Authors

FLOPpy is developed by researchers at the Institute of High Performance Computing and Networking (ICAR-CNR).

Francesco Scala Francesco Mandarino Liliana Martirano Luigi Pontieri

Citation (Scientific Paper)

If you use FLOPpy in your research, please cite our work on hardware-agnostic computational workload estimation for Machine and Deep Learning algorithms.


@article{SCALA2026102865,
    title = {FLOPpy: A hardware-agnostic Python library to monitor the computational cost of machine and deep learning algorithms},
    journal = {SoftwareX},
    volume = {35},
    pages = {102865},
    year = {2026},
    issn = {2352-7110},
    doi = {https://doi.org/10.1016/j.softx.2026.102865},
    url = {https://www.sciencedirect.com/science/article/pii/S2352711026003572},
    author = {Francesco Scala and Francesco Mandarino and Liliana Martirano and Luigi Pontieri},
    keywords = {Green AI, Computational workload, Hardware-agnostic, Deep learning, Machine learning, Floating point operations, Bit-operations}
}