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.
pip install "fp-arena[dace]" # spcl's dace >= 2.0.0b2
pip install "fp-arena[extended]" # DaCe extended (dace-extended), adds GPU vectorizationBoth extras install the dace package; take one. With your own DaCe checkout, pip install fp-arena pulls no DaCe.
- Types.
float16sr,float32sr,float64srstore like IEEE fp16/32/64 but round every operation stochastically: the result is computed exactly (indouble, 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. Withstorage_only=Trueonly 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.searchmeasures error against a reference, runtime, and input sensitivity per precision point, and searches for the cheapest point within an error budget.
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.