Skip to content

Commit

Permalink
chore(ci): add randomized long run tests on CPU and GPU
Browse files Browse the repository at this point in the history
  • Loading branch information
agnesLeroy committed Dec 5, 2024
1 parent fd31694 commit 9cb4b03
Show file tree
Hide file tree
Showing 8 changed files with 1,616 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/gpu_integer_long_run_tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: AWS Long Run Tests on GPU
name: Long Run Tests on GPU

env:
CARGO_TERM_COLOR: always
Expand All @@ -15,8 +15,8 @@ on:
# Allows you to run this workflow manually from the Actions tab as an alternative.
workflow_dispatch:
schedule:
# Weekly tests will be triggered each Friday at 1a.m.
- cron: '0 1 * * FRI'
# Nightly tests @ 1AM after each work day
- cron: "0 1 * * MON-FRI"

jobs:
setup-instance:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integer_long_run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ on:
# Allows you to run this workflow manually from the Actions tab as an alternative.
workflow_dispatch:
schedule:
# Weekly tests will be triggered each Friday at 1a.m.
- cron: '0 1 * * FRI'
# Nightly tests @ 1AM after each work day
- cron: "0 1 * * MON-FRI"

jobs:
setup-instance:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,10 @@ clippy_trivium: install_rs_check_toolchain
.PHONY: clippy_all_targets # Run clippy lints on all targets (benches, examples, etc.)
clippy_all_targets: install_rs_check_toolchain
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy --all-targets \
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache,zk-pok,strings \
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache,zk-pok,strings,__long_run_tests \
-p $(TFHE_SPEC) -- --no-deps -D warnings
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy --all-targets \
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache,zk-pok,strings,experimental \
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache,zk-pok,strings,experimental,__long_run_tests \
-p $(TFHE_SPEC) -- --no-deps -D warnings

.PHONY: clippy_tfhe_csprng # Run clippy lints on tfhe-csprng
Expand Down
6 changes: 5 additions & 1 deletion tfhe/src/integer/gpu/server_key/radix/tests_long_run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ use crate::integer::gpu::server_key::radix::tests_unsigned::GpuContext;
use crate::integer::gpu::CudaServerKey;
use crate::integer::server_key::radix_parallel::tests_cases_unsigned::FunctionExecutor;
use crate::integer::{BooleanBlock, RadixCiphertext, RadixClientKey, ServerKey, U256};
use rand::Rng;
use std::sync::Arc;
use tfhe_cuda_backend::cuda_bind::cuda_get_number_of_gpus;

pub(crate) mod test_erc20;
pub(crate) mod test_random_op_sequence;

pub(crate) struct GpuMultiDeviceFunctionExecutor<F> {
pub(crate) context: Option<GpuContext>,
pub(crate) func: F,
Expand All @@ -27,7 +30,8 @@ impl<F> GpuMultiDeviceFunctionExecutor<F> {
impl<F> GpuMultiDeviceFunctionExecutor<F> {
pub(crate) fn setup_from_keys(&mut self, cks: &RadixClientKey, _sks: &Arc<ServerKey>) {
let num_gpus = unsafe { cuda_get_number_of_gpus() } as u32;
let streams = CudaStreams::new_single_gpu(GpuIndex(num_gpus - 1));
let gpu_index = GpuIndex(rand::thread_rng().gen_range(0..num_gpus));
let streams = CudaStreams::new_single_gpu(gpu_index);

let sks = CudaServerKey::new(cks.as_ref(), &streams);
streams.synchronize();
Expand Down
Loading

0 comments on commit 9cb4b03

Please sign in to comment.