Skip to content

Commit 9baf9ef

Browse files
CUDA: faster multi GPU synchronization (#2448)
1 parent 8a88e58 commit 9baf9ef

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

ggml-cuda.cu

+4-5
Original file line numberDiff line numberDiff line change
@@ -3529,13 +3529,12 @@ static void ggml_cuda_op(const ggml_tensor * src0, const ggml_tensor * src1, ggm
35293529
if (split) {
35303530
// src0 = weight matrix is saved as a transposed matrix for better memory layout.
35313531
// dst is NOT transposed.
3532-
// The outputs of cuBLAS matrix matrix multiplications can therefore NOT simply be concatenated for >1 GPU.
3532+
// The outputs of matrix matrix multiplications can therefore NOT simply be concatenated for >1 GPU.
35333533
// Instead they need to be copied to the correct slice in ne0 = dst row index.
35343534
// If dst is a vector with ne0 == 1 then you don't have to do this but it still produces correct results.
3535-
for (int64_t j = 0; j < ne1; ++j) {
3536-
float * dhf_dst_i = (float *) ((char *) dst_off_device + (j*ne0 + i01_low)*sizeof(float) + i02*nb2 + i03*nb3);
3537-
CUDA_CHECK(cudaMemcpyAsync(dhf_dst_i, dst_ddf_i + j*i01_diff, i01_diff*sizeof(float), kind, cudaStream_main));
3538-
}
3535+
float * dhf_dst_i = (float *) ((char *) dst_off_device + i01_low*sizeof(float) + i02*nb2 + i03*nb3);
3536+
CUDA_CHECK(cudaMemcpy2DAsync(dhf_dst_i, ne0*sizeof(float), dst_ddf_i, i01_diff*sizeof(float),
3537+
i01_diff*sizeof(float), ne1, kind, cudaStream_main));
35393538
} else {
35403539
float * dhf_dst_i = (float *) ((char *) dst_off_device + i02*nb2 + i03*nb3);
35413540
CUDA_CHECK(cudaMemcpyAsync(dhf_dst_i, dst_ddf_i, dst_stride*sizeof(float), kind, cudaStream_main));

0 commit comments

Comments
 (0)