You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Discussion / Feedback] ONNX Backend: Benchmarks, Questions, and Issues #1238
This issue is to collect discussions and feedback regarding the ONNX backend. Feel free to post your thoughts.
#1234 has been merged, bringing large speedups on Intel GPUs and NPUs, as well as a generic DirectML backend that may perform better than OpenCL on the latest transformer models.
The OpenVINO backend is currently only built when lightvector manually triggers a run or tags a commit. If you want to test it, you can use https://github.com/seniorfish/KataGo/releases/tag/v1.17.2-onnx-openvino, but note that this is not the latest version. For configuration, you can refer to gtp_example.cfg.
Future plans:
There are reports that the NPU backend is not working on the largest b40 net; I will investigate this. If the backend crashes on your device, please let me know.
Optimize the OpenVINO batching strategy and fine-tune config options, which may require more benchmark data across various processors.
onnxbackend.cpp seems a bit messy with many special cases in the code. I might look into refactoring it for better maintainability as more execution providers might be added in the future.
On the NPU, for b11c768h12nbt3, onnxTransformerNHWC=false provides a 3× speedup; for b28c512nbt and b18c384nbt, onnxSkipScale8=true provides a 4× speedup.
On the GPU, for b11c768h12nbt3, onnxTransformerNHWC=true provides a 3× speedup; for b40c768nbt, b28c512nbt, and b18c384nbt, onnxSkipScale8=true provides a 2× speedup. The performance starts to decline with 15 threads or more, and the speed with 20 threads is below 5 v/s.
from #1234 (comment) @foxrainowo It looks like a problem related to model size, since only the largest network crashed. What processor model are you using? How much memory do you have for npu?
To answer your question: the purpose of onnxSkipScale8 is to work around the workaround(means disables it) that skips FP16 activation scaling. If the intermediate activations of a large convnet get too large, they overflow to inf/NaN under FP16 inference, or their precision degrades sharply near the upper limit (FP16 only has about 3 decimal digits of precision). KataGo uses the mathematically equivalent transformation of "dividing the whole network's activations by 8" to keep activations in a safe range — that's the scale8 workaround. However, after deep profiling of the code's performance, we found that when this option is enabled, it blocks operator fusion and significantly lowers performance on convnets (which you measured). The cost of enabling it is that under extreme conditions (very large boards) it might overflow and produce invalid values, but in that case KataGo should fail loud, and testing shows this problem is hardly hit on a normal 19x19 board. This option defaults to false, meaning slower speed but higher stability; you can enable it in daily use for better performance, and it is forcibly disabled when contributing. This option does not affect transformer models. See 4f86efa and c2e5552 for details.
The purpose of onnxTransformerNHWC is that for models containing transformer blocks, the entire trunk stack of blocks runs in NHWC (channel-last, [N,H,W,C]) layout instead of NCHW. This should improve memory access locality. It defaults to true. See onnxmodelbuilder.cpp:1190-1204 for details. According to your benchmarks, this option seems to slow down NPU performance when enabled; I'll look into that when I have time.
@seniorfish
Thank you for your development and answer! I am using Intel® Core™ Ultra 5 Processor 228V, Intel® Arc™ 130V GPU, Intel® AI Boost. The GPU and NPU share 18 GB of memory. I have never met memory lack when I running match, I suspect that it is more likely to be a software issue than a hardware problem.
This is a separate issue from the ones discussed above. The way "onnxProvider" is currently declared in "default_gtp.cfg" is confusing. I'm referring to the config file in "katago-v1.18.1-onnx-openvino-linux-x64.zip".
At the end of the config file, we find the lines:
# This package runs on Intel GPUs and NPUs via OpenVINO.
onnxProvider = openvino
However, the proper place to define the onnxProvider appears to be in the "ONNX Runtime backend settings" block, where we find:
# onnxProvider = ...
It is commented out, so does not conflict. But trying to follow the setup instructions, I actually uncommented this line to define openvino as the provider and was then confronted with an error message about defining twice.
I suggest to remove the lines at the end and to declare onnxProvider in the "ONNX Runtime backend settings" block.
@Yodo13 Sorry about that, it was an issue with the preparation of the files packaging for that specific build. I attempted to reupload fixed versions now, I think it should be fixed.
@HackYardoThis should answer your first two questions. In short:
This implementation reuses existing modules. Also, Looong01's branch has been synced with this one.
Performance gains are hardware-dependent, so there is no fixed "speedup rate." If you are using an Intel GPU, the OpenVINO backend brings a significant speedup to the transformer model (see the benchmark results in the link for details).
DirectML requires DirectX 12, while OpenVINO requires Intel hardware. You don't need to install ONNX separately, as the required libraries are already shipped with the release and automatically loaded at runtime. Just ensure your hardware meets the requirements, download the corresponding backend build, and configure the settings properly.
Activity
seniorfish commentedon Aug 14, 2026
from #1234 (comment)
@foxrainowo It looks like a problem related to model size, since only the largest network crashed. What processor model are you using? How much memory do you have for npu?
To answer your question: the purpose of
onnxSkipScale8is to work around the workaround(means disables it) that skips FP16 activation scaling. If the intermediate activations of a large convnet get too large, they overflow to inf/NaN under FP16 inference, or their precision degrades sharply near the upper limit (FP16 only has about 3 decimal digits of precision). KataGo uses the mathematically equivalent transformation of "dividing the whole network's activations by 8" to keep activations in a safe range — that's the scale8 workaround. However, after deep profiling of the code's performance, we found that when this option is enabled, it blocks operator fusion and significantly lowers performance on convnets (which you measured). The cost of enabling it is that under extreme conditions (very large boards) it might overflow and produce invalid values, but in that case KataGo should fail loud, and testing shows this problem is hardly hit on a normal 19x19 board. This option defaults to false, meaning slower speed but higher stability; you can enable it in daily use for better performance, and it is forcibly disabled when contributing. This option does not affect transformer models. See 4f86efa and c2e5552 for details.The purpose of
onnxTransformerNHWCis that for models containing transformer blocks, the entire trunk stack of blocks runs in NHWC (channel-last, [N,H,W,C]) layout instead of NCHW. This should improve memory access locality. It defaults to true. See onnxmodelbuilder.cpp:1190-1204 for details. According to your benchmarks, this option seems to slow down NPU performance when enabled; I'll look into that when I have time.seniorfish commentedon Aug 14, 2026
from #1222 (comment)
yes, any modern GPU that supports DirectX 12 on Windows 10/11.
foxrainowo commentedon Aug 14, 2026
@seniorfish
Thank you for your development and answer! I am using Intel® Core™ Ultra 5 Processor 228V, Intel® Arc™ 130V GPU, Intel® AI Boost. The GPU and NPU share 18 GB of memory. I have never met memory lack when I running
match, I suspect that it is more likely to be a software issue than a hardware problem.seniorfish commentedon Aug 15, 2026
foxrainowo commentedon Aug 15, 2026
@seniorfish
Thank you very much. Here are some debug logs, but I do not have
katago_crash.dmp.run_debug.log
katago_crash.log
debug_log.txt
Windows_error_log.txt
seniorfish commentedon Aug 16, 2026
foxrainowo commentedon Aug 16, 2026
@seniorfish
The issue still happens. The program hangs and does not exit. I also asked an AI about the possible cause (which may not be accurate), and I’m sending its analysis to you for reference. I can run b40 with https://github.com/Looong01/KataGo-Multi-backends/releases/tag/v1.17.1-openvino.
debug_logs_2.zip
seniorfish commentedon Aug 18, 2026
foxrainowo commentedon Aug 19, 2026
No, it still don't work and hangs again.
seniorfish commentedon Aug 23, 2026
Yodo13 commentedon Aug 25, 2026
This is a separate issue from the ones discussed above. The way "onnxProvider" is currently declared in "default_gtp.cfg" is confusing. I'm referring to the config file in "katago-v1.18.1-onnx-openvino-linux-x64.zip".
At the end of the config file, we find the lines:
However, the proper place to define the onnxProvider appears to be in the "ONNX Runtime backend settings" block, where we find:
# onnxProvider = ...It is commented out, so does not conflict. But trying to follow the setup instructions, I actually uncommented this line to define openvino as the provider and was then confronted with an error message about defining twice.
I suggest to remove the lines at the end and to declare onnxProvider in the "ONNX Runtime backend settings" block.
lightvector commentedon Aug 25, 2026
@Yodo13 Sorry about that, it was an issue with the preparation of the files packaging for that specific build. I attempted to reupload fixed versions now, I think it should be fixed.
seniorfish commentedon Aug 28, 2026
@foxrainowo Can #1171 resolve this issue?
HackYardo commentedon Sep 7, 2026
Thx for ur ONNS Speedup!
Few questions to ask:
seniorfish commentedon Sep 10, 2026
@HackYardo This should answer your first two questions. In short:
HackYardo commentedon Sep 12, 2026
Thx reply, I'll check it out the next time I play with KataGo.