FLOPSCOPE · A FLOP-COUNTING NUMPY

Count every FLOP.

A NumPy-compatible math library that counts every FLOP analytically, so compute budgets stop being guesswork.

uv add git+https://github.com/AIcrowd/flopscope.git
flopscope
508Operations

NumPy-compatible operations with analytical FLOP costs.

πSymmetry-aware

Symmetry metadata propagates through the chain, so costs scale with unique elements.

Composable

Budget contexts, namespaces, and per-operation breakdowns.

IN ACTION

What does this code cost?

Same five-layer MLP, written twice. The one on the right counts every FLOP analytically as it runs.

NumPy
import numpy as np
 
 
depth, width = 5, 256
 
# Weight init
scale = np.sqrt(2 / width)
weights = [
np.random.randn(width, width) * scale
for _ in range(depth)
]
 
# Forward pass
x = np.random.randn(width)
h = x
for i, W in enumerate(weights):
h = np.einsum('ij,j->i', W, h)
if i < depth - 1:
h = np.maximum(h, 0)
# Total FLOPs? No idea.
Flopscope
import flopscope as flops
import flopscope.numpy as fnp
 
depth, width = 5, 256
 
# Weight init
scale = fnp.sqrt(2 / width)
weights = [
fnp.random.randn(width, width) * scale
for _ in range(depth)
]
 
# Forward pass
x = fnp.random.randn(width)
h = x
for i, W in enumerate(weights):
h = fnp.einsum('ij,j->i', W, h)
if i < depth - 1:
h = fnp.maximum(h, 0)
flops.budget_summary() # 984,321 FLOPs

The answer, on the right: 984,321 FLOPs — counted analytically as the NumPy call runs.

READ ON

Explore the docs.