|
| 1 | +# CUDA Build Check - Verifies CUDA-related crates compile correctly |
| 2 | +# Note: Full runtime testing requires cuQuantum SDK which is not available in CI |
| 3 | +# For actual GPU testing, use a self-hosted runner with CUDA and cuQuantum installed |
| 4 | + |
| 5 | +name: CUDA Build Check |
| 6 | + |
| 7 | +env: |
| 8 | + RUSTFLAGS: -C debuginfo=0 |
| 9 | + RUST_BACKTRACE: 1 |
| 10 | + |
| 11 | +on: |
| 12 | + push: |
| 13 | + branches: [ "main", "master", "development", "dev" ] |
| 14 | + paths: |
| 15 | + - 'crates/pecos-cuquantum/**' |
| 16 | + - 'crates/pecos-cuquantum-sys/**' |
| 17 | + - 'python/pecos-rslib-cuda/**' |
| 18 | + - '.github/workflows/cuda-build-check.yml' |
| 19 | + pull_request: |
| 20 | + branches: [ "main", "master", "development", "dev" ] |
| 21 | + paths: |
| 22 | + - 'crates/pecos-cuquantum/**' |
| 23 | + - 'crates/pecos-cuquantum-sys/**' |
| 24 | + - 'python/pecos-rslib-cuda/**' |
| 25 | + - '.github/workflows/cuda-build-check.yml' |
| 26 | + |
| 27 | +concurrency: |
| 28 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 29 | + cancel-in-progress: true |
| 30 | + |
| 31 | +jobs: |
| 32 | + cuda-build-check: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v6 |
| 36 | + |
| 37 | + - name: Free disk space |
| 38 | + run: | |
| 39 | + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc |
| 40 | + sudo apt-get clean |
| 41 | + df -h |
| 42 | +
|
| 43 | + - name: Install Rust |
| 44 | + run: | |
| 45 | + curl https://sh.rustup.rs -sSf | sh -s -- -y |
| 46 | + echo "$HOME/.cargo/bin" >> $GITHUB_PATH |
| 47 | + export PATH="$HOME/.cargo/bin:$PATH" |
| 48 | +
|
| 49 | + - name: Set up Rust |
| 50 | + run: rustup override set stable && rustup update |
| 51 | + |
| 52 | + - name: Cache Rust |
| 53 | + uses: Swatinem/rust-cache@v2 |
| 54 | + with: |
| 55 | + save-if: ${{ github.ref_name == 'main' || github.ref_name == 'master' || github.ref_name == 'development' || github.ref_name == 'dev' }} |
| 56 | + |
| 57 | + - name: Install CUDA Toolkit |
| 58 | + uses: Jimver/cuda-toolkit@v0.2.30 |
| 59 | + id: cuda-toolkit |
| 60 | + with: |
| 61 | + cuda: '12.6.3' |
| 62 | + method: 'network' |
| 63 | + sub-packages: '["nvcc", "cudart-dev"]' |
| 64 | + non-cuda-sub-packages: '["libcublas", "libcublas-dev"]' |
| 65 | + |
| 66 | + - name: Check pecos-cuquantum-sys compiles (stub mode) |
| 67 | + run: | |
| 68 | + echo "Building pecos-cuquantum-sys (will use stubs since cuQuantum SDK is not installed)..." |
| 69 | + cargo check -p pecos-cuquantum-sys |
| 70 | +
|
| 71 | + - name: Check pecos-cuquantum compiles (stub mode) |
| 72 | + run: | |
| 73 | + echo "Building pecos-cuquantum (will use stubs since cuQuantum SDK is not installed)..." |
| 74 | + cargo check -p pecos-cuquantum |
| 75 | +
|
| 76 | + - name: Check pecos-rslib-cuda compiles (stub mode) |
| 77 | + run: | |
| 78 | + echo "Building pecos-rslib-cuda Python bindings..." |
| 79 | + cargo check -p pecos-rslib-cuda |
| 80 | +
|
| 81 | + - name: Run clippy on CUDA crates |
| 82 | + run: | |
| 83 | + echo "Running clippy on CUDA crates..." |
| 84 | + cargo clippy -p pecos-cuquantum-sys -p pecos-cuquantum -p pecos-rslib-cuda -- -D warnings |
| 85 | +
|
| 86 | + - name: Verify stub mode detection |
| 87 | + run: | |
| 88 | + echo "Verifying that build correctly detects stub mode..." |
| 89 | + # The crates should compile but is_cuquantum_available() should return false |
| 90 | + cargo build -p pecos-cuquantum --release |
| 91 | + # Note: We can't actually run the binary to test is_cuquantum_available() |
| 92 | + # because it requires the cuQuantum runtime, but the build succeeding |
| 93 | + # in stub mode means the detection is working |
| 94 | +
|
| 95 | + # Documentation for setting up GPU testing |
| 96 | + cuda-testing-info: |
| 97 | + runs-on: ubuntu-latest |
| 98 | + steps: |
| 99 | + - name: CUDA Testing Requirements |
| 100 | + run: | |
| 101 | + echo "==============================================" |
| 102 | + echo "CUDA GPU Testing Requirements" |
| 103 | + echo "==============================================" |
| 104 | + echo "" |
| 105 | + echo "Full runtime tests for pecos-rslib-cuda require:" |
| 106 | + echo " 1. NVIDIA GPU with CUDA support" |
| 107 | + echo " 2. CUDA Toolkit 12.x installed" |
| 108 | + echo " 3. cuQuantum SDK installed" |
| 109 | + echo "" |
| 110 | + echo "To run GPU tests locally:" |
| 111 | + echo " 1. Install CUDA Toolkit: https://developer.nvidia.com/cuda-downloads" |
| 112 | + echo " 2. Install cuQuantum SDK: https://developer.nvidia.com/cuquantum-sdk" |
| 113 | + echo " 3. Run: cargo test -p pecos-cuquantum --features cuda" |
| 114 | + echo " 4. Build Python package: maturin develop -m python/pecos-rslib-cuda/Cargo.toml" |
| 115 | + echo "" |
| 116 | + echo "For self-hosted CI runners with GPU support:" |
| 117 | + echo " - Use runners labeled with 'cuda' or 'gpu'" |
| 118 | + echo " - Ensure cuQuantum SDK is pre-installed" |
| 119 | + echo " - Run: cargo test -p pecos-cuquantum" |
| 120 | + echo "==============================================" |
0 commit comments