diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index 7eaf017fbc..0dba2e9177 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04, windows-2022, macos-14, macos-15] + os: [ubuntu-22.04-arm, ubuntu-22.04, windows-2022, macos-14] # , macos-15 steps: - uses: actions/checkout@v4 @@ -19,33 +19,58 @@ jobs: submodules: "recursive" # Used to host cibuildwheel - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v6 with: python-version: "3.9" - name: Install dependencies (Linux/MacOS) if: runner.os != 'Windows' + env: + #RUST_LOG: trace + CMAKE_ARGS: "-DGGML_NATIVE=OFF -DLLAMA_NATIVE=OFF" run: | + if [ "$RUNNER_OS" == "Linux" ]; then + sudo apt-get update + sudo apt-get install -y libopenblas-dev + CMAKE_ARGS="$CMAKE_ARGS -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" + else + #brew install openblas + #CMAKE_ARGS="$CMAKE_ARGS -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DGGML_OPENMP=OFF -DCMAKE_PREFIX_PATH=/opt/homebrew/opt/openblas" + CMAKE_ARGS="$CMAKE_ARGS -DGGML_ACCELERATE=ON" + fi + echo "CMAKE_ARGS=$CMAKE_ARGS" >> $GITHUB_ENV python -m pip install --upgrade pip python -m pip install uv - RUST_LOG=trace python -m uv pip install -e .[all] --verbose + python -m uv pip install -e .[all] --verbose shell: bash - name: Install dependencies (Windows) if: runner.os == 'Windows' env: - RUST_LOG: trace + #RUST_LOG: trace + CMAKE_ARGS: "-DGGML_NATIVE=OFF -DLLAMA_NATIVE=OFF -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" run: | + (echo CMAKE_ARGS=%CMAKE_ARGS%)>>%GITHUB_ENV% + vcpkg install openblas pkgconf python -m pip install --upgrade pip python -m pip install uv python -m uv pip install -e .[all] --verbose shell: cmd - name: Build wheels - uses: pypa/cibuildwheel@v2.22.0 + uses: pypa/cibuildwheel@v3.3.1 env: + CIBW_SKIP: "*musllinux*" + #CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-* cp314-*" # disable repair CIBW_REPAIR_WHEEL_COMMAND: "" + CIBW_ENVIRONMENT: CMAKE_ARGS="${{ env.CMAKE_ARGS }}" #-DGGML_NATIVE=OFF -DLLAMA_NATIVE=OFF + CIBW_BEFORE_BUILD_LINUX: "rm -rf build/ llama_cpp/lib/*.so" + #CIBW_BEFORE_ALL_MACOS: "brew install openblas" + #CIBW_BEFORE_ALL_WINDOWS: "vcpkg install openblas pkgconf" + CIBW_BEFORE_ALL_LINUX: >- + if command -v yum >/dev/null 2>&1; then yum install -y openblas-devel; + elif command -v apk >/dev/null 2>&1; then apk add openblas-dev; fi with: package-dir: . output-dir: wheelhouse @@ -54,37 +79,7 @@ jobs: with: name: wheels-${{ matrix.os }} path: ./wheelhouse/*.whl - - build_wheels_arm64: - name: Build arm64 wheels - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: "recursive" - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: linux/arm64 - - - name: Build wheels - uses: pypa/cibuildwheel@v2.22.0 - env: - CIBW_SKIP: "*musllinux* pp*" - CIBW_REPAIR_WHEEL_COMMAND: "" - CIBW_ARCHS: "aarch64" - CIBW_ENVIRONMENT: CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_APPLE_SILICON_PROCESSOR=arm64 -DCMAKE_CROSSCOMPILING=ON" - CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*" - with: - output-dir: wheelhouse - - - name: Upload wheels as artifacts - uses: actions/upload-artifact@v4 - with: - name: wheels_arm64 - path: ./wheelhouse/*.whl - + build_sdist: name: Build source distribution runs-on: ubuntu-latest @@ -94,24 +89,40 @@ jobs: with: submodules: "recursive" - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v6 with: python-version: "3.9" - name: Install dependencies (Linux/MacOS) if: runner.os != 'Windows' + env: + #RUST_LOG: trace + CMAKE_ARGS: "-DGGML_NATIVE=OFF -DLLAMA_NATIVE=OFF" run: | + if [ "$RUNNER_OS" == "Linux" ]; then + sudo apt-get update + sudo apt-get install -y libopenblas-dev + CMAKE_ARGS="$CMAKE_ARGS -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" + else + #brew install openblas + #CMAKE_ARGS="$CMAKE_ARGS -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DGGML_OPENMP=OFF -DCMAKE_PREFIX_PATH=/opt/homebrew/opt/openblas" + CMAKE_ARGS="$CMAKE_ARGS -DGGML_ACCELERATE=ON" + fi + echo "CMAKE_ARGS=$CMAKE_ARGS" >> $GITHUB_ENV python -m pip install --upgrade pip python -m pip install uv - RUST_LOG=trace python -m uv pip install -e .[all] --verbose + python -m uv pip install -e .[all] --verbose python -m uv pip install build shell: bash - name: Install dependencies (Windows) if: runner.os == 'Windows' env: - RUST_LOG: trace + #RUST_LOG: trace + CMAKE_ARGS: "-DGGML_NATIVE=OFF -DLLAMA_NATIVE=OFF -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" run: | + (echo CMAKE_ARGS=%CMAKE_ARGS%)>>%GITHUB_ENV% + vcpkg install openblas pkgconf python -m pip install --upgrade pip python -m pip install uv python -m uv pip install -e .[all] --verbose @@ -129,7 +140,7 @@ jobs: release: name: Release - needs: [build_wheels, build_wheels_arm64, build_sdist] + needs: [build_wheels, build_sdist] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/build-wheels-metal.yaml b/.github/workflows/build-wheels-metal.yaml index 98f511e4a6..40d011b3fa 100644 --- a/.github/workflows/build-wheels-metal.yaml +++ b/.github/workflows/build-wheels-metal.yaml @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-14, macos-15] + os: [macos-14] # , macos-15 steps: - uses: actions/checkout@v4 @@ -19,7 +19,7 @@ jobs: submodules: "recursive" # Used to host cibuildwheel - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v6 with: python-version: "3.12" cache: 'pip' @@ -32,13 +32,13 @@ jobs: shell: bash - name: Build wheels - uses: pypa/cibuildwheel@v2.22.0 + uses: pypa/cibuildwheel@v3.3.1 env: # disable repair CIBW_REPAIR_WHEEL_COMMAND: "" CIBW_ARCHS: "arm64" CIBW_ENVIRONMENT: CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_APPLE_SILICON_PROCESSOR=arm64 -DGGML_METAL=on -DCMAKE_CROSSCOMPILING=ON" - CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-*" + CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-* cp314-*" with: package-dir: . output-dir: wheelhouse2 diff --git a/.github/workflows/generate-index-from-release.yaml b/.github/workflows/generate-index-from-release.yaml index 255ee67d6f..5307f3042a 100644 --- a/.github/workflows/generate-index-from-release.yaml +++ b/.github/workflows/generate-index-from-release.yaml @@ -35,17 +35,23 @@ jobs: - name: Setup Pages uses: actions/configure-pages@v5 - name: Build + #continue-on-error: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | ./scripts/get-releases.sh + # Non-existing file could cause an error at the script ./scripts/releases-to-pep-503.sh index/whl/cpu '^[v]?[0-9]+\.[0-9]+\.[0-9]+$' - ./scripts/releases-to-pep-503.sh index/whl/cu121 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu121$' - ./scripts/releases-to-pep-503.sh index/whl/cu122 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu122$' - ./scripts/releases-to-pep-503.sh index/whl/cu123 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu123$' - ./scripts/releases-to-pep-503.sh index/whl/cu124 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu124$' - # ./scripts/releases-to-pep-503.sh index/whl/cu125 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu124$' - # ./scripts/releases-to-pep-503.sh index/whl/cu126 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu124$' + #./scripts/releases-to-pep-503.sh index/whl/cu121 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu121$' + #./scripts/releases-to-pep-503.sh index/whl/cu122 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu122$' + #./scripts/releases-to-pep-503.sh index/whl/cu123 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu123$' + #./scripts/releases-to-pep-503.sh index/whl/cu124 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu124$' + ./scripts/releases-to-pep-503.sh index/whl/cu125 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu125$' + ./scripts/releases-to-pep-503.sh index/whl/cu126 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu126$' + ./scripts/releases-to-pep-503.sh index/whl/cu128 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu128$' + #./scripts/releases-to-pep-503.sh index/whl/cu129 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu129$' + ./scripts/releases-to-pep-503.sh index/whl/cu130 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu130$' + #./scripts/releases-to-pep-503.sh index/whl/cu131 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu131$' ./scripts/releases-to-pep-503.sh index/whl/metal '^[v]?[0-9]+\.[0-9]+\.[0-9]+-metal$' - name: Upload artifact uses: actions/upload-pages-artifact@v3 diff --git a/.github/workflows/manual_wheel_cuda.yml b/.github/workflows/manual_wheel_cuda.yml new file mode 100644 index 0000000000..a3e9b76830 --- /dev/null +++ b/.github/workflows/manual_wheel_cuda.yml @@ -0,0 +1,225 @@ +name: Build Wheels (CUDA) + +on: workflow_dispatch + +permissions: + contents: write + +jobs: + define_matrix: + name: Define Build Matrix + runs-on: ubuntu-22.04 + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + defaults: + run: + shell: pwsh + + steps: + - name: Define Job Output + id: set-matrix + run: | + $matrix = @{ + 'os' = @('ubuntu-22.04-arm', 'ubuntu-22.04', 'windows-2022') # + 'pyver' = @("3.9", "3.10", "3.11", "3.12", "3.13", "3.14") # + 'cuda' = @("12.5.1", "12.6.3", "12.8.1", "13.0.2") # "12.1.1", "12.2.2", "12.3.2", "12.4.1", "12.9.1", "13.1.0" + 'releasetag' = @("basic") + } + + $matrixOut = ConvertTo-Json $matrix -Compress + Write-Output ('matrix=' + $matrixOut) >> $env:GITHUB_OUTPUT + + build_wheels: + name: Build Wheel ${{ matrix.os }} ${{ matrix.pyver }} ${{ matrix.cuda }} ${{ matrix.releasetag == 'wheels' && 'AVX2' || matrix.releasetag }} + needs: define_matrix + runs-on: ${{ matrix.os }} + strategy: + max-parallel: 12 + matrix: ${{ fromJSON(needs.define_matrix.outputs.matrix) }} + defaults: + run: + shell: pwsh + env: + CUDAVER: ${{ matrix.cuda }} + AVXVER: ${{ matrix.releasetag }} + + steps: + - name: Add MSBuild to PATH + if: runner.os == 'Windows' + uses: microsoft/setup-msbuild@v2 + #with: + # vs-version: '[16.11,17.14)' + + - uses: actions/checkout@v4 + with: + submodules: "recursive" + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.pyver }} + cache: 'pip' + + - name: Setup Mamba + uses: conda-incubator/setup-miniconda@v3.3.0 + with: + activate-environment: "llamacpp" + python-version: ${{ matrix.pyver }} + miniforge-version: latest + add-pip-as-python-dependency: true + auto-activate-base: false + + - name: VS Integration Cache + id: vs-integration-cache + if: runner.os == 'Windows' + uses: actions/cache@v4 + with: + path: ./MSBuildExtensions + key: cuda-${{ matrix.cuda }}-vs-integration + + - name: Get Visual Studio Integration + if: runner.os == 'Windows' && steps.vs-integration-cache.outputs.cache-hit != 'true' + run: | + if ($env:CUDAVER -eq '12.1.1') {$x = '12.1.0'} else {$x = $env:CUDAVER} + if ($env:CUDAVER -eq '12.9.2') {$x = '12.9.1'} else {$x = $env:CUDAVER} + $links = (Invoke-RestMethod 'https://raw.githubusercontent.com/Jimver/cuda-toolkit/master/src/links/windows-links.ts').Trim().split().where({$_ -ne ''}) + for ($i=$q=0;$i -lt $links.count -and $q -lt 2;$i++) {if ($links[$i] -eq "'$x',") {$q++}} + Invoke-RestMethod $links[$i].Trim("'") -OutFile 'cudainstaller.zip' + & 'C:\Program Files\7-Zip\7z.exe' e cudainstaller.zip -oMSBuildExtensions -r *\MSBuildExtensions\* > $null + Remove-Item 'cudainstaller.zip' + + - name: Install Visual Studio Integration + if: runner.os == 'Windows' + run: | + $y = (gi '.\MSBuildExtensions').fullname + '\*' + (gi 'C:\Program Files*\Microsoft Visual Studio\20*\Enterprise\MSBuild\Microsoft\VC\*\BuildCustomizations').fullname.foreach({cp $y $_}) + $cupath = 'CUDA_PATH_V' + $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','_') + echo "$cupath=$env:CONDA_PREFIX" >> $env:GITHUB_ENV + + - name: Install Dependencies + env: + MAMBA_DOWNLOAD_FAILFAST: "0" + MAMBA_NO_LOW_SPEED_LIMIT: "1" + run: | + $cudaVersion = $env:CUDAVER + $cudaParts = $cudaVersion -split '\.' + #if ("$($cudaParts[0]).$($cudaParts[1])" -eq "12.4") {$cudaParts[1] = '5'} + $cudaMajor = $cudaParts[0] + $cudaMajorMinor = "$($cudaParts[0]).$($cudaParts[1])" + #conda config --set channel_priority flexible # strict + #conda config --prepend channels nvidia + #conda config --append channels conda-forge + #conda config --remove channels defaults + conda config --show channels + #mamba install -y "nvidia::cuda-version==$cudaMajorMinor.*" "nvidia::cuda-toolkit" "nvidia::cuda-nvcc" "nvidia::cuda-cudart-dev" "conda-forge::gcc==13.*" # "conda-forge::libstdcxx-ng" + mamba install -y -c conda-forge "cuda-version==$cudaMajorMinor.*" "cuda-toolkit" "cuda-cudart-dev" "cuda-cccl" "cuda-nvvm" "cuda-nvcc" # "conda-forge::gcc==13.*" # -c "nvidia/label/cuda-$cudaVersion" "cuda-libraries-dev" "nvidia::cuda-thrust" + python -m pip install build wheel + + - name: Build Wheel + run: | + $cpuArch = $env:PROCESSOR_ARCHITECTURE + $cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','') + $cudaMajor = $env:CUDAVER.Split('.')[0] + #if ($env:RUNNER_OS -eq 'Windows') { + # $env:CONDA_PREFIX = $env:CONDA_PREFIX + '\Library' + #} + $env:CUDA_PATH = $env:CONDA_PREFIX + $env:CUDA_HOME = $env:CONDA_PREFIX + $env:CUDA_TOOLKIT_ROOT_DIR = $env:CONDA_PREFIX + $env:CUDAToolkit_ROOT = $env:CONDA_PREFIX + $env:CUDATOOLKITDIR = $env:CONDA_PREFIX + echo "CONDA_PREFIX = $env:CONDA_PREFIX" + if ($IsLinux) { + if ($cpuArch -eq 'AMD64') { $cpuArch = 'x86_64' } else { $cpuArch = 'sbsa' } + #$cpuArch = uname -m + $env:LD_LIBRARY_PATH = $env:CONDA_PREFIX + '/lib:' + $env:CONDA_PREFIX + "/targets/$cpuArch-linux/lib:" + $env:LD_LIBRARY_PATH + $env:CPATH = $env:CONDA_PREFIX + '/include:' + $env:CONDA_PREFIX + "/targets/$cpuArch-linux/include:" + $env:CPATH + Get-ChildItem -Path ~ -Filter "nvcc" -Recurse -ErrorAction SilentlyContinue + Get-ChildItem -Path ~ -Filter "cicc" -Recurse -ErrorAction SilentlyContinue + } + elseif ($IsWindows) { + if ($cpuArch -eq 'AMD64') { $cpuArch = 'x64' } + $env:CUDA_TOOLKIT_ROOT_DIR += "\\Library" + $env:CUDAToolkit_ROOT += "\\Library" + ##$env:CUDA_PATH = $env:CONDA_PREFIX + '\\Library\\bin' + ##$env:CUDA_INC_PATH = $env:CONDA_PREFIX + '\\Library\\include' + ##$env:CUDA_LIB_PATH = $env:CONDA_PREFIX + '\\Library\\lib' + ##$env:CUDACXX = $env:CONDA_PREFIX + '\\Library\\bin\\nvcc.exe' + ##$env:LIB = $env:CONDA_PREFIX + '\\lib;' + $env:CONDA_PREFIX + '\\lib64;' + $env:CONDA_PREFIX + '\\Library\\lib;' + $env:CONDA_PREFIX + '\\Library\\lib64;' + $env:CONDA_PREFIX + '\\Library\\lib\\x64;' + $env:LIB + ##$env:LIBPATH = $env:CONDA_PREFIX + '\\lib;' + $env:CONDA_PREFIX + '\\lib64;' + $env:CONDA_PREFIX + '\\Library\\lib;' + $env:CONDA_PREFIX + '\\Library\\lib64;' + $env:CONDA_PREFIX + '\\Library\\lib\\x64;' + $env:LIBPATH + $env:IncludePath = $env:CONDA_PREFIX + '\\include;' + $env:CONDA_PREFIX + '\\Library\\include;' + $env:IncludePath + ##$env:C_INCLUDE_PATH = $env:CONDA_PREFIX + '\\include;' + $env:CONDA_PREFIX + '\\Library\\include;' + $env:C_INCLUDE_PATH + ##$env:CPLUS_INCLUDE_PATH = $env:CONDA_PREFIX + '\\include;' + $env:CONDA_PREFIX + '\\Library\\include;' + $env:CPLUS_INCLUDE_PATH + ##$env:INCLUDE = $env:CONDA_PREFIX + '\\include;' + $env:CONDA_PREFIX + '\\Library\\include;' + $env:INCLUDE + ##$env:CL='/I\' + $env:CONDA_PREFIX + '\\Library\\include' + $env:Path = "$env:CONDA_PREFIX\\bin; $env:CONDA_PREFIX\\Library\\bin; $env:CONDA_PREFIX\\nvvm\\bin; $env:CONDA_PREFIX\\Library\\nvvm\\bin;" + $env:Path + #echo "$env:CONDA_PREFIX\\Library\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + #echo "$env:CONDA_PREFIX\\Library\\nvvm\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + Get-ChildItem -Path ~ -Filter "nvcc.exe" -Recurse -ErrorAction SilentlyContinue + nvcc.exe --version + Get-ChildItem -Path ~ -Filter "cicc.exe" -Recurse -ErrorAction SilentlyContinue + Get-ChildItem -Path ~ -Filter "cudart_static.lib" -Recurse -ErrorAction SilentlyContinue + if (-not (Test-Path -Path "$env:CONDA_PREFIX\\include")) { + New-Item -ItemType SymbolicLink -Path "$env:CONDA_PREFIX\\include" -Target "$env:CONDA_PREFIX\\Library\\include" + } else { echo "Warning: include directory already existed! Not creating symlink."} + if (-not (Test-Path -Path "$env:CONDA_PREFIX\\bin")) { + New-Item -ItemType SymbolicLink -Path "$env:CONDA_PREFIX\\bin" -Target "$env:CONDA_PREFIX\\Library\\bin" + } else { echo "Warning: bin directory already existed! Not creating symlink."} + if (-not (Test-Path -Path "$env:CONDA_PREFIX\\nvvm")) { + New-Item -ItemType SymbolicLink -Path "$env:CONDA_PREFIX\\nvvm" -Target "$env:CONDA_PREFIX\\Library\\nvvm" + } else { echo "Warning: nvvm directory already existed! Not creating symlink."} + if (-not (Test-Path -Path "$env:CONDA_PREFIX\\lib")) { + New-Item -ItemType SymbolicLink -Path "$env:CONDA_PREFIX\\lib" -Target "$env:CONDA_PREFIX\\Library\\lib" # -Force + } else { + echo "Warning: lib directory already existed! Not creating symlink." + if (-not (Test-Path -Path "$env:CONDA_PREFIX\\lib\\$cpuArch")) { + if ([int]$cudaMajor -ge 13) { + New-Item -ItemType SymbolicLink -Path "$env:CONDA_PREFIX\\lib\\$cpuArch" -Target "$env:CONDA_PREFIX\\Library\\lib\\$cpuArch" + } else { + New-Item -ItemType SymbolicLink -Path "$env:CONDA_PREFIX\\lib\\cpuArch" -Target "$env:CONDA_PREFIX\\Library\\lib" + } + } else { echo "Warning: lib\$cpuArch directory already existed! Not creating symlink."} + } + if (-not (Test-Path -Path "$env:CONDA_PREFIX\\lib64")) { + New-Item -ItemType SymbolicLink -Path "$env:CONDA_PREFIX\\lib64" -Target "$env:CONDA_PREFIX\\Library\\lib" # -Force + } else { echo "Warning: lib64 directory already existed! Not creating symlink."} + #Get-ChildItem -Path "C:\Users\runneradmin\miniconda3\envs\llamacpp" -Directory -Recurse -ErrorAction SilentlyContinue + } + Get-ChildItem -Path ~ -Filter "cuda_runtime.h" -Recurse -ErrorAction SilentlyContinue + + # Applying Windows CUDA DLL Patch from PR 2083 + curl -L -O https://github.com/abetlen/llama-cpp-python/pull/2083.patch + git apply 2083.patch # git am + + #$env:VERBOSE = '1' + #$env:NVCCFLAGS="-allow-unsupported-compiler" + #$env:FORCE_CMAKE=1 + #$env:MAX_JOBS=4 + #$env:CMAKE_BUILD_PARALLEL_LEVEL=4 + #$env:CMAKE_GENERATOR_TOOLSET = $env:CUDA_HOME + $env:CMAKE_ARGS = '-DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES=all' + $env:CMAKE_ARGS = "-DGGML_CUDA_FORCE_MMQ=ON $env:CMAKE_ARGS" + #if ($env:RUNNER_OS -eq 'Windows') { + ##$env:CMAKE_ARGS = "-DCMAKE_CUDA_COMPILER='$env:CONDA_PREFIX\\Library\\bin' $env:CMAKE_ARGS" + ##$env:CMAKE_ARGS = "-DCMAKE_LINKER_FLAGS='/LIBPATH:$env:CONDA_PREFIX\\Library\\lib' $env:CMAKE_ARGS" + #} + #$env:CMAKE_ARGS = "-DCMAKE_CUDA_FLAGS='-allow-unsupported-compiler' $env:CMAKE_ARGS" + # if ($env:AVXVER -eq 'AVX') { + $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off' + # } + # if ($env:AVXVER -eq 'AVX512') { + # $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX512=on' + # } + # if ($env:AVXVER -eq 'basic') { + # $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX=off -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off' + # } + python -m build --wheel + # write the build tag to the output + Write-Output "CUDA_VERSION=$cudaVersion" >> $env:GITHUB_ENV + + - uses: softprops/action-gh-release@v2 + with: + files: dist/* + # Set tag_name to -cu + tag_name: ${{ github.ref_name }}-cu${{ env.CUDA_VERSION }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 95f6e5a272..5feb7f3702 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,13 +16,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: "3.9" - name: Install huggingface-hub run: pip install huggingface-hub - name: Download model - run: huggingface-cli download ${{ env.REPO_ID }} ${{ env.MODEL_FILE }} + run: hf download ${{ env.REPO_ID }} ${{ env.MODEL_FILE }} - name: Cache model uses: actions/cache@v4 with: @@ -34,14 +34,45 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] steps: - uses: actions/checkout@v4 with: submodules: "recursive" - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + - name: Restore model cache + uses: actions/cache@v4 + with: + path: ~/.cache/huggingface/hub + key: ${{ runner.os }}-model-${{ env.REPO_ID }}-${{ env.MODEL_FILE }} + - name: Install dependencies (Linux/MacOS) + run: | + python -m pip install --upgrade pip + python -m pip install uv + python -m uv pip install -e .[all] --verbose + shell: bash + - name: Test with pytest + run: | + python -m pytest + + build-linux-arm: + needs: download-model + runs-on: ubuntu-24.04-arm + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} cache: 'pip' @@ -65,14 +96,14 @@ jobs: runs-on: windows-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] steps: - uses: actions/checkout@v4 with: submodules: "recursive" - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} cache: 'pip' @@ -96,17 +127,17 @@ jobs: build-macos: needs: download-model - runs-on: macos-13 + runs-on: macos-14 strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] steps: - uses: actions/checkout@v4 with: submodules: "recursive" - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} cache: 'pip' @@ -137,14 +168,14 @@ jobs: build-macos-metal: needs: download-model - runs-on: macos-13 + runs-on: macos-14 steps: - uses: actions/checkout@v4 with: submodules: "recursive" - name: Set up Python 3.9 - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: "3.9" diff --git a/scripts/get-releases.sh b/scripts/get-releases.sh index 4c904da78c..9a2fe11458 100755 --- a/scripts/get-releases.sh +++ b/scripts/get-releases.sh @@ -15,7 +15,7 @@ get_all_releases() { while true; do response=$(curl -s "${headers[@]}" \ - "https://api.github.com/repos/abetlen/llama-cpp-python/releases?page=$page&per_page=$per_page") + "https://api.github.com/repos/anr2me/llama-cpp-python/releases?page=$page&per_page=$per_page") # Check if the response is valid JSON if ! echo "$response" | jq empty > /dev/null 2>&1; then diff --git a/scripts/releases-to-pep-503.sh b/scripts/releases-to-pep-503.sh index 71910efcbf..b79012dc4a 100755 --- a/scripts/releases-to-pep-503.sh +++ b/scripts/releases-to-pep-503.sh @@ -12,6 +12,7 @@ log_info() { echo "INFO: $1" } +log_info "$1" # Get output directory or default to index/whl/cpu output_dir=${1:-"index/whl/cpu"} @@ -56,6 +57,13 @@ EOF # Filter releases by pattern releases=$(grep -E "$pattern" "$current_dir/all_releases.txt") +log_info "Test1" +cat "$current_dir/all_releases.txt" +log_info "Test2" +echo "$releases" +log_info "Test3" +echo "$pattern" +log_info "Test4" # Prepare curl headers headers=('--header' 'Accept: application/vnd.github.v3+json') @@ -68,7 +76,7 @@ headers+=('--header' 'content-type: application/json') for release in $releases; do log_info "Processing release: $release" response=$(curl -s "${headers[@]}" \ - "https://api.github.com/repos/abetlen/llama-cpp-python/releases/tags/$release") + "https://api.github.com/repos/anr2me/llama-cpp-python/releases/tags/$release") if [ -z "$response" ]; then log_error "Empty response from GitHub API for release $release" @@ -96,6 +104,7 @@ for release in $releases; do echo "
" >> "$output_dir/llama-cpp-python/index.html" done done +log_info "Test5" echo " " >> "$output_dir/llama-cpp-python/index.html" echo "" >> "$output_dir/llama-cpp-python/index.html"