Skip to content

francescomandarino15/FLOPpy-Usage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FLOPpy-Usage

Python PyPI version PyPI downloads License Status

This repository provides practical examples demonstrating how to use FLOPpy, a hardware-agnostic Python library for monitoring the computational cost of Machine Learning and Deep Learning models.

FLOPpy enables the estimation of computational cost using metrics such as:

  • FLOP (Floating Point Operations)
  • BOP (Bit Operations)

supporting the development of efficient and sustainable AI systems in line with Green AI principles.


🔗 Resources


⚙️ Installation

Clone the repository:

git clone https://github.com/YOUR_USERNAME/floppy-examples.git
cd floppy-examples
# Install dependencies
pip install -r requirements.txt
# Install FLOPpy
pip install floppy-tracker

🧠 FLOPpy Usage Modes

FLOPpy supports two main usage paradigms:

1️⃣ Run-based mode The simplest way to monitor computational cost.

from floppy import FLOPpyTracker
tracker = FLOPpyTracker(run_name="sklearn_example")
tracker.run(model=model)
model.fit(X_train, y_train)
report = tracker.report(print_summary=True)

✔ Ideal for:

  • quick experiments
  • simple pipelines
  • high-level monitoring

2️⃣ Context manager mode Provides finer control by tracking operations inside a defined execution scope.

from floppy import FLOPpyTracker
tracker = FLOPpyTracker(run_name="context_example")
with tracker:
    model.fit(X_train, y_train)
report = tracker.report(print_summary=True)

✔ Ideal for:

  • precise measurements
  • custom workflows
  • advanced usage

🤖 PyTorch Integration FLOPpy can be integrated directly into deep learning pipelines:

tracker.torch_bind(
    model=model,
    optimizer=optimizer,
    loss_fn=loss_fn,
    device=device
)

📊 Example Scripts

Scikit-learn Example

  • Dataset loading
  • Model training
  • FLOP/BOP tracking
  • Performance reporting

PyTorch Example

  • Neural network training
  • Integrated computational tracking
  • Detailed cost analysis

🌱 Green AI Perspective

FLOPpy contributes to sustainable AI development by enabling:

  • efficient model evaluation
  • reduced computational waste
  • awareness of computational cost

👨‍💻 About

FLOPpy is a hardware-agnostic library for monitoring computational cost in ML/DL models, developed during a research internship at ICAR-CNR.

This repository is maintained by:

Francesco Mandarino

Junior Software Engineer | Machine Learning | Green AI


📄 License

This project is released under the MIT License.