Compare commits

...

1 Commits

Author SHA1 Message Date
Agnes Leroy
9037c2ceac chore(gpu): update noise squashing parameters 2025-07-03 14:29:46 +01:00
18 changed files with 66 additions and 34 deletions

View File

@@ -178,8 +178,8 @@ mod cuda {
use tfhe::core_crypto::prelude::*;
use tfhe::shortint::engine::ShortintEngine;
use tfhe::shortint::parameters::{
ModulusSwitchType, NOISE_SQUASHING_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
ModulusSwitchType, NOISE_SQUASHING_PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
};
use tfhe::shortint::server_key::ModulusSwitchNoiseReductionKey;
@@ -191,8 +191,8 @@ mod cuda {
.measurement_time(std::time::Duration::from_secs(30));
type Scalar = u128;
let input_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let squash_params = NOISE_SQUASHING_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let input_params = PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let squash_params = NOISE_SQUASHING_PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
let lwe_noise_distribution_u64 = DynamicDistribution::new_t_uniform(46);
let ct_modulus_u64: CiphertextModulus<u64> = CiphertextModulus::new_native();

View File

@@ -1,6 +1,6 @@
[package]
name = "tfhe"
version = "1.3.0"
version = "1.3.1"
edition = "2021"
readme = "../README.md"
keywords = ["fully", "homomorphic", "encryption", "fhe", "cryptography"]

View File

@@ -18,7 +18,7 @@ This guide explains how to update your existing program to leverage GPU accelera
To use the **TFHE-rs** GPU backend in your project, add the following dependency in your `Cargo.toml`.
```toml
tfhe = { version = "~1.3.0", features = ["boolean", "shortint", "integer", "gpu"] }
tfhe = { version = "~1.3.1", features = ["boolean", "shortint", "integer", "gpu"] }
```
{% hint style="success" %}

View File

@@ -17,7 +17,7 @@ This guide explains how to update your existing program to leverage HPU accelera
To use the **TFHE-rs** HPU backend in your project, add the following dependency in your `Cargo.toml`.
```toml
tfhe = { version = "~1.3.0", features = ["integer", "hpu-v80"] }
tfhe = { version = "~1.3.1", features = ["integer", "hpu-v80"] }
```
{% hint style="success" %}

View File

@@ -16,7 +16,7 @@ You can load serialized data with the `unversionize` function, even in newer ver
[dependencies]
# ...
tfhe = { version = "~1.3.0", features = ["integer"] }
tfhe = { version = "~1.3.1", features = ["integer"] }
tfhe-versionable = "0.5.0"
bincode = "1.3.3"
```

View File

@@ -161,7 +161,7 @@ In the following example, we use [bincode](https://crates.io/crates/bincode) for
[dependencies]
# ...
tfhe = { version = "~1.3.0", features = ["integer"] }
tfhe = { version = "~1.3.1", features = ["integer"] }
bincode = "1.3.3"
```

View File

@@ -19,7 +19,7 @@ The following example shows a complete workflow of working with encrypted arrays
# Cargo.toml
[dependencies]
tfhe = { version = "~1.3.0", features = ["integer"] }
tfhe = { version = "~1.3.1", features = ["integer"] }
```
```rust

View File

@@ -29,7 +29,7 @@ Here is an example:
# Cargo.toml
[dependencies]
tfhe = { version = "~1.3.0", features = ["integer", "strings"] }
tfhe = { version = "~1.3.1", features = ["integer", "strings"] }
```
```rust

View File

@@ -7,7 +7,7 @@ This document provides instructions to set up **TFHE-rs** in your project.
First, add **TFHE-rs** as a dependency in your `Cargo.toml`.
```toml
tfhe = { version = "~1.3.0", features = ["boolean", "shortint", "integer"] }
tfhe = { version = "~1.3.1", features = ["boolean", "shortint", "integer"] }
```
{% hint style="info" %}
@@ -35,5 +35,5 @@ By default, **TFHE-rs** makes the assumption that hardware AES features are enab
To add support for older CPU, import **TFHE-rs** with the `software-prng` feature in your `Cargo.toml`:
```toml
tfhe = { version = "~1.3.0", features = ["boolean", "shortint", "integer", "software-prng"] }
tfhe = { version = "~1.3.1", features = ["boolean", "shortint", "integer", "software-prng"] }
```

View File

@@ -59,7 +59,7 @@ edition = "2021"
Then add the following configuration to include **TFHE-rs**:
```toml
tfhe = { version = "~1.3.0", features = ["integer"] }
tfhe = { version = "~1.3.1", features = ["integer"] }
```
Your updated `Cargo.toml` file should look like this:
@@ -71,7 +71,7 @@ version = "0.1.0"
edition = "2021"
[dependencies]
tfhe = { version = "~1.3.0", features = ["integer"] }
tfhe = { version = "~1.3.1", features = ["integer"] }
```
If you are on a different platform please refer to the [installation documentation](installation.md) for configuration options of other supported platforms.

View File

@@ -9,7 +9,7 @@ Welcome to this tutorial about `TFHE-rs` `core_crypto` module.
To use `TFHE-rs`, it first has to be added as a dependency in the `Cargo.toml`:
```toml
tfhe = { version = "~1.3.0" }
tfhe = { version = "~1.3.1" }
```
### Commented code to double a 2-bit message in a leveled fashion and using a PBS with the `core_crypto` module.

View File

@@ -28,7 +28,7 @@ To use the `FheUint8` type, enable the `integer` feature:
# Cargo.toml
[dependencies]
tfhe = { version = "~1.3.0", features = ["integer"] }
tfhe = { version = "~1.3.1", features = ["integer"] }
```
The `MyFheString::encrypt` function performs data validation to ensure the input string contains only ASCII characters.
@@ -167,7 +167,7 @@ First, add the feature in your `Cargo.toml`
# Cargo.toml
[dependencies]
tfhe = { version = "~1.3.0", features = ["strings"] }
tfhe = { version = "~1.3.1", features = ["strings"] }
```
The `FheAsciiString` type allows to simply do homomorphic case changing of encrypted strings (and much more!):

View File

@@ -17,7 +17,7 @@ This function returns a Boolean (`true` or `false`) so that the total count of `
```toml
# Cargo.toml
tfhe = { version = "~1.3.0", features = ["integer"] }
tfhe = { version = "~1.3.1", features = ["integer"] }
```
First, define the verification function.

View File

@@ -1,5 +1,8 @@
pub(crate) use crate::core_crypto::algorithms::test::gen_keys_or_get_from_cache_if_enabled;
use crate::shortint::parameters::DynamicDistribution;
use crate::shortint::parameters::{
DynamicDistribution, NOISE_SQUASHING_PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
};
use crate::shortint::prelude::{DecompositionBaseLog, LweDimension};
use crate::core_crypto::algorithms::par_allocate_and_generate_new_lwe_bootstrap_key;
@@ -18,13 +21,9 @@ use crate::core_crypto::prelude::{
Plaintext, SignedDecomposer, UnsignedTorus,
};
use crate::shortint::engine::ShortintEngine;
use crate::shortint::parameters::{
ModulusSwitchType, NoiseSquashingParameters,
NOISE_SQUASHING_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
};
use crate::shortint::parameters::{ModulusSwitchType, NoiseSquashingParameters};
use crate::shortint::server_key::ModulusSwitchNoiseReductionKey;
use crate::shortint::ClassicPBSParameters;
use crate::shortint::MultiBitPBSParameters;
use serde::de::DeserializeOwned;
use serde::Serialize;
@@ -74,7 +73,7 @@ pub fn generate_keys<
pub fn execute_bootstrap_u128(
squash_params: NoiseSquashingParameters,
input_params: ClassicPBSParameters,
input_params: MultiBitPBSParameters,
) {
let glwe_dimension = squash_params.glwe_dimension;
let polynomial_size = squash_params.polynomial_size;
@@ -209,7 +208,7 @@ pub fn execute_bootstrap_u128(
#[test]
fn test_bootstrap_u128_with_squashing() {
execute_bootstrap_u128(
NOISE_SQUASHING_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
NOISE_SQUASHING_PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
);
}

View File

@@ -4,6 +4,8 @@ use crate::high_level_api::{
};
use crate::integer::U256;
use crate::set_server_key;
#[cfg(feature = "gpu")]
use crate::shortint::parameters::NOISE_SQUASHING_PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
use crate::shortint::parameters::{
NOISE_SQUASHING_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
@@ -82,7 +84,7 @@ fn test_gpu_noise_squashing() {
let config = ConfigBuilder::with_custom_parameters(
crate::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
)
.enable_noise_squashing(NOISE_SQUASHING_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128)
.enable_noise_squashing(NOISE_SQUASHING_PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128)
.build();
let cks = crate::ClientKey::generate(config);
let sks = cks.generate_compressed_server_key();

View File

@@ -5,6 +5,7 @@ use crate::shortint::parameters::{
};
use crate::shortint::parameters::current_params::key_switching::p_fail_2_minus_128::ks_pbs_gpu::V1_3_PARAM_MULTI_BIT_GROUP_4_KEYSWITCH_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
use crate::shortint::parameters::v1_3::V1_3_NOISE_SQUASHING_PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
use current_params::classic::gaussian::p_fail_2_minus_128::ks_pbs::{
V1_3_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
V1_3_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
@@ -120,6 +121,10 @@ pub const NOISE_SQUASHING_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128:
NoiseSquashingCompressionParameters =
V1_3_NOISE_SQUASHING_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
pub const NOISE_SQUASHING_PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128:
NoiseSquashingParameters =
V1_3_NOISE_SQUASHING_PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
// GPU 2^-64
// GPU TUniform
pub const PARAM_GPU_MULTI_BIT_GROUP_4_MESSAGE_1_CARRY_1_KS_PBS_TUNIFORM_2M64:

View File

@@ -1689,10 +1689,16 @@ pub const VEC_ALL_COMPACT_PUBLIC_KEY_ENCRYPTION_PARAMETERS: [(
];
/// All [`NoiseSquashingParameters`] in this module.
pub const VEC_ALL_NOISE_SQUASHING_PARAMETERS: [(&NoiseSquashingParameters, &str); 1] = [(
&V1_3_NOISE_SQUASHING_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
"V1_3_NOISE_SQUASHING_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128",
)];
pub const VEC_ALL_NOISE_SQUASHING_PARAMETERS: [(&NoiseSquashingParameters, &str); 2] = [
(
&V1_3_NOISE_SQUASHING_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
"V1_3_NOISE_SQUASHING_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128",
),
(
&V1_3_NOISE_SQUASHING_PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
"V1_3_NOISE_SQUASHING_PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128",
),
];
/// All [`NoiseSquashingCompressionParameters`] in this module.
pub const VEC_ALL_NOISE_SQUASHING_COMPRESSION_PARAMETERS: [(

View File

@@ -38,3 +38,23 @@ pub const V1_3_NOISE_SQUASHING_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M12
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(4),
};
pub const V1_3_NOISE_SQUASHING_PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128:
NoiseSquashingParameters = NoiseSquashingParameters {
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(4096),
glwe_noise_distribution: DynamicDistribution::new_t_uniform(30),
decomp_base_log: DecompositionBaseLog(24),
decomp_level_count: DecompositionLevelCount(3),
modulus_switch_noise_reduction_params: ModulusSwitchType::DriftTechniqueNoiseReduction(
ModulusSwitchNoiseReductionParams {
modulus_switch_zeros_count: LweCiphertextCount(2827),
ms_bound: NoiseEstimationMeasureBound(288230376151711744f64),
ms_r_sigma_factor: RSigmaFactor(20.83904137608219f64),
ms_input_variance: Variance(2.7596542105799535e-07f64),
},
),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(4),
ciphertext_modulus: CoreCiphertextModulus::<u128>::new_native(),
};