Skip to content
spclPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

FP-Arena

Prototype custom floating-point formats in DaCe. FP-Arena registers new float types (stochastic rounding, MPFR) into DaCe at import time, retypes existing programs to them, and measures the error and runtime of each precision choice. DaCe itself is not changed.

Install

pip install "fp-arena[dace]"       # spcl's dace >= 2.0.0b2
pip install "fp-arena[extended]"   # DaCe extended (dace-extended), adds GPU vectorization

Both extras install the dace package; take one. With your own DaCe checkout, pip install fp-arena pulls no DaCe.

Ideas

  • Types. float16sr, float32sr, float64sr store like IEEE fp16/32/64 but round every operation stochastically: the result is computed exactly (in double, or with error-free transforms for fp64) and rounded up with probability equal to its distance from the lower neighbour. dace.mpfr(bits) gives arbitrary precision.
  • Retyping. change_and_propagate_fp_types(sdfg, {"A": dace.float16}) pins arrays to a type and propagates it through the dataflow with promotion rules, inserting explicit casts. With storage_only=True only the pinned arrays change: computation and every other array keep the program's precision, values are rounded on store and widened on load.
  • Experiments. fp_arena.search measures error against a reference, runtime, and input sensitivity per precision point, and searches for the cheapest point within an error budget.

Quick start

import numpy as np
import dace
import fp_arena  # registers the types; SDFGs using them get headers and precise math

@dace.program
def axpy(a: fp_arena.float32sr[1024], b: fp_arena.float32sr[1024], c: fp_arena.float32sr[1024]):
    for i in dace.map[0:1024]:
        c[i] = a[i] * b[i] + c[i]

a = np.ones(1024, np.float32)
b = np.ones(1024, np.float32)
c = np.ones(1024, np.float32)
axpy(a=a, b=b, c=c)

Stochastic rounding needs exact IEEE rounding, so SDFGs that use an FP-Arena type compile without fast-math. gpu_vectorize needs DaCe extended; on spcl's dace it is a no-op with a warning.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages