Skip to content

Commit 35beead

Browse files
authored
feat(coprocessor): enable gpu backend in zkproof-worker (#1827)
1 parent 44b3d40 commit 35beead

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

.github/workflows/coprocessor-gpu-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ jobs:
191191
cargo test \
192192
-p tfhe-worker \
193193
-p sns-worker \
194+
-p zkproof-worker \
194195
--release \
195196
--features=gpu \
196197
-- \

coprocessor/fhevm-engine/fhevm-engine-common/src/tenant_keys.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ pub struct TfheTenantKeys {
1212
pub chain_id: i64,
1313
pub verifying_contract_address: String,
1414
pub acl_contract_address: String,
15+
16+
#[cfg(not(feature = "gpu"))]
1517
pub sks: tfhe::ServerKey,
1618

19+
#[cfg(feature = "gpu")]
20+
pub sks: tfhe::CudaServerKey,
21+
1722
pub pks: tfhe::CompactPublicKey,
1823
pub public_params: Arc<tfhe::zk::CompactPkeCrs>,
1924
}
@@ -23,7 +28,12 @@ pub struct FetchTenantKeyResult {
2328
pub chain_id: i64,
2429
pub verifying_contract_address: String,
2530
pub acl_contract_address: String,
31+
32+
#[cfg(not(feature = "gpu"))]
2633
pub server_key: tfhe::ServerKey,
34+
#[cfg(feature = "gpu")]
35+
pub server_key: tfhe::CudaServerKey,
36+
2737
pub public_params: Arc<tfhe::zk::CompactPkeCrs>,
2838
pub pks: tfhe::CompactPublicKey,
2939
}
@@ -103,7 +113,7 @@ where
103113
#[cfg(feature = "gpu")]
104114
let sks = {
105115
let csks: tfhe::CompressedServerKey = safe_deserialize_key(&sks_key)?;
106-
csks.decompress()
116+
csks.decompress_to_gpu()
107117
};
108118
let pks: tfhe::CompactPublicKey = safe_deserialize_key(&pks_key)?;
109119
let public_params: tfhe::zk::CompactPkeCrs = safe_deserialize_key(&public_params_key)?;

coprocessor/fhevm-engine/fhevm-engine-common/src/tfhe_ops.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ pub fn extract_ct_list(
292292
let mut res = Vec::new();
293293
for idx in 0..expanded.len() {
294294
let Some(data_kind) = expanded.get_kind_of(idx) else {
295-
panic!("we're itering over what ciphertext told us how many ciphertexts are there, it must exist")
295+
tracing::error!(len = expanded.len(), idx, "get_kind_of returned None");
296+
continue;
296297
};
297298

298299
match data_kind {

coprocessor/fhevm-engine/zkproof-worker/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ fhevm-engine-common = { path = "../fhevm-engine-common" }
3030
# crates.io dependencies
3131
[features]
3232
nightly-avx512 = ["tfhe/nightly-avx512"]
33+
gpu = ["tfhe/gpu", "fhevm-engine-common/gpu", "test-harness/gpu"]
34+
3335

3436
[dev-dependencies]
3537
serial_test = { workspace = true }

coprocessor/fhevm-engine/zkproof-worker/src/verifier.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ pub async fn execute_verify_proofs_loop(
125125
conf: Config,
126126
last_active_at: Arc<RwLock<SystemTime>>,
127127
) -> Result<(), ExecutionError> {
128-
info!(conf = %conf, "Starting with config");
128+
let gpu_enabled = fhevm_engine_common::utils::log_backend();
129+
info!(gpu_enabled, conf = %conf, "Starting with config");
129130

130131
// Tenants key cache is shared amongst all workers
131132
let tenant_key_cache = Arc::new(RwLock::new(LruCache::new(

0 commit comments

Comments
 (0)