NNPDF / pineappl

PineAPPL is not an extension of APPLgrid
https://nnpdf.github.io/pineappl/
GNU General Public License v3.0
12 stars 3 forks source link

Add single- and half- (?) precision float subgrid types #119

Open cschwan opened 2 years ago

cschwan commented 2 years ago

Currently we store the full double-precision information in subgrids, but this is more precision than we need; the interpolation error is typically sub-per mille, meaning that we get four to five correct digits. This means we should be able to store all numerical data with single-precision floats (f32), and maybe we can even get away with half-precision floats (f16).

alecandido commented 2 years ago

I perfectly agree, I'm planning to do the same thing in eko and yadism.

Since we usually do not target precision less 1e-6 (and this is really the best we hope for). Half precision might be a bit too hard:

>>> import numpy as np  
>>> np.finfo(np.float32)
finfo(resolution=1e-06, min=-3.4028235e+38, max=3.4028235e+38, dtype=float32)
>>> np.finfo(np.float16)
finfo(resolution=0.001, min=-6.55040e+04, max=6.55040e+04, dtype=float16)

It might be interesting to keep as an option f16, but it can result even in considerable overhead, so I'm not sure.

cschwan commented 2 years ago

I agree, half-precision might be too pushing it outside the precision we need, but since Rust has generics I can design a subgrid type that supports basically any floating-point type, including f64, f32, f16. Then we can experiment a bit with f16 without expecting too much from it.