build.yml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. name: CI
  2. on:
  3. push:
  4. branches: [main, master]
  5. paths:
  6. - '**/*.cpp'
  7. - '**/*.h'
  8. - '**/*.hpp'
  9. - '**/CMakeLists.txt'
  10. - '.github/workflows/**'
  11. pull_request:
  12. types: [opened, synchronize, reopened]
  13. workflow_dispatch:
  14. concurrency:
  15. group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
  16. cancel-in-progress: true
  17. env:
  18. # HuggingFace model info (Mel-Band)
  19. HF_MB_REPO: GaboxR67/MelBandRoformers
  20. HF_MB_CHECKPOINT: melbandroformers/vocals/voc_fv6.ckpt
  21. HF_MB_CONFIG: melbandroformers/vocals/voc_gabox.yaml
  22. # BS Roformer model info
  23. HF_BS_REPO: anvuew/BS-RoFormer
  24. HF_BS_CHECKPOINT: bs_roformer_anvuew_sdr_12.45.ckpt
  25. HF_BS_CONFIG: config.yaml
  26. # Music-Source-Separation-Training repo
  27. MSST_REPO: https://github.com/ZFTurbo/Music-Source-Separation-Training.git
  28. # Enable sccache GitHub Actions cache
  29. SCCACHE_GHA_ENABLED: "true"
  30. jobs:
  31. # ===========================================================================
  32. # Prepare: Generate test data (runs once, shared via artifacts)
  33. # ===========================================================================
  34. prepare-test-data:
  35. runs-on: ubuntu-latest
  36. steps:
  37. - name: Checkout
  38. uses: actions/checkout@v4
  39. - name: Setup Python
  40. uses: actions/setup-python@v5
  41. with:
  42. python-version: '3.11'
  43. - name: Clone MSST Repository
  44. run: git clone --depth 1 ${{ env.MSST_REPO }} msst
  45. - name: Install Dependencies
  46. run: |
  47. pip install torch torchaudio --index-url https://download.pytorch.org/whl/cpu
  48. pip install huggingface_hub scipy soundfile gguf librosa ml_collections einops pyyaml numpy tqdm beartype rotary_embedding_torch
  49. - name: Download Model from HuggingFace
  50. env:
  51. HF_TOKEN: ${{ secrets.HF_TOKEN }}
  52. run: |
  53. python -c "
  54. from huggingface_hub import hf_hub_download
  55. import os
  56. token = os.environ.get('HF_TOKEN') or None
  57. # Download Mel-Band Roformer
  58. hf_hub_download('${{ env.HF_MB_REPO }}', '${{ env.HF_MB_CHECKPOINT }}',
  59. local_dir='./model', token=token)
  60. hf_hub_download('${{ env.HF_MB_REPO }}', '${{ env.HF_MB_CONFIG }}',
  61. local_dir='./model', token=token)
  62. # Download BS Roformer
  63. hf_hub_download('${{ env.HF_BS_REPO }}', '${{ env.HF_BS_CHECKPOINT }}',
  64. local_dir='./model_bs', token=token)
  65. hf_hub_download('${{ env.HF_BS_REPO }}', '${{ env.HF_BS_CONFIG }}',
  66. local_dir='./model_bs', token=token)
  67. "
  68. - name: Generate Test Audio
  69. run: |
  70. python scripts/generate_test_audio.py --output test_audio.wav --duration 5.0 --sample-rate 44100
  71. - name: Generate Test Data
  72. run: |
  73. python scripts/generate_test_data.py \
  74. --model-repo msst \
  75. --audio test_audio.wav \
  76. --checkpoint model/${{ env.HF_MB_CHECKPOINT }} \
  77. --config model/${{ env.HF_MB_CONFIG }} \
  78. --output test_data
  79. - name: Convert Model to GGUF (Mel-Band)
  80. run: |
  81. python scripts/convert_to_gguf.py \
  82. --ckpt model/${{ env.HF_MB_CHECKPOINT }} \
  83. --config model/${{ env.HF_MB_CONFIG }} \
  84. --out model.gguf \
  85. --dtype fp32
  86. # ----- BS Roformer Setup -----
  87. - name: Generate Test Data (BS)
  88. run: |
  89. # Need to make sure msst is in python path
  90. export PYTHONPATH=$PYTHONPATH:$(pwd)/msst
  91. # Use real BS model
  92. python scripts/generate_test_data.py \
  93. --model-repo msst \
  94. --audio test_audio.wav \
  95. --checkpoint model_bs/${{ env.HF_BS_CHECKPOINT }} \
  96. --config model_bs/${{ env.HF_BS_CONFIG }} \
  97. --output test_data_bs
  98. - name: Convert Model to GGUF (BS)
  99. run: |
  100. python scripts/convert_to_gguf.py \
  101. --ckpt model_bs/${{ env.HF_BS_CHECKPOINT }} \
  102. --config model_bs/${{ env.HF_BS_CONFIG }} \
  103. --out model_bs.gguf \
  104. --dtype fp32 \
  105. --arch bs
  106. - name: Upload Test Data Artifact
  107. uses: actions/upload-artifact@v4
  108. with:
  109. name: test-data
  110. path: |
  111. test_data/
  112. model.gguf
  113. test_audio.wav
  114. test_data_bs/
  115. model_bs.gguf
  116. retention-days: 1
  117. # ===========================================================================
  118. # Build Matrix: Core Platforms + Vulkan
  119. # ===========================================================================
  120. build:
  121. needs: prepare-test-data
  122. strategy:
  123. fail-fast: false
  124. matrix:
  125. include:
  126. # Tier 1: Core Platforms (CPU)
  127. - { name: linux-x64-cpu, os: ubuntu-22.04, backend: cpu, test: true }
  128. - { name: linux-arm64-cpu, os: ubuntu-22.04-arm, backend: cpu, test: true }
  129. - { name: macos-arm64, os: macos-latest, backend: cpu, test: true }
  130. - { name: macos-x64, os: macos-15-intel, backend: cpu, test: true }
  131. - { name: windows-x64-msvc, os: windows-2025, backend: cpu, test: true }
  132. # Tier 2: Vulkan Backend
  133. - { name: linux-vulkan, os: ubuntu-24.04, backend: vulkan, test: true }
  134. - { name: windows-vulkan, os: windows-2025, backend: vulkan, test: true }
  135. runs-on: ${{ matrix.os }}
  136. steps:
  137. - name: Checkout
  138. uses: actions/checkout@v4
  139. - name: Clone GGML
  140. run: git clone --depth 1 https://github.com/ggerganov/ggml.git ggml
  141. - name: Download Test Data
  142. uses: actions/download-artifact@v4
  143. with:
  144. name: test-data
  145. - name: Setup Python
  146. uses: actions/setup-python@v5
  147. with:
  148. python-version: '3.11'
  149. - name: Setup MSVC
  150. if: runner.os == 'Windows'
  151. uses: ilammy/msvc-dev-cmd@v1
  152. - name: Install Python Dependencies
  153. run: pip install numpy scipy
  154. - name: Setup sccache
  155. uses: mozilla-actions/sccache-action@v0.0.9
  156. with:
  157. version: "v0.12.0"
  158. # ----- Linux Dependencies -----
  159. - name: Install Dependencies (Linux)
  160. if: runner.os == 'Linux'
  161. run: |
  162. sudo apt-get update
  163. sudo apt-get install -y build-essential cmake
  164. - name: Install Vulkan SDK (Linux)
  165. if: matrix.backend == 'vulkan' && runner.os == 'Linux'
  166. run: |
  167. sudo apt-get install -y libvulkan-dev glslc mesa-vulkan-drivers
  168. # ----- macOS Dependencies -----
  169. - name: Install Dependencies (macOS)
  170. if: runner.os == 'macOS'
  171. run: brew install cmake
  172. # ----- Windows Dependencies -----
  173. - name: Install Dependencies (Windows)
  174. if: runner.os == 'Windows'
  175. run: choco install ninja -y
  176. - name: Install Vulkan SDK (Windows)
  177. if: matrix.backend == 'vulkan' && runner.os == 'Windows'
  178. run: |
  179. $VK_VERSION = "1.4.313.2"
  180. curl.exe -o VulkanSDK.exe -L "https://sdk.lunarg.com/sdk/download/${VK_VERSION}/windows/vulkansdk-windows-X64-${VK_VERSION}.exe"
  181. Start-Process -FilePath .\VulkanSDK.exe -ArgumentList "--accept-licenses --default-answer --confirm-command install" -Wait
  182. Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${VK_VERSION}"
  183. Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${VK_VERSION}\bin"
  184. # ----- Configure -----
  185. - name: Configure (Unix)
  186. if: runner.os != 'Windows'
  187. run: |
  188. cmake -B build \
  189. -DCMAKE_BUILD_TYPE=Release \
  190. -DGGML_DIR=ggml \
  191. -DGGML_CUDA=OFF \
  192. -DGGML_VULKAN=${{ matrix.backend == 'vulkan' && 'ON' || 'OFF' }} \
  193. -DCMAKE_C_COMPILER_LAUNCHER=sccache \
  194. -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
  195. -DMBR_BUILD_TESTS=ON \
  196. -DMBR_BUILD_CLI=ON
  197. - name: Configure (Windows)
  198. if: runner.os == 'Windows'
  199. run: |
  200. cmake -B build -G "Ninja Multi-Config" `
  201. -DGGML_DIR=ggml `
  202. -DGGML_CUDA=OFF `
  203. -DGGML_VULKAN=${{ matrix.backend == 'vulkan' && 'ON' || 'OFF' }} `
  204. -DCMAKE_C_COMPILER_LAUNCHER=sccache `
  205. -DCMAKE_CXX_COMPILER_LAUNCHER=sccache `
  206. -DMBR_BUILD_TESTS=ON `
  207. -DMBR_BUILD_CLI=ON
  208. # ----- Build -----
  209. - name: Build (Unix)
  210. if: runner.os != 'Windows'
  211. run: cmake --build build --config Release -j $(nproc 2>/dev/null || sysctl -n hw.logicalcpu)
  212. - name: Build (Windows)
  213. if: runner.os == 'Windows'
  214. run: cmake --build build --config Release -j $env:NUMBER_OF_PROCESSORS
  215. # ----- Unit Tests -----
  216. - name: Run Unit Tests
  217. if: matrix.test
  218. env:
  219. MBR_MODEL_PATH: ${{ github.workspace }}/model.gguf
  220. MBR_TEST_DATA_DIR: ${{ github.workspace }}/test_data
  221. MBR_FORCE_CPU: ${{ runner.os == 'macOS' && '1' || '' }}
  222. run: ctest --test-dir build -C Release -V --output-on-failure --timeout 300
  223. - name: Run Unit Tests (BS Roformer)
  224. if: matrix.test
  225. env:
  226. MBR_MODEL_PATH: ${{ github.workspace }}/model_bs.gguf
  227. MBR_TEST_DATA_DIR: ${{ github.workspace }}/test_data_bs
  228. MBR_ARCHITECTURE: bs
  229. MBR_FORCE_CPU: ${{ runner.os == 'macOS' && '1' || '' }}
  230. run: ctest --test-dir build -C Release -V --output-on-failure --timeout 300
  231. # ----- CLI Tests -----
  232. - name: Test CLI
  233. if: matrix.test
  234. shell: bash
  235. env:
  236. MBR_MODEL_PATH: ${{ github.workspace }}/model.gguf
  237. MBR_FORCE_CPU: ${{ runner.os == 'macOS' && '1' || '' }}
  238. run: |
  239. echo "=== CLI Test Suite ==="
  240. # Dynamically find CLI executable
  241. CLI_NAME="bs_roformer-cli"
  242. if [[ "$RUNNER_OS" == "Windows" ]]; then CLI_NAME="bs_roformer-cli.exe"; fi
  243. echo "Searching for $CLI_NAME..."
  244. CLI_PATH=$(find build -name "$CLI_NAME" | head -n 1)
  245. if [[ -z "$CLI_PATH" ]]; then
  246. echo "Error: CLI executable not found!"
  247. find build
  248. exit 1
  249. fi
  250. echo "Found CLI at: $CLI_PATH"
  251. chmod +x "$CLI_PATH"
  252. # Setup execution variables
  253. CLI_DIR=$(dirname "$CLI_PATH")
  254. CLI_EXE="./$CLI_NAME"
  255. # Debug Info
  256. echo "Debug: Listing directory $CLI_DIR"
  257. ls -l "$CLI_DIR"
  258. echo "Debug: Checking dependencies"
  259. if command -v ldd >/dev/null; then
  260. ldd "$CLI_PATH" || echo "ldd returned error"
  261. fi
  262. # Define runner helper
  263. run_cli() {
  264. echo "Executing: ./$CLI_NAME $@"
  265. (cd "$CLI_DIR" && ./$CLI_NAME "$@")
  266. }
  267. # Debug PATH
  268. echo "PATH: $PATH"
  269. # 1. Test --help
  270. echo "[1/4] Testing --help..."
  271. run_cli --help
  272. # 2. Test with missing arguments (should fail)
  273. echo "[2/4] Testing error handling..."
  274. if run_cli 2>/dev/null; then
  275. echo "ERROR: CLI should fail without arguments"
  276. exit 1
  277. fi
  278. # 3. Use existing test audio
  279. echo "[3/4] Using generated test audio..."
  280. cp test_audio.wav cli_test_input.wav
  281. # 4. Run full inference
  282. echo "[4/4] Running inference..."
  283. # Use absolute paths for input/output to avoid directory issues
  284. ABS_MODEL=$(readlink -f "$MBR_MODEL_PATH" || echo "$(pwd)/model.gguf")
  285. ABS_INPUT=$(readlink -f cli_test_input.wav || echo "$(pwd)/cli_test_input.wav")
  286. ABS_OUTPUT=$(readlink -f cli_test_output.wav || echo "$(pwd)/cli_test_output.wav")
  287. # Convert paths for Windows MSVC executables
  288. if [[ "$RUNNER_OS" == "Windows" ]]; then
  289. ABS_MODEL=$(cygpath -w "$ABS_MODEL")
  290. ABS_INPUT=$(cygpath -w "$ABS_INPUT")
  291. ABS_OUTPUT=$(cygpath -w "$ABS_OUTPUT")
  292. fi
  293. echo "Running with model: $ABS_MODEL"
  294. run_cli "$ABS_MODEL" "$ABS_INPUT" "$ABS_OUTPUT" --chunk-size 88200 --overlap 2
  295. # Verify output exists and has reasonable size
  296. if [[ ! -f cli_test_output.wav ]]; then
  297. echo "ERROR: Output file not created"
  298. exit 1
  299. fi
  300. OUTPUT_SIZE=$(stat -c%s cli_test_output.wav 2>/dev/null || stat -f%z cli_test_output.wav)
  301. if [[ $OUTPUT_SIZE -lt 1000 ]]; then
  302. echo "ERROR: Output file too small: $OUTPUT_SIZE bytes"
  303. exit 1
  304. fi
  305. echo "=== CLI Tests Passed ==="
  306. # ----- Upload Artifacts -----
  307. - name: Upload Build Artifacts
  308. uses: actions/upload-artifact@v4
  309. with:
  310. name: build-${{ matrix.name }}
  311. path: |
  312. build/bin/
  313. build/lib*/
  314. build/*.dll
  315. build/*.so
  316. build/*.dylib
  317. build/bs_roformer-cli*
  318. build/Release/
  319. retention-days: 7
  320. # ----- Prepare Release Artifact -----
  321. - name: Prepare Release Artifact (Unix)
  322. if: runner.os != 'Windows'
  323. shell: bash
  324. run: |
  325. # Create release directory
  326. mkdir -p release/mel-band-roformer
  327. # Find and copy CLI executable
  328. CLI_PATH=$(find build -name "bs_roformer-cli" -type f | head -n 1)
  329. if [[ -n "$CLI_PATH" ]]; then
  330. cp "$CLI_PATH" release/mel-band-roformer/
  331. chmod +x release/mel-band-roformer/bs_roformer-cli
  332. fi
  333. # Copy shared libraries if exist (only real files, not symlinks)
  334. find build \( -name "*.so*" -o -name "*.dylib" \) -type f ! -type l | while read lib; do
  335. cp "$lib" release/mel-band-roformer/ 2>/dev/null || true
  336. done
  337. # List contents
  338. echo "Release artifact contents:"
  339. ls -lh release/mel-band-roformer/
  340. - name: Prepare Release Artifact (Windows)
  341. if: runner.os == 'Windows'
  342. shell: pwsh
  343. run: |
  344. # Create release directory
  345. New-Item -ItemType Directory -Force -Path "release\mel-band-roformer"
  346. # Find and copy CLI executable
  347. $CliPath = Get-ChildItem -Path build -Filter "bs_roformer-cli.exe" -Recurse -File | Select-Object -First 1
  348. if ($CliPath) {
  349. Copy-Item $CliPath.FullName "release\mel-band-roformer\"
  350. }
  351. # Copy DLL files
  352. Get-ChildItem -Path build -Filter "*.dll" -Recurse -File | ForEach-Object {
  353. Copy-Item $_.FullName "release\mel-band-roformer\" -ErrorAction SilentlyContinue
  354. }
  355. # List contents
  356. Write-Host "Release artifact contents:"
  357. Get-ChildItem "release\mel-band-roformer" | Format-Table Name, Length
  358. - name: Upload Release Artifact
  359. uses: actions/upload-artifact@v4
  360. with:
  361. name: BSRoformer-${{ matrix.name }}
  362. path: release/mel-band-roformer/
  363. retention-days: 30
  364. # ===========================================================================
  365. # CUDA Build: Linux (Compile Verification Only)
  366. # ===========================================================================
  367. build-cuda-linux:
  368. name: build-cuda-linux-${{ matrix.cuda_version }}
  369. runs-on: ${{ matrix.os }}
  370. strategy:
  371. fail-fast: false
  372. matrix:
  373. include:
  374. - { cuda_version: "11.8.0", os: ubuntu-22.04 }
  375. - { cuda_version: "12.9.1", os: ubuntu-latest }
  376. - { cuda_version: "13.1.0", os: ubuntu-latest }
  377. steps:
  378. - name: Checkout
  379. uses: actions/checkout@v4
  380. - name: Clone GGML
  381. run: git clone --depth 1 https://github.com/ggerganov/ggml.git ggml
  382. - name: Install CUDA Toolkit
  383. uses: Jimver/cuda-toolkit@master
  384. with:
  385. cuda: ${{ matrix.cuda_version }}
  386. method: network
  387. sub-packages: '["nvcc", "cudart", "thrust"]'
  388. non-cuda-sub-packages: '["libcublas", "libcublas-dev"]'
  389. - name: Install Dependencies
  390. run: |
  391. sudo apt-get install -y cmake build-essential ninja-build
  392. - name: Setup sccache
  393. uses: mozilla-actions/sccache-action@v0.0.9
  394. - name: Configure
  395. run: |
  396. ls -ld ggml
  397. # Minimal architectures for compile verification
  398. # Just verify compilation works, not for distribution
  399. CUDA_ARCHS="75;86"
  400. echo "Verifying build for CUDA architectures: $CUDA_ARCHS"
  401. cmake -B build -G Ninja \
  402. -DCMAKE_BUILD_TYPE=Release \
  403. -DGGML_DIR=ggml \
  404. -DGGML_CUDA=ON \
  405. -DGGML_CUDA_FORCE_MMQ=ON \
  406. -DCMAKE_CUDA_ARCHITECTURES="$CUDA_ARCHS" \
  407. -DCMAKE_C_COMPILER_LAUNCHER=sccache \
  408. -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
  409. -DCMAKE_CUDA_COMPILER_LAUNCHER=sccache \
  410. -DMBR_BUILD_TESTS=OFF \
  411. -DMBR_BUILD_CLI=ON
  412. - name: Build
  413. run: cmake --build build --config Release -j $(nproc)
  414. - name: Upload Artifacts
  415. uses: actions/upload-artifact@v4
  416. with:
  417. name: build-linux-cuda-${{ matrix.cuda_version }}
  418. path: |
  419. build/bin/
  420. build/lib*/
  421. build/*.so
  422. retention-days: 7
  423. # ----- Prepare Release Artifact -----
  424. - name: Prepare Release Artifact
  425. run: |
  426. # Create release directory
  427. mkdir -p release/mel-band-roformer
  428. # Find and copy CLI executable
  429. CLI_PATH=$(find build -name "bs_roformer-cli" -type f | head -n 1)
  430. if [[ -n "$CLI_PATH" ]]; then
  431. cp "$CLI_PATH" release/mel-band-roformer/
  432. chmod +x release/mel-band-roformer/bs_roformer-cli
  433. fi
  434. # Copy shared libraries
  435. find build -name "*.so*" | while read lib; do
  436. cp "$lib" release/mel-band-roformer/ 2>/dev/null || true
  437. done
  438. # List contents
  439. echo "Release artifact contents:"
  440. ls -lh release/mel-band-roformer/
  441. - name: Upload Release Artifact
  442. uses: actions/upload-artifact@v4
  443. with:
  444. name: BSRoformer-linux-cuda-${{ matrix.cuda_version }}
  445. path: release/mel-band-roformer/
  446. retention-days: 30
  447. # ===========================================================================
  448. # CUDA Build: Windows (Compile Only - No GPU for testing)
  449. # ===========================================================================
  450. build-cuda-windows:
  451. name: build-cuda-windows-${{ matrix.cuda_version }}
  452. runs-on: windows-2022
  453. strategy:
  454. fail-fast: false
  455. matrix:
  456. cuda_version: ["11.8.0", "12.9.1", "13.1.0"]
  457. env:
  458. CUDA_VERSION: ${{ matrix.cuda_version }}
  459. steps:
  460. - name: Checkout
  461. uses: actions/checkout@v4
  462. - name: Setup MSVC
  463. if: runner.os == 'Windows'
  464. uses: ilammy/msvc-dev-cmd@v1
  465. - name: Clone GGML
  466. run: git clone --depth 1 https://github.com/ggerganov/ggml.git ggml
  467. - name: Install CUDA Toolkit
  468. if: ${{ matrix.cuda_version != '13.1.0' }}
  469. uses: Jimver/cuda-toolkit@master
  470. with:
  471. cuda: ${{ matrix.cuda_version }}
  472. method: network
  473. sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
  474. - name: Install CUDA Toolkit(13.1.0)
  475. if: ${{ matrix.cuda_version == '13.1.0' }}
  476. uses: Jimver/cuda-toolkit@master
  477. with:
  478. cuda: ${{ matrix.cuda_version }}
  479. method: network
  480. sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "nvrtc", "nvrtc_dev", "crt", "nvvm", "visual_studio_integration"]'
  481. - name: Install Ninja
  482. run: choco install ninja -y
  483. - name: Setup sccache
  484. uses: mozilla-actions/sccache-action@v0.0.9
  485. - name: Configure and Build
  486. shell: pwsh
  487. run: |
  488. # Consumer GPU architectures:
  489. # 61=Pascal (GTX 10), 75=Turing (RTX 20/GTX 16), 86=Ampere (RTX 30), 89=Ada (RTX 40), 120=Blackwell (RTX 50)
  490. $cudaVersion = "${{ matrix.cuda_version }}"
  491. if ($cudaVersion -match "^11\.") {
  492. # CUDA 11.x: Support Pascal (61) to Ada (89)
  493. $cudaArchs = "61;75;86;89"
  494. $env:CUDAFLAGS = "-allow-unsupported-compiler -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH -D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR"
  495. } elseif ($cudaVersion -match "^12\.") {
  496. # CUDA 12.x: Support Pascal (61) to Blackwell (120) (technically 120 needs 12.8+, keeping unified for now or simple)
  497. # Actually 12.x still supports Pascal.
  498. $cudaArchs = "61;75;86;89"
  499. $env:CUDAFLAGS = ""
  500. } else {
  501. # CUDA 13+: Drop Pascal (61). Support Turing (75) to Blackwell (120)
  502. $cudaArchs = "75;86;89;120"
  503. $env:CUDAFLAGS = ""
  504. }
  505. Write-Host "Building for CUDA architectures: $cudaArchs"
  506. cmake -B build -G "Ninja Multi-Config" `
  507. -DGGML_DIR=ggml `
  508. -DGGML_CUDA=ON `
  509. -DGGML_CUDA_FORCE_MMQ=ON `
  510. "-DCMAKE_CUDA_ARCHITECTURES=$cudaArchs" `
  511. -DCMAKE_C_COMPILER_LAUNCHER=sccache `
  512. -DCMAKE_CXX_COMPILER_LAUNCHER=sccache `
  513. -DMBR_BUILD_TESTS=OFF `
  514. -DMBR_BUILD_CLI=ON
  515. cmake --build build --config Release -j $env:NUMBER_OF_PROCESSORS
  516. - name: Upload Artifacts
  517. uses: actions/upload-artifact@v4
  518. with:
  519. name: build-windows-cuda-${{ matrix.cuda_version }}
  520. path: |
  521. build/bin/
  522. build/Release/
  523. build/*.dll
  524. retention-days: 7
  525. # ----- Prepare Release Artifact -----
  526. - name: Prepare Release Artifact
  527. shell: pwsh
  528. run: |
  529. # Create release directory
  530. New-Item -ItemType Directory -Force -Path "release\mel-band-roformer"
  531. # Find and copy CLI executable
  532. $CliPath = Get-ChildItem -Path build -Filter "bs_roformer-cli.exe" -Recurse -File | Select-Object -First 1
  533. if ($CliPath) {
  534. Copy-Item $CliPath.FullName "release\mel-band-roformer\"
  535. }
  536. # Copy DLL files
  537. Get-ChildItem -Path build -Filter "*.dll" -Recurse -File | ForEach-Object {
  538. Copy-Item $_.FullName "release\mel-band-roformer\" -ErrorAction SilentlyContinue
  539. }
  540. # List contents
  541. Write-Host "Release artifact contents:"
  542. Get-ChildItem "release\mel-band-roformer" | Format-Table Name, Length
  543. - name: Upload Release Artifact
  544. uses: actions/upload-artifact@v4
  545. with:
  546. name: BSRoformer-windows-cuda-${{ matrix.cuda_version }}
  547. path: release\mel-band-roformer\
  548. retention-days: 30