
whest
NumPy-compatible math primitives with analytical FLOP counting.
whest is not a drop-in NumPy replacement
Operations have analytical FLOP costs and 35 operations are blocked.
A BudgetContext is optional โ a global default activates automatically โ but
using one explicitly gives you budget limits, namespacing, and summaries.
See Operation Categories.
Pick the path that matches what you need right now.
๐ I want to get started
๐ Something isn't working
๐ I want to write efficient code with whest
- Migrate from NumPy
- Use Einsum
- Exploit Symmetry
- Use Linear Algebra
- Plan Your Budget
- Calibrate Weights
- Debug Budget Overruns
๐ง I want to understand how it works
- FLOP Counting Model โ how costs are computed, why FLOPs
- Operation Categories โ free vs counted vs unsupported
๐ I want to understand the sandboxed architecture
- Client-Server Model โ why it exists, how it works
- Running with Docker โ local setup with Docker
๐งช I want to work on the repository
- Contributor Guide โ repo layout, test commands, generated docs
Quick example
Operations run freely without any setup โ the global default budget tracks FLOPs automatically:
import whest as we
# No BudgetContext needed โ the global default is active
scale = we.sqrt(we.array(2 / 256))
W = we.multiply(we.random.randn(256, 256), scale)
x = we.einsum('ij,j->i', W, we.random.randn(256))
we.budget_summary()
For budget limits and namespacing, use an explicit BudgetContext:
import whest as we
depth, width = 5, 256
with we.BudgetContext(flop_budget=10**8, namespace="mlp-forward") as budget:
# Weight init โ randn and multiply are both counted
scale = we.sqrt(we.array(2 / width))
weights = [we.multiply(we.random.randn(width, width), scale)
for _ in range(depth)]
# Forward pass
x = we.random.randn(width)
h = x
for i, W in enumerate(weights):
h = we.einsum('ij,j->i', W, h) # linear layer
if i < depth - 1:
h = we.maximum(h, 0) # ReLU
we.budget_summary()
whest FLOP Budget Summary
==================================================
Total budget: 100,000,000
Used: 984,322 (1.0%)
Remaining: 99,015,678 (99.0%)
[mlp-forward]
Budget: 100,000,000
Used: 984,322 (1.0%)
Operations:
random.randn 327,936 ( 33.3%) [6 calls]
multiply 327,680 ( 33.3%) [5 calls]
einsum 327,680 ( 33.3%) [5 calls]
maximum 1,024 ( 0.1%) [4 calls]
array 1 ( 0.0%) [1 call]
sqrt 1 ( 0.0%) [1 call]
All operations (session total):
random.randn 327,936 ( 33.3%) [6 calls]
multiply 327,680 ( 33.3%) [5 calls]
einsum 327,680 ( 33.3%) [5 calls]
maximum 1,024 ( 0.1%) [4 calls]
array 1 ( 0.0%) [1 call]
sqrt 1 ( 0.0%) [1 call]
Installation
Full Taxonomy
- Getting Started: Installation, Your First Budget
- How-To: Migrate from NumPy, Use Einsum, Exploit Symmetry, Use Linear Algebra, Use FFT, Plan Your Budget, Calibrate Weights, Debug Budget Overruns
- Concepts: FLOP Counting Model, Operation Categories, NumPy Compatibility Testing
- Architecture: Client-Server Model, Running with Docker
- Development: Contributor Guide
- API Reference: Counted Ops, Free Ops, Symmetric Tensors, Linear Algebra, FFT, Random, Polynomial, Window Functions, Budget, FLOP Cost Query, Errors
- Reference: For AI Agents, Operation Audit, FLOP Cost Cheat Sheet
- Troubleshooting: Common Errors
- Changelog: Changelog