Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ if (NOT MSVC)
endif()

set(ENGINE_DEFAULT_ENABLE_CUDA OFF)
set(ENGINE_DEFAULT_ENABLE_HIP OFF)
set(ENGINE_DEFAULT_ENABLE_VULKAN OFF)
set(ENGINE_DEFAULT_ENABLE_METAL OFF)
set(ENGINE_DEFAULT_ENABLE_LLAMAFILE ON)
Expand All @@ -60,6 +61,9 @@ endif()
if (DEFINED GGML_CUDA)
set(ENGINE_DEFAULT_ENABLE_CUDA ${GGML_CUDA})
endif()
if (DEFINED GGML_HIP)
set(ENGINE_DEFAULT_ENABLE_HIP ${GGML_HIP})
endif()
if (DEFINED GGML_VULKAN)
set(ENGINE_DEFAULT_ENABLE_VULKAN ${GGML_VULKAN})
endif()
Expand All @@ -74,6 +78,7 @@ if (DEFINED GGML_CUDA_GRAPHS)
endif()

option(ENGINE_ENABLE_CUDA "Build ggml with CUDA backend support" ${ENGINE_DEFAULT_ENABLE_CUDA})
option(ENGINE_ENABLE_HIP "Build ggml with HIP/ROCm backend support" ${ENGINE_DEFAULT_ENABLE_HIP})
option(ENGINE_ENABLE_VULKAN "Build ggml with Vulkan backend support" ${ENGINE_DEFAULT_ENABLE_VULKAN})
option(ENGINE_ENABLE_METAL "Build ggml with Metal backend support" ${ENGINE_DEFAULT_ENABLE_METAL})
option(ENGINE_ENABLE_LLAMAFILE "Build ggml with llamafile SGEMM support" ${ENGINE_DEFAULT_ENABLE_LLAMAFILE})
Expand All @@ -84,7 +89,7 @@ option(ENGINE_BUILD_EXAMPLES "Build example binaries" OFF)
option(ENGINE_BUILD_TESTS "Build framework unit tests" OFF)
option(ENGINE_BUILD_WARMBENCH "Build warmbench helper binaries" OFF)

if (ENGINE_ENABLE_CUDA)
if (ENGINE_ENABLE_CUDA AND NOT ENGINE_ENABLE_HIP)
enable_language(CUDA)
find_package(CUDAToolkit REQUIRED)
if (NOT MSVC)
Expand All @@ -101,10 +106,14 @@ set(GGML_BUILD_TESTS OFF CACHE BOOL "Do not build upstream tests" FORCE)
set(GGML_ALL_WARNINGS OFF CACHE BOOL "Keep upstream warnings quiet in this sample" FORCE)
set(GGML_CCACHE OFF CACHE BOOL "Do not probe for ccache in this local setup" FORCE)
set(GGML_CUDA ${ENGINE_ENABLE_CUDA} CACHE BOOL "Build ggml with CUDA backend support" FORCE)
set(GGML_HIP ${ENGINE_ENABLE_HIP} CACHE BOOL "Build ggml with HIP backend support" FORCE)
set(GGML_VULKAN ${ENGINE_ENABLE_VULKAN} CACHE BOOL "Build ggml with Vulkan backend support" FORCE)
set(GGML_METAL ${ENGINE_ENABLE_METAL} CACHE BOOL "Build ggml with Metal backend support" FORCE)
set(GGML_LLAMAFILE ${ENGINE_ENABLE_LLAMAFILE} CACHE BOOL "Build ggml with llamafile SGEMM support" FORCE)
set(GGML_CUDA_GRAPHS ${ENGINE_ENABLE_CUDA_GRAPHS} CACHE BOOL "Enable ggml CUDA graphs support" FORCE)
# HIP graphs are controlled by a separate upstream option that defaults to ON;
# keep it in sync so ENGINE_ENABLE_CUDA_GRAPHS=OFF also disables graphs on HIP builds
set(GGML_HIP_GRAPHS ${ENGINE_ENABLE_CUDA_GRAPHS} CACHE BOOL "Enable ggml HIP graphs support" FORCE)
set(GGML_NATIVE ${ENGINE_ENABLE_NATIVE_CPU} CACHE BOOL "Build ggml CPU kernels with native host ISA flags" FORCE)

set(SPM_ENABLE_SHARED OFF CACHE BOOL "Build sentencepiece shared libs" FORCE)
Expand Down Expand Up @@ -529,7 +538,11 @@ if (ENGINE_ENABLE_OPENMP)
target_link_libraries(engine_runtime PRIVATE OpenMP::OpenMP_CXX)
endif()

if (ENGINE_ENABLE_CUDA)
if (MSVC)
target_compile_options(engine_runtime PRIVATE /utf-8)
endif()

if (ENGINE_ENABLE_CUDA AND NOT ENGINE_ENABLE_HIP)
target_sources(engine_runtime PRIVATE
src/framework/audio/istft_cuda_runtime.cu
src/framework/sampling/torch_random_cuda_runtime.cu
Expand Down Expand Up @@ -849,6 +862,16 @@ if (ENGINE_BUILD_TESTS)
COMMAND depthwise_conv1d_lowering_test
)

add_engine_unittest(conv_lowering_matrix_test tests/unittests/test_conv_lowering_matrix.cpp)
if (ENGINE_ENABLE_HIP)
target_compile_definitions(conv_lowering_matrix_test PRIVATE ENGINE_TEST_ENABLE_HIP=1)
endif()

add_test(
NAME conv_lowering_matrix_test
COMMAND conv_lowering_matrix_test
)

add_engine_unittest(gguf_tensor_source_test tests/unittests/test_gguf_tensor_source.cpp)
target_include_directories(gguf_tensor_source_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests/unittests)

Expand Down
3 changes: 3 additions & 0 deletions app/cli/args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ engine::core::BackendType parse_backend(const std::string & value) {
if (value == "cuda") {
return engine::core::BackendType::Cuda;
}
if (value == "hip" || value == "rocm") {
return engine::core::BackendType::Hip;
}
if (value == "vulkan") {
return engine::core::BackendType::Vulkan;
}
Expand Down
2 changes: 1 addition & 1 deletion app/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void print_task_list_help() {
<< " --task vad|asr|diar|sep|gen|tts|clon|vc|s2s|align|vdes|spk|svc\n"
<< " --family <name>\n"
<< " --model <path>\n"
<< " --backend cpu|cuda|vulkan|metal|best\n"
<< " --backend cpu|cuda|hip|rocm|vulkan|metal|best (rocm is an alias for hip)\n"
<< " --mode offline|streaming default offline\n"
<< " --device <n>\n"
<< " --threads <n> Backend and OpenMP worker threads, default 4\n"
Expand Down
2 changes: 2 additions & 0 deletions app/server/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ const char * backend_name(engine::core::BackendType type) {
return "cpu";
case engine::core::BackendType::Cuda:
return "cuda";
case engine::core::BackendType::Hip:
return "hip";
case engine::core::BackendType::Vulkan:
return "vulkan";
case engine::core::BackendType::Metal:
Expand Down
Loading