Skip to content

Commit c63e537

Browse files
fix(gpu): force uint64 when calculating lwe chunksize
1 parent 580e545 commit c63e537

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

backends/tfhe-cuda-backend/cuda/src/pbs/programmable_bootstrap_multibit.cu

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ uint64_t get_lwe_chunk_size(uint32_t gpu_index, uint32_t max_num_pbs,
482482
size_t total_mem, free_mem;
483483
check_cuda_error(cudaMemGetInfo(&free_mem, &total_mem));
484484
// Estimate the size of one chunk
485-
uint64_t size_one_chunk = max_num_pbs * polynomial_size *
485+
uint64_t size_one_chunk = (uint64_t)max_num_pbs * polynomial_size *
486486
(glwe_dimension + 1) * (glwe_dimension + 1) *
487487
level_count * sizeof(Torus);
488488

@@ -494,7 +494,9 @@ uint64_t get_lwe_chunk_size(uint32_t gpu_index, uint32_t max_num_pbs,
494494
PANIC_IF_FALSE(
495495
max_num_chunks > 0,
496496
"Cuda error (multi-bit PBS): Not enough GPU memory to allocate PBS "
497-
"temporary arrays.");
497+
"temporary arrays. free_mem: %lu, size_one_chunk: %lu, max_num_chunks: "
498+
"%u, max_num_pbs %u",
499+
free_mem, size_one_chunk, max_num_chunks, max_num_pbs);
498500
int x = num_sms * max_blocks_per_sm;
499501
int count = 0;
500502

0 commit comments

Comments
 (0)