Update model builder for gpt-oss #6949
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Windows CUDA x64 Build" | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| - rel-* | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }} | |
| cancel-in-progress: true | |
| env: | |
| AZCOPY_AUTO_LOGIN_TYPE: MSI | |
| AZCOPY_MSI_CLIENT_ID: d712a4c7-a0cf-4e87-af75-31510eba0a8e | |
| cuda_dir: "${{ github.workspace }}\\cuda_sdk" | |
| cuda_version: "12.8" | |
| CUDA_PATH: ${{ github.workspace }}\\cuda_sdk\\v12.8 | |
| binaryDir: 'build/cuda/win-x64' | |
| ORT_NIGHTLY_REST_API: "https://feeds.dev.azure.com/aiinfra/PublicPackages/_apis/packaging/Feeds/ORT-Nightly/packages?packageNameQuery=Microsoft.ML.OnnxRuntime.Gpu.Windows&api-version=6.0-preview.1" | |
| ORT_PACKAGE_NAME: "Microsoft.ML.OnnxRuntime.Gpu.Windows" | |
| jobs: | |
| windows-cuda-x64-build: | |
| runs-on: ["self-hosted", "1ES.Pool=onnxruntime-genai-Win2022-GPU-A10"] | |
| steps: | |
| - name: Checkout OnnxRuntime GenAI repo | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: true | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.11.x' | |
| architecture: 'x64' | |
| - name: Setup VCPKG | |
| uses: microsoft/onnxruntime-github-actions/setup-build-tools@v0.0.8 | |
| with: | |
| vcpkg-version: '2025.03.19' | |
| vcpkg-hash: '17e96169cd3f266c4716fcdc1bb728e6a64f103941ece463a2834d50694eba4fb48f30135503fd466402afa139abc847ef630733c442595d1c34979f261b0114' | |
| cmake-version: '3.31.6' | |
| cmake-hash: '0f1584e8666cf4a65ec514bd02afe281caabf1d45d2c963f3151c41484f457386aa03273ab25776a670be02725354ce0b46f3a5121857416da37366342a833a0' | |
| add-cmake-to-path: 'true' | |
| disable-terrapin: 'false' | |
| - name: Download cuda | |
| run: | | |
| azcopy.exe cp --recursive "https://lotusscus.blob.core.windows.net/models/cuda_sdk/v${{ env.cuda_version }}" ${{ env.cuda_dir}} | |
| - uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Download OnnxRuntime Nightly | |
| shell: pwsh | |
| run: | | |
| $resp = Invoke-RestMethod "${{ env.ORT_NIGHTLY_REST_API }}" | |
| $ORT_NIGHTLY_VERSION = "1.26.0" | |
| Write-Host "$ORT_NIGHTLY_VERSION" | |
| "ORT_NIGHTLY_VERSION=$ORT_NIGHTLY_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| nuget install ${{ env.ORT_PACKAGE_NAME }} -version $ORT_NIGHTLY_VERSION -ExcludeVersion -NonInteractive | |
| - run: Get-ChildItem ${{ env.ORT_PACKAGE_NAME }} -Recurse | |
| continue-on-error: true | |
| - name: Extract OnnxRuntime library and header files | |
| run: | | |
| mkdir ort/lib | |
| move ${{ env.ORT_PACKAGE_NAME }}/buildTransitive/native/include ort/ | |
| move ${{ env.ORT_PACKAGE_NAME }}/runtimes/win-x64/native/* ort/lib/ | |
| - name: Install Rust Toolchain | |
| run: | | |
| $exePath = "$env:TEMP\rustup-init.exe" | |
| (New-Object Net.WebClient).DownloadFile('https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe', $exePath) | |
| & $exePath -y --default-toolchain=1.86.0 | |
| Add-Content $env:GITHUB_PATH "$env:USERPROFILE\.cargo\bin" | |
| # Restore sccache from a previous run so the C/C++ compile step gets cache hits. | |
| # restore-keys allow a partial match from any prior run on this branch or main. | |
| - name: Restore sccache | |
| id: restore-sccache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: ${{ github.workspace }}\sccache | |
| key: sccache-win-cuda-${{ hashFiles('**/CMakePresets.json', '**/CMakeLists.txt') }} | |
| restore-keys: | | |
| sccache-win-cuda- | |
| - name: Install sccache | |
| run: | | |
| $version = "0.9.0" | |
| $url = "https://github.com/mozilla/sccache/releases/download/v${version}/sccache-v${version}-x86_64-pc-windows-msvc.tar.gz" | |
| $dest = "$env:TEMP\sccache.tar.gz" | |
| Invoke-WebRequest -Uri $url -OutFile $dest | |
| tar -xzf $dest -C "$env:TEMP" | |
| $binDir = "$env:USERPROFILE\sccache_bin" | |
| New-Item -ItemType Directory -Force -Path $binDir | Out-Null | |
| Copy-Item "$env:TEMP\sccache-v${version}-x86_64-pc-windows-msvc\sccache.exe" "$binDir\sccache.exe" | |
| echo $binDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| & "$binDir\sccache.exe" --version | |
| - name: Configure CMake | |
| run: | | |
| $env:SCCACHE_DIR = "${{ github.workspace }}\sccache" | |
| # Limit CUDA archs to SM 86 (matches the A10 runner GPU) to keep CI build | |
| # time and memory usage manageable. The full SM list in CMakePresets.json | |
| # is intended for release packaging, not CI validation. | |
| cmake --preset windows_x64_cuda_release -T cuda=${{ env.cuda_dir }}\\v${{ env.cuda_version }} -DTEST_PHI2=True -DTEST_QWEN_2_5=True -DENABLE_JAVA=ON -DUSE_GUIDANCE=ON ` | |
| -DCMAKE_CUDA_ARCHITECTURES=86-real ` | |
| -DCMAKE_C_COMPILER_LAUNCHER=sccache ` | |
| -DCMAKE_CXX_COMPILER_LAUNCHER=sccache | |
| - name: Build with CMake | |
| run: | | |
| $env:SCCACHE_DIR = "${{ github.workspace }}\sccache" | |
| cmake --build --preset windows_x64_cuda_release --parallel | |
| cmake --build --preset windows_x64_cuda_release --target PyPackageBuild | |
| - name: Show sccache stats | |
| run: sccache --show-stats | |
| # Save sccache inline (before the test steps) so the cache is written even if | |
| # a later step kills the runner. Skip if we had a full key hit (nothing new to store). | |
| - name: Save sccache | |
| if: steps.restore-sccache.outputs.cache-hit != 'true' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: ${{ github.workspace }}\sccache | |
| key: sccache-win-cuda-${{ hashFiles('**/CMakePresets.json', '**/CMakeLists.txt') }} | |
| - name: Add CUDA to PATH | |
| run: | | |
| echo "${{ env.cuda_dir }}\\v${{ env.cuda_version }}\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| - name: Build the C Examples | |
| run: | | |
| cmake -S examples\c -B examples\c\build ` | |
| -DMODEL_QA=ON -DMODEL_CHAT=ON -DMODEL_MM=ON -DWHISPER=ON -DNEMOTRON_SPEECH=ON ` | |
| "-DORT_INCLUDE_DIR=$env:GITHUB_WORKSPACE\ort\include" ` | |
| "-DORT_LIB_DIR=$env:GITHUB_WORKSPACE\ort\lib" ` | |
| "-DOGA_INCLUDE_DIR=$env:GITHUB_WORKSPACE\src" ` | |
| "-DOGA_LIB_DIR=$env:GITHUB_WORKSPACE\$env:binaryDir\Release" | |
| cmake --build examples\c\build --config Release | |
| - name: Install the Python Wheel and Test Dependencies | |
| run: | | |
| python -m pip install -r test\python\requirements.txt | |
| python -m pip install -r test\python\cuda\torch\requirements.txt | |
| python -m pip install -r test\python\cuda\ort\requirements.txt | |
| python -m pip install (Get-ChildItem ("$env:binaryDir\wheel\*.whl")) --no-deps | |
| - name: Run the Java tests | |
| run: | | |
| ctest --test-dir $env:binaryDir\src\java --build-config Release --verbose --timeout 10800 | |
| - name: Run the Python Tests | |
| run: | | |
| python test/python/test_onnxruntime_genai.py --cwd "test\python" --test_models "test\models" --e2e | |
| - name: Verify Build Artifacts | |
| if: always() | |
| continue-on-error: true | |
| run: |2 | |
| Get-ChildItem -Path $env:GITHUB_WORKSPACE\$env:binaryDir -Recurse | |
| - name: Build the C# API and Run the C# Tests | |
| run: | | |
| $env:PATH = "${{ env.cuda_dir }}\\v${{ env.cuda_version }}\\bin;" + $env:PATH | |
| cd test\csharp | |
| dotnet test /p:Configuration=release /p:NativeBuildOutputDir="$env:GITHUB_WORKSPACE\$env:binaryDir\Release" /p:OrtLibDir="$env:GITHUB_WORKSPACE\ort\lib" | |
| - name: Build the C# Examples | |
| run: | | |
| cd examples\csharp\ModelChat | |
| dotnet build -c Release | |
| cd ..\ModelMM | |
| dotnet build -c Release | |
| - name: Test the C# LLM Example with Tool Calling | |
| run: | | |
| python test\python\special_tokens.py -p test\models\qwen-2.5-0.5b\int4\cpu\tokenizer.json -s "<tool_call>" -e "</tool_call>" | |
| .\examples\csharp\ModelChat\bin\Release\net8.0\ModelChat.exe -m test\models\qwen-2.5-0.5b\int4\cpu\ -e cpu --response_format lark_grammar --tools_file test\models\tool-definitions\weather.json --tool_call_start "<tool_call>" --tool_call_end "</tool_call>" --user_prompt "What is the weather in Redmond, WA?" --tool_output --non_interactive --verbose | |
| - name: Prepend CUDA to PATH and Run tests | |
| run: |- | |
| $env:PATH = "${{ env.cuda_dir }}\\v${{ env.cuda_version }}\\bin;" + $env:PATH | |
| echo "Current PATH variable is: $env:PATH" | |
| copy $env:GITHUB_WORKSPACE\ort\lib\* .\$env:binaryDir\Release | |
| & .\$env:binaryDir\Release\unit_tests.exe |