build.yml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  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. -DBSR_BUILD_TESTS=ON \
  196. -DBSR_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. -DBSR_BUILD_TESTS=ON `
  207. -DBSR_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. BSR_MODEL_PATH: ${{ github.workspace }}/model.gguf
  220. BSR_TEST_DATA_DIR: ${{ github.workspace }}/test_data
  221. BSR_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. BSR_MODEL_PATH: ${{ github.workspace }}/model_bs.gguf
  227. BSR_TEST_DATA_DIR: ${{ github.workspace }}/test_data_bs
  228. BSR_FORCE_CPU: ${{ runner.os == 'macOS' && '1' || '' }}
  229. run: ctest --test-dir build -C Release -V --output-on-failure --timeout 300
  230. # ----- CLI Tests -----
  231. - name: Test CLI
  232. if: matrix.test
  233. shell: bash
  234. env:
  235. BSR_MODEL_PATH: ${{ github.workspace }}/model.gguf
  236. BSR_FORCE_CPU: ${{ runner.os == 'macOS' && '1' || '' }}
  237. run: |
  238. echo "=== CLI Test Suite ==="
  239. # Dynamically find CLI executable
  240. CLI_NAME="bs_roformer-cli"
  241. if [[ "$RUNNER_OS" == "Windows" ]]; then CLI_NAME="bs_roformer-cli.exe"; fi
  242. echo "Searching for $CLI_NAME..."
  243. CLI_PATH=$(find build -name "$CLI_NAME" | head -n 1)
  244. if [[ -z "$CLI_PATH" ]]; then
  245. echo "Error: CLI executable not found!"
  246. find build
  247. exit 1
  248. fi
  249. echo "Found CLI at: $CLI_PATH"
  250. chmod +x "$CLI_PATH"
  251. # Setup execution variables
  252. CLI_DIR=$(dirname "$CLI_PATH")
  253. CLI_EXE="./$CLI_NAME"
  254. # Debug Info
  255. echo "Debug: Listing directory $CLI_DIR"
  256. ls -l "$CLI_DIR"
  257. echo "Debug: Checking dependencies"
  258. if command -v ldd >/dev/null; then
  259. ldd "$CLI_PATH" || echo "ldd returned error"
  260. fi
  261. # Define runner helper
  262. run_cli() {
  263. echo "Executing: ./$CLI_NAME $@"
  264. (cd "$CLI_DIR" && ./$CLI_NAME "$@")
  265. }
  266. # Debug PATH
  267. echo "PATH: $PATH"
  268. # 1. Test --help
  269. echo "[1/4] Testing --help..."
  270. run_cli --help
  271. # 2. Test with missing arguments (should fail)
  272. echo "[2/4] Testing error handling..."
  273. if run_cli 2>/dev/null; then
  274. echo "ERROR: CLI should fail without arguments"
  275. exit 1
  276. fi
  277. # 3. Use existing test audio
  278. echo "[3/4] Using generated test audio..."
  279. cp test_audio.wav cli_test_input.wav
  280. # 4. Run full inference
  281. echo "[4/4] Running inference..."
  282. # Use absolute paths for input/output to avoid directory issues
  283. ABS_MODEL=$(readlink -f "$BSR_MODEL_PATH" || echo "$(pwd)/model.gguf")
  284. ABS_INPUT=$(readlink -f cli_test_input.wav || echo "$(pwd)/cli_test_input.wav")
  285. ABS_OUTPUT=$(readlink -f cli_test_output.wav || echo "$(pwd)/cli_test_output.wav")
  286. # Convert paths for Windows MSVC executables
  287. if [[ "$RUNNER_OS" == "Windows" ]]; then
  288. ABS_MODEL=$(cygpath -w "$ABS_MODEL")
  289. ABS_INPUT=$(cygpath -w "$ABS_INPUT")
  290. ABS_OUTPUT=$(cygpath -w "$ABS_OUTPUT")
  291. fi
  292. echo "Running with model: $ABS_MODEL"
  293. run_cli "$ABS_MODEL" "$ABS_INPUT" "$ABS_OUTPUT" --chunk-size 88200 --overlap 2
  294. # Verify output exists and has reasonable size
  295. if [[ ! -f cli_test_output.wav ]]; then
  296. echo "ERROR: Output file not created"
  297. exit 1
  298. fi
  299. OUTPUT_SIZE=$(stat -c%s cli_test_output.wav 2>/dev/null || stat -f%z cli_test_output.wav)
  300. if [[ $OUTPUT_SIZE -lt 1000 ]]; then
  301. echo "ERROR: Output file too small: $OUTPUT_SIZE bytes"
  302. exit 1
  303. fi
  304. echo "=== CLI Tests Passed ==="
  305. # ----- Upload Artifacts -----
  306. - name: Upload Build Artifacts
  307. uses: actions/upload-artifact@v4
  308. with:
  309. name: build-${{ matrix.name }}
  310. path: |
  311. build/bin/
  312. build/lib*/
  313. build/*.dll
  314. build/*.so
  315. build/*.dylib
  316. build/bs_roformer-cli*
  317. build/Release/
  318. retention-days: 7
  319. # ----- Prepare Release Artifact -----
  320. - name: Prepare Release Artifact (Unix)
  321. if: runner.os != 'Windows'
  322. shell: bash
  323. run: |
  324. # Create release directory
  325. mkdir -p release/mel-band-roformer
  326. # Find and copy CLI executable
  327. CLI_PATH=$(find build -name "bs_roformer-cli" -type f | head -n 1)
  328. if [[ -n "$CLI_PATH" ]]; then
  329. cp "$CLI_PATH" release/mel-band-roformer/
  330. chmod +x release/mel-band-roformer/bs_roformer-cli
  331. fi
  332. # Copy shared libraries if exist (only real files, not symlinks)
  333. find build \( -name "*.so*" -o -name "*.dylib" \) -type f ! -type l | while read lib; do
  334. cp "$lib" release/mel-band-roformer/ 2>/dev/null || true
  335. done
  336. # List contents
  337. echo "Release artifact contents:"
  338. ls -lh release/mel-band-roformer/
  339. - name: Prepare Release Artifact (Windows)
  340. if: runner.os == 'Windows'
  341. shell: pwsh
  342. run: |
  343. # Create release directory
  344. New-Item -ItemType Directory -Force -Path "release\mel-band-roformer"
  345. # Find and copy CLI executable
  346. $CliPath = Get-ChildItem -Path build -Filter "bs_roformer-cli.exe" -Recurse -File | Select-Object -First 1
  347. if ($CliPath) {
  348. Copy-Item $CliPath.FullName "release\mel-band-roformer\"
  349. }
  350. # Copy DLL files
  351. Get-ChildItem -Path build -Filter "*.dll" -Recurse -File | ForEach-Object {
  352. Copy-Item $_.FullName "release\mel-band-roformer\" -ErrorAction SilentlyContinue
  353. }
  354. # List contents
  355. Write-Host "Release artifact contents:"
  356. Get-ChildItem "release\mel-band-roformer" | Format-Table Name, Length
  357. - name: Upload Release Artifact
  358. uses: actions/upload-artifact@v4
  359. with:
  360. name: BSRoformer-${{ matrix.name }}
  361. path: release/mel-band-roformer/
  362. retention-days: 30
  363. # ===========================================================================
  364. # CUDA Build: Linux (Compile Verification Only)
  365. # ===========================================================================
  366. build-cuda-linux:
  367. name: build-cuda-linux-${{ matrix.cuda_version }}
  368. runs-on: ${{ matrix.os }}
  369. strategy:
  370. fail-fast: false
  371. matrix:
  372. include:
  373. - { cuda_version: "11.8.0", os: ubuntu-22.04 }
  374. - { cuda_version: "12.9.1", os: ubuntu-latest }
  375. - { cuda_version: "13.1.0", os: ubuntu-latest }
  376. steps:
  377. - name: Checkout
  378. uses: actions/checkout@v4
  379. - name: Clone GGML
  380. run: git clone --depth 1 https://github.com/ggerganov/ggml.git ggml
  381. - name: Install CUDA Toolkit
  382. uses: Jimver/cuda-toolkit@master
  383. with:
  384. cuda: ${{ matrix.cuda_version }}
  385. method: network
  386. sub-packages: '["nvcc", "cudart", "thrust"]'
  387. non-cuda-sub-packages: '["libcublas", "libcublas-dev"]'
  388. - name: Install Dependencies
  389. run: |
  390. sudo apt-get install -y cmake build-essential ninja-build
  391. - name: Setup sccache
  392. uses: mozilla-actions/sccache-action@v0.0.9
  393. - name: Configure
  394. run: |
  395. ls -ld ggml
  396. # Minimal architectures for compile verification
  397. # Just verify compilation works, not for distribution
  398. CUDA_ARCHS="75;86"
  399. echo "Verifying build for CUDA architectures: $CUDA_ARCHS"
  400. cmake -B build -G Ninja \
  401. -DCMAKE_BUILD_TYPE=Release \
  402. -DGGML_DIR=ggml \
  403. -DGGML_CUDA=ON \
  404. -DGGML_CUDA_FORCE_MMQ=ON \
  405. -DCMAKE_CUDA_ARCHITECTURES="$CUDA_ARCHS" \
  406. -DCMAKE_C_COMPILER_LAUNCHER=sccache \
  407. -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
  408. -DCMAKE_CUDA_COMPILER_LAUNCHER=sccache \
  409. -DBSR_BUILD_TESTS=OFF \
  410. -DBSR_BUILD_CLI=ON
  411. - name: Build
  412. run: cmake --build build --config Release -j $(nproc)
  413. - name: Upload Artifacts
  414. uses: actions/upload-artifact@v4
  415. with:
  416. name: build-linux-cuda-${{ matrix.cuda_version }}
  417. path: |
  418. build/bin/
  419. build/lib*/
  420. build/*.so
  421. retention-days: 7
  422. # ----- Prepare Release Artifact -----
  423. - name: Prepare Release Artifact
  424. run: |
  425. # Create release directory
  426. mkdir -p release/mel-band-roformer
  427. # Find and copy CLI executable
  428. CLI_PATH=$(find build -name "bs_roformer-cli" -type f | head -n 1)
  429. if [[ -n "$CLI_PATH" ]]; then
  430. cp "$CLI_PATH" release/mel-band-roformer/
  431. chmod +x release/mel-band-roformer/bs_roformer-cli
  432. fi
  433. # Copy shared libraries
  434. find build -name "*.so*" | while read lib; do
  435. cp "$lib" release/mel-band-roformer/ 2>/dev/null || true
  436. done
  437. # List contents
  438. echo "Release artifact contents:"
  439. ls -lh release/mel-band-roformer/
  440. - name: Upload Release Artifact
  441. uses: actions/upload-artifact@v4
  442. with:
  443. name: BSRoformer-linux-cuda-${{ matrix.cuda_version }}
  444. path: release/mel-band-roformer/
  445. retention-days: 30
  446. # ===========================================================================
  447. # CUDA Build: Windows (Compile Only - No GPU for testing)
  448. # ===========================================================================
  449. build-cuda-windows:
  450. name: build-cuda-windows-${{ matrix.cuda_version }}
  451. runs-on: windows-2022
  452. strategy:
  453. fail-fast: false
  454. matrix:
  455. cuda_version: ["11.8.0", "12.9.1", "13.1.0"]
  456. env:
  457. CUDA_VERSION: ${{ matrix.cuda_version }}
  458. steps:
  459. - name: Checkout
  460. uses: actions/checkout@v4
  461. - name: Setup MSVC
  462. if: runner.os == 'Windows'
  463. uses: ilammy/msvc-dev-cmd@v1
  464. - name: Clone GGML
  465. run: git clone --depth 1 https://github.com/ggerganov/ggml.git ggml
  466. - name: Install CUDA Toolkit
  467. if: ${{ matrix.cuda_version != '13.1.0' }}
  468. uses: Jimver/cuda-toolkit@master
  469. with:
  470. cuda: ${{ matrix.cuda_version }}
  471. method: network
  472. sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
  473. - name: Install CUDA Toolkit(13.1.0)
  474. if: ${{ matrix.cuda_version == '13.1.0' }}
  475. uses: Jimver/cuda-toolkit@master
  476. with:
  477. cuda: ${{ matrix.cuda_version }}
  478. method: network
  479. sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "nvrtc", "nvrtc_dev", "crt", "nvvm", "visual_studio_integration"]'
  480. - name: Install Ninja
  481. run: choco install ninja -y
  482. - name: Setup sccache
  483. uses: mozilla-actions/sccache-action@v0.0.9
  484. - name: Configure and Build
  485. shell: pwsh
  486. run: |
  487. # Consumer GPU architectures:
  488. # 61=Pascal (GTX 10), 75=Turing (RTX 20/GTX 16), 86=Ampere (RTX 30), 89=Ada (RTX 40), 120=Blackwell (RTX 50)
  489. $cudaVersion = "${{ matrix.cuda_version }}"
  490. if ($cudaVersion -match "^11\.") {
  491. # CUDA 11.x: Support Pascal (61) to Ada (89)
  492. $cudaArchs = "61;75;86;89"
  493. $env:CUDAFLAGS = "-allow-unsupported-compiler -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH -D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR"
  494. } elseif ($cudaVersion -match "^12\.") {
  495. # CUDA 12.x: Support Pascal (61) to Blackwell (120) (technically 120 needs 12.8+, keeping unified for now or simple)
  496. # Actually 12.x still supports Pascal.
  497. $cudaArchs = "61;75;86;89"
  498. $env:CUDAFLAGS = ""
  499. } else {
  500. # CUDA 13+: Drop Pascal (61). Support Turing (75) to Blackwell (120)
  501. $cudaArchs = "75;86;89;120"
  502. $env:CUDAFLAGS = ""
  503. }
  504. Write-Host "Building for CUDA architectures: $cudaArchs"
  505. cmake -B build -G "Ninja Multi-Config" `
  506. -DGGML_DIR=ggml `
  507. -DGGML_CUDA=ON `
  508. -DGGML_CUDA_FORCE_MMQ=ON `
  509. "-DCMAKE_CUDA_ARCHITECTURES=$cudaArchs" `
  510. -DCMAKE_C_COMPILER_LAUNCHER=sccache `
  511. -DCMAKE_CXX_COMPILER_LAUNCHER=sccache `
  512. -DBSR_BUILD_TESTS=OFF `
  513. -DBSR_BUILD_CLI=ON
  514. cmake --build build --config Release -j $env:NUMBER_OF_PROCESSORS
  515. - name: Upload Artifacts
  516. uses: actions/upload-artifact@v4
  517. with:
  518. name: build-windows-cuda-${{ matrix.cuda_version }}
  519. path: |
  520. build/bin/
  521. build/Release/
  522. build/*.dll
  523. retention-days: 7
  524. # ----- Prepare Release Artifact -----
  525. - name: Prepare Release Artifact
  526. shell: pwsh
  527. run: |
  528. # Create release directory
  529. New-Item -ItemType Directory -Force -Path "release\mel-band-roformer"
  530. # Find and copy CLI executable
  531. $CliPath = Get-ChildItem -Path build -Filter "bs_roformer-cli.exe" -Recurse -File | Select-Object -First 1
  532. if ($CliPath) {
  533. Copy-Item $CliPath.FullName "release\mel-band-roformer\"
  534. }
  535. # Copy DLL files
  536. Get-ChildItem -Path build -Filter "*.dll" -Recurse -File | ForEach-Object {
  537. Copy-Item $_.FullName "release\mel-band-roformer\" -ErrorAction SilentlyContinue
  538. }
  539. # List contents
  540. Write-Host "Release artifact contents:"
  541. Get-ChildItem "release\mel-band-roformer" | Format-Table Name, Length
  542. - name: Upload Release Artifact
  543. uses: actions/upload-artifact@v4
  544. with:
  545. name: BSRoformer-windows-cuda-${{ matrix.cuda_version }}
  546. path: release\mel-band-roformer\
  547. retention-days: 30