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
NumPy-compatible operations with analytical FLOP costs.
Symmetry metadata propagates through the chain, so costs scale with unique elements.
Budget contexts, namespaces, and per-operation breakdowns.
What does this code cost?
Same five-layer MLP, written twice. The one on the right counts every FLOP analytically as it runs.
import numpy as np depth, width = 5, 256 # Weight initscale = np.sqrt(2 / width)weights = [ np.random.randn(width, width) * scale for _ in range(depth)] # Forward passx = np.random.randn(width)h = xfor 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.import flopscope as flopsimport flopscope.numpy as fnp depth, width = 5, 256 # Weight initscale = fnp.sqrt(2 / width)weights = [ fnp.random.randn(width, width) * scale for _ in range(depth)] # Forward passx = fnp.random.randn(width)h = xfor 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 FLOPsThe answer, on the right: 984,321 FLOPs — counted analytically as the NumPy call runs.
Explore the docs.
Install flopscope and create your first FLOP budget.
Convert existing code with FLOP annotations.
Search all 508 operations with interactive filters.
How costs are computed analytically.
Interactive einsum symmetry visualization.
Machine-readable resources and rules.
