Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
ff3c105
Add ONNX Runtime neural net backend
seniorfish Jul 31, 2026
30a01b8
Merge remote-tracking branch 'origin/master' into feature/onnx-backend
seniorfish Jul 31, 2026
46d1842
@
seniorfish Aug 1, 2026
4f86efa
Skip applyScale8ToReduceActivations in ONNX backend to avoid MISH_SCA…
seniorfish Aug 1, 2026
815378d
@
seniorfish Aug 2, 2026
cac464b
Remove deprecated onnxOpenVINOEnableNPUFastCompile; document onnxOpen…
seniorfish Aug 4, 2026
3e71064
Remove alignInputsToConsumptionOrder; declare inputs unconditionally
seniorfish Aug 4, 2026
2e2d772
Remove per-server-thread max batch size feature
seniorfish Aug 5, 2026
f6767d5
Address review feedback and default transformer trunk to NHWC
seniorfish Aug 5, 2026
c2e5552
Restore applyScale8ToReduceActivations in the ONNX backend
seniorfish Aug 5, 2026
8883c4e
Scope SetIntraOpNumThreads(1) to the OpenVINO provider
seniorfish Aug 5, 2026
9f1d598
Drop the deprecated OpenVINO device_id option; map device index into …
seniorfish Aug 5, 2026
ce8c146
Add ONNX backend CI workflow for the fork
seniorfish Aug 5, 2026
e77c88d
Fix ONNX CI: onnxruntime has no v1.29.0 tag
seniorfish Aug 5, 2026
c2cedbc
Merge origin/master into feature/onnx-backend
seniorfish Aug 5, 2026
1bdb258
Document InputMeta position in the OpenVINO input-order comment
seniorfish Aug 5, 2026
3a8ddf2
Fix unexpanded $env:GITHUB_WORKSPACE in CMake -D paths
seniorfish Aug 5, 2026
0909331
Restrict CI trigger back to the PR branch
seniorfish Aug 5, 2026
7b91582
Clean up ONNX backend: plain-bool scale8 flag, drop dead field, warn …
seniorfish Aug 5, 2026
895b266
Document execution-provider verification status; hoist ONNX provider …
seniorfish Aug 5, 2026
22960c0
Add Windows ONNX CPU build CI using the prebuilt ORT package
seniorfish Aug 5, 2026
e99d4d3
Add DirectML execution provider support to the ONNX backend
seniorfish Aug 5, 2026
f7c383b
Consolidate ONNX CI into one matrix workflow with reusable composite …
seniorfish Aug 5, 2026
2346f94
Add Linux CPU backend to the ONNX CI matrix
seniorfish Aug 5, 2026
166a435
Add TensorRT backend to the ONNX CI and cache ORT builds
seniorfish Aug 6, 2026
db0a622
Merge upstream master (v1.17.2) into feature/onnx-backend
seniorfish Aug 6, 2026
eff9bd7
Various fixes, simplify onnx section in compiling doc
lightvector Aug 9, 2026
f205351
Report onnx backend in contribute
lightvector Aug 9, 2026
2b8c3b5
Add better neural net error check for contribute
lightvector Aug 9, 2026
49d8d54
Allow dumping and directly running onnx files
lightvector Aug 10, 2026
0856575
Fix logit bound term for zero logit heads
lightvector Aug 5, 2026
0a30a49
Fix rules about territory in ko mouths in seki
lightvector Aug 8, 2026
c1727bd
Fix onnx for rules change flag and shore up onnx known param checks
lightvector Aug 10, 2026
6a1757f
Factor protobuf in cmake
lightvector Aug 10, 2026
dc7dd78
Add ROCm backend for AMD GPUs via HIP and MIOpen
Looong01 Jul 7, 2026
b90b1bb
Rename overly long files to prevent path length issues on windows
lightvector Aug 10, 2026
7e5bbbd
Openvino backend names
lightvector Aug 11, 2026
d7d28b3
Fix segfault in evalsgf
lightvector Aug 11, 2026
c002c97
Many rocm fixes and refactoring
lightvector Aug 10, 2026
ec7470e
Various cuda/rocm fixes
lightvector Aug 12, 2026
439a760
Greatly reduce cuda transformer mem usage
lightvector Aug 11, 2026
d558dad
A few more rocm fixes
lightvector Aug 12, 2026
a193414
Bump batch size cap slightly
lightvector Aug 12, 2026
392cf17
Merge backend work
lightvector Aug 12, 2026
5826921
Update contributors
lightvector Aug 12, 2026
73f6706
Attempt fixing build issue
lightvector Aug 12, 2026
66b12ac
Try fixing build issue again
lightvector Aug 12, 2026
aadfa4b
fix(onnx): log DirectML init failure cause and fix guidance
seniorfish Aug 13, 2026
976b6e9
ci(onnx): ship DirectML.dll in DirectML release artifacts
seniorfish Aug 13, 2026
26ea773
refactor(onnx)!: slim down OpenVINO config options
seniorfish Aug 13, 2026
0b249c2
Small cmake fixes for rocm
lightvector Aug 14, 2026
ccdec95
Small fixes for onnx backend
lightvector Aug 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 166 additions & 0 deletions .github/actions/onnx-build-katago/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
name: Build and test KataGo (ONNX backend)
description: >
Configure, build, run `katago runtests`, verify the ORT backend is wired up, and stage a
self-contained runnable directory under release/ (katago binary + ORT runtime +
execution-provider runtimes + example config). Expects onnx-prepare-ort to have populated
deps/install/{ort,protobuf,zlib} and the MSVC environment to be ready on Windows.
inputs:
ort_root:
description: Path to the ORT install tree (deps/install/ort)
required: true
ep:
description: Execution provider, used for EP-specific runtime staging
required: true

runs:
using: composite
steps:
- name: Configure KataGo (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cmake -S cpp -B cpp\build -G Ninja -DCMAKE_BUILD_TYPE=Release -DUSE_BACKEND=ONNX `
-DONNXRUNTIME_ROOT=${{ inputs.ort_root }} `
-DProtobuf_PROTOC_EXECUTABLE=${{ github.workspace }}\deps\install\protobuf\bin\protoc.exe `
-DProtobuf_INCLUDE_DIR=${{ github.workspace }}\deps\install\protobuf\include `
-DProtobuf_LIBRARY=${{ github.workspace }}\deps\install\protobuf\lib\libprotobuf.lib `
-DZLIB_INCLUDE_DIR=${{ github.workspace }}\deps\install\zlib\include `
-DZLIB_LIBRARY=${{ github.workspace }}\deps\install\zlib\lib\zlibstatic.lib

- name: Configure KataGo (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
# Use $GITHUB_WORKSPACE (not the github.workspace context): it resolves correctly
# both on plain runners (/home/runner/...) and inside a container job (/__w/...).
cmake -S cpp -B cpp/build -G Ninja -DCMAKE_BUILD_TYPE=Release -DUSE_BACKEND=ONNX \
-DONNXRUNTIME_ROOT="$GITHUB_WORKSPACE/deps/install/ort" \
-DProtobuf_PROTOC_EXECUTABLE="$GITHUB_WORKSPACE/deps/install/protobuf/bin/protoc" \
-DProtobuf_INCLUDE_DIR="$GITHUB_WORKSPACE/deps/install/protobuf/include" \
-DProtobuf_LIBRARY="$GITHUB_WORKSPACE/deps/install/protobuf/lib/libprotobuf.a" \
-DZLIB_INCLUDE_DIR="$GITHUB_WORKSPACE/deps/install/zlib/include" \
-DZLIB_LIBRARY="$GITHUB_WORKSPACE/deps/install/zlib/lib/libz.a"

- name: Build KataGo
shell: bash
run: cmake --build cpp/build

- name: Run tests
shell: bash
run: |
if [ "${{ runner.os }}" = "Windows" ]; then ./cpp/build/katago.exe runtests; else ./cpp/build/katago runtests; fi

- name: Run tiny neural net tests (real inference, CPU EP)
shell: bash
run: |
# runtests never creates an Ort::Session (it uses debugSkipNeuralNet), so this is
# the step that actually exercises ORT session creation + inference through the
# emitted graph, using the embedded tiny model. It runs on the CPU execution
# provider, which is present in every ORT build regardless of the EP row.
mkdir -p tinynn-scratch
if [ "${{ runner.os }}" = "Windows" ]; then ./cpp/build/katago.exe runtinynntests tinynn-scratch 1.0; else ./cpp/build/katago runtinynntests tinynn-scratch 1.0; fi

- name: Run onnx model file unit tests
shell: bash
run: |
# Unit tests for the .onnx model file reader: metadata validation, graph IO signature
# checks, and a dump/load round trip of a real model's metadata through the emitter.
if [ "${{ runner.os }}" = "Windows" ]; then KATAGO=./cpp/build/katago.exe; else KATAGO=./cpp/build/katago; fi
mkdir -p onnx-scratch
$KATAGO runonnxmodelfiletests onnx-scratch cpp/tests/models/g170-b6c96-s175395328-d26788732.bin.gz

- name: Dump ONNX model files and run them (CPU EP)
shell: bash
run: |
# Round-trip check for `dumponnx` and for loading a .onnx as a model file: the same net
# loaded as .bin.gz, where the graph is emitted at startup, and as .onnx, where it is read
# from the file, must evaluate identically. Covers a convnet and a transformer, since the
# emitter's transformer path is separate code. runnnsymmetriestest uses a 13x13 buffer and
# the board size is baked into the graph, so dump at that size.
if [ "${{ runner.os }}" = "Windows" ]; then KATAGO=./cpp/build/katago.exe; else KATAGO=./cpp/build/katago; fi
mkdir -p onnx-scratch
FAILED=0
for MODEL in g170-b6c96-s175395328-d26788732 b7c96h6kv3qk32v16tflrs-fson-bnh; do
echo "=== $MODEL"
BINGZ=cpp/tests/models/$MODEL.bin.gz
$KATAGO dumponnx -model $BINGZ -out onnx-scratch/$MODEL.onnx -nn-x-len 13 -nn-y-len 13
$KATAGO runnnsymmetriestest $BINGZ false false false > onnx-scratch/${MODEL}_bingz.txt
$KATAGO runnnsymmetriestest onnx-scratch/$MODEL.onnx false false false > onnx-scratch/${MODEL}_onnx.txt
# Drop the log lines that legitimately differ (rand seed, model path, graph source).
FILTER='nnModelFile|nnRandSeed|ONNX backend|Building internal onnx'
grep -Ev "$FILTER" onnx-scratch/${MODEL}_bingz.txt > onnx-scratch/a.txt
grep -Ev "$FILTER" onnx-scratch/${MODEL}_onnx.txt > onnx-scratch/b.txt
if diff onnx-scratch/a.txt onnx-scratch/b.txt; then
echo "$MODEL: dumped .onnx reproduces the .bin.gz evaluations exactly"
else
echo "$MODEL: evaluations from the dumped .onnx do not match the .bin.gz"
FAILED=1
fi
done
exit $FAILED

- name: Verify backend wiring
shell: bash
run: |
# Command substitution flattens multi-line output: testing the raw array for a
# substring is unreliable, so check the flattened string with grep.
if [ "${{ runner.os }}" = "Windows" ]; then OUT=$(cpp/build/katago.exe version 2>&1); else OUT=$(cpp/build/katago version 2>&1); fi
if ! echo "$OUT" | grep -q "ONNX Runtime"; then
echo "unexpected backend version output: $OUT"
exit 1
fi
echo "$OUT" | head -8

- name: Stage release directory (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path "release" | Out-Null
Copy-Item "cpp\build\katago.exe" "release\"
Get-ChildItem "deps\install\ort\bin\*.dll" -ErrorAction SilentlyContinue | Copy-Item -Destination "release\" -Force
# EP-specific runtime DLLs
if ("${{ inputs.ep }}" -eq "openvino") {
Get-ChildItem "deps\install\ort\lib\onnxruntime_providers_openvino.dll" -ErrorAction SilentlyContinue | Copy-Item -Destination "release\" -Force
$ovBin = "deps\openvino\runtime\bin\intel64\Release"
if (Test-Path $ovBin) {
Copy-Item "$ovBin\*.dll" "release\"
Copy-Item "$ovBin\*.json" "release\"
} else {
Write-Warning "OpenVINO runtime bin dir not found at $ovBin"
}
$tbb = Get-ChildItem "deps\openvino" -Recurse -Filter "tbb12.dll" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($tbb) { Copy-Item $tbb.FullName "release\" }
}
# DirectML.dll is delay-loaded by ORT and is NOT inside onnxruntime.dll, so it must be
# shipped next to it or the DirectML provider cannot initialize (Windows 10's inbox
# DirectML is too old; the app-local copy from Microsoft.AI.DirectML overrides it).
if ("${{ inputs.ep }}" -eq "directml") {
if (Test-Path "deps\directml\DirectML.dll") {
Copy-Item "deps\directml\DirectML.dll" "release\"
} else {
throw "DirectML.dll not found at deps\directml\DirectML.dll - the artifact would fail DirectML init on Windows 10"
}
}
Copy-Item "cpp\configs\gtp_example.cfg" "release\"
Write-Output "--- release contents ---"
Get-ChildItem "release" | Select-Object Name, Length

- name: Stage release directory (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
mkdir -p release
cp cpp/build/katago release/
cp deps/install/ort/lib/libonnxruntime*.so* release/ 2>/dev/null || true
# EP-specific runtime libs (TensorRT/CUDA/ROCm, etc.) go here once wired up.
cp cpp/configs/gtp_example.cfg release/
# katago's build-time DT_RUNPATH points at the CI workspace
# (deps/install/ort/lib), which no longer exists once the artifact is downloaded
# elsewhere. Rewrite it to $ORIGIN so the binary finds the sibling
# libonnxruntime.so* in the release dir, matching the Windows DLL convention.
if ! command -v patchelf >/dev/null 2>&1; then
# Ubuntu runners have sudo; the NGC TensorRT container runs as root without it.
if command -v sudo >/dev/null 2>&1; then sudo apt-get install -y patchelf >/dev/null; else apt-get install -y patchelf >/dev/null; fi
fi
patchelf --set-rpath '$ORIGIN' release/katago
ls -la release
Loading
Loading