Floppy is a framework for analyzing and counting floating-point operations (FLOPs) in Python code, with special focus on numerical computations using NumPy.
-
Runtime FLOP Counting: Track FLOPs in your code as it executes
- Transparent array operation tracking
- Support for high-level NumPy operations
- Thread-safe operation
- Selective monitoring of code paths
-
Static Analysis: Analyze potential FLOP operations in your codebase
- Identify potential FLOP-contributing functions
- Get insights before execution
Floppy can be installed in your environment to profile code. For Monty specifically, follow these directions:
-
First, clone and install the
tbp.monty
repository in~/tbp/tbp.monty
directory by following instructions from Thousand Brains Project documentation -
Next, in
~/tbp/tbp.floppy
clone thetbp.monty
conda
environment via:
conda create --clone tbp.monty -n floppy
conda activate floppy
pip install -e .
from floppy.counting.base import FlopCounter
with FlopCounter() as counter:
result = np.matmul(a, b)
print(f"FLOPs: {counter.flops}")
For profiling Monty experiments:
python floppy/run_flop_counter.py --experiment=dist_agent_1lm_randrot_x_percent_5p
For statically analyzing a repo:
python run_static_analysis.py --dir path/to/analyze
Contributions are welcome! Please follow the Thousand Brains Project Contributing Guide.
The MIT License. See the LICENSE for details.