diff --git a/icicle/src/ntt/kernel_ntt.cu b/icicle/src/ntt/kernel_ntt.cu index 46e97243f..6acc97528 100644 --- a/icicle/src/ntt/kernel_ntt.cu +++ b/icicle/src/ntt/kernel_ntt.cu @@ -702,6 +702,11 @@ namespace mxntt { { CHK_INIT_IF_RETURN(); + if (log_size < 4) { + // TODO: fast twiddles should be used only with mixed radix ntt + THROW_ICICLE_ERR(IcicleError_t::InvalidArgument, "when using fast twiddles, log_size must be at least 4"); + } + S* w6_table; S* w12_table; S* w18_table; diff --git a/icicle/src/ntt/ntt.cu b/icicle/src/ntt/ntt.cu index 0afe4a296..0e9cbaf5c 100644 --- a/icicle/src/ntt/ntt.cu +++ b/icicle/src/ntt/ntt.cu @@ -469,6 +469,8 @@ namespace ntt { CHK_IF_RETURN(mxntt::generate_external_twiddles_generic( primitive_root, domain.twiddles, domain.internal_twiddles, domain.basic_twiddles, domain.max_log_size, ctx.stream)); + + fast_twiddles_mode &= domain.max_log_size >= 4; // fast twiddles cannot be built for smaller domain if (fast_twiddles_mode) { // generating fast-twiddles (note that this cost 4N additional memory)