feat(hpu): Add Hpu TUniform parameter inside shortint list.

Enable to use this Hpu TUniform parameter set inside hpu benches.
Also update hpu targets in Makefile
This commit is contained in:
pgardratzama
2025-04-28 12:29:47 +02:00
committed by Baptiste Roux
parent 5e7546756d
commit 1c0202562b
5 changed files with 30 additions and 7 deletions

View File

@@ -57,9 +57,7 @@ TFHECUDA_SRC=backends/tfhe-cuda-backend/cuda
TFHECUDA_BUILD=$(TFHECUDA_SRC)/build
# tfhe-hpu-backend
HPU_BACKEND_DIR=$(shell pwd)/backends/tfhe-hpu-backend
HPU_CONFIG=v80
V80_PCIE_DEV=$(shell lspci -d 10ee:50b5 | sed -e "s/\(..\).*/\1/")
# Exclude these files from coverage reports
define COVERAGE_EXCLUDED_FILES
@@ -1148,6 +1146,7 @@ bench_signed_integer_gpu: install_rs_check_toolchain
.PHONY: bench_integer_hpu # Run benchmarks for integer on HPU backend
bench_integer_hpu: install_rs_check_toolchain
source ./setup_hpu.sh --config $(HPU_CONFIG) ; \
RUSTFLAGS="$(RUSTFLAGS)" __TFHE_RS_BENCH_OP_FLAVOR=$(BENCH_OP_FLAVOR) __TFHE_RS_FAST_BENCH=$(FAST_BENCH) __TFHE_RS_BENCH_TYPE=$(BENCH_TYPE) \
cargo $(CARGO_RS_CHECK_TOOLCHAIN) bench \
--bench integer-bench \
--features=integer,internal-keycache,pbs-stats,hpu,hpu-v80 -p $(TFHE_SPEC) -- --quick
@@ -1341,8 +1340,8 @@ bench_hlapi_erc20_gpu: install_rs_check_toolchain
.PHONY: bench_hlapi_erc20_hpu # Run benchmarks for ECR20 operations on HPU
bench_hlapi_erc20_hpu: install_rs_check_toolchain
source ./setup_hpu.sh --config $(HPU_CONFIG)
RUSTFLAGS="$(RUSTFLAGS)" HPU_BACKEND_DIR="$(HPU_BACKEND_DIR)" HPU_CONFIG="$(HPU_CONFIG)" V80_PCIE_DEV="$(V80_PCIE_DEV)" \
source ./setup_hpu.sh --config $(HPU_CONFIG) ; \
RUSTFLAGS="$(RUSTFLAGS)" \
cargo $(CARGO_RS_CHECK_TOOLCHAIN) bench \
--bench hlapi-erc20 \
--features=integer,internal-keycache,hpu,hpu-v80 -p $(TFHE_SPEC) -- --quick

View File

@@ -410,7 +410,7 @@ fn hpu_bench_transfer_throughput<FheType, F>(
{
let mut rng = thread_rng();
for num_elems in [10, 100, 300] {
for num_elems in [10, 100] {
group.throughput(Throughput::Elements(num_elems));
let bench_id =
format!("{bench_name}::throughput::{fn_name}::{type_name}::{num_elems}_elems");

View File

@@ -42,7 +42,7 @@ pub mod shortint_utils {
use std::vec::IntoIter;
use tfhe::shortint::parameters::compact_public_key_only::CompactPublicKeyEncryptionParameters;
#[cfg(feature = "hpu")]
use tfhe::shortint::parameters::current_params::V1_1_HPU_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
use tfhe::shortint::parameters::current_params::V1_1_HPU_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
#[cfg(not(any(feature = "gpu", feature = "hpu")))]
use tfhe::shortint::parameters::current_params::V1_1_PARAM_MULTI_BIT_GROUP_4_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
use tfhe::shortint::parameters::list_compression::CompressionParameters;
@@ -96,7 +96,7 @@ pub mod shortint_utils {
// FIXME One set of parameter is tested since we want to benchmark only quickest
// operations.
#[cfg(feature = "hpu")]
let params = vec![V1_1_HPU_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64.into()];
let params = vec![V1_1_HPU_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.into()];
#[cfg(not(feature = "hpu"))]
let params = vec![PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128.into()];

View File

@@ -406,6 +406,8 @@ named_params_impl!( ShortintParameterSet =>
#[cfg(feature ="hpu")]
V1_1_HPU_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
#[cfg(feature ="hpu")]
V1_1_HPU_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
);
impl NamedParam for ClassicPBSParameters {

View File

@@ -87,3 +87,25 @@ pub const V1_1_PARAM_MESSAGE_4_CARRY_4_KS_PBS_TUNIFORM_2M64: ClassicPBSParameter
encryption_key_choice: EncryptionKeyChoice::Big,
modulus_switch_noise_reduction_params: None,
};
#[cfg(feature = "hpu")]
// p-fail = 2^-64, dedicated to HPU hardware
pub const V1_1_HPU_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64: ClassicPBSParameters =
ClassicPBSParameters {
lwe_dimension: LweDimension(839),
glwe_dimension: GlweDimension(1),
polynomial_size: PolynomialSize(2048),
lwe_noise_distribution: DynamicDistribution::new_t_uniform(4),
glwe_noise_distribution: DynamicDistribution::new_t_uniform(17),
pbs_base_log: DecompositionBaseLog(23),
pbs_level: DecompositionLevelCount(1),
ks_base_log: DecompositionBaseLog(2),
ks_level: DecompositionLevelCount(7),
message_modulus: MessageModulus(4),
carry_modulus: CarryModulus(4),
max_noise_level: MaxNoiseLevel::new(5),
log2_p_fail: -64.0,
ciphertext_modulus: CiphertextModulus::new_native(),
encryption_key_choice: EncryptionKeyChoice::Big,
modulus_switch_noise_reduction_params: None,
};