GPU key generation for multiplication

Hello I’m trying to combine two examples the one from [GPU acceleration | 0.6 | TFHE-rs (zama.ai)] and the other one from [Computation on encrypted data | 0.6 | TFHE-rs (zama.ai)]. The speed computation is very obvious but if I use this approach for key generation

let config = ConfigBuilder::with_custom_parameters(PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS, None).build();

    let client_key= ClientKey::generate(config);
    let compressed_server_key = CompressedServerKey::new(&client_key);

    let gpu_key = compressed_server_key.decompress_to_gpu();

It fails to do multiplication and divisions. Any of you guide me on how to generate the GPU key and do the multiplication?

Regards,
Claoo

Hey @Claudiu_Stirbei! What is the error that you are getting? Maybe you’re out of memory on the GPU?

This is my code

use tfhe::{ConfigBuilder, set_server_key, FheUint8, ClientKey, CompressedServerKey};
use tfhe::prelude::*;
use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS;

fn main() {

let config = ConfigBuilder::with_custom_parameters(PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS, None).build();

let client_key= ClientKey::generate(config);
let compressed_server_key = CompressedServerKey::new(&client_key);

let gpu_key = compressed_server_key.decompress_to_gpu();

let clear_a = 3u8;
let clear_b = 8u8;

let a = FheUint8::encrypt(clear_a, &client_key);
let b = FheUint8::encrypt(clear_b, &client_key);

let a = &a;
let b = &b;

//Server-side

set_server_key(gpu_key);
let result = a + b;
let mult = a * b;

//Client-side
let decrypted_result: u8 = result.decrypt(&client_key);

let clear_result = clear_a + clear_b;

assert_eq!(decrypted_result, clear_result);

let decrypted_mult: u8 = mult.decrypt(&client_key);

let clear_mult = clear_a * clear_b;

assert_eq!(decrypted_mult, clear_mult);

}

this is the error:
demo1: /home/claoo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tfhe-cuda-backend-0.2.0/cuda/include/integer.h:455: int_radix_lut::int_radix_lut(cuda_stream_t*, int_radix_params, uint32_t, uint32_t, int_radix_lut*) [with Torus = long unsigned int; uint32_t = unsigned int]: Assertion `num_radix_blocks <= base_lut_object->num_blocks’ failed.
this is the assembly line where it is happening
7FFFF78419FC: 41 89 C5 movl %eax, %r13d
with Exception has occurred: Signal x
signal SIGABRT

Hmm with this code I don’t get this error on tfhe-cuda-backend 0.2.0, nor main: the code executes correctly. Could you try removing these two lines just to check:

let a = &a;
let b = &b;

It shouldn’t make any difference but just to be sure.

Also, just to be sure, could you try to cargo clean and cargo run --release again please?

You’re a genius. It only crashes when I try step-by-step debug on source code. I’m using VS Code. It is any trick to make debugging to work?
Great video about GPU topic and FheBool basically the today’s video answered to both of my questions from yesterday. Tailor made.
Thank you very much, I appreciate the work and effort.
Claoo

By the way, I tested the code from the GPU acceleration video tutorial and in debug mode is getting the same ugly error.

Oh interesting: I don’t use vscode so I’ve never tried to do this. We’ll try to check it out, see why this is happening and find a fix if possible.

Cheers,
Agnes

1 Like