ingonyama-zk / icicle

A hardware acceleration library for compute intensive cryptography :ice_cube:
https://dev.ingonyama.com/icicle/overview
MIT License
329 stars 97 forks source link

hotfix for slow twiddles on small domain sizes #557

Open vhnatyk opened 2 months ago

vhnatyk commented 2 months ago

Describe the changes

This PR is a hotfix for ntt domains of log2 sizes < 4

Linked Issues

Resolves #

vhnatyk commented 2 months ago

"proper fix" - the fast twiddles must only be used with mixed radix ntt, so should be part of config and not decoupled or validated. But maybe it's late to refactor v2 for this

vhnatyk commented 2 months ago

I would add the following to init_domain() just before constructing the fast twiddles, to disable it from there rather than calling a function that seems to return success but doesn't do anything.

fast_twiddles_mode &= domain.max_log_size >= 4; // fast twiddles cannot be built for smaller domain

so this would solve one particular call to a generate_external_twiddles_fast_twiddles_mode , not fix the function itself. And cudaSuccess is default return if no CUDA errors during the call anyway. But since it's called only once perhaps it's indeed ok