chore(ci): add workflow to update documentation benchmark tables

This new workflow can trigger all the required benchmarks needed
to populate benchmarks tables in documentation.
It also can generate SVG tables and store them as artifacts.
Optionally, it can open a pull-request to update the current
tables in documentation.
This commit is contained in:
David Testé
2025-11-20 18:24:27 +01:00
committed by David Testé
parent 3c76dd8cad
commit b3c3647530
14 changed files with 572 additions and 170 deletions

View File

@@ -351,12 +351,33 @@ const BENCH_BIT_SIZES: [usize; 8] = [2, 8, 16, 32, 40, 64, 128, 256];
const BENCH_BIT_SIZES: [usize; 7] = [8, 16, 32, 40, 64, 128, 256];
const HPU_BENCH_BIT_SIZES: [usize; 5] = [8, 16, 32, 64, 128];
const MULTI_BIT_CPU_SIZES: [usize; 5] = [8, 16, 32, 40, 64];
const BENCH_BIT_SIZES_DOCUMENTATION: [usize; 5] = [8, 16, 32, 64, 128];
#[derive(Default)]
pub enum BitSizesSet {
#[default]
Fast,
All,
Documentation,
}
impl BitSizesSet {
pub fn from_env() -> Result<Self, String> {
let raw_value = env::var("__TFHE_RS_BENCH_BIT_SIZES_SET").unwrap_or("fast".to_string());
match raw_value.to_lowercase().as_str() {
"fast" => Ok(BitSizesSet::Fast),
"all" => Ok(BitSizesSet::All),
"documentation" => Ok(BitSizesSet::Documentation),
_ => Err(format!("bit sizes set '{raw_value}' is not supported")),
}
}
}
/// User configuration in which benchmarks must be run.
#[derive(Default)]
pub struct EnvConfig {
pub is_multi_bit: bool,
pub is_fast_bench: bool,
pub bit_sizes_set: BitSizesSet,
}
impl EnvConfig {
@@ -366,22 +387,21 @@ impl EnvConfig {
ParamType::MultiBit | ParamType::MultiBitDocumentation
);
let is_fast_bench = match env::var("__TFHE_RS_FAST_BENCH") {
Ok(val) => val.to_lowercase() == "true",
Err(_) => false,
};
EnvConfig {
is_multi_bit,
is_fast_bench,
bit_sizes_set: BitSizesSet::from_env().unwrap(),
}
}
/// Get precisions values to benchmark.
pub fn bit_sizes(&self) -> Vec<usize> {
if self.is_fast_bench {
FAST_BENCH_BIT_SIZES.to_vec()
} else if self.is_multi_bit {
let bit_sizes_set = match self.bit_sizes_set {
BitSizesSet::Fast => return FAST_BENCH_BIT_SIZES.to_vec(),
BitSizesSet::All => BENCH_BIT_SIZES.to_vec(),
BitSizesSet::Documentation => return BENCH_BIT_SIZES_DOCUMENTATION.to_vec(),
};
if self.is_multi_bit {
if cfg!(feature = "gpu") {
BENCH_BIT_SIZES.to_vec()
} else {
@@ -390,7 +410,7 @@ impl EnvConfig {
} else if cfg!(feature = "hpu") {
HPU_BENCH_BIT_SIZES.to_vec()
} else {
BENCH_BIT_SIZES.to_vec()
bit_sizes_set
}
}
}