Skip to content

Commit dbf12a6

Browse files
committed
HIP: workaround runtime bug in hipGraph support
1 parent 300907b commit dbf12a6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ggml/src/ggml-cuda/ggml-cuda.cu

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2558,7 +2558,14 @@ static void maintain_cuda_graph(ggml_backend_cuda_context * cuda_ctx, std::vecto
25582558
for (size_t i = 0; i < cuda_ctx->cuda_graph->num_nodes; i++) {
25592559
if(count(ggml_cuda_cpy_fn_ptrs.begin(), ggml_cuda_cpy_fn_ptrs.end(), cuda_ctx->cuda_graph->params[i].func) > 0) {
25602560
char ** updated_kernel_arg_ptr = cuda_ctx->cuda_graph->updated_kernel_arg.at(k++);
2561+
#if defined(__HIP_PLATFORM_AMD__)
2562+
// Workaroudnd for https://github.com/ROCm/clr/issues/138
2563+
// The hip runtime fails to copy this and calls delete on it later, so we must
2564+
// perform an alloc here.
2565+
cuda_ctx->cuda_graph->params[i].kernelParams[1] = new void*(*updated_kernel_arg_ptr);
2566+
#else
25612567
cuda_ctx->cuda_graph->params[i].kernelParams[1] = updated_kernel_arg_ptr;
2568+
#endif // defined(__HIP_PLATFORM_AMD__)
25622569
CUDA_CHECK(cudaGraphKernelNodeSetParams(cuda_ctx->cuda_graph->nodes[i], &cuda_ctx->cuda_graph->params[i]));
25632570
}
25642571
}

0 commit comments

Comments
 (0)