-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(gpu): optimize packing keyswitch on gpu #1908
base: main
Are you sure you want to change the base?
Conversation
Performance improvement on H100s is also quite impressive:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some smaller fixes. Although I still want to better understand the algorithm here. Also, let's run some extensive tests to be sure we are not breaking anything before merge.
@@ -31,8 +31,7 @@ __host__ inline bool can_use_pks_fast_path(uint32_t lwe_dimension, | |||
uint32_t polynomial_size, | |||
uint32_t level_count, | |||
uint32_t glwe_dimension) { | |||
// TODO: Generalize to level_count > 1 by transposing the KSK | |||
return level_count == 1; | |||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think now we can get rid of this function, now?
|
||
Torus a_i = lwe_in[read_val_idx]; | ||
|
||
Torus state = init_decomposer_state(a_i, base_log, level_count); | ||
|
||
Torus mod_b_mask = (1ll << base_log) - 1ll; | ||
lwe_out[write_val_idx] = decompose_one<Torus>(state, mod_b_mask, base_log); | ||
__syncthreads(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you replace __syncthreads()
by synchronize_threads_in_block()
? This is obviously not wrong but we are trying to encapsulate some CUDA intrinsics.
|
||
Torus a_i = lwe_in[read_val_idx]; | ||
|
||
Torus state = init_decomposer_state(a_i, base_log, level_count); | ||
|
||
Torus mod_b_mask = (1ll << base_log) - 1ll; | ||
lwe_out[write_val_idx] = decompose_one<Torus>(state, mod_b_mask, base_log); | ||
__syncthreads(); | ||
lwe_out[write_state_idx] = state; | ||
__syncthreads(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is not needed.
|
||
Torus mod_b_mask = (1ll << base_log) - 1ll; | ||
|
||
buffer_in[val_idx] = decompose_one<Torus>(state, mod_b_mask, base_log); | ||
__syncthreads(); | ||
buffer_in[state_idx] = state; | ||
__syncthreads(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is not needed.
9589a09
to
e120ed8
Compare
GPU optimization for packing keyswitch for any level count using GEMM.
Bench using
make bench_integer_compression_gpu
on GTX 4060 mobile