Skip to content

Commit 52cc72c

Browse files
committed
musa: restore MUSA graph settings in CMakeLists.txt
Signed-off-by: Xiaodong Ye <xiaodong.ye@mthreads.com>
1 parent 1ba52e9 commit 52cc72c

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

ggml/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ option(GGML_HIP_GRAPHS "ggml: use HIP graph, experimental,
174174
option(GGML_HIP_NO_VMM "ggml: do not try to use HIP VMM" ON)
175175
option(GGML_HIP_ROCWMMA_FATTN "ggml: enable rocWMMA for FlashAttention" OFF)
176176
option(GGML_HIP_FORCE_ROCWMMA_FATTN_GFX12 "ggml: enable rocWMMA FlashAttention on GFX12" OFF)
177+
option(GGML_MUSA_GRAPHS "ggml: use MUSA graph, experimental" OFF)
177178
option(GGML_VULKAN "ggml: use Vulkan" OFF)
178179
option(GGML_VULKAN_CHECK_RESULTS "ggml: run Vulkan op checks" OFF)
179180
option(GGML_VULKAN_DEBUG "ggml: enable Vulkan debug output" OFF)

ggml/src/ggml-cuda/common.cuh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ struct ggml_tensor_extra_gpu {
765765
};
766766

767767

768-
#if (defined(GGML_CUDA_USE_GRAPHS) || defined(GGML_HIP_GRAPHS))
768+
#if (defined(GGML_CUDA_USE_GRAPHS) || defined(GGML_HIP_GRAPHS)) || defined(GGML_MUSA_GRAPHS)
769769
#define USE_CUDA_GRAPH
770770
#endif
771771

ggml/src/ggml-cuda/cpy.cu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static __global__ void cpy_q_f32(const char * cx, char * cdst_direct, const int
358358
// Copy destination pointers to GPU to be available when pointer indirection is in use
359359

360360
void ggml_cuda_cpy_dest_ptrs_copy(ggml_cuda_graph * cuda_graph, char ** host_dest_ptrs, const int host_dest_ptrs_size, cudaStream_t stream) {
361-
#if defined(GGML_CUDA_USE_GRAPHS) || defined(GGML_HIP_GRAPHS)
361+
#if defined(GGML_CUDA_USE_GRAPHS) || defined(GGML_HIP_GRAPHS) || defined(GGML_MUSA_GRAPHS)
362362
if (cuda_graph->dest_ptrs_size < host_dest_ptrs_size) { // (re-)allocate GPU memory for destination pointers
363363
CUDA_CHECK(cudaStreamSynchronize(stream));
364364
if (cuda_graph->dest_ptrs_d != nullptr) {
@@ -590,7 +590,7 @@ void ggml_cuda_cpy(ggml_backend_cuda_context & ctx, const ggml_tensor * src0, gg
590590

591591
char ** dest_ptrs_d = nullptr;
592592
int graph_cpynode_index = -1;
593-
#if defined(GGML_CUDA_USE_GRAPHS) || defined(GGML_HIP_GRAPHS)
593+
#if defined(GGML_CUDA_USE_GRAPHS) || defined(GGML_HIP_GRAPHS) || defined(GGML_MUSA_GRAPHS)
594594
if(ctx.cuda_graph->use_cpy_indirection && !disable_indirection_for_this_node) {
595595
dest_ptrs_d = ctx.cuda_graph->dest_ptrs_d;
596596
graph_cpynode_index = ctx.cuda_graph->graph_cpynode_index;
@@ -647,7 +647,7 @@ void ggml_cuda_cpy(ggml_backend_cuda_context & ctx, const ggml_tensor * src0, gg
647647
GGML_ABORT("%s: unsupported type combination (%s to %s)\n", __func__,
648648
ggml_type_name(src0->type), ggml_type_name(src1->type));
649649
}
650-
#if defined(GGML_CUDA_USE_GRAPHS) || defined(GGML_HIP_GRAPHS)
650+
#if defined(GGML_CUDA_USE_GRAPHS) || defined(GGML_HIP_GRAPHS) || defined(GGML_MUSA_GRAPHS)
651651
if(ctx.cuda_graph->use_cpy_indirection && !disable_indirection_for_this_node) {
652652
ctx.cuda_graph->graph_cpynode_index = graph_cpynode_index;
653653
}

ggml/src/ggml-musa/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ if (MUSAToolkit_FOUND)
7272
add_compile_definitions(GGML_USE_MUSA)
7373
add_compile_definitions(GGML_CUDA_PEER_MAX_BATCH_SIZE=${GGML_CUDA_PEER_MAX_BATCH_SIZE})
7474

75+
if (GGML_MUSA_GRAPHS)
76+
add_compile_definitions(GGML_MUSA_GRAPHS)
77+
endif()
78+
7579
if (GGML_CUDA_FORCE_MMQ)
7680
add_compile_definitions(GGML_CUDA_FORCE_MMQ)
7781
endif()

0 commit comments

Comments
 (0)