Skip to content

Commit 6e3d584

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

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2558,7 +2558,12 @@ 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-
cuda_ctx->cuda_graph->params[i].kernelParams[1] = updated_kernel_arg_ptr;
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+
#endif // defined(__HIP_PLATFORM_AMD__)
25622567
CUDA_CHECK(cudaGraphKernelNodeSetParams(cuda_ctx->cuda_graph->nodes[i], &cuda_ctx->cuda_graph->params[i]));
25632568
}
25642569
}

0 commit comments

Comments
 (0)