From 66e882aeedf387614316e0c94f7d59a815766c9b Mon Sep 17 00:00:00 2001 From: "Kumawat, Sachin" Date: Tue, 13 Jan 2026 14:14:27 -0800 Subject: [PATCH 01/25] Add VitisAI Plugin * Added VitisAI encoder module placeholder files * VitisAI build integration * VitisAI encoder offload functional * Clean up vitisai integration * Add c++17 requirement for Windows * Enabled preemption for windows runs * Add model cache override option * Remove vitisai premature log message * Add rai support through file mapping * Fixed flatbuffer loading * Fixed Windows file mapping issue * Update FlexmlRT resolution * Use Flexmlrt wheel pkg to build VitisAI plugin * Clean up * Remove prints * Change flexmlrt target from Shared to Interface * Add c++17 requirement for Windows * Enabled preemption for windows runs * Add rai support through file mapping * Fixed flatbuffer loading * Fixed Windows file mapping issue * Update FlexmlRT resolution * Use Flexmlrt wheel pkg to build VitisAI plugin * Clean up * Remove prints * Change flexmlrt target from Shared to Interface * Cleanup FlexmlRT integration * format fix * Adding AMD Licenses * Update CMakeLists.txt Co-authored-by: Kumawat, Sachin * Update src/CMakeLists.txt Co-authored-by: Kumawat, Sachin * Update whisper.cpp * Added VitisAI encoder readme section * Remove license headers from common files to whisper.cpp --------- Co-authored-by: Sachin Kumawat Co-authored-by: Jeff Lin Co-authored-by: Lin Co-authored-by: Lin, Jeff (DCG-ENG) Co-authored-by: Iswarya Alex Co-authored-by: Alex, Iswarya --- CMakeLists.txt | 1 + README.md | 29 ++++ src/CMakeLists.txt | 32 ++++ src/vitisai/whisper-vitisai-encoder.cpp | 204 ++++++++++++++++++++++++ src/vitisai/whisper-vitisai-encoder.h | 32 ++++ src/whisper.cpp | 61 ++++++- 6 files changed, 358 insertions(+), 1 deletion(-) create mode 100644 src/vitisai/whisper-vitisai-encoder.cpp create mode 100644 src/vitisai/whisper-vitisai-encoder.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b60bb045..a8c7347a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,6 +91,7 @@ endif() option(WHISPER_COREML "whisper: enable Core ML framework" OFF) option(WHISPER_COREML_ALLOW_FALLBACK "whisper: allow non-CoreML fallback" OFF) option(WHISPER_OPENVINO "whisper: support for OpenVINO" OFF) +option(WHISPER_VITISAI "whisper: support for AMD Vitis AI" OFF) # Required for relocatable CMake package include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/build-info.cmake) diff --git a/README.md b/README.md index 6d4988e6..0369f142 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,35 @@ This can result in significant speedup in encoder performance. Here are the inst For more information about the OpenVINO implementation please refer to PR [#1037](https://github.com/ggml-org/whisper.cpp/pull/1037). +## VitisAI encoder support + +On AMD Ryzen AI NPU devices, you can run the Encoder via the VitisAI plugin to significantly accelerate the whisper models. + +- Prepare the AMD runtime packages (required before building): + + - Obtain the XRT package and the FlexmlRT package from AMD. Both are distributed as tarballs or wheels. + - Copy the downloaded archives to a local path, extract them, and run the setup script from each extracted package in your shell (for example `source /path/to/xrt/setup.sh` and `source /path/to/flexmlrt/setup.sh`). Run these in every new shell you use to build or run `whisper.cpp`. + +- Fetch the prebuilt VitisAI encoder cache: + + - Download the appropriate Whisper encoder `.rai` cache for your model size from the AMD collection on Hugging Face: https://huggingface.co/collections/amd/ryzen-ai-16-whisper-npu-optimized-onnx-models + - Place and rename the downloaded `.rai` file as `-encoder-vitisai.rai` alongside your ggml model files `.bin`. + +- Build `whisper.cpp` with VitisAI support: + + ```bash + cmake -B build -DWHISPER_VITISAI=1 + cmake --build build -j --config Release + ``` + +- Run the examples as usual. For example: + + ```text + $ ./build/bin/whisper-cli -m models/ggml-base.en.bin -f samples/jfk.wav + ``` + +The VitisAI artifact from Huggingface is already optimized for Ryzen AI NPUs, there is no slow compilation needed. The acceleration advantage should be seen from first run itself apart from CPU caching overheads. + ## NVIDIA GPU support With NVIDIA cards the processing of the models is done efficiently on the GPU via cuBLAS and custom CUDA kernels. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 095a2791..6cba1c6e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,6 +48,10 @@ if (WHISPER_OPENVINO) find_package(OpenVINO REQUIRED COMPONENTS Runtime) endif() +if (WHISPER_VITISAI) + find_package(FlexmlRT REQUIRED) +endif() + # # libraries # @@ -101,6 +105,30 @@ if (WHISPER_OPENVINO) set_target_properties(${TARGET} PROPERTIES FOLDER "libs") endif() +if (WHISPER_VITISAI) + set(TARGET whisper.vitisai) + + add_library(${TARGET} OBJECT + vitisai/whisper-vitisai-encoder.h + vitisai/whisper-vitisai-encoder.cpp + ) + + target_include_directories(${TARGET} PUBLIC + . + ) + + set_property(TARGET ${TARGET} PROPERTY POSITION_INDEPENDENT_CODE ON) + set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DWHISPER_USE_VITISAI) + + # Add C++17 standard for MSVC + if (MSVC) + target_compile_options(${TARGET} PRIVATE /std:c++17) + endif() + + target_link_libraries(${TARGET} PRIVATE ggml flexmlrt::flexmlrt) + set_target_properties(${TARGET} PROPERTIES FOLDER "libs") +endif() + # whisper add_library(whisper @@ -137,6 +165,10 @@ if (WHISPER_OPENVINO) target_link_libraries(whisper PRIVATE whisper.openvino) endif() +if (WHISPER_VITISAI) + target_link_libraries(whisper PRIVATE whisper.vitisai) +endif() + if (WHISPER_MKL) target_link_libraries(whisper PRIVATE MKL::MKL) endif() diff --git a/src/vitisai/whisper-vitisai-encoder.cpp b/src/vitisai/whisper-vitisai-encoder.cpp new file mode 100644 index 00000000..a6d20a88 --- /dev/null +++ b/src/vitisai/whisper-vitisai-encoder.cpp @@ -0,0 +1,204 @@ +// Copyright(C) 2025 Advanced Micro Devices, Inc. All rights reserved. +#include "vitisai/whisper-vitisai-encoder.h" +#include "FlexMLClient.h" +#include "ggml.h" +#include "ggml-backend.h" + +#include +#include +#ifdef _WIN32 + #include +#else + #include + #include + #include +#endif +#include +#include + +struct whisper_vitisai_context { + std::string model_path; + std::shared_ptr runner; + uint8_t * fbs_buffer; + size_t fbs_buffer_size; +}; + +// Function to mmap rai file for Linux and MapViewOfFile for Windows +bool map_rai_file(const char * path, uint8_t ** buffer, size_t * size) { +#ifdef _WIN32 + // Open the file + HANDLE hFile = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile == INVALID_HANDLE_VALUE) { + std::fprintf(stderr, "%s: %d: Failed to open rai file '%s'\n", __func__, __LINE__, path); + return false; + } + + // Get the file size + LARGE_INTEGER fileSize; + if (!GetFileSizeEx(hFile, &fileSize)) { + CloseHandle(hFile); + std::fprintf(stderr, "%s: %d: Failed to get file size for rai file '%s'\n", __func__, __LINE__, path); + return false; + } + + // Create a file mapping object + HANDLE hMapping = CreateFileMappingA(hFile, NULL, PAGE_READONLY, 0, fileSize.QuadPart, NULL); + if (hMapping == NULL) { + CloseHandle(hFile); + std::fprintf(stderr, "%s: %d: Failed to create file mapping for rai file '%s'\n", __func__, __LINE__, path); + return false; + } + + // Map the file + *buffer = (uint8_t *)MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, fileSize.QuadPart); + if (*buffer == NULL) { + CloseHandle(hMapping); + CloseHandle(hFile); + std::fprintf(stderr, "%s: %d: Failed to map rai file '%s'\n", __func__, __LINE__, path); + return false; + } + *size = fileSize.QuadPart; + return true; +#else + // Open the file + FILE * fd = fopen(path, "rb"); + if (!fd) { + std::fprintf(stderr, "%s: %d: Failed to open rai file '%s'\n", __func__, __LINE__, path); + return false; + } + + // Get the file size + struct stat st; + if (fstat(fileno(fd), &st) == -1) { + fclose(fd); + std::fprintf(stderr, "%s: %d: Failed to get file size for rai file '%s'\n", __func__, __LINE__, path); + return false; + } + + // Mmap the file + *buffer = (uint8_t *)mmap(nullptr, st.st_size, PROT_READ, MAP_SHARED, fileno(fd), 0); + if (*buffer == MAP_FAILED) { + fclose(fd); + std::fprintf(stderr, "%s: %d: Failed to mmap rai file '%s'\n", __func__, __LINE__, path); + return false; + } + *size = st.st_size; + return true; +#endif // _WIN32 +} + +void unmap_rai_file(uint8_t * buffer, size_t size) { +#ifdef _WIN32 + UnmapViewOfFile(buffer); +#else + munmap(buffer, size); +#endif // _WIN32 +} + +struct whisper_vitisai_context * whisper_vitisai_init(const char * path_model) { + if (!path_model) { + std::fprintf(stderr, "%s: path_model is null\n", __func__); + return nullptr; + } + + auto * ctx = new whisper_vitisai_context; + ctx->model_path = path_model; + + // Override the model path with the environment variable if it is set + if (const char * env_model_path = std::getenv("OVERRIDE_VITISAI_MODEL_PATH")) { + if (env_model_path[0] != '\0') { + ctx->model_path = env_model_path; + } + } + + // Step 1: Set up the model + flexmlrt::client::Options options; + options.modelPath = ctx->model_path; + options.deviceName = "stx"; + options.debug = false; + options.executeMode = 2; + options.extOptions["ai_analyzer_profiling"] = true; // Enable AIA profiling + options.extOptions["enable_preemption"] = true; + + // Check if model_path is rai file and if so, add fbs_buffer and fbs_buffer_size to the options + if (ctx->model_path.find(".rai") != std::string::npos) { + // mmap rai file for both Linux and Windows and pass the buffer to the options + ctx->fbs_buffer = nullptr; + ctx->fbs_buffer_size = 0; + if (map_rai_file(ctx->model_path.c_str(), &ctx->fbs_buffer, &ctx->fbs_buffer_size)) { + options.extOptions["fbs_buffer"] = ctx->fbs_buffer; + options.extOptions["fbs_buffer_size"] = ctx->fbs_buffer_size; + options.subgraphName = "vaiml_par_0"; + options.extOptions["cache_dir"] = std::string("."); + } else { + std::fprintf(stderr, "%s: Failed to mmap rai file '%s'\n", __func__, ctx->model_path.c_str()); + delete ctx; + return nullptr; + } + } + + try { + ctx->runner = std::make_shared(options); + + if (!ctx->runner->good()) { + throw std::runtime_error("Runner creation ran into an error"); + } + } catch (const std::exception & e) { + std::fprintf(stderr, "%s: Exception during Vitis AI runner creation: %s\n", __func__, e.what()); + delete ctx; + return nullptr; + } + return ctx; +} + +void whisper_vitisai_free(struct whisper_vitisai_context * ctx) { + if (!ctx) { + return; + } + + std::fprintf(stderr, "%s: releasing Vitis AI encoder context for model '%s'\n", __func__, ctx->model_path.c_str()); + if (ctx->fbs_buffer) { + unmap_rai_file(ctx->fbs_buffer, ctx->fbs_buffer_size); + } + delete ctx; +} + +int whisper_vitisai_encode(struct whisper_vitisai_context * ctx, struct ggml_tensor * mel, struct ggml_tensor * out) { + if (!ctx || !mel || !out) { + std::fprintf(stderr, "%s: ctx/mel/out must not be null\n", __func__); + return 0; + } + + if (ggml_n_dims(mel) != 2) { + std::fprintf(stderr, "%s: mel tensor expected to have 2 dims, got %d\n", __func__, ggml_n_dims(mel)); + return 0; + } + + if (ggml_n_dims(out) != 2) { + std::fprintf(stderr, "%s: out tensor expected to have 2 dims, got %d\n", __func__, ggml_n_dims(out)); + return 0; + } + + // setup input and output tensors for Vitis AI model + std::vector input_tensors, output_tensors; + auto model = ctx->runner; + + // Get tensors as CPU tensors (hwTensor = false) + input_tensors = model->getIOTensors("input", false); + output_tensors = model->getIOTensors("output", false); + + // TODO: add assert checks for tensor numbers and shapes + + input_tensors[0].data = mel->data; + output_tensors[0].data = out->data; + + try { + model->forward(input_tensors, output_tensors); + std::fprintf(stdout, "%s: Vitis AI model inference completed.\n", __func__); + } catch (const std::exception & e) { + std::fprintf(stderr, "%s: Exception during model inference: %s\n", __func__, e.what()); + return 0; + } + + return 1; +} diff --git a/src/vitisai/whisper-vitisai-encoder.h b/src/vitisai/whisper-vitisai-encoder.h new file mode 100644 index 00000000..05dc812b --- /dev/null +++ b/src/vitisai/whisper-vitisai-encoder.h @@ -0,0 +1,32 @@ +// Copyright(C) 2025 Advanced Micro Devices, Inc. All rights reserved. + +#pragma once + +#include +#include +#include + +#if __cplusplus +extern "C" { +#endif + +struct whisper_vitisai_context; + +struct whisper_vitisai_context * whisper_vitisai_init(const char * path_model); +void whisper_vitisai_free(struct whisper_vitisai_context * ctx); + +// Function to mmap rai file for Linux and MapViewOfFile for Windows +bool map_rai_file(const char * path, uint8_t ** buffer, size_t * size); +// Function to unmap rai file for Linux and UnmapViewOfFile for Windows +void unmap_rai_file(uint8_t * buffer, size_t size); + +struct ggml_tensor; + +int whisper_vitisai_encode( + struct whisper_vitisai_context * ctx, + struct ggml_tensor * mel, + struct ggml_tensor * out); + +#if __cplusplus +} +#endif diff --git a/src/whisper.cpp b/src/whisper.cpp index 5b6e4b4b..59dd59c5 100644 --- a/src/whisper.cpp +++ b/src/whisper.cpp @@ -14,6 +14,10 @@ #include "openvino/whisper-openvino-encoder.h" #endif +#ifdef WHISPER_USE_VITISAI +#include "vitisai/whisper-vitisai-encoder.h" +#endif + #include #include #include @@ -903,6 +907,10 @@ struct whisper_state { whisper_openvino_context * ctx_openvino = nullptr; #endif +#ifdef WHISPER_USE_VITISAI + whisper_vitisai_context * ctx_vitisai = nullptr; +#endif + // [EXPERIMENTAL] token-level timestamps data int64_t t_beg = 0; int64_t t_last = 0; @@ -1970,7 +1978,13 @@ static bool whisper_encode_external(const whisper_state & wstate) { const bool use_openvino = wstate.ctx_openvino != nullptr; #endif - return use_coreml || use_openvino; +#ifndef WHISPER_USE_VITISAI + const bool use_vitisai = false; +#else + const bool use_vitisai = wstate.ctx_vitisai != nullptr; +#endif + + return use_coreml || use_openvino || use_vitisai; } static struct ggml_cgraph * whisper_build_graph_conv( @@ -2411,6 +2425,8 @@ static bool whisper_encode_internal( #if defined(WHISPER_USE_COREML) whisper_coreml_encode(wstate.ctx_coreml, mel->ne[0], mel->ne[1], (float *) mel->data, (float *) wstate.embd_enc->data); +#elif defined(WHISPER_USE_VITISAI) + whisper_vitisai_encode(wstate.ctx_vitisai, mel, wstate.embd_enc); #elif defined(WHISPER_USE_OPENVINO) whisper_openvino_encode(wstate.ctx_openvino, mel, wstate.embd_enc); #endif @@ -3346,6 +3362,20 @@ static std::string whisper_get_coreml_path_encoder(std::string path_bin) { } #endif +#ifdef WHISPER_USE_VITISAI +// replace extension with Vitis AI encoder artifact +static std::string whisper_get_vitisai_path_encoder_cache(std::string path_bin) { + auto pos = path_bin.rfind('.'); + if (pos != std::string::npos) { + path_bin = path_bin.substr(0, pos); + } + + path_bin += "-encoder-vitisai.rai"; + + return path_bin; +} +#endif + #ifdef WHISPER_USE_OPENVINO // replace .bin with-encoder-openvino.xml static std::string whisper_openvino_get_path_encoder(std::string path_bin) { @@ -3455,6 +3485,19 @@ struct whisper_state * whisper_init_state(whisper_context * ctx) { } #endif +#ifdef WHISPER_USE_VITISAI + const auto path_vitisai = whisper_get_vitisai_path_encoder_cache(ctx->path_model); + + state->ctx_vitisai = whisper_vitisai_init(path_vitisai.c_str()); + if (!state->ctx_vitisai) { + WHISPER_LOG_ERROR("%s: failed to load Vitis AI model from '%s'\n", __func__, path_vitisai.c_str()); + whisper_free_state(state); + return nullptr; + } else { + WHISPER_LOG_INFO("%s: Vitis AI model loaded\n", __func__); + } +#endif + state->logits.reserve(ctx->vocab.n_vocab * ctx->model.hparams.n_text_ctx); state->batch = whisper_batch_init(ctx->model.hparams.n_text_ctx, WHISPER_MAX_DECODERS); @@ -3821,6 +3864,13 @@ void whisper_free_state(struct whisper_state * state) { } #endif +#ifdef WHISPER_USE_VITISAI + if (state->ctx_vitisai != nullptr) { + whisper_vitisai_free(state->ctx_vitisai); + state->ctx_vitisai = nullptr; + } +#endif + whisper_batch_free(state->batch); ggml_backend_sched_free(state->sched_conv.sched); @@ -4312,11 +4362,20 @@ static int whisper_has_openvino(void) { #endif } +static int whisper_has_vitisai(void) { +#ifdef WHISPER_USE_VITISAI + return 1; +#else + return 0; +#endif +} + const char * whisper_print_system_info(void) { static std::string s; s = ""; s += "WHISPER : "; + s += "VITISAI = " + std::to_string(whisper_has_vitisai()) + " | "; s += "COREML = " + std::to_string(whisper_has_coreml()) + " | "; s += "OPENVINO = " + std::to_string(whisper_has_openvino()) + " | "; From b2feb49ed8230ce56bd979e693ed43cc566f100e Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Wed, 21 Jan 2026 23:23:00 -0800 Subject: [PATCH 02/25] Placeholder instruction update. Need Links --- README.md | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 0369f142..7dad2011 100644 --- a/README.md +++ b/README.md @@ -312,35 +312,55 @@ This can result in significant speedup in encoder performance. Here are the inst For more information about the OpenVINO implementation please refer to PR [#1037](https://github.com/ggml-org/whisper.cpp/pull/1037). -## VitisAI encoder support +## AMD Ryzen™ AI support for NPU -On AMD Ryzen AI NPU devices, you can run the Encoder via the VitisAI plugin to significantly accelerate the whisper models. +On AMD's Ryzen™ AI 300 Series that has dedicated NPUs for acceleration - you can now run whisper models with the ability to fully offload the encoder to NPU. This brings 4x speedup from running on CPU. -- Prepare the AMD runtime packages (required before building): +### Setup environment - - Obtain the XRT package and the FlexmlRT package from AMD. Both are distributed as tarballs or wheels. - - Copy the downloaded archives to a local path, extract them, and run the setup script from each extracted package in your shell (for example `source /path/to/xrt/setup.sh` and `source /path/to/flexmlrt/setup.sh`). Run these in every new shell you use to build or run `whisper.cpp`. + - Ensure you have NPU drivers .280 0r above installed from here: + + - Download the necessary dependencies for RyzenAI from here: + - **Windows**: + - **Linux**: + + - Extract and source the environment: -- Fetch the prebuilt VitisAI encoder cache: + **Windows:** + ```powershell + tar xvf flexmlrt1.7rc3.zip + flexmlrt\setup.bat + ``` - - Download the appropriate Whisper encoder `.rai` cache for your model size from the AMD collection on Hugging Face: https://huggingface.co/collections/amd/ryzen-ai-16-whisper-npu-optimized-onnx-models - - Place and rename the downloaded `.rai` file as `-encoder-vitisai.rai` alongside your ggml model files `.bin`. + **Linux:** + ```bash + unzip flexmlrt1.7rc3.zip + source flexmlrt/setup.sh + ``` -- Build `whisper.cpp` with VitisAI support: + + Your environment is now ready. + +### Build Whisper.cpp for Ryzen™ AI support ```bash cmake -B build -DWHISPER_VITISAI=1 cmake --build build -j --config Release ``` -- Run the examples as usual. For example: +### Download NPU-optimized models - ```text - $ ./build/bin/whisper-cli -m models/ggml-base.en.bin -f samples/jfk.wav +- The collection at https://huggingface.co/collections/amd/ryzen-ai-16-whisper-npu-optimized-onnx-models contains all the NPU supported Whisper models and their compiled `.rai` cache files. +- Download the `.rai` file matching your desired model and place it in your `models/` directory alongside the corresponding `ggml-<...>.bin` file. + +> **Note:** The ".rai" models provided by Hugging Face are already pre-optimized for Ryzen™ AI NPUs. This means you should experience acceleration benefits on the very first run (aside from any initial CPU-side caching overhead). + + Run the examples as usual: + + ```bash + ./build/bin/whisper-cli -m models/ggml-base.en.bin -f samples/jfk.wav ``` -The VitisAI artifact from Huggingface is already optimized for Ryzen AI NPUs, there is no slow compilation needed. The acceleration advantage should be seen from first run itself apart from CPU caching overheads. - ## NVIDIA GPU support With NVIDIA cards the processing of the models is done efficiently on the GPU via cuBLAS and custom CUDA kernels. From 759636f837bf988472edba2348571084314de502 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Thu, 22 Jan 2026 09:23:12 -0800 Subject: [PATCH 03/25] update --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7dad2011..ce0baf4a 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ High-performance inference of [OpenAI's Whisper](https://github.com/openai/whisp - [Vulkan support](#vulkan-gpu-support) - Support for CPU-only inference - [Efficient GPU support for NVIDIA](#nvidia-gpu-support) +- [AMD Ryzen AI NPU Support](#amd-ryzen-ai-support-for-npu) - [OpenVINO Support](#openvino-support) - [Ascend NPU Support](#ascend-npu-support) - [Moore Threads GPU Support](#moore-threads-gpu-support) From 500f5d5836e1d088c95efe87bccb7cd9cb2911a9 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Thu, 22 Jan 2026 10:59:28 -0800 Subject: [PATCH 04/25] removed Linux --- README.md | 54 ++++++++++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index ce0baf4a..6b206f65 100644 --- a/README.md +++ b/README.md @@ -315,52 +315,46 @@ For more information about the OpenVINO implementation please refer to PR [#1037 ## AMD Ryzen™ AI support for NPU -On AMD's Ryzen™ AI 300 Series that has dedicated NPUs for acceleration - you can now run whisper models with the ability to fully offload the encoder to NPU. This brings 4x speedup from running on CPU. +On AMD's Ryzen™ AI 300 Series with dedicated NPUs for acceleration, you can now run Whisper models with the ability to fully offload the encoder to NPU. This brings significant speedup compared to CPU-only. +> **Note:** +> **Ryzen™ AI NPU acceleration is currently supported on Windows only.** Linux support is planned for upcoming releases. -### Setup environment +### Setup environment (Windows only) - - Ensure you have NPU drivers .280 0r above installed from here: - - - Download the necessary dependencies for RyzenAI from here: - - **Windows**: - - **Linux**: - - - Extract and source the environment: +- Ensure you have NPU drivers version .280 or above installed + [Download latest drivers here: ] +- Download the necessary dependencies for RyzenAI + [Windows download link: ] +- Extract and set up the environment: - **Windows:** ```powershell tar xvf flexmlrt1.7rc3.zip flexmlrt\setup.bat ``` - **Linux:** - ```bash - unzip flexmlrt1.7rc3.zip - source flexmlrt/setup.sh - ``` - - - Your environment is now ready. +Your environment is now ready. ### Build Whisper.cpp for Ryzen™ AI support - ```bash - cmake -B build -DWHISPER_VITISAI=1 - cmake --build build -j --config Release - ``` +```bash +cmake -B build -DWHISPER_VITISAI=1 +cmake --build build -j --config Release +``` ### Download NPU-optimized models -- The collection at https://huggingface.co/collections/amd/ryzen-ai-16-whisper-npu-optimized-onnx-models contains all the NPU supported Whisper models and their compiled `.rai` cache files. -- Download the `.rai` file matching your desired model and place it in your `models/` directory alongside the corresponding `ggml-<...>.bin` file. +- All NPU-supported Whisper models and their compiled `.rai` cache files are available in this collection: + https://huggingface.co/collections/amd/ryzen-ai-16-whisper-npu-optimized-onnx-models +- Download the `.rai` file matching your desired model, and place it in your `models/` directory alongside its corresponding `ggml-<...>.bin` file. -> **Note:** The ".rai" models provided by Hugging Face are already pre-optimized for Ryzen™ AI NPUs. This means you should experience acceleration benefits on the very first run (aside from any initial CPU-side caching overhead). - - Run the examples as usual: +> **Note:** The ".rai" models from Hugging Face are pre-optimized for Ryzen™ AI NPUs, delivering acceleration benefits from the very first run (aside from any initial CPU-side caching overhead). + +Run the examples as usual: + +```bash +./build/bin/whisper-cli -m models/ggml-base.en.bin -f samples/jfk.wav +``` - ```bash - ./build/bin/whisper-cli -m models/ggml-base.en.bin -f samples/jfk.wav - ``` ## NVIDIA GPU support From 426daf28dd6ac161da12894b26b6d2c8b4e1b7a8 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Thu, 22 Jan 2026 11:49:32 -0800 Subject: [PATCH 05/25] removed Linux --- README.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6b206f65..1e7ff080 100644 --- a/README.md +++ b/README.md @@ -317,21 +317,18 @@ For more information about the OpenVINO implementation please refer to PR [#1037 On AMD's Ryzen™ AI 300 Series with dedicated NPUs for acceleration, you can now run Whisper models with the ability to fully offload the encoder to NPU. This brings significant speedup compared to CPU-only. > **Note:** -> **Ryzen™ AI NPU acceleration is currently supported on Windows only.** Linux support is planned for upcoming releases. +> **Ryzen™ AI NPU acceleration is currently supported on Windows only.** Linux support is planned for upcoming releases. +> For the latest updates on Ryzen AI, check out [the official documentation](https://ryzenai.docs.amd.com/en/latest/). ### Setup environment (Windows only) -- Ensure you have NPU drivers version .280 or above installed - [Download latest drivers here: ] -- Download the necessary dependencies for RyzenAI - [Windows download link: ] -- Extract and set up the environment: - +- **Driver:** Make sure you have NPU drivers version **.280 or newer** installed. [Download latest drivers from here](https://account.amd.com/en/forms/downloads/ryzenai-eula-public-xef.html?filename=NPU_RAI1.5_280_WHQL.zip) +- **Runtime libraries:** Download and install the necessary [runtime dependencies from here](https://account.amd.com/en/forms/downloads/ryzenai-eula-public-xef.html?filename=NPU_RAI1.5_280_WHQL.zip). +- **Environment:** Extract the runtime package and set up the environment: ```powershell tar xvf flexmlrt1.7rc3.zip flexmlrt\setup.bat ``` - Your environment is now ready. ### Build Whisper.cpp for Ryzen™ AI support From 832e24fef9d6784568b1e127b8da9d6630108972 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Thu, 22 Jan 2026 22:27:52 -0800 Subject: [PATCH 06/25] test build --- .github/workflows/ryzen-ai-minimal.yml | 108 +++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 .github/workflows/ryzen-ai-minimal.yml diff --git a/.github/workflows/ryzen-ai-minimal.yml b/.github/workflows/ryzen-ai-minimal.yml new file mode 100644 index 00000000..f0d5b28b --- /dev/null +++ b/.github/workflows/ryzen-ai-minimal.yml @@ -0,0 +1,108 @@ +name: Ryzen AI Minimal Build + +on: + workflow_dispatch: + inputs: + runson: + description: 'Which runner group to run the workflow on' + default: 'stx' + required: true + type: choice + options: + - 'rai300_400' + - 'stx' + - 'stx-halo' + - 'stx-test' + +jobs: + build-ryzenai: + runs-on: ${{ github.event.inputs.runson }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v2 + + - name: Download FlexML Runtime + shell: pwsh + run: | + Write-Host "Downloading FlexML Runtime..." + Invoke-WebRequest -Uri "https://github.com/lemonade-sdk/whisper.cpp/releases/download/deps/flexmlrt1.7.0rc.zip" -OutFile flexmlrt.zip + Write-Host "Download complete" + + - name: Extract FlexML Runtime + shell: pwsh + run: | + Write-Host "Extracting FlexML Runtime..." + tar xvf flexmlrt.zip + Write-Host "Extraction complete" + + # List what was extracted + Get-ChildItem -Directory | Where-Object { $_.Name -like "flexmlrt*" } + + - name: Setup FlexML Runtime environment + shell: cmd + run: | + echo "Setting up FlexML environment..." + cd flexmlrt + call setup.bat + echo "Setup complete" + + - name: Configure CMake with VitisAI + shell: pwsh + run: | + Write-Host "Configuring CMake..." + cmake -B build -A x64 -DCMAKE_BUILD_TYPE=Release -DWHISPER_VITISAI=ON + + - name: Build + shell: pwsh + run: | + Write-Host "Building..." + cmake --build build --config Release -j + Write-Host "Build complete" + + - name: List build output + shell: pwsh + run: | + Write-Host "Build output contents:" + Get-ChildItem -Path "build/bin/Release" -Recurse | Format-Table Name, Length + + - name: Copy FlexML Runtime DLLs to build output + shell: pwsh + run: | + Write-Host "Copying FlexML Runtime DLLs..." + + if (Test-Path "flexmlrt/bin") { + Copy-Item -Path "flexmlrt/bin/*.dll" -Destination "build/bin/Release/" -Force -ErrorAction SilentlyContinue + } + + if (Test-Path "flexmlrt/lib") { + Copy-Item -Path "flexmlrt/lib/*.dll" -Destination "build/bin/Release/" -Force -ErrorAction SilentlyContinue + } + + Write-Host "DLLs copied" + + - name: Package binaries + shell: pwsh + run: | + Write-Host "Creating ZIP package..." + Compress-Archive -Path "build/bin/Release/*" -DestinationPath "whisper-ryzenai-minimal.zip" + Write-Host "Package created" + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: whisper-ryzenai-minimal + path: whisper-ryzenai-minimal.zip + + - name: Build Summary + shell: pwsh + run: | + Write-Host "========================================" -ForegroundColor Green + Write-Host "Build completed successfully!" -ForegroundColor Green + Write-Host "========================================" -ForegroundColor Green + Write-Host "" + Write-Host "Artifact: whisper-ryzenai-minimal.zip" + Write-Host "Download from: Actions > This workflow run > Artifacts" From faee4d4ddc1cb7429da57c00da2291ef08630c21 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Thu, 22 Jan 2026 22:36:12 -0800 Subject: [PATCH 07/25] test build --- .github/workflows/ryzen-ai-minimal.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ryzen-ai-minimal.yml b/.github/workflows/ryzen-ai-minimal.yml index f0d5b28b..f6d23ff8 100644 --- a/.github/workflows/ryzen-ai-minimal.yml +++ b/.github/workflows/ryzen-ai-minimal.yml @@ -1,6 +1,16 @@ name: Ryzen AI Minimal Build on: + pull_request: + branches: + - main + - master + paths: + - '.github/workflows/ryzen-ai-minimal.yml' + - 'src/**' + - 'ggml/**' + - 'CMakeLists.txt' + - '**.cmake' workflow_dispatch: inputs: runson: @@ -16,7 +26,7 @@ on: jobs: build-ryzenai: - runs-on: ${{ github.event.inputs.runson }} + runs-on: ${{ github.event.inputs.runson || 'stx' }} steps: - name: Checkout code From 1166f5a61144dc19ca0031c990bbaf150e0e1aed Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Thu, 22 Jan 2026 22:59:11 -0800 Subject: [PATCH 08/25] test build --- .github/workflows/ryzen-ai-minimal.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ryzen-ai-minimal.yml b/.github/workflows/ryzen-ai-minimal.yml index f6d23ff8..a6b43dcf 100644 --- a/.github/workflows/ryzen-ai-minimal.yml +++ b/.github/workflows/ryzen-ai-minimal.yml @@ -12,21 +12,21 @@ on: - 'CMakeLists.txt' - '**.cmake' workflow_dispatch: - inputs: - runson: - description: 'Which runner group to run the workflow on' - default: 'stx' - required: true - type: choice - options: - - 'rai300_400' - - 'stx' - - 'stx-halo' - - 'stx-test' + # inputs: + # runson: + # description: 'Which runner group to run the workflow on' + # default: 'stx' + # required: true + # type: choice + # options: + # - 'rai300_400' + # - 'stx' + # - 'stx-halo' + # - 'stx-test' jobs: build-ryzenai: - runs-on: ${{ github.event.inputs.runson || 'stx' }} + runs-on: [rai-160-sdk, Windows] steps: - name: Checkout code From 296b0c7c88a73a98b657e919cd74aba98de9e018 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Fri, 23 Jan 2026 13:45:58 -0800 Subject: [PATCH 09/25] worflow activate --- .github/workflows/ryzen-ai-minimal.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ryzen-ai-minimal.yml b/.github/workflows/ryzen-ai-minimal.yml index a6b43dcf..1bbec968 100644 --- a/.github/workflows/ryzen-ai-minimal.yml +++ b/.github/workflows/ryzen-ai-minimal.yml @@ -39,7 +39,7 @@ jobs: shell: pwsh run: | Write-Host "Downloading FlexML Runtime..." - Invoke-WebRequest -Uri "https://github.com/lemonade-sdk/whisper.cpp/releases/download/deps/flexmlrt1.7.0rc.zip" -OutFile flexmlrt.zip + Invoke-WebRequest -Uri "https://github.com/lemonade-sdk/whisper.cpp/releases/download/deps/flexmlrt1.7.0-win.zip" -OutFile flexmlrt.zip Write-Host "Download complete" - name: Extract FlexML Runtime From 5186ae80c2edf7819fb2ab532ccb7af0db9f9848 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Fri, 23 Jan 2026 14:20:35 -0800 Subject: [PATCH 10/25] worflow activate --- .github/workflows/ryzen-ai-minimal.yml | 34 ++++++++++++++++++++------ 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ryzen-ai-minimal.yml b/.github/workflows/ryzen-ai-minimal.yml index 1bbec968..fc11bd65 100644 --- a/.github/workflows/ryzen-ai-minimal.yml +++ b/.github/workflows/ryzen-ai-minimal.yml @@ -36,14 +36,32 @@ jobs: uses: microsoft/setup-msbuild@v2 - name: Download FlexML Runtime - shell: pwsh + shell: powershell run: | Write-Host "Downloading FlexML Runtime..." Invoke-WebRequest -Uri "https://github.com/lemonade-sdk/whisper.cpp/releases/download/deps/flexmlrt1.7.0-win.zip" -OutFile flexmlrt.zip Write-Host "Download complete" + + # Verify download + if (-Not (Test-Path "flexmlrt.zip")) { + Write-Error "ERROR: flexmlrt.zip was not downloaded!" + exit 1 + } + + $fileSize = (Get-Item "flexmlrt.zip").Length + $fileSizeMB = [math]::Round($fileSize / 1MB, 2) + + if ($fileSize -eq 0) { + Write-Error "ERROR: flexmlrt.zip is empty (0 bytes)!" + exit 1 + } + + Write-Host "✓ Download verified successfully" -ForegroundColor Green + Write-Host " File: flexmlrt.zip" + Write-Host " Size: $fileSizeMB MB ($fileSize bytes)" - name: Extract FlexML Runtime - shell: pwsh + shell: powershell run: | Write-Host "Extracting FlexML Runtime..." tar xvf flexmlrt.zip @@ -61,26 +79,26 @@ jobs: echo "Setup complete" - name: Configure CMake with VitisAI - shell: pwsh + shell: powershell run: | Write-Host "Configuring CMake..." cmake -B build -A x64 -DCMAKE_BUILD_TYPE=Release -DWHISPER_VITISAI=ON - name: Build - shell: pwsh + shell: powershell run: | Write-Host "Building..." cmake --build build --config Release -j Write-Host "Build complete" - name: List build output - shell: pwsh + shell: powershell run: | Write-Host "Build output contents:" Get-ChildItem -Path "build/bin/Release" -Recurse | Format-Table Name, Length - name: Copy FlexML Runtime DLLs to build output - shell: pwsh + shell: powershell run: | Write-Host "Copying FlexML Runtime DLLs..." @@ -95,7 +113,7 @@ jobs: Write-Host "DLLs copied" - name: Package binaries - shell: pwsh + shell: powershell run: | Write-Host "Creating ZIP package..." Compress-Archive -Path "build/bin/Release/*" -DestinationPath "whisper-ryzenai-minimal.zip" @@ -108,7 +126,7 @@ jobs: path: whisper-ryzenai-minimal.zip - name: Build Summary - shell: pwsh + shell: powershell run: | Write-Host "========================================" -ForegroundColor Green Write-Host "Build completed successfully!" -ForegroundColor Green From 1586a6051c44c182751aa8ccd5a698d5e489a9b3 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Fri, 23 Jan 2026 14:52:04 -0800 Subject: [PATCH 11/25] worflow activate --- .github/workflows/ryzen-ai-minimal.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ryzen-ai-minimal.yml b/.github/workflows/ryzen-ai-minimal.yml index fc11bd65..df6797e7 100644 --- a/.github/workflows/ryzen-ai-minimal.yml +++ b/.github/workflows/ryzen-ai-minimal.yml @@ -56,9 +56,9 @@ jobs: exit 1 } - Write-Host "✓ Download verified successfully" -ForegroundColor Green - Write-Host " File: flexmlrt.zip" - Write-Host " Size: $fileSizeMB MB ($fileSize bytes)" + Write-Host "Download verified successfully" -ForegroundColor Green + Write-Host "File: flexmlrt.zip" + Write-Host "Size: $fileSizeMB MB" - name: Extract FlexML Runtime shell: powershell From 40a622f5291ff83263881b341a088d4e4bc71e6d Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Fri, 23 Jan 2026 15:22:26 -0800 Subject: [PATCH 12/25] worflow activate --- .github/workflows/ryzen-ai-minimal.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ryzen-ai-minimal.yml b/.github/workflows/ryzen-ai-minimal.yml index df6797e7..8063a3ba 100644 --- a/.github/workflows/ryzen-ai-minimal.yml +++ b/.github/workflows/ryzen-ai-minimal.yml @@ -26,7 +26,7 @@ on: jobs: build-ryzenai: - runs-on: [rai-160-sdk, Windows] + runs-on: [stx, Windows] steps: - name: Checkout code @@ -70,18 +70,16 @@ jobs: # List what was extracted Get-ChildItem -Directory | Where-Object { $_.Name -like "flexmlrt*" } - - name: Setup FlexML Runtime environment + - name: Setup FlexML Runtime and Configure CMake shell: cmd run: | echo "Setting up FlexML environment..." cd flexmlrt call setup.bat + cd .. echo "Setup complete" - - - name: Configure CMake with VitisAI - shell: powershell - run: | - Write-Host "Configuring CMake..." + echo. + echo "Configuring CMake..." cmake -B build -A x64 -DCMAKE_BUILD_TYPE=Release -DWHISPER_VITISAI=ON - name: Build From 479c9237f4e809bb7180d18593a57b1cdd7789e3 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Fri, 23 Jan 2026 15:26:57 -0800 Subject: [PATCH 13/25] worflow activate --- .github/workflows/ryzen-ai-minimal.yml | 114 ++++++++++++++++++++++--- 1 file changed, 100 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ryzen-ai-minimal.yml b/.github/workflows/ryzen-ai-minimal.yml index 8063a3ba..3f4b0161 100644 --- a/.github/workflows/ryzen-ai-minimal.yml +++ b/.github/workflows/ryzen-ai-minimal.yml @@ -35,6 +35,45 @@ jobs: - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v2 + - name: Install CMake if not available + shell: powershell + run: | + # Check if CMake is already installed + $cmakeInstalled = Get-Command cmake -ErrorAction SilentlyContinue + + if (-not $cmakeInstalled) { + Write-Host "CMake not found, installing..." -ForegroundColor Yellow + + # Download CMake installer + $cmakeVersion = "3.28.1" + $cmakeUrl = "https://github.com/Kitware/CMake/releases/download/v$cmakeVersion/cmake-$cmakeVersion-windows-x86_64.msi" + $cmakeInstaller = "cmake-installer.msi" + + Invoke-WebRequest -Uri $cmakeUrl -OutFile $cmakeInstaller + + # Install CMake silently + Start-Process msiexec.exe -ArgumentList "/i $cmakeInstaller /quiet /norestart" -Wait + + # Add CMake to PATH for this session AND future steps + $cmakePath = "C:\Program Files\CMake\bin" + $env:PATH = "$cmakePath;$env:PATH" + + # Persist to GITHUB_PATH for future steps + echo $cmakePath >> $env:GITHUB_PATH + + # Verify installation + cmake --version + if ($LASTEXITCODE -ne 0) { + Write-Host "ERROR: CMake installation failed!" -ForegroundColor Red + exit 1 + } + + Write-Host "CMake installed successfully and added to PATH!" -ForegroundColor Green + } else { + Write-Host "CMake is already installed:" -ForegroundColor Green + cmake --version + } + - name: Download FlexML Runtime shell: powershell run: | @@ -65,57 +104,104 @@ jobs: run: | Write-Host "Extracting FlexML Runtime..." tar xvf flexmlrt.zip + if ($LASTEXITCODE -ne 0) { + Write-Error "ERROR: Extraction failed!" + exit 1 + } Write-Host "Extraction complete" # List what was extracted - Get-ChildItem -Directory | Where-Object { $_.Name -like "flexmlrt*" } + $extractedDirs = Get-ChildItem -Directory | Where-Object { $_.Name -like "flexmlrt*" } + if ($extractedDirs) { + Write-Host "Extracted directories:" -ForegroundColor Green + $extractedDirs | ForEach-Object { Write-Host " - $($_.Name)" } + } else { + Write-Error "ERROR: No flexmlrt directory found after extraction!" + exit 1 + } - - name: Setup FlexML Runtime and Configure CMake + - name: Setup FlexML Runtime, Configure and Build shell: cmd run: | echo "Setting up FlexML environment..." cd flexmlrt call setup.bat + if errorlevel 1 ( + echo ERROR: FlexML setup failed! + exit /b 1 + ) cd .. echo "Setup complete" echo. echo "Configuring CMake..." cmake -B build -A x64 -DCMAKE_BUILD_TYPE=Release -DWHISPER_VITISAI=ON - - - name: Build - shell: powershell - run: | - Write-Host "Building..." + if errorlevel 1 ( + echo ERROR: CMake configuration failed! + exit /b 1 + ) + echo. + echo "Building..." cmake --build build --config Release -j - Write-Host "Build complete" + if errorlevel 1 ( + echo ERROR: Build failed! + exit /b 1 + ) + echo "Build complete" - name: List build output shell: powershell run: | Write-Host "Build output contents:" - Get-ChildItem -Path "build/bin/Release" -Recurse | Format-Table Name, Length + if (Test-Path "build/bin/Release") { + Get-ChildItem -Path "build/bin/Release" -Recurse | Format-Table Name, Length + } else { + Write-Warning "build/bin/Release directory not found!" + exit 1 + } - name: Copy FlexML Runtime DLLs to build output shell: powershell run: | Write-Host "Copying FlexML Runtime DLLs..." + $dllsCopied = 0 + if (Test-Path "flexmlrt/bin") { - Copy-Item -Path "flexmlrt/bin/*.dll" -Destination "build/bin/Release/" -Force -ErrorAction SilentlyContinue + $binDlls = Get-ChildItem -Path "flexmlrt/bin/*.dll" -ErrorAction SilentlyContinue + if ($binDlls) { + Copy-Item -Path "flexmlrt/bin/*.dll" -Destination "build/bin/Release/" -Force + $dllsCopied += $binDlls.Count + Write-Host "Copied $($binDlls.Count) DLLs from flexmlrt/bin" + } } if (Test-Path "flexmlrt/lib") { - Copy-Item -Path "flexmlrt/lib/*.dll" -Destination "build/bin/Release/" -Force -ErrorAction SilentlyContinue + $libDlls = Get-ChildItem -Path "flexmlrt/lib/*.dll" -ErrorAction SilentlyContinue + if ($libDlls) { + Copy-Item -Path "flexmlrt/lib/*.dll" -Destination "build/bin/Release/" -Force + $dllsCopied += $libDlls.Count + Write-Host "Copied $($libDlls.Count) DLLs from flexmlrt/lib" + } } - Write-Host "DLLs copied" + if ($dllsCopied -eq 0) { + Write-Warning "No DLLs found to copy from flexmlrt/bin or flexmlrt/lib" + } else { + Write-Host "Total DLLs copied: $dllsCopied" -ForegroundColor Green + } - name: Package binaries shell: powershell run: | Write-Host "Creating ZIP package..." - Compress-Archive -Path "build/bin/Release/*" -DestinationPath "whisper-ryzenai-minimal.zip" - Write-Host "Package created" + Compress-Archive -Path "build/bin/Release/*" -DestinationPath "whisper-ryzenai-minimal.zip" -Force + if (Test-Path "whisper-ryzenai-minimal.zip") { + $zipSize = (Get-Item "whisper-ryzenai-minimal.zip").Length / 1MB + Write-Host "Package created successfully: $([math]::Round($zipSize, 2)) MB" + } else { + Write-Error "ERROR: Failed to create package!" + exit 1 + } - name: Upload artifact uses: actions/upload-artifact@v4 From 5a406d166746a4939afcfe5ea84a757c958add39 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Fri, 23 Jan 2026 15:35:09 -0800 Subject: [PATCH 14/25] worflow activate --- .github/workflows/ryzen-ai-minimal.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ryzen-ai-minimal.yml b/.github/workflows/ryzen-ai-minimal.yml index 3f4b0161..0b66e930 100644 --- a/.github/workflows/ryzen-ai-minimal.yml +++ b/.github/workflows/ryzen-ai-minimal.yml @@ -26,7 +26,7 @@ on: jobs: build-ryzenai: - runs-on: [stx, Windows] + runs-on: [rai-160-sdk, Windows] steps: - name: Checkout code From 60457d2f24015477cacf4ba33420a72ebea046a1 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Thu, 12 Feb 2026 15:23:51 -0800 Subject: [PATCH 15/25] Add linux build --- .github/workflows/linux-cpu-build.yml | 148 +++++++++++++++++++++++++ .github/workflows/ryzen-ai-minimal.yml | 2 +- 2 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/linux-cpu-build.yml diff --git a/.github/workflows/linux-cpu-build.yml b/.github/workflows/linux-cpu-build.yml new file mode 100644 index 00000000..a78b8ec9 --- /dev/null +++ b/.github/workflows/linux-cpu-build.yml @@ -0,0 +1,148 @@ +name: Linux CPU Build + +on: + pull_request: + branches: + - main + - master + paths: + - '.github/workflows/linux-cpu-build.yml' + - 'src/**' + - 'ggml/**' + - 'CMakeLists.txt' + - '**.cmake' + workflow_dispatch: + release: + types: [created] + +jobs: + build-cpu-linux: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + echo "Installing build dependencies..." + sudo apt-get update + sudo apt-get install -y \ + build-essential \ + cmake \ + git \ + libsdl2-dev \ + pkg-config + echo "Dependencies installed" + cmake --version + gcc --version + + - name: Configure CMake + run: | + echo "Configuring CMake..." + cmake -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DWHISPER_BUILD_EXAMPLES=ON \ + -DWHISPER_BUILD_TESTS=OFF \ + -DWHISPER_BUILD_SERVER=ON + if [ $? -ne 0 ]; then + echo "ERROR: CMake configuration failed!" + exit 1 + fi + echo "Configuration complete" + + - name: Build + run: | + echo "Building..." + cmake --build build --config Release -j$(nproc) + if [ $? -ne 0 ]; then + echo "ERROR: Build failed!" + exit 1 + fi + echo "Build complete" + + - name: List build output + run: | + echo "Build output contents:" + if [ -d "build/bin" ]; then + find build/bin -type f -executable -o -name "*.so*" | while read file; do + ls -lh "$file" + done + echo "" + echo "All build artifacts:" + find build/bin -type f | sort + else + echo "ERROR: build/bin directory not found!" + exit 1 + fi + + - name: Package binaries + run: | + echo "Creating package..." + + # Create package directory + PACKAGE_NAME="whisper-cpu-linux-$(uname -m)" + PACKAGE_DIR="$PACKAGE_NAME" + mkdir -p "$PACKAGE_DIR" + + # Copy binaries + if [ -d "build/bin" ]; then + cp -r build/bin/* "$PACKAGE_DIR/" 2>/dev/null || true + # Also copy any .so files + find build -name "*.so*" -exec cp {} "$PACKAGE_DIR/" \; 2>/dev/null || true + fi + + # Create README + cat > "$PACKAGE_DIR/README.txt" << EOF +Whisper.cpp CPU Build for Linux +=============================== + +Build Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC") +Architecture: $(uname -m) +OS: $(uname -o) +Kernel: $(uname -r) + +Binaries: +EOF + ls -lh "$PACKAGE_DIR" | grep -v "^total" | grep -v "^d" | awk '{print " " $9 " (" $5 ")"}' >> "$PACKAGE_DIR/README.txt" + + # Create tarball + tar -czf "${PACKAGE_NAME}.tar.gz" "$PACKAGE_DIR" + + if [ -f "${PACKAGE_NAME}.tar.gz" ]; then + PACKAGE_SIZE=$(du -h "${PACKAGE_NAME}.tar.gz" | cut -f1) + echo "Package created successfully: ${PACKAGE_NAME}.tar.gz ($PACKAGE_SIZE)" + ls -lh "${PACKAGE_NAME}.tar.gz" + else + echo "ERROR: Failed to create package!" + exit 1 + fi + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: whisper-cpu-linux + path: whisper-cpu-linux-*.tar.gz + retention-days: 30 + + - name: Create Release + if: github.event_name == 'release' + uses: softprops/action-gh-release@v1 + with: + files: whisper-cpu-linux-*.tar.gz + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Summary + run: | + echo "========================================" + echo "Build completed successfully!" + echo "========================================" + echo "" + echo "Artifact: whisper-cpu-linux-*.tar.gz" + echo "Download from: Actions > This workflow run > Artifacts" + if [ "${{ github.event_name }}" == "release" ]; then + echo "Release: Available in GitHub Releases" + fi diff --git a/.github/workflows/ryzen-ai-minimal.yml b/.github/workflows/ryzen-ai-minimal.yml index 0b66e930..7f989c95 100644 --- a/.github/workflows/ryzen-ai-minimal.yml +++ b/.github/workflows/ryzen-ai-minimal.yml @@ -26,7 +26,7 @@ on: jobs: build-ryzenai: - runs-on: [rai-160-sdk, Windows] + runs-on: [rai-170-sdk, Windows] steps: - name: Checkout code From 04b888adac1fa41e8aa10db0bf282c3062673f59 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Thu, 12 Feb 2026 15:30:16 -0800 Subject: [PATCH 16/25] Add linux build --- .github/workflows/linux-cpu-build.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linux-cpu-build.yml b/.github/workflows/linux-cpu-build.yml index a78b8ec9..cde7b911 100644 --- a/.github/workflows/linux-cpu-build.yml +++ b/.github/workflows/linux-cpu-build.yml @@ -1,12 +1,20 @@ name: Linux CPU Build on: + push: + branches: + - main + - master + paths: + - 'src/**' + - 'ggml/**' + - 'CMakeLists.txt' + - '**.cmake' pull_request: branches: - main - master paths: - - '.github/workflows/linux-cpu-build.yml' - 'src/**' - 'ggml/**' - 'CMakeLists.txt' From d800153a78e0eadfa8d8696e1da46524948a785e Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Thu, 12 Feb 2026 15:32:15 -0800 Subject: [PATCH 17/25] wflow --- .github/workflows/linux-cpu-build.yml | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/linux-cpu-build.yml b/.github/workflows/linux-cpu-build.yml index cde7b911..75bcb8df 100644 --- a/.github/workflows/linux-cpu-build.yml +++ b/.github/workflows/linux-cpu-build.yml @@ -101,17 +101,13 @@ jobs: fi # Create README - cat > "$PACKAGE_DIR/README.txt" << EOF -Whisper.cpp CPU Build for Linux -=============================== - -Build Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC") -Architecture: $(uname -m) -OS: $(uname -o) -Kernel: $(uname -r) - -Binaries: -EOF + printf "Whisper.cpp CPU Build for Linux\n" > "$PACKAGE_DIR/README.txt" + printf "===============================\n\n" >> "$PACKAGE_DIR/README.txt" + printf "Build Date: %s\n" "$(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> "$PACKAGE_DIR/README.txt" + printf "Architecture: %s\n" "$(uname -m)" >> "$PACKAGE_DIR/README.txt" + printf "OS: %s\n" "$(uname -o)" >> "$PACKAGE_DIR/README.txt" + printf "Kernel: %s\n\n" "$(uname -r)" >> "$PACKAGE_DIR/README.txt" + printf "Binaries:\n" >> "$PACKAGE_DIR/README.txt" ls -lh "$PACKAGE_DIR" | grep -v "^total" | grep -v "^d" | awk '{print " " $9 " (" $5 ")"}' >> "$PACKAGE_DIR/README.txt" # Create tarball From 199699e84ba1d10971081ae4eba3370bdfbe808a Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Thu, 12 Feb 2026 15:59:47 -0800 Subject: [PATCH 18/25] wflow --- .github/workflows/linux-cpu-build.yml | 77 ++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 12 deletions(-) diff --git a/.github/workflows/linux-cpu-build.yml b/.github/workflows/linux-cpu-build.yml index 75bcb8df..0cefb3f3 100644 --- a/.github/workflows/linux-cpu-build.yml +++ b/.github/workflows/linux-cpu-build.yml @@ -79,6 +79,11 @@ jobs: echo "" echo "All build artifacts:" find build/bin -type f | sort + echo "" + echo "Checking library dependencies for whisper-server:" + if [ -f "build/bin/whisper-server" ]; then + ldd build/bin/whisper-server || echo "Note: ldd may show missing libs if statically linked" + fi else echo "ERROR: build/bin directory not found!" exit 1 @@ -93,22 +98,67 @@ jobs: PACKAGE_DIR="$PACKAGE_NAME" mkdir -p "$PACKAGE_DIR" - # Copy binaries + # Copy binaries and libraries from build/bin if [ -d "build/bin" ]; then + # Copy all files from build/bin cp -r build/bin/* "$PACKAGE_DIR/" 2>/dev/null || true - # Also copy any .so files - find build -name "*.so*" -exec cp {} "$PACKAGE_DIR/" \; 2>/dev/null || true + + # Also find and copy .so files from build directory (they might be in lib/) + find build -name "*.so*" -type f -exec cp {} "$PACKAGE_DIR/" \; 2>/dev/null || true fi - # Create README - printf "Whisper.cpp CPU Build for Linux\n" > "$PACKAGE_DIR/README.txt" - printf "===============================\n\n" >> "$PACKAGE_DIR/README.txt" - printf "Build Date: %s\n" "$(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> "$PACKAGE_DIR/README.txt" - printf "Architecture: %s\n" "$(uname -m)" >> "$PACKAGE_DIR/README.txt" - printf "OS: %s\n" "$(uname -o)" >> "$PACKAGE_DIR/README.txt" - printf "Kernel: %s\n\n" "$(uname -r)" >> "$PACKAGE_DIR/README.txt" - printf "Binaries:\n" >> "$PACKAGE_DIR/README.txt" - ls -lh "$PACKAGE_DIR" | grep -v "^total" | grep -v "^d" | awk '{print " " $9 " (" $5 ")"}' >> "$PACKAGE_DIR/README.txt" + # Verify whisper-server exists + if [ ! -f "$PACKAGE_DIR/whisper-server" ]; then + echo "ERROR: whisper-server not found in package!" + echo "Contents of package directory:" + ls -la "$PACKAGE_DIR" + exit 1 + fi + + # Check dependencies + echo "Checking whisper-server dependencies:" + ldd "$PACKAGE_DIR/whisper-server" || echo "Note: May be statically linked or missing system libs" + + # Make whisper-server executable + chmod +x "$PACKAGE_DIR/whisper-server" + + # Create a run script that sets LD_LIBRARY_PATH + { + printf "#!/bin/bash\n" + printf "# Run whisper-server with proper library path\n" + printf "SCRIPT_DIR=\"\$(cd \"\$(dirname \"\${BASH_SOURCE[0]}\")\" && pwd)\"\n" + printf "export LD_LIBRARY_PATH=\"\${SCRIPT_DIR}:\${LD_LIBRARY_PATH}\"\n" + printf "exec \"\${SCRIPT_DIR}/whisper-server\" \"\$@\"\n" + } > "$PACKAGE_DIR/run-whisper-server.sh" + chmod +x "$PACKAGE_DIR/run-whisper-server.sh" + + # Create README with usage instructions + { + printf "Whisper.cpp CPU Build for Linux\n" + printf "===============================\n\n" + printf "Build Date: %s\n" "$(date -u +"%Y-%m-%d %H:%M:%S UTC")" + printf "Architecture: %s\n" "$(uname -m)" + printf "OS: %s\n" "$(uname -o)" + printf "Kernel: %s\n\n" "$(uname -r)" + printf "Binaries:\n" + ls -lh "$PACKAGE_DIR" | grep -v "^total" | grep -v "^d" | awk '{print " " $9 " (" $5 ")"}' + printf "\n" + printf "Usage:\n" + printf "------\n\n" + printf "Option 1: Use the run script (recommended):\n" + printf " ./run-whisper-server.sh --host 127.0.0.1 -m /path/to/model.bin\n\n" + printf "Option 2: Set LD_LIBRARY_PATH manually:\n" + printf " export LD_LIBRARY_PATH=\$(pwd):\$LD_LIBRARY_PATH\n" + printf " ./whisper-server --host 127.0.0.1 -m /path/to/model.bin\n\n" + printf "System Requirements:\n" + printf "-------------------\n" + printf "This build requires standard Linux system libraries:\n" + printf " - libc (glibc)\n" + printf " - libstdc++\n" + printf " - libpthread\n" + printf " - libm\n" + printf "These are typically pre-installed on most Linux distributions.\n" + } > "$PACKAGE_DIR/README.txt" # Create tarball tar -czf "${PACKAGE_NAME}.tar.gz" "$PACKAGE_DIR" @@ -117,6 +167,9 @@ jobs: PACKAGE_SIZE=$(du -h "${PACKAGE_NAME}.tar.gz" | cut -f1) echo "Package created successfully: ${PACKAGE_NAME}.tar.gz ($PACKAGE_SIZE)" ls -lh "${PACKAGE_NAME}.tar.gz" + echo "" + echo "Package contents:" + tar -tzf "${PACKAGE_NAME}.tar.gz" | head -20 else echo "ERROR: Failed to create package!" exit 1 From b634073baed1ce7ca6849a819a421e242b5af5ec Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Thu, 12 Feb 2026 16:28:14 -0800 Subject: [PATCH 19/25] wflow --- .github/workflows/linux-cpu-build.yml | 77 +++++---------------------- 1 file changed, 12 insertions(+), 65 deletions(-) diff --git a/.github/workflows/linux-cpu-build.yml b/.github/workflows/linux-cpu-build.yml index 0cefb3f3..75bcb8df 100644 --- a/.github/workflows/linux-cpu-build.yml +++ b/.github/workflows/linux-cpu-build.yml @@ -79,11 +79,6 @@ jobs: echo "" echo "All build artifacts:" find build/bin -type f | sort - echo "" - echo "Checking library dependencies for whisper-server:" - if [ -f "build/bin/whisper-server" ]; then - ldd build/bin/whisper-server || echo "Note: ldd may show missing libs if statically linked" - fi else echo "ERROR: build/bin directory not found!" exit 1 @@ -98,67 +93,22 @@ jobs: PACKAGE_DIR="$PACKAGE_NAME" mkdir -p "$PACKAGE_DIR" - # Copy binaries and libraries from build/bin + # Copy binaries if [ -d "build/bin" ]; then - # Copy all files from build/bin cp -r build/bin/* "$PACKAGE_DIR/" 2>/dev/null || true - - # Also find and copy .so files from build directory (they might be in lib/) - find build -name "*.so*" -type f -exec cp {} "$PACKAGE_DIR/" \; 2>/dev/null || true + # Also copy any .so files + find build -name "*.so*" -exec cp {} "$PACKAGE_DIR/" \; 2>/dev/null || true fi - # Verify whisper-server exists - if [ ! -f "$PACKAGE_DIR/whisper-server" ]; then - echo "ERROR: whisper-server not found in package!" - echo "Contents of package directory:" - ls -la "$PACKAGE_DIR" - exit 1 - fi - - # Check dependencies - echo "Checking whisper-server dependencies:" - ldd "$PACKAGE_DIR/whisper-server" || echo "Note: May be statically linked or missing system libs" - - # Make whisper-server executable - chmod +x "$PACKAGE_DIR/whisper-server" - - # Create a run script that sets LD_LIBRARY_PATH - { - printf "#!/bin/bash\n" - printf "# Run whisper-server with proper library path\n" - printf "SCRIPT_DIR=\"\$(cd \"\$(dirname \"\${BASH_SOURCE[0]}\")\" && pwd)\"\n" - printf "export LD_LIBRARY_PATH=\"\${SCRIPT_DIR}:\${LD_LIBRARY_PATH}\"\n" - printf "exec \"\${SCRIPT_DIR}/whisper-server\" \"\$@\"\n" - } > "$PACKAGE_DIR/run-whisper-server.sh" - chmod +x "$PACKAGE_DIR/run-whisper-server.sh" - - # Create README with usage instructions - { - printf "Whisper.cpp CPU Build for Linux\n" - printf "===============================\n\n" - printf "Build Date: %s\n" "$(date -u +"%Y-%m-%d %H:%M:%S UTC")" - printf "Architecture: %s\n" "$(uname -m)" - printf "OS: %s\n" "$(uname -o)" - printf "Kernel: %s\n\n" "$(uname -r)" - printf "Binaries:\n" - ls -lh "$PACKAGE_DIR" | grep -v "^total" | grep -v "^d" | awk '{print " " $9 " (" $5 ")"}' - printf "\n" - printf "Usage:\n" - printf "------\n\n" - printf "Option 1: Use the run script (recommended):\n" - printf " ./run-whisper-server.sh --host 127.0.0.1 -m /path/to/model.bin\n\n" - printf "Option 2: Set LD_LIBRARY_PATH manually:\n" - printf " export LD_LIBRARY_PATH=\$(pwd):\$LD_LIBRARY_PATH\n" - printf " ./whisper-server --host 127.0.0.1 -m /path/to/model.bin\n\n" - printf "System Requirements:\n" - printf "-------------------\n" - printf "This build requires standard Linux system libraries:\n" - printf " - libc (glibc)\n" - printf " - libstdc++\n" - printf " - libpthread\n" - printf " - libm\n" - printf "These are typically pre-installed on most Linux distributions.\n" - } > "$PACKAGE_DIR/README.txt" + # Create README + printf "Whisper.cpp CPU Build for Linux\n" > "$PACKAGE_DIR/README.txt" + printf "===============================\n\n" >> "$PACKAGE_DIR/README.txt" + printf "Build Date: %s\n" "$(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> "$PACKAGE_DIR/README.txt" + printf "Architecture: %s\n" "$(uname -m)" >> "$PACKAGE_DIR/README.txt" + printf "OS: %s\n" "$(uname -o)" >> "$PACKAGE_DIR/README.txt" + printf "Kernel: %s\n\n" "$(uname -r)" >> "$PACKAGE_DIR/README.txt" + printf "Binaries:\n" >> "$PACKAGE_DIR/README.txt" + ls -lh "$PACKAGE_DIR" | grep -v "^total" | grep -v "^d" | awk '{print " " $9 " (" $5 ")"}' >> "$PACKAGE_DIR/README.txt" # Create tarball tar -czf "${PACKAGE_NAME}.tar.gz" "$PACKAGE_DIR" @@ -167,9 +117,6 @@ jobs: PACKAGE_SIZE=$(du -h "${PACKAGE_NAME}.tar.gz" | cut -f1) echo "Package created successfully: ${PACKAGE_NAME}.tar.gz ($PACKAGE_SIZE)" ls -lh "${PACKAGE_NAME}.tar.gz" - echo "" - echo "Package contents:" - tar -tzf "${PACKAGE_NAME}.tar.gz" | head -20 else echo "ERROR: Failed to create package!" exit 1 From 9400cff1657c15ac539145dced4846041317bda8 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Fri, 20 Feb 2026 12:17:33 -0800 Subject: [PATCH 20/25] vulkan build --- .github/workflows/linux-vulkan-build.yml | 179 +++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 .github/workflows/linux-vulkan-build.yml diff --git a/.github/workflows/linux-vulkan-build.yml b/.github/workflows/linux-vulkan-build.yml new file mode 100644 index 00000000..e5a378ce --- /dev/null +++ b/.github/workflows/linux-vulkan-build.yml @@ -0,0 +1,179 @@ +name: Linux Vulkan Build + +on: + push: + branches: + - main + - master + paths: + - '.github/workflows/linux-vulkan-build.yml' + - 'src/**' + - 'ggml/**' + - 'CMakeLists.txt' + - '**.cmake' + pull_request: + branches: + - main + - master + paths: + - '.github/workflows/linux-vulkan-build.yml' + - 'src/**' + - 'ggml/**' + - 'CMakeLists.txt' + - '**.cmake' + workflow_dispatch: + release: + types: [created] + +jobs: + build-vulkan-linux: + # Targets self-hosted STX Halo Linux runners (e.g. sjlab-stx-halo-10/11/12/13) + runs-on: [self-hosted, Linux, X64, stx-halo] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Vulkan and build dependencies + run: | + echo "Installing Vulkan and build dependencies..." + sudo apt-get update + sudo apt-get install -y \ + build-essential \ + cmake \ + git \ + libsdl2-dev \ + pkg-config \ + vulkan-tools \ + libvulkan-dev \ + vulkan-validationlayers \ + spirv-tools \ + mesa-vulkan-drivers \ + glslc + + # Some Ubuntu images may provide glslc through shaderc instead of glslc package. + if ! command -v glslc >/dev/null 2>&1; then + echo "glslc not found after install, trying shaderc..." + sudo apt-get install -y shaderc + fi + + echo "Dependencies installed" + cmake --version + gcc --version + vulkaninfo --summary || true + + - name: Configure CMake (Vulkan) + run: | + echo "Configuring CMake with Vulkan backend..." + cmake -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DGGML_VULKAN=ON \ + -DWHISPER_BUILD_EXAMPLES=ON \ + -DWHISPER_BUILD_TESTS=OFF \ + -DWHISPER_BUILD_SERVER=ON + + if [ $? -ne 0 ]; then + echo "ERROR: CMake configuration failed!" + exit 1 + fi + echo "Configuration complete" + + - name: Build + run: | + echo "Building..." + cmake --build build --config Release -j"$(nproc)" + if [ $? -ne 0 ]; then + echo "ERROR: Build failed!" + exit 1 + fi + echo "Build complete" + + - name: Validate Vulkan artifacts + run: | + echo "Checking Vulkan-related outputs..." + find build -iname "*vulkan*" | sort || true + + VULKAN_FILES=$(find build -type f \( -iname "*vulkan*.so*" -o -iname "*vulkan*" \) | wc -l) + if [ "$VULKAN_FILES" -eq 0 ]; then + echo "ERROR: No Vulkan-related build artifacts found!" + exit 1 + fi + + if [ -f "build/bin/whisper-cli" ]; then + echo "whisper-cli found, printing linked Vulkan libs if present:" + ldd build/bin/whisper-cli | grep -i vulkan || true + fi + + - name: List build output + run: | + echo "Build output contents:" + if [ -d "build/bin" ]; then + find build/bin -type f | sort + else + echo "ERROR: build/bin directory not found!" + exit 1 + fi + + - name: Package binaries + run: | + echo "Creating package..." + + PACKAGE_NAME="whisper-vulkan-linux-$(uname -m)" + PACKAGE_DIR="$PACKAGE_NAME" + mkdir -p "$PACKAGE_DIR" + + # Copy binaries and runtime libraries + if [ -d "build/bin" ]; then + cp -r build/bin/* "$PACKAGE_DIR/" 2>/dev/null || true + fi + find build -name "*.so*" -exec cp {} "$PACKAGE_DIR/" \; 2>/dev/null || true + + printf "Whisper.cpp Vulkan Build for Linux\n" > "$PACKAGE_DIR/README.txt" + printf "===================================\n\n" >> "$PACKAGE_DIR/README.txt" + printf "Build Date: %s\n" "$(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> "$PACKAGE_DIR/README.txt" + printf "Architecture: %s\n" "$(uname -m)" >> "$PACKAGE_DIR/README.txt" + printf "OS: %s\n" "$(uname -o)" >> "$PACKAGE_DIR/README.txt" + printf "Kernel: %s\n" "$(uname -r)" >> "$PACKAGE_DIR/README.txt" + printf "Backend: GGML_VULKAN=ON\n\n" >> "$PACKAGE_DIR/README.txt" + printf "Binaries:\n" >> "$PACKAGE_DIR/README.txt" + ls -lh "$PACKAGE_DIR" | grep -v "^total" | grep -v "^d" | awk '{print " " $9 " (" $5 ")"}' >> "$PACKAGE_DIR/README.txt" + + tar -czf "${PACKAGE_NAME}.tar.gz" "$PACKAGE_DIR" + + if [ -f "${PACKAGE_NAME}.tar.gz" ]; then + PACKAGE_SIZE=$(du -h "${PACKAGE_NAME}.tar.gz" | cut -f1) + echo "Package created successfully: ${PACKAGE_NAME}.tar.gz (${PACKAGE_SIZE})" + ls -lh "${PACKAGE_NAME}.tar.gz" + else + echo "ERROR: Failed to create package!" + exit 1 + fi + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: whisper-vulkan-linux + path: whisper-vulkan-linux-*.tar.gz + retention-days: 30 + + - name: Create Release + if: github.event_name == 'release' + uses: softprops/action-gh-release@v1 + with: + files: whisper-vulkan-linux-*.tar.gz + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Summary + run: | + echo "========================================" + echo "Vulkan build completed successfully!" + echo "========================================" + echo "" + echo "Artifact: whisper-vulkan-linux-*.tar.gz" + echo "Download from: Actions > This workflow run > Artifacts" + if [ "${{ github.event_name }}" == "release" ]; then + echo "Release: Available in GitHub Releases" + fi From 892e56511830e5a9000631e49833d24324121b19 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Fri, 20 Feb 2026 12:23:03 -0800 Subject: [PATCH 21/25] vulkan build --- .github/workflows/linux-vulkan-build.yml | 30 ++++++++++-------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/.github/workflows/linux-vulkan-build.yml b/.github/workflows/linux-vulkan-build.yml index e5a378ce..b0d424f5 100644 --- a/.github/workflows/linux-vulkan-build.yml +++ b/.github/workflows/linux-vulkan-build.yml @@ -34,22 +34,19 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Install Vulkan and build dependencies + - name: Check Vulkan readiness run: | - echo "Installing Vulkan and build dependencies..." - sudo apt-get update - sudo apt-get install -y \ - build-essential \ - cmake \ - git \ - libsdl2-dev \ - pkg-config \ - vulkan-tools \ - libvulkan-dev \ - vulkan-validationlayers \ - spirv-tools \ - mesa-vulkan-drivers \ - glslc + echo "Checking Vulkan readiness..." + if ! command -v vulkaninfo >/dev/null 2>&1; then + echo "ERROR: vulkaninfo is not available on this runner." + exit 1 + fi + + vulkaninfo | grep "GPU id" + if [ $? -ne 0 ]; then + echo "ERROR: Vulkan check failed. 'vulkaninfo | grep \"GPU id\"' returned no result." + exit 1 + fi # Some Ubuntu images may provide glslc through shaderc instead of glslc package. if ! command -v glslc >/dev/null 2>&1; then @@ -57,10 +54,9 @@ jobs: sudo apt-get install -y shaderc fi - echo "Dependencies installed" + echo "Vulkan is ready" cmake --version gcc --version - vulkaninfo --summary || true - name: Configure CMake (Vulkan) run: | From ed27d47583eeb89e8dcc32f5b9b0010c97cc8bd4 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Fri, 20 Feb 2026 12:29:21 -0800 Subject: [PATCH 22/25] vulkan build --- .github/workflows/linux-vulkan-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux-vulkan-build.yml b/.github/workflows/linux-vulkan-build.yml index b0d424f5..05393a0d 100644 --- a/.github/workflows/linux-vulkan-build.yml +++ b/.github/workflows/linux-vulkan-build.yml @@ -27,8 +27,8 @@ on: jobs: build-vulkan-linux: - # Targets self-hosted STX Halo Linux runners (e.g. sjlab-stx-halo-10/11/12/13) - runs-on: [self-hosted, Linux, X64, stx-halo] + # Pinned to one specific self-hosted runner host. + runs-on: [self-hosted, Linux, X64, stx-halo, sjlab-stx-halo-11] steps: - name: Checkout code From 9c30aaf33dba92110880f9090d9108c4fd651319 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Fri, 20 Feb 2026 12:40:25 -0800 Subject: [PATCH 23/25] vulkan build --- .github/workflows/linux-vulkan-build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linux-vulkan-build.yml b/.github/workflows/linux-vulkan-build.yml index 05393a0d..51c85dd0 100644 --- a/.github/workflows/linux-vulkan-build.yml +++ b/.github/workflows/linux-vulkan-build.yml @@ -134,7 +134,8 @@ jobs: printf "Binaries:\n" >> "$PACKAGE_DIR/README.txt" ls -lh "$PACKAGE_DIR" | grep -v "^total" | grep -v "^d" | awk '{print " " $9 " (" $5 ")"}' >> "$PACKAGE_DIR/README.txt" - tar -czf "${PACKAGE_NAME}.tar.gz" "$PACKAGE_DIR" + # Create a flat tarball (files at archive root, no extra top-level directory). + tar -czf "${PACKAGE_NAME}.tar.gz" -C "$PACKAGE_DIR" . if [ -f "${PACKAGE_NAME}.tar.gz" ]; then PACKAGE_SIZE=$(du -h "${PACKAGE_NAME}.tar.gz" | cut -f1) From 616ac9d2f1b2a03084bba7976c5f67dc77c906c4 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Tue, 3 Mar 2026 15:38:11 -0800 Subject: [PATCH 24/25] Revert "Merge pull request #1 from lemonade-sdk/iswarya/npu-support" This reverts commit 63cd7a7b10623cd57f90f15f374d2e54418a860a, reversing changes made to 7aa8818647303b567c3a21fe4220b2681988e220. --- .github/workflows/linux-cpu-build.yml | 152 ---------------- .github/workflows/linux-vulkan-build.yml | 176 ------------------ .github/workflows/ryzen-ai-minimal.yml | 220 ----------------------- CMakeLists.txt | 1 - README.md | 41 ----- src/CMakeLists.txt | 32 ---- src/vitisai/whisper-vitisai-encoder.cpp | 204 --------------------- src/vitisai/whisper-vitisai-encoder.h | 32 ---- src/whisper.cpp | 61 +------ 9 files changed, 1 insertion(+), 918 deletions(-) delete mode 100644 .github/workflows/linux-cpu-build.yml delete mode 100644 .github/workflows/linux-vulkan-build.yml delete mode 100644 .github/workflows/ryzen-ai-minimal.yml delete mode 100644 src/vitisai/whisper-vitisai-encoder.cpp delete mode 100644 src/vitisai/whisper-vitisai-encoder.h diff --git a/.github/workflows/linux-cpu-build.yml b/.github/workflows/linux-cpu-build.yml deleted file mode 100644 index 75bcb8df..00000000 --- a/.github/workflows/linux-cpu-build.yml +++ /dev/null @@ -1,152 +0,0 @@ -name: Linux CPU Build - -on: - push: - branches: - - main - - master - paths: - - 'src/**' - - 'ggml/**' - - 'CMakeLists.txt' - - '**.cmake' - pull_request: - branches: - - main - - master - paths: - - 'src/**' - - 'ggml/**' - - 'CMakeLists.txt' - - '**.cmake' - workflow_dispatch: - release: - types: [created] - -jobs: - build-cpu-linux: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install dependencies - run: | - echo "Installing build dependencies..." - sudo apt-get update - sudo apt-get install -y \ - build-essential \ - cmake \ - git \ - libsdl2-dev \ - pkg-config - echo "Dependencies installed" - cmake --version - gcc --version - - - name: Configure CMake - run: | - echo "Configuring CMake..." - cmake -B build \ - -DCMAKE_BUILD_TYPE=Release \ - -DWHISPER_BUILD_EXAMPLES=ON \ - -DWHISPER_BUILD_TESTS=OFF \ - -DWHISPER_BUILD_SERVER=ON - if [ $? -ne 0 ]; then - echo "ERROR: CMake configuration failed!" - exit 1 - fi - echo "Configuration complete" - - - name: Build - run: | - echo "Building..." - cmake --build build --config Release -j$(nproc) - if [ $? -ne 0 ]; then - echo "ERROR: Build failed!" - exit 1 - fi - echo "Build complete" - - - name: List build output - run: | - echo "Build output contents:" - if [ -d "build/bin" ]; then - find build/bin -type f -executable -o -name "*.so*" | while read file; do - ls -lh "$file" - done - echo "" - echo "All build artifacts:" - find build/bin -type f | sort - else - echo "ERROR: build/bin directory not found!" - exit 1 - fi - - - name: Package binaries - run: | - echo "Creating package..." - - # Create package directory - PACKAGE_NAME="whisper-cpu-linux-$(uname -m)" - PACKAGE_DIR="$PACKAGE_NAME" - mkdir -p "$PACKAGE_DIR" - - # Copy binaries - if [ -d "build/bin" ]; then - cp -r build/bin/* "$PACKAGE_DIR/" 2>/dev/null || true - # Also copy any .so files - find build -name "*.so*" -exec cp {} "$PACKAGE_DIR/" \; 2>/dev/null || true - fi - - # Create README - printf "Whisper.cpp CPU Build for Linux\n" > "$PACKAGE_DIR/README.txt" - printf "===============================\n\n" >> "$PACKAGE_DIR/README.txt" - printf "Build Date: %s\n" "$(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> "$PACKAGE_DIR/README.txt" - printf "Architecture: %s\n" "$(uname -m)" >> "$PACKAGE_DIR/README.txt" - printf "OS: %s\n" "$(uname -o)" >> "$PACKAGE_DIR/README.txt" - printf "Kernel: %s\n\n" "$(uname -r)" >> "$PACKAGE_DIR/README.txt" - printf "Binaries:\n" >> "$PACKAGE_DIR/README.txt" - ls -lh "$PACKAGE_DIR" | grep -v "^total" | grep -v "^d" | awk '{print " " $9 " (" $5 ")"}' >> "$PACKAGE_DIR/README.txt" - - # Create tarball - tar -czf "${PACKAGE_NAME}.tar.gz" "$PACKAGE_DIR" - - if [ -f "${PACKAGE_NAME}.tar.gz" ]; then - PACKAGE_SIZE=$(du -h "${PACKAGE_NAME}.tar.gz" | cut -f1) - echo "Package created successfully: ${PACKAGE_NAME}.tar.gz ($PACKAGE_SIZE)" - ls -lh "${PACKAGE_NAME}.tar.gz" - else - echo "ERROR: Failed to create package!" - exit 1 - fi - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: whisper-cpu-linux - path: whisper-cpu-linux-*.tar.gz - retention-days: 30 - - - name: Create Release - if: github.event_name == 'release' - uses: softprops/action-gh-release@v1 - with: - files: whisper-cpu-linux-*.tar.gz - draft: false - prerelease: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Build Summary - run: | - echo "========================================" - echo "Build completed successfully!" - echo "========================================" - echo "" - echo "Artifact: whisper-cpu-linux-*.tar.gz" - echo "Download from: Actions > This workflow run > Artifacts" - if [ "${{ github.event_name }}" == "release" ]; then - echo "Release: Available in GitHub Releases" - fi diff --git a/.github/workflows/linux-vulkan-build.yml b/.github/workflows/linux-vulkan-build.yml deleted file mode 100644 index 51c85dd0..00000000 --- a/.github/workflows/linux-vulkan-build.yml +++ /dev/null @@ -1,176 +0,0 @@ -name: Linux Vulkan Build - -on: - push: - branches: - - main - - master - paths: - - '.github/workflows/linux-vulkan-build.yml' - - 'src/**' - - 'ggml/**' - - 'CMakeLists.txt' - - '**.cmake' - pull_request: - branches: - - main - - master - paths: - - '.github/workflows/linux-vulkan-build.yml' - - 'src/**' - - 'ggml/**' - - 'CMakeLists.txt' - - '**.cmake' - workflow_dispatch: - release: - types: [created] - -jobs: - build-vulkan-linux: - # Pinned to one specific self-hosted runner host. - runs-on: [self-hosted, Linux, X64, stx-halo, sjlab-stx-halo-11] - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Check Vulkan readiness - run: | - echo "Checking Vulkan readiness..." - if ! command -v vulkaninfo >/dev/null 2>&1; then - echo "ERROR: vulkaninfo is not available on this runner." - exit 1 - fi - - vulkaninfo | grep "GPU id" - if [ $? -ne 0 ]; then - echo "ERROR: Vulkan check failed. 'vulkaninfo | grep \"GPU id\"' returned no result." - exit 1 - fi - - # Some Ubuntu images may provide glslc through shaderc instead of glslc package. - if ! command -v glslc >/dev/null 2>&1; then - echo "glslc not found after install, trying shaderc..." - sudo apt-get install -y shaderc - fi - - echo "Vulkan is ready" - cmake --version - gcc --version - - - name: Configure CMake (Vulkan) - run: | - echo "Configuring CMake with Vulkan backend..." - cmake -B build \ - -DCMAKE_BUILD_TYPE=Release \ - -DGGML_VULKAN=ON \ - -DWHISPER_BUILD_EXAMPLES=ON \ - -DWHISPER_BUILD_TESTS=OFF \ - -DWHISPER_BUILD_SERVER=ON - - if [ $? -ne 0 ]; then - echo "ERROR: CMake configuration failed!" - exit 1 - fi - echo "Configuration complete" - - - name: Build - run: | - echo "Building..." - cmake --build build --config Release -j"$(nproc)" - if [ $? -ne 0 ]; then - echo "ERROR: Build failed!" - exit 1 - fi - echo "Build complete" - - - name: Validate Vulkan artifacts - run: | - echo "Checking Vulkan-related outputs..." - find build -iname "*vulkan*" | sort || true - - VULKAN_FILES=$(find build -type f \( -iname "*vulkan*.so*" -o -iname "*vulkan*" \) | wc -l) - if [ "$VULKAN_FILES" -eq 0 ]; then - echo "ERROR: No Vulkan-related build artifacts found!" - exit 1 - fi - - if [ -f "build/bin/whisper-cli" ]; then - echo "whisper-cli found, printing linked Vulkan libs if present:" - ldd build/bin/whisper-cli | grep -i vulkan || true - fi - - - name: List build output - run: | - echo "Build output contents:" - if [ -d "build/bin" ]; then - find build/bin -type f | sort - else - echo "ERROR: build/bin directory not found!" - exit 1 - fi - - - name: Package binaries - run: | - echo "Creating package..." - - PACKAGE_NAME="whisper-vulkan-linux-$(uname -m)" - PACKAGE_DIR="$PACKAGE_NAME" - mkdir -p "$PACKAGE_DIR" - - # Copy binaries and runtime libraries - if [ -d "build/bin" ]; then - cp -r build/bin/* "$PACKAGE_DIR/" 2>/dev/null || true - fi - find build -name "*.so*" -exec cp {} "$PACKAGE_DIR/" \; 2>/dev/null || true - - printf "Whisper.cpp Vulkan Build for Linux\n" > "$PACKAGE_DIR/README.txt" - printf "===================================\n\n" >> "$PACKAGE_DIR/README.txt" - printf "Build Date: %s\n" "$(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> "$PACKAGE_DIR/README.txt" - printf "Architecture: %s\n" "$(uname -m)" >> "$PACKAGE_DIR/README.txt" - printf "OS: %s\n" "$(uname -o)" >> "$PACKAGE_DIR/README.txt" - printf "Kernel: %s\n" "$(uname -r)" >> "$PACKAGE_DIR/README.txt" - printf "Backend: GGML_VULKAN=ON\n\n" >> "$PACKAGE_DIR/README.txt" - printf "Binaries:\n" >> "$PACKAGE_DIR/README.txt" - ls -lh "$PACKAGE_DIR" | grep -v "^total" | grep -v "^d" | awk '{print " " $9 " (" $5 ")"}' >> "$PACKAGE_DIR/README.txt" - - # Create a flat tarball (files at archive root, no extra top-level directory). - tar -czf "${PACKAGE_NAME}.tar.gz" -C "$PACKAGE_DIR" . - - if [ -f "${PACKAGE_NAME}.tar.gz" ]; then - PACKAGE_SIZE=$(du -h "${PACKAGE_NAME}.tar.gz" | cut -f1) - echo "Package created successfully: ${PACKAGE_NAME}.tar.gz (${PACKAGE_SIZE})" - ls -lh "${PACKAGE_NAME}.tar.gz" - else - echo "ERROR: Failed to create package!" - exit 1 - fi - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: whisper-vulkan-linux - path: whisper-vulkan-linux-*.tar.gz - retention-days: 30 - - - name: Create Release - if: github.event_name == 'release' - uses: softprops/action-gh-release@v1 - with: - files: whisper-vulkan-linux-*.tar.gz - draft: false - prerelease: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Build Summary - run: | - echo "========================================" - echo "Vulkan build completed successfully!" - echo "========================================" - echo "" - echo "Artifact: whisper-vulkan-linux-*.tar.gz" - echo "Download from: Actions > This workflow run > Artifacts" - if [ "${{ github.event_name }}" == "release" ]; then - echo "Release: Available in GitHub Releases" - fi diff --git a/.github/workflows/ryzen-ai-minimal.yml b/.github/workflows/ryzen-ai-minimal.yml deleted file mode 100644 index 7f989c95..00000000 --- a/.github/workflows/ryzen-ai-minimal.yml +++ /dev/null @@ -1,220 +0,0 @@ -name: Ryzen AI Minimal Build - -on: - pull_request: - branches: - - main - - master - paths: - - '.github/workflows/ryzen-ai-minimal.yml' - - 'src/**' - - 'ggml/**' - - 'CMakeLists.txt' - - '**.cmake' - workflow_dispatch: - # inputs: - # runson: - # description: 'Which runner group to run the workflow on' - # default: 'stx' - # required: true - # type: choice - # options: - # - 'rai300_400' - # - 'stx' - # - 'stx-halo' - # - 'stx-test' - -jobs: - build-ryzenai: - runs-on: [rai-170-sdk, Windows] - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v2 - - - name: Install CMake if not available - shell: powershell - run: | - # Check if CMake is already installed - $cmakeInstalled = Get-Command cmake -ErrorAction SilentlyContinue - - if (-not $cmakeInstalled) { - Write-Host "CMake not found, installing..." -ForegroundColor Yellow - - # Download CMake installer - $cmakeVersion = "3.28.1" - $cmakeUrl = "https://github.com/Kitware/CMake/releases/download/v$cmakeVersion/cmake-$cmakeVersion-windows-x86_64.msi" - $cmakeInstaller = "cmake-installer.msi" - - Invoke-WebRequest -Uri $cmakeUrl -OutFile $cmakeInstaller - - # Install CMake silently - Start-Process msiexec.exe -ArgumentList "/i $cmakeInstaller /quiet /norestart" -Wait - - # Add CMake to PATH for this session AND future steps - $cmakePath = "C:\Program Files\CMake\bin" - $env:PATH = "$cmakePath;$env:PATH" - - # Persist to GITHUB_PATH for future steps - echo $cmakePath >> $env:GITHUB_PATH - - # Verify installation - cmake --version - if ($LASTEXITCODE -ne 0) { - Write-Host "ERROR: CMake installation failed!" -ForegroundColor Red - exit 1 - } - - Write-Host "CMake installed successfully and added to PATH!" -ForegroundColor Green - } else { - Write-Host "CMake is already installed:" -ForegroundColor Green - cmake --version - } - - - name: Download FlexML Runtime - shell: powershell - run: | - Write-Host "Downloading FlexML Runtime..." - Invoke-WebRequest -Uri "https://github.com/lemonade-sdk/whisper.cpp/releases/download/deps/flexmlrt1.7.0-win.zip" -OutFile flexmlrt.zip - Write-Host "Download complete" - - # Verify download - if (-Not (Test-Path "flexmlrt.zip")) { - Write-Error "ERROR: flexmlrt.zip was not downloaded!" - exit 1 - } - - $fileSize = (Get-Item "flexmlrt.zip").Length - $fileSizeMB = [math]::Round($fileSize / 1MB, 2) - - if ($fileSize -eq 0) { - Write-Error "ERROR: flexmlrt.zip is empty (0 bytes)!" - exit 1 - } - - Write-Host "Download verified successfully" -ForegroundColor Green - Write-Host "File: flexmlrt.zip" - Write-Host "Size: $fileSizeMB MB" - - - name: Extract FlexML Runtime - shell: powershell - run: | - Write-Host "Extracting FlexML Runtime..." - tar xvf flexmlrt.zip - if ($LASTEXITCODE -ne 0) { - Write-Error "ERROR: Extraction failed!" - exit 1 - } - Write-Host "Extraction complete" - - # List what was extracted - $extractedDirs = Get-ChildItem -Directory | Where-Object { $_.Name -like "flexmlrt*" } - if ($extractedDirs) { - Write-Host "Extracted directories:" -ForegroundColor Green - $extractedDirs | ForEach-Object { Write-Host " - $($_.Name)" } - } else { - Write-Error "ERROR: No flexmlrt directory found after extraction!" - exit 1 - } - - - name: Setup FlexML Runtime, Configure and Build - shell: cmd - run: | - echo "Setting up FlexML environment..." - cd flexmlrt - call setup.bat - if errorlevel 1 ( - echo ERROR: FlexML setup failed! - exit /b 1 - ) - cd .. - echo "Setup complete" - echo. - echo "Configuring CMake..." - cmake -B build -A x64 -DCMAKE_BUILD_TYPE=Release -DWHISPER_VITISAI=ON - if errorlevel 1 ( - echo ERROR: CMake configuration failed! - exit /b 1 - ) - echo. - echo "Building..." - cmake --build build --config Release -j - if errorlevel 1 ( - echo ERROR: Build failed! - exit /b 1 - ) - echo "Build complete" - - - name: List build output - shell: powershell - run: | - Write-Host "Build output contents:" - if (Test-Path "build/bin/Release") { - Get-ChildItem -Path "build/bin/Release" -Recurse | Format-Table Name, Length - } else { - Write-Warning "build/bin/Release directory not found!" - exit 1 - } - - - name: Copy FlexML Runtime DLLs to build output - shell: powershell - run: | - Write-Host "Copying FlexML Runtime DLLs..." - - $dllsCopied = 0 - - if (Test-Path "flexmlrt/bin") { - $binDlls = Get-ChildItem -Path "flexmlrt/bin/*.dll" -ErrorAction SilentlyContinue - if ($binDlls) { - Copy-Item -Path "flexmlrt/bin/*.dll" -Destination "build/bin/Release/" -Force - $dllsCopied += $binDlls.Count - Write-Host "Copied $($binDlls.Count) DLLs from flexmlrt/bin" - } - } - - if (Test-Path "flexmlrt/lib") { - $libDlls = Get-ChildItem -Path "flexmlrt/lib/*.dll" -ErrorAction SilentlyContinue - if ($libDlls) { - Copy-Item -Path "flexmlrt/lib/*.dll" -Destination "build/bin/Release/" -Force - $dllsCopied += $libDlls.Count - Write-Host "Copied $($libDlls.Count) DLLs from flexmlrt/lib" - } - } - - if ($dllsCopied -eq 0) { - Write-Warning "No DLLs found to copy from flexmlrt/bin or flexmlrt/lib" - } else { - Write-Host "Total DLLs copied: $dllsCopied" -ForegroundColor Green - } - - - name: Package binaries - shell: powershell - run: | - Write-Host "Creating ZIP package..." - Compress-Archive -Path "build/bin/Release/*" -DestinationPath "whisper-ryzenai-minimal.zip" -Force - if (Test-Path "whisper-ryzenai-minimal.zip") { - $zipSize = (Get-Item "whisper-ryzenai-minimal.zip").Length / 1MB - Write-Host "Package created successfully: $([math]::Round($zipSize, 2)) MB" - } else { - Write-Error "ERROR: Failed to create package!" - exit 1 - } - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: whisper-ryzenai-minimal - path: whisper-ryzenai-minimal.zip - - - name: Build Summary - shell: powershell - run: | - Write-Host "========================================" -ForegroundColor Green - Write-Host "Build completed successfully!" -ForegroundColor Green - Write-Host "========================================" -ForegroundColor Green - Write-Host "" - Write-Host "Artifact: whisper-ryzenai-minimal.zip" - Write-Host "Download from: Actions > This workflow run > Artifacts" diff --git a/CMakeLists.txt b/CMakeLists.txt index 8525d0e3..06577bf1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,7 +91,6 @@ endif() option(WHISPER_COREML "whisper: enable Core ML framework" OFF) option(WHISPER_COREML_ALLOW_FALLBACK "whisper: allow non-CoreML fallback" OFF) option(WHISPER_OPENVINO "whisper: support for OpenVINO" OFF) -option(WHISPER_VITISAI "whisper: support for AMD Vitis AI" OFF) # Required for relocatable CMake package include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/build-info.cmake) diff --git a/README.md b/README.md index 1e7ff080..6d4988e6 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,6 @@ High-performance inference of [OpenAI's Whisper](https://github.com/openai/whisp - [Vulkan support](#vulkan-gpu-support) - Support for CPU-only inference - [Efficient GPU support for NVIDIA](#nvidia-gpu-support) -- [AMD Ryzen AI NPU Support](#amd-ryzen-ai-support-for-npu) - [OpenVINO Support](#openvino-support) - [Ascend NPU Support](#ascend-npu-support) - [Moore Threads GPU Support](#moore-threads-gpu-support) @@ -313,46 +312,6 @@ This can result in significant speedup in encoder performance. Here are the inst For more information about the OpenVINO implementation please refer to PR [#1037](https://github.com/ggml-org/whisper.cpp/pull/1037). -## AMD Ryzen™ AI support for NPU - -On AMD's Ryzen™ AI 300 Series with dedicated NPUs for acceleration, you can now run Whisper models with the ability to fully offload the encoder to NPU. This brings significant speedup compared to CPU-only. -> **Note:** -> **Ryzen™ AI NPU acceleration is currently supported on Windows only.** Linux support is planned for upcoming releases. -> For the latest updates on Ryzen AI, check out [the official documentation](https://ryzenai.docs.amd.com/en/latest/). - -### Setup environment (Windows only) - -- **Driver:** Make sure you have NPU drivers version **.280 or newer** installed. [Download latest drivers from here](https://account.amd.com/en/forms/downloads/ryzenai-eula-public-xef.html?filename=NPU_RAI1.5_280_WHQL.zip) -- **Runtime libraries:** Download and install the necessary [runtime dependencies from here](https://account.amd.com/en/forms/downloads/ryzenai-eula-public-xef.html?filename=NPU_RAI1.5_280_WHQL.zip). -- **Environment:** Extract the runtime package and set up the environment: - ```powershell - tar xvf flexmlrt1.7rc3.zip - flexmlrt\setup.bat - ``` -Your environment is now ready. - -### Build Whisper.cpp for Ryzen™ AI support - -```bash -cmake -B build -DWHISPER_VITISAI=1 -cmake --build build -j --config Release -``` - -### Download NPU-optimized models - -- All NPU-supported Whisper models and their compiled `.rai` cache files are available in this collection: - https://huggingface.co/collections/amd/ryzen-ai-16-whisper-npu-optimized-onnx-models -- Download the `.rai` file matching your desired model, and place it in your `models/` directory alongside its corresponding `ggml-<...>.bin` file. - -> **Note:** The ".rai" models from Hugging Face are pre-optimized for Ryzen™ AI NPUs, delivering acceleration benefits from the very first run (aside from any initial CPU-side caching overhead). - -Run the examples as usual: - -```bash -./build/bin/whisper-cli -m models/ggml-base.en.bin -f samples/jfk.wav -``` - - ## NVIDIA GPU support With NVIDIA cards the processing of the models is done efficiently on the GPU via cuBLAS and custom CUDA kernels. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6cba1c6e..095a2791 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,10 +48,6 @@ if (WHISPER_OPENVINO) find_package(OpenVINO REQUIRED COMPONENTS Runtime) endif() -if (WHISPER_VITISAI) - find_package(FlexmlRT REQUIRED) -endif() - # # libraries # @@ -105,30 +101,6 @@ if (WHISPER_OPENVINO) set_target_properties(${TARGET} PROPERTIES FOLDER "libs") endif() -if (WHISPER_VITISAI) - set(TARGET whisper.vitisai) - - add_library(${TARGET} OBJECT - vitisai/whisper-vitisai-encoder.h - vitisai/whisper-vitisai-encoder.cpp - ) - - target_include_directories(${TARGET} PUBLIC - . - ) - - set_property(TARGET ${TARGET} PROPERTY POSITION_INDEPENDENT_CODE ON) - set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DWHISPER_USE_VITISAI) - - # Add C++17 standard for MSVC - if (MSVC) - target_compile_options(${TARGET} PRIVATE /std:c++17) - endif() - - target_link_libraries(${TARGET} PRIVATE ggml flexmlrt::flexmlrt) - set_target_properties(${TARGET} PROPERTIES FOLDER "libs") -endif() - # whisper add_library(whisper @@ -165,10 +137,6 @@ if (WHISPER_OPENVINO) target_link_libraries(whisper PRIVATE whisper.openvino) endif() -if (WHISPER_VITISAI) - target_link_libraries(whisper PRIVATE whisper.vitisai) -endif() - if (WHISPER_MKL) target_link_libraries(whisper PRIVATE MKL::MKL) endif() diff --git a/src/vitisai/whisper-vitisai-encoder.cpp b/src/vitisai/whisper-vitisai-encoder.cpp deleted file mode 100644 index a6d20a88..00000000 --- a/src/vitisai/whisper-vitisai-encoder.cpp +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright(C) 2025 Advanced Micro Devices, Inc. All rights reserved. -#include "vitisai/whisper-vitisai-encoder.h" -#include "FlexMLClient.h" -#include "ggml.h" -#include "ggml-backend.h" - -#include -#include -#ifdef _WIN32 - #include -#else - #include - #include - #include -#endif -#include -#include - -struct whisper_vitisai_context { - std::string model_path; - std::shared_ptr runner; - uint8_t * fbs_buffer; - size_t fbs_buffer_size; -}; - -// Function to mmap rai file for Linux and MapViewOfFile for Windows -bool map_rai_file(const char * path, uint8_t ** buffer, size_t * size) { -#ifdef _WIN32 - // Open the file - HANDLE hFile = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (hFile == INVALID_HANDLE_VALUE) { - std::fprintf(stderr, "%s: %d: Failed to open rai file '%s'\n", __func__, __LINE__, path); - return false; - } - - // Get the file size - LARGE_INTEGER fileSize; - if (!GetFileSizeEx(hFile, &fileSize)) { - CloseHandle(hFile); - std::fprintf(stderr, "%s: %d: Failed to get file size for rai file '%s'\n", __func__, __LINE__, path); - return false; - } - - // Create a file mapping object - HANDLE hMapping = CreateFileMappingA(hFile, NULL, PAGE_READONLY, 0, fileSize.QuadPart, NULL); - if (hMapping == NULL) { - CloseHandle(hFile); - std::fprintf(stderr, "%s: %d: Failed to create file mapping for rai file '%s'\n", __func__, __LINE__, path); - return false; - } - - // Map the file - *buffer = (uint8_t *)MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, fileSize.QuadPart); - if (*buffer == NULL) { - CloseHandle(hMapping); - CloseHandle(hFile); - std::fprintf(stderr, "%s: %d: Failed to map rai file '%s'\n", __func__, __LINE__, path); - return false; - } - *size = fileSize.QuadPart; - return true; -#else - // Open the file - FILE * fd = fopen(path, "rb"); - if (!fd) { - std::fprintf(stderr, "%s: %d: Failed to open rai file '%s'\n", __func__, __LINE__, path); - return false; - } - - // Get the file size - struct stat st; - if (fstat(fileno(fd), &st) == -1) { - fclose(fd); - std::fprintf(stderr, "%s: %d: Failed to get file size for rai file '%s'\n", __func__, __LINE__, path); - return false; - } - - // Mmap the file - *buffer = (uint8_t *)mmap(nullptr, st.st_size, PROT_READ, MAP_SHARED, fileno(fd), 0); - if (*buffer == MAP_FAILED) { - fclose(fd); - std::fprintf(stderr, "%s: %d: Failed to mmap rai file '%s'\n", __func__, __LINE__, path); - return false; - } - *size = st.st_size; - return true; -#endif // _WIN32 -} - -void unmap_rai_file(uint8_t * buffer, size_t size) { -#ifdef _WIN32 - UnmapViewOfFile(buffer); -#else - munmap(buffer, size); -#endif // _WIN32 -} - -struct whisper_vitisai_context * whisper_vitisai_init(const char * path_model) { - if (!path_model) { - std::fprintf(stderr, "%s: path_model is null\n", __func__); - return nullptr; - } - - auto * ctx = new whisper_vitisai_context; - ctx->model_path = path_model; - - // Override the model path with the environment variable if it is set - if (const char * env_model_path = std::getenv("OVERRIDE_VITISAI_MODEL_PATH")) { - if (env_model_path[0] != '\0') { - ctx->model_path = env_model_path; - } - } - - // Step 1: Set up the model - flexmlrt::client::Options options; - options.modelPath = ctx->model_path; - options.deviceName = "stx"; - options.debug = false; - options.executeMode = 2; - options.extOptions["ai_analyzer_profiling"] = true; // Enable AIA profiling - options.extOptions["enable_preemption"] = true; - - // Check if model_path is rai file and if so, add fbs_buffer and fbs_buffer_size to the options - if (ctx->model_path.find(".rai") != std::string::npos) { - // mmap rai file for both Linux and Windows and pass the buffer to the options - ctx->fbs_buffer = nullptr; - ctx->fbs_buffer_size = 0; - if (map_rai_file(ctx->model_path.c_str(), &ctx->fbs_buffer, &ctx->fbs_buffer_size)) { - options.extOptions["fbs_buffer"] = ctx->fbs_buffer; - options.extOptions["fbs_buffer_size"] = ctx->fbs_buffer_size; - options.subgraphName = "vaiml_par_0"; - options.extOptions["cache_dir"] = std::string("."); - } else { - std::fprintf(stderr, "%s: Failed to mmap rai file '%s'\n", __func__, ctx->model_path.c_str()); - delete ctx; - return nullptr; - } - } - - try { - ctx->runner = std::make_shared(options); - - if (!ctx->runner->good()) { - throw std::runtime_error("Runner creation ran into an error"); - } - } catch (const std::exception & e) { - std::fprintf(stderr, "%s: Exception during Vitis AI runner creation: %s\n", __func__, e.what()); - delete ctx; - return nullptr; - } - return ctx; -} - -void whisper_vitisai_free(struct whisper_vitisai_context * ctx) { - if (!ctx) { - return; - } - - std::fprintf(stderr, "%s: releasing Vitis AI encoder context for model '%s'\n", __func__, ctx->model_path.c_str()); - if (ctx->fbs_buffer) { - unmap_rai_file(ctx->fbs_buffer, ctx->fbs_buffer_size); - } - delete ctx; -} - -int whisper_vitisai_encode(struct whisper_vitisai_context * ctx, struct ggml_tensor * mel, struct ggml_tensor * out) { - if (!ctx || !mel || !out) { - std::fprintf(stderr, "%s: ctx/mel/out must not be null\n", __func__); - return 0; - } - - if (ggml_n_dims(mel) != 2) { - std::fprintf(stderr, "%s: mel tensor expected to have 2 dims, got %d\n", __func__, ggml_n_dims(mel)); - return 0; - } - - if (ggml_n_dims(out) != 2) { - std::fprintf(stderr, "%s: out tensor expected to have 2 dims, got %d\n", __func__, ggml_n_dims(out)); - return 0; - } - - // setup input and output tensors for Vitis AI model - std::vector input_tensors, output_tensors; - auto model = ctx->runner; - - // Get tensors as CPU tensors (hwTensor = false) - input_tensors = model->getIOTensors("input", false); - output_tensors = model->getIOTensors("output", false); - - // TODO: add assert checks for tensor numbers and shapes - - input_tensors[0].data = mel->data; - output_tensors[0].data = out->data; - - try { - model->forward(input_tensors, output_tensors); - std::fprintf(stdout, "%s: Vitis AI model inference completed.\n", __func__); - } catch (const std::exception & e) { - std::fprintf(stderr, "%s: Exception during model inference: %s\n", __func__, e.what()); - return 0; - } - - return 1; -} diff --git a/src/vitisai/whisper-vitisai-encoder.h b/src/vitisai/whisper-vitisai-encoder.h deleted file mode 100644 index 05dc812b..00000000 --- a/src/vitisai/whisper-vitisai-encoder.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright(C) 2025 Advanced Micro Devices, Inc. All rights reserved. - -#pragma once - -#include -#include -#include - -#if __cplusplus -extern "C" { -#endif - -struct whisper_vitisai_context; - -struct whisper_vitisai_context * whisper_vitisai_init(const char * path_model); -void whisper_vitisai_free(struct whisper_vitisai_context * ctx); - -// Function to mmap rai file for Linux and MapViewOfFile for Windows -bool map_rai_file(const char * path, uint8_t ** buffer, size_t * size); -// Function to unmap rai file for Linux and UnmapViewOfFile for Windows -void unmap_rai_file(uint8_t * buffer, size_t size); - -struct ggml_tensor; - -int whisper_vitisai_encode( - struct whisper_vitisai_context * ctx, - struct ggml_tensor * mel, - struct ggml_tensor * out); - -#if __cplusplus -} -#endif diff --git a/src/whisper.cpp b/src/whisper.cpp index aa8be2b2..796bccfb 100644 --- a/src/whisper.cpp +++ b/src/whisper.cpp @@ -14,10 +14,6 @@ #include "openvino/whisper-openvino-encoder.h" #endif -#ifdef WHISPER_USE_VITISAI -#include "vitisai/whisper-vitisai-encoder.h" -#endif - #include #include #include @@ -907,10 +903,6 @@ struct whisper_state { whisper_openvino_context * ctx_openvino = nullptr; #endif -#ifdef WHISPER_USE_VITISAI - whisper_vitisai_context * ctx_vitisai = nullptr; -#endif - // [EXPERIMENTAL] token-level timestamps data int64_t t_beg = 0; int64_t t_last = 0; @@ -1978,13 +1970,7 @@ static bool whisper_encode_external(const whisper_state & wstate) { const bool use_openvino = wstate.ctx_openvino != nullptr; #endif -#ifndef WHISPER_USE_VITISAI - const bool use_vitisai = false; -#else - const bool use_vitisai = wstate.ctx_vitisai != nullptr; -#endif - - return use_coreml || use_openvino || use_vitisai; + return use_coreml || use_openvino; } static struct ggml_cgraph * whisper_build_graph_conv( @@ -2425,8 +2411,6 @@ static bool whisper_encode_internal( #if defined(WHISPER_USE_COREML) whisper_coreml_encode(wstate.ctx_coreml, mel->ne[0], mel->ne[1], (float *) mel->data, (float *) wstate.embd_enc->data); -#elif defined(WHISPER_USE_VITISAI) - whisper_vitisai_encode(wstate.ctx_vitisai, mel, wstate.embd_enc); #elif defined(WHISPER_USE_OPENVINO) whisper_openvino_encode(wstate.ctx_openvino, mel, wstate.embd_enc); #endif @@ -3362,20 +3346,6 @@ static std::string whisper_get_coreml_path_encoder(std::string path_bin) { } #endif -#ifdef WHISPER_USE_VITISAI -// replace extension with Vitis AI encoder artifact -static std::string whisper_get_vitisai_path_encoder_cache(std::string path_bin) { - auto pos = path_bin.rfind('.'); - if (pos != std::string::npos) { - path_bin = path_bin.substr(0, pos); - } - - path_bin += "-encoder-vitisai.rai"; - - return path_bin; -} -#endif - #ifdef WHISPER_USE_OPENVINO // replace .bin with-encoder-openvino.xml static std::string whisper_openvino_get_path_encoder(std::string path_bin) { @@ -3485,19 +3455,6 @@ struct whisper_state * whisper_init_state(whisper_context * ctx) { } #endif -#ifdef WHISPER_USE_VITISAI - const auto path_vitisai = whisper_get_vitisai_path_encoder_cache(ctx->path_model); - - state->ctx_vitisai = whisper_vitisai_init(path_vitisai.c_str()); - if (!state->ctx_vitisai) { - WHISPER_LOG_ERROR("%s: failed to load Vitis AI model from '%s'\n", __func__, path_vitisai.c_str()); - whisper_free_state(state); - return nullptr; - } else { - WHISPER_LOG_INFO("%s: Vitis AI model loaded\n", __func__); - } -#endif - state->logits.reserve(ctx->vocab.n_vocab * ctx->model.hparams.n_text_ctx); state->batch = whisper_batch_init(ctx->model.hparams.n_text_ctx, WHISPER_MAX_DECODERS); @@ -3864,13 +3821,6 @@ void whisper_free_state(struct whisper_state * state) { } #endif -#ifdef WHISPER_USE_VITISAI - if (state->ctx_vitisai != nullptr) { - whisper_vitisai_free(state->ctx_vitisai); - state->ctx_vitisai = nullptr; - } -#endif - whisper_batch_free(state->batch); ggml_backend_sched_free(state->sched_conv.sched); @@ -4362,20 +4312,11 @@ static int whisper_has_openvino(void) { #endif } -static int whisper_has_vitisai(void) { -#ifdef WHISPER_USE_VITISAI - return 1; -#else - return 0; -#endif -} - const char * whisper_print_system_info(void) { static std::string s; s = ""; s += "WHISPER : "; - s += "VITISAI = " + std::to_string(whisper_has_vitisai()) + " | "; s += "COREML = " + std::to_string(whisper_has_coreml()) + " | "; s += "OPENVINO = " + std::to_string(whisper_has_openvino()) + " | "; From 97db30618aae1f9a7f6b77104e4290bdb12868f0 Mon Sep 17 00:00:00 2001 From: Iswarya Alex Date: Wed, 4 Mar 2026 15:40:30 -0800 Subject: [PATCH 25/25] Workflows for VULKAN on windows and Linux --- .github/workflows/build.yml | 241 ++++++++++++++++++++++++++++++------ ci/README.md | 5 +- ci/run.sh | 8 +- 3 files changed, 216 insertions(+), 38 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8ce887fd..df0cc8cc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -116,8 +116,8 @@ jobs: ubuntu-22: - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || - github.event.inputs.run_type == 'full-ci' }} + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: ubuntu-22.04 strategy: @@ -148,8 +148,8 @@ jobs: cmake --build build --config Release -j $(nproc)' ubuntu-22-arm64: - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || - github.event.inputs.run_type == 'full-ci' }} + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: ubuntu-22.04 strategy: @@ -180,8 +180,8 @@ jobs: cmake --build build --config Release -j $(nproc)' ubuntu-22-arm-v7: - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || - github.event.inputs.run_type == 'full-ci' }} + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: ubuntu-22.04 strategy: @@ -212,8 +212,8 @@ jobs: cmake --build build --config Release -j $(nproc)' macOS-latest: - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || - github.event.inputs.run_type == 'full-ci' }} + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: macOS-latest strategy: @@ -269,8 +269,8 @@ jobs: # cmake --build build --config Release ubuntu-22-gcc: - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || - github.event.inputs.run_type == 'full-ci' }} + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: ubuntu-22.04 strategy: @@ -303,8 +303,8 @@ jobs: ctest -L gh --output-on-failure' ubuntu-22-gcc-arm64: - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || - github.event.inputs.run_type == 'full-ci' }} + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: ubuntu-22.04 strategy: @@ -337,8 +337,8 @@ jobs: ctest -L gh --output-on-failure' ubuntu-22-gcc-arm-v7: - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || - github.event.inputs.run_type == 'full-ci' }} + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: ubuntu-22.04 strategy: @@ -371,8 +371,8 @@ jobs: ctest -L gh --output-on-failure' ubuntu-22-clang: - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || - github.event.inputs.run_type == 'full-ci' }} + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: ubuntu-22.04 strategy: @@ -408,8 +408,8 @@ jobs: ctest -L gh --output-on-failure' ubuntu-22-gcc-sanitized: - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || - github.event.inputs.run_type == 'full-ci' }} + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: ubuntu-22.04 strategy: @@ -443,9 +443,110 @@ jobs: make ctest -L gh --output-on-failure' - ubuntu-22-cmake-sycl: + linux-x64-cpu: if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || github.event.inputs.run_type == 'full-ci' }} + runs-on: ubuntu-latest + needs: determine-tag + + strategy: + matrix: + build: [Release] + + steps: + - name: Clone + uses: actions/checkout@v6 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake git libsdl2-dev pkg-config + + - name: Configure CMake + run: | + cmake -B build \ + -DCMAKE_BUILD_TYPE=${{ matrix.build }} \ + -DWHISPER_BUILD_EXAMPLES=ON \ + -DWHISPER_BUILD_TESTS=OFF \ + -DWHISPER_BUILD_SERVER=ON + + - name: Build + run: cmake --build build --config ${{ matrix.build }} -j$(nproc) + + - name: Package binaries + run: | + PACKAGE_NAME="whisper-bin-linux-x64-cpu" + mkdir -p "$PACKAGE_NAME" + cp -r build/bin/* "$PACKAGE_NAME/" 2>/dev/null || true + find build -name "*.so*" -exec cp {} "$PACKAGE_NAME/" \; 2>/dev/null || true + zip -r "${PACKAGE_NAME}.zip" "$PACKAGE_NAME" + + - name: Upload binaries + if: ${{ needs.determine-tag.outputs.should_release }} + uses: actions/upload-artifact@v6 + with: + name: whisper-bin-linux-x64-cpu.zip + path: whisper-bin-linux-x64-cpu.zip + + linux-x64-vulkan: + if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci' }} + runs-on: ubuntu-latest + needs: determine-tag + + strategy: + matrix: + build: [Release] + + steps: + - name: Clone + uses: actions/checkout@v6 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake git libsdl2-dev pkg-config \ + libvulkan-dev vulkan-tools + sudo apt-get install -y glslc || sudo apt-get install -y shaderc + + - name: Configure CMake (Vulkan) + run: | + cmake -B build \ + -DCMAKE_BUILD_TYPE=${{ matrix.build }} \ + -DGGML_VULKAN=ON \ + -DWHISPER_BUILD_EXAMPLES=ON \ + -DWHISPER_BUILD_TESTS=OFF \ + -DWHISPER_BUILD_SERVER=ON + + - name: Build + run: cmake --build build --config ${{ matrix.build }} -j$(nproc) + + - name: Validate Vulkan artifacts + run: | + find build -iname "*vulkan*" | sort || true + VULKAN_FILES=$(find build -type f \( -iname "*vulkan*.so*" -o -iname "*vulkan*" \) 2>/dev/null | wc -l) + if [ "$VULKAN_FILES" -eq 0 ]; then + echo "WARNING: No Vulkan-related build artifacts found" + fi + + - name: Package binaries + run: | + PACKAGE_NAME="whisper-bin-linux-x64-vulkan" + mkdir -p "$PACKAGE_NAME" + cp -r build/bin/* "$PACKAGE_NAME/" 2>/dev/null || true + find build -name "*.so*" -exec cp {} "$PACKAGE_NAME/" \; 2>/dev/null || true + zip -r "${PACKAGE_NAME}.zip" "$PACKAGE_NAME" + + - name: Upload binaries + if: ${{ needs.determine-tag.outputs.should_release }} + uses: actions/upload-artifact@v6 + with: + name: whisper-bin-linux-x64-vulkan.zip + path: whisper-bin-linux-x64-vulkan.zip + + ubuntu-22-cmake-sycl: + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: ubuntu-22.04 strategy: @@ -496,8 +597,8 @@ jobs: cmake --build . --config Release -j $(nproc) ubuntu-22-cmake-sycl-fp16: - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || - github.event.inputs.run_type == 'full-ci' }} + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: ubuntu-22.04 strategy: @@ -548,8 +649,8 @@ jobs: cmake --build . --config Release -j $(nproc) windows-msys2: - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || - github.event.inputs.run_type == 'full-ci' }} + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: windows-latest strategy: @@ -594,8 +695,8 @@ jobs: cmake --build build --config ${{ matrix.build }} -j $(nproc) windows: - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || - github.event.inputs.run_type == 'full-ci' }} + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: windows-latest needs: determine-tag @@ -688,8 +789,8 @@ jobs: path: whisper-bin-${{ matrix.arch }}.zip windows-blas: - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || - github.event.inputs.run_type == 'full-ci' }} + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: windows-latest strategy: @@ -774,8 +875,8 @@ jobs: path: whisper-blas-bin-${{ matrix.arch }}.zip windows-cublas: - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || - github.event.inputs.run_type == 'full-ci' }} + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: windows-2022 needs: determine-tag strategy: @@ -982,9 +1083,74 @@ jobs: name: whisper-cublas-${{ matrix.cuda-toolkit }}-bin-${{ matrix.arch }}.zip path: whisper-cublas-${{ matrix.cuda-toolkit }}-bin-${{ matrix.arch }}.zip - emscripten: + windows-vulkan: if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || github.event.inputs.run_type == 'full-ci' }} + runs-on: windows-latest + needs: determine-tag + + strategy: + matrix: + build: [Release] + arch: [x64] + + steps: + - name: Clone + uses: actions/checkout@v6 + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v2 + + - name: Install Vulkan SDK + shell: pwsh + run: | + winget install --id KhronosGroup.VulkanSDK -e --silent --accept-package-agreements --accept-source-agreements + $sdkDir = Get-ChildItem "C:\VulkanSDK" -ErrorAction SilentlyContinue | Select-Object -First 1 + if (-not $sdkDir) { throw "Vulkan SDK not found under C:\VulkanSDK after install" } + "VULKAN_SDK=$($sdkDir.FullName)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Host "VULKAN_SDK=$($sdkDir.FullName)" + + - name: Fetch SDL2 and set SDL2_DIR + run: | + C:/msys64/usr/bin/wget.exe -qO sdl2.zip https://github.com/libsdl-org/SDL/releases/download/release-2.28.5/SDL2-devel-2.28.5-VC.zip + 7z x sdl2.zip + echo "SDL2_DIR=$env:GITHUB_WORKSPACE/SDL2-2.28.5/cmake" >> $env:GITHUB_ENV + + - name: Configure + shell: pwsh + run: | + $vulkan = $env:VULKAN_SDK + if (-not $vulkan) { $vulkan = (Get-ChildItem "C:\VulkanSDK" -ErrorAction SilentlyContinue | Select-Object -First 1).FullName } + cmake -S . -B ./build -A ${{ matrix.arch }} ` + -DCMAKE_BUILD_TYPE=${{ matrix.build }} ` + -DBUILD_SHARED_LIBS=ON ` + -DGGML_VULKAN=ON ` + -DWHISPER_SDL2=ON ` + -DVULKAN_SDK="$vulkan" + + - name: Build + run: | + cd ./build + msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }} + + - name: Copy SDL2.dll + run: copy "$env:SDL2_DIR/../lib/${{ matrix.arch }}/SDL2.dll" build/bin/${{ matrix.build }} + + - name: Pack bin artifacts + shell: pwsh + run: | + Compress-Archive -Path "build/bin/${{ matrix.build }}" -DestinationPath "whisper-bin-x64-vulkan.zip" + + - name: Upload binaries + if: ${{ needs.determine-tag.outputs.should_release }} + uses: actions/upload-artifact@v6 + with: + name: whisper-bin-x64-vulkan.zip + path: whisper-bin-x64-vulkan.zip + + emscripten: + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: ubuntu-22.04 strategy: @@ -1064,8 +1230,8 @@ jobs: name: whisper-${{ needs.determine-tag.outputs.tag_name }}-xcframework.zip android: - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || - github.event.inputs.run_type == 'full-ci' }} + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request' || + github.event.inputs.run_type == 'full-ci') }} runs-on: ubuntu-22.04 steps: @@ -1235,7 +1401,7 @@ jobs: ./build/bin/whisper-quantize models/ggml-tiny.en.bin models/ggml-tiny.en-q4_0.bin q4_0 release: - if: ${{ github.event.inputs.create_release == 'true' || github.event.inputs.pre_release_tag != '' || startsWith(github.ref, 'refs/tags/v') }} + if: ${{ (github.event.inputs.create_release == 'true' || github.event.inputs.pre_release_tag != '' || startsWith(github.ref, 'refs/tags/v')) }} runs-on: ubuntu-latest @@ -1245,6 +1411,9 @@ jobs: - windows - windows-blas - windows-cublas + - linux-x64-cpu + - linux-x64-vulkan + - windows-vulkan steps: - name: Clone @@ -1303,10 +1472,10 @@ jobs: } coreml-base-en: - if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') || + if: ${{ ((github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event.inputs.create_release == 'true' || github.event.inputs.pre_release_tag != '' || - startsWith(github.ref, 'refs/tags/v') }} + startsWith(github.ref, 'refs/tags/v')) }} runs-on: macos-latest needs: determine-tag @@ -1557,4 +1726,4 @@ jobs: id: ggml-ci run: | vulkaninfo --summary - GG_BUILD_VULKAN=1 bash ./ci/run.sh ~/results/whisper.cpp ~/mnt/whisper.cpp + GG_BUILD_VULKAN=1 bash ./ci/run.sh ~/results/whisper.cpp ~/mnt/whisper.cpp \ No newline at end of file diff --git a/ci/README.md b/ci/README.md index 63df4aa1..10deaea3 100644 --- a/ci/README.md +++ b/ci/README.md @@ -20,6 +20,9 @@ mkdir tmp # CPU-only build bash ./ci/run.sh ./tmp/results ./tmp/mnt +# with Vulkan +GG_BUILD_VULKAN=1 bash ./ci/run.sh ./tmp/results ./tmp/mnt + # with CUDA support GG_BUILD_CUDA=1 bash ./ci/run.sh ./tmp/results ./tmp/mnt ``` @@ -38,4 +41,4 @@ The CI script supports several environment variables to control the build: | `GG_BUILD_OPENVINO` | Enable OpenVINO support | | `GG_BUILD_COREML` | Enable Core ML support for Apple Neural Engine | | `GG_BUILD_LOW_PERF` | Limit tests for low-performance hardware | -| `GG_BUILD_TEST_MODELS` | Comma-separated list of models to test (e.g. "tiny.en,tiny,base,medium", defaults to all models unless `GG_BUILD_LOW_PERF` is set) | +| `GG_BUILD_TEST_MODELS` | Comma-separated list of models to test (e.g. "tiny.en,tiny,base,medium", defaults to all models unless `GG_BUILD_LOW_PERF` is set) | \ No newline at end of file diff --git a/ci/run.sh b/ci/run.sh index cbe28442..ed013145 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -7,6 +7,9 @@ # # CPU-only build # bash ./ci/run.sh ./tmp/results ./tmp/mnt # +# # with Vulkan support +# GG_BUILD_VULKAN=1 bash ./ci/run.sh ./tmp/results ./tmp/mnt +# # # with CUDA support # GG_BUILD_CUDA=1 bash ./ci/run.sh ./tmp/results ./tmp/mnt # @@ -312,6 +315,9 @@ function gg_run_bench { if [[ $system_info == *"METAL = 1"* ]]; then config="$config METAL" fi + if [[ $system_info == *"VULKAN = 1"* ]]; then + config="$config VULKAN" + fi # get commit hash commit=$(git rev-parse --short HEAD) @@ -376,4 +382,4 @@ test $ret -eq 0 && gg_run bench cat $OUT/README.md -exit $ret +exit $ret \ No newline at end of file