From 2e1e743bcc8fbadf3fca6f8cb6ef905aebd90a30 Mon Sep 17 00:00:00 2001 From: Agnes Leroy Date: Mon, 10 Feb 2025 10:13:39 +0100 Subject: [PATCH] fix(gpu): fix degree after shift/rotate --- .../cuda/include/integer/integer_utilities.h | 4 +++- .../tfhe-cuda-backend/cuda/src/integer/shift_and_rotate.cuh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backends/tfhe-cuda-backend/cuda/include/integer/integer_utilities.h b/backends/tfhe-cuda-backend/cuda/include/integer/integer_utilities.h index cf2308aa8..5d7231484 100644 --- a/backends/tfhe-cuda-backend/cuda/include/integer/integer_utilities.h +++ b/backends/tfhe-cuda-backend/cuda/include/integer/integer_utilities.h @@ -799,7 +799,9 @@ template struct int_shift_and_rotate_buffer { params.carry_modulus, mux_lut_f); mux_lut->broadcast_lut(streams, gpu_indexes, 0); - auto cleaning_lut_f = [](Torus x) -> Torus { return x; }; + auto cleaning_lut_f = [params](Torus x) -> Torus { + return x % params.message_modulus; + }; generate_device_accumulator( streams[0], gpu_indexes[0], cleaning_lut->get_lut(0, 0), cleaning_lut->get_degree(0), cleaning_lut->get_max_degree(0), diff --git a/backends/tfhe-cuda-backend/cuda/src/integer/shift_and_rotate.cuh b/backends/tfhe-cuda-backend/cuda/src/integer/shift_and_rotate.cuh index de79803d2..223610ab9 100644 --- a/backends/tfhe-cuda-backend/cuda/src/integer/shift_and_rotate.cuh +++ b/backends/tfhe-cuda-backend/cuda/src/integer/shift_and_rotate.cuh @@ -185,7 +185,7 @@ __host__ void host_integer_radix_shift_and_rotate_kb_inplace( // control_bit|b|a integer_radix_apply_univariate_lookup_table_kb( streams, gpu_indexes, gpu_count, input_bits_a, mux_inputs, bsks, ksks, - mux_lut, mux_inputs->num_radix_blocks); + mux_lut, total_nb_bits); } // Initializes the output