|
@@ -1,9 +1,9 @@
|
|
|
#include "cpy.cuh"
|
|
#include "cpy.cuh"
|
|
|
#include "dequantize.cuh"
|
|
#include "dequantize.cuh"
|
|
|
#include "cpy-utils.cuh"
|
|
#include "cpy-utils.cuh"
|
|
|
-#ifdef GGML_USE_MUSA
|
|
|
|
|
|
|
+#if defined(GGML_USE_MUSA) && defined(GGML_MUSA_MUDNN_COPY)
|
|
|
#include "ggml-musa/mudnn.cuh"
|
|
#include "ggml-musa/mudnn.cuh"
|
|
|
-#endif // GGML_USE_MUSA
|
|
|
|
|
|
|
+#endif // GGML_USE_MUSA && GGML_MUSA_MUDNN_COPY
|
|
|
|
|
|
|
|
typedef void (*cpy_kernel_t)(const char * cx, char * cdst);
|
|
typedef void (*cpy_kernel_t)(const char * cx, char * cdst);
|
|
|
|
|
|
|
@@ -121,7 +121,7 @@ static __global__ void cpy_q_f32(const char * cx, char * cdst_direct, const int
|
|
|
// Copy destination pointers to GPU to be available when pointer indirection is in use
|
|
// Copy destination pointers to GPU to be available when pointer indirection is in use
|
|
|
|
|
|
|
|
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) {
|
|
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) {
|
|
|
-#if defined(GGML_CUDA_USE_GRAPHS) || defined(GGML_HIP_GRAPHS)
|
|
|
|
|
|
|
+#if defined(GGML_CUDA_USE_GRAPHS) || defined(GGML_HIP_GRAPHS) || defined(GGML_MUSA_GRAPHS)
|
|
|
if (cuda_graph->dest_ptrs_size < host_dest_ptrs_size) { // (re-)allocate GPU memory for destination pointers
|
|
if (cuda_graph->dest_ptrs_size < host_dest_ptrs_size) { // (re-)allocate GPU memory for destination pointers
|
|
|
CUDA_CHECK(cudaStreamSynchronize(stream));
|
|
CUDA_CHECK(cudaStreamSynchronize(stream));
|
|
|
if (cuda_graph->dest_ptrs_d != nullptr) {
|
|
if (cuda_graph->dest_ptrs_d != nullptr) {
|
|
@@ -314,7 +314,7 @@ void ggml_cuda_cpy(ggml_backend_cuda_context & ctx, const ggml_tensor * src0, gg
|
|
|
|
|
|
|
|
char ** dest_ptrs_d = nullptr;
|
|
char ** dest_ptrs_d = nullptr;
|
|
|
int graph_cpynode_index = -1;
|
|
int graph_cpynode_index = -1;
|
|
|
-#if defined(GGML_CUDA_USE_GRAPHS) || defined(GGML_HIP_GRAPHS)
|
|
|
|
|
|
|
+#if defined(GGML_CUDA_USE_GRAPHS) || defined(GGML_HIP_GRAPHS) || defined(GGML_MUSA_GRAPHS)
|
|
|
if(ctx.cuda_graph->use_cpy_indirection && !disable_indirection_for_this_node) {
|
|
if(ctx.cuda_graph->use_cpy_indirection && !disable_indirection_for_this_node) {
|
|
|
dest_ptrs_d = ctx.cuda_graph->dest_ptrs_d;
|
|
dest_ptrs_d = ctx.cuda_graph->dest_ptrs_d;
|
|
|
graph_cpynode_index = ctx.cuda_graph->graph_cpynode_index;
|
|
graph_cpynode_index = ctx.cuda_graph->graph_cpynode_index;
|
|
@@ -324,11 +324,11 @@ void ggml_cuda_cpy(ggml_backend_cuda_context & ctx, const ggml_tensor * src0, gg
|
|
|
#endif
|
|
#endif
|
|
|
if (src0->type == src1->type && ggml_is_contiguous(src0) && ggml_is_contiguous(src1)) {
|
|
if (src0->type == src1->type && ggml_is_contiguous(src0) && ggml_is_contiguous(src1)) {
|
|
|
GGML_ASSERT(ggml_nbytes(src0) == ggml_nbytes(src1));
|
|
GGML_ASSERT(ggml_nbytes(src0) == ggml_nbytes(src1));
|
|
|
-#ifdef GGML_USE_MUSA
|
|
|
|
|
|
|
+#if defined(GGML_USE_MUSA) && defined(GGML_MUSA_MUDNN_COPY)
|
|
|
if (src0->type == GGML_TYPE_F32 || src0->type == GGML_TYPE_F16) {
|
|
if (src0->type == GGML_TYPE_F32 || src0->type == GGML_TYPE_F16) {
|
|
|
CUDA_CHECK(mudnnMemcpyAsync(ctx, src1, src0));
|
|
CUDA_CHECK(mudnnMemcpyAsync(ctx, src1, src0));
|
|
|
} else
|
|
} else
|
|
|
-#endif // GGML_USE_MUSA
|
|
|
|
|
|
|
+#endif // GGML_USE_MUSA && GGML_MUSA_MUDNN_COPY
|
|
|
{
|
|
{
|
|
|
CUDA_CHECK(cudaMemcpyAsync(src1_ddc, src0_ddc, ggml_nbytes(src0), cudaMemcpyDeviceToDevice, main_stream));
|
|
CUDA_CHECK(cudaMemcpyAsync(src1_ddc, src0_ddc, ggml_nbytes(src0), cudaMemcpyDeviceToDevice, main_stream));
|
|
|
}
|
|
}
|
|
@@ -379,7 +379,7 @@ void ggml_cuda_cpy(ggml_backend_cuda_context & ctx, const ggml_tensor * src0, gg
|
|
|
GGML_ABORT("%s: unsupported type combination (%s to %s)\n", __func__,
|
|
GGML_ABORT("%s: unsupported type combination (%s to %s)\n", __func__,
|
|
|
ggml_type_name(src0->type), ggml_type_name(src1->type));
|
|
ggml_type_name(src0->type), ggml_type_name(src1->type));
|
|
|
}
|
|
}
|
|
|
-#if defined(GGML_CUDA_USE_GRAPHS) || defined(GGML_HIP_GRAPHS)
|
|
|
|
|
|
|
+#if defined(GGML_CUDA_USE_GRAPHS) || defined(GGML_HIP_GRAPHS) || defined(GGML_MUSA_GRAPHS)
|
|
|
if(ctx.cuda_graph->use_cpy_indirection && !disable_indirection_for_this_node) {
|
|
if(ctx.cuda_graph->use_cpy_indirection && !disable_indirection_for_this_node) {
|
|
|
ctx.cuda_graph->graph_cpynode_index = graph_cpynode_index;
|
|
ctx.cuda_graph->graph_cpynode_index = graph_cpynode_index;
|
|
|
}
|
|
}
|