Neptune-Crypto / twenty-first

Collection of mathematics routines and cryptography for the twenty-first century
GNU General Public License v2.0
74 stars 22 forks source link

Investigate `fast_interpolate` #210

Open aszepieniec opened 6 months ago

aszepieniec commented 6 months ago

Commit a0a4cc0ebff7ac940262b60dbfe1006e6ea3efda separates parallel from sequential versions of fast_interpolate. The resulting benchmarks shows that there is no threshold for which fast_interpolate is faster than lagrange_interpolate, even though one would expect such a threshold to exist based on the asymptotics. I suspect the issue is due to these lines

        let (left_zerofier, right_zerofier) = (
            Self::zerofier(left_domain_half),
            Self::zerofier(right_domain_half),
        );

        let (left_offset, right_offset) = (
            right_zerofier.batch_evaluate(left_domain_half),
            left_zerofier.batch_evaluate(right_domain_half),
        );

which, in a recursive context, will end up computing the same zerofiers (or factors thereof) over and over again. To make the fast interpolation fast, we need to memoize the zerofiers or otherwise avoid doing redundant work.

This task is not critical because, as far as I can tell, no component in Triton VM or Neptune relies on it.