13 releases (7 breaking)

new 0.8.1 Mar 6, 2025
0.7.0 Jan 7, 2025
0.6.0 Nov 6, 2024
0.4.0-alpha.0 Jul 17, 2024
0.1.3 Jan 30, 2024

#1802 in Cryptography

Download history 11/week @ 2024-11-18 26/week @ 2024-12-02 17/week @ 2024-12-09 120/week @ 2025-01-06 10/week @ 2025-01-13 1/week @ 2025-01-20 5/week @ 2025-02-03 32/week @ 2025-02-10 134/week @ 2025-02-17 12/week @ 2025-02-24 182/week @ 2025-03-03

361 downloads per month
Used in tfhe

BSD-3-Clause-Clear

1MB
16K SLoC

CUDA 12K SLoC // 0.0% comments C++ 2K SLoC // 0.1% comments Rust 2K SLoC // 0.0% comments Shell 16 SLoC // 0.2% comments Forge Config 3 SLoC

TFHE Cuda backend

Introduction

The tfhe-cuda-backend holds the code for GPU acceleration of Zama's variant of TFHE. It implements CUDA/C++ functions to perform homomorphic operations on LWE ciphertexts.

It provides functions to allocate memory on the GPU, to copy data back and forth between the CPU and the GPU, to create and destroy Cuda streams, etc.:

  • cuda_create_stream, cuda_destroy_stream
  • cuda_malloc, cuda_check_valid_malloc
  • cuda_memcpy_async_to_cpu, cuda_memcpy_async_to_gpu
  • cuda_get_number_of_gpus
  • cuda_synchronize_device The cryptographic operations it provides are:
  • an implementation of the classical TFHE programmable bootstrap,
  • an implementation of the multi-bit TFHE programmable bootstrap,
  • the keyswitch,
  • acceleration for leveled operations,
  • acceleration for arithmetics over encrypted integers of arbitrary size,
  • acceleration for integer compression/decompression.

Dependencies

Disclaimer: Compilation on Windows/Mac is not supported yet. Only Nvidia GPUs are supported.

  • nvidia driver - for example, if you're running Ubuntu 20.04 check this page for installation. You need an Nvidia GPU with Compute Capability >= 3.0
  • nvcc >= 10.0
  • gcc >= 8.0 - check this page for more details about nvcc/gcc compatible versions
  • cmake >= 3.24
  • libclang, to match Rust bingen requirements >= 9.0

Build

The Cuda project held in tfhe-cuda-backend can be compiled independently of TFHE-rs in the following way:

git clone git@github.com:zama-ai/tfhe-rs
cd backends/tfhe-cuda-backend/cuda
mkdir build
cd build
cmake ..
make

The compute capability is detected automatically (with the first GPU information) and set accordingly. If your machine does not have an available Nvidia GPU, the compilation will work if you have the nvcc compiler installed. The generated executable will target a 7.0 compute capability (sm_70).

License

This software is distributed under the BSD-3-Clause-Clear license. If you have any questions, please contact us at hello@zama.ai.

No runtime deps

~0–2.3MB
~46K SLoC