Skip to content

whest logo

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

๐Ÿง  I want to understand how it works

๐Ÿ— I want to understand the sandboxed architecture

๐Ÿงช I want to work on the repository

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

uv add git+https://github.com/AIcrowd/whest.git

Full Taxonomy