Repository navigation
ONNX backend: 1bit serve --device onnx runs ONNX Runtime GenAI models (ryzenai-server) - #100
Merged
Merged
Conversation
…ime GenAI) third_party/ryzenai-server (lemonade-sdk, MIT) is the engine's ONNX Runtime GenAI backend, run as a child like llama-server. scripts/build-onnx.sh builds it against Microsoft's ONNX Runtime GenAI 0.11.2 and ONNX Runtime 1.23.2 (MIT, pinned, sha256-checked; CPU), or AMD's Ryzen AI Software when RYZENAI_INSTALL_PATH names it (NPU, hybrid). -DONEBIT_ONNX builds it with the engine. A directory with a genai_config.json goes to --device onnx. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cies Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Docs7 for 1bit-monster/engine
Commit |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
bong-water-water-bong
added a commit
that referenced
this pull request
Oct 9, 2026
…_NL GET_ROWS on HRX; fork #98-#100) (#373) Co-authored-by: bong-water-water-bong <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
bong-water-water-bong
pushed a commit
that referenced
this pull request
Oct 13, 2026
…e live mechanism bounded_key_value_token_count appears 24 times in the faulting pin (26330cc20) and 24 times in the current pin (0e255d7) - identical. The token-bound masking that the 'rows past the sequence end hold whatever an earlier request left there' comment describes was therefore ALREADY PRESENT when the fault reproduced (the faulting cell ran at gtt_start=102G with parse=0). That comment is the rationale for the #314 fix, not evidence of a live defect; the kernel reads key/value only up to the bounded count and masks scores accordingly. Recorded so it is not re-explored. What survives from the trail is only the merge message's phrase 'looser arena reuse', which points at the allocation/reuse boundary generally rather than at this kernel. Also settled: the sole change to ggml-hrx.cpp between the faulting pin and the current pin removes a return false for IQ3_S/IQ4_NL GET_ROWS, i.e. PR #100 enables an op the faulting pin refused - unrelated to the reuse boundary, and evidence that the faulting configuration is otherwise carried forward unchanged, consistent with the fault still reproducing. Add-only.
This was referenced Nov 12, 2026
Merged
This was referenced Nov 20, 2026
bong-water-water-bong
added a commit
that referenced
this pull request
Nov 20, 2026
…letion guards, two of them mine) (#2981) One line plus the files the build now needs. The range is 26 commits and every one of them is inside runtime/npu_rt: * #100 refuses an argument buffer smaller than the transfers the program was built with (code 307) and a device-heap buffer where the device moves data (308); * #101/#102 give a launch the driver killed its own code: TIMEOUT -> command_timeout, ABORT -> command_aborted, and run/runlist::require_completed() so a harness gets an exception instead of a return value it can drop (engine#2542: a stalled design printed "ok, 1 launches" after a TDR); * #103 puts ert_cmd_state back inside namespace npu_rt, which npu_rt_api.cpp's static_assert requires -- that one was my regression, caught by the engine build against the bumped runtime and not by the runtime's own build, because npu_rt_api.cpp is compiled here only on the engine side. require= gains npu_rt_bounds.h and npu_rt_completion.h: npu_rt.h includes the completion header, so a checkout without it does not build, and that is the state an older pin is in. Verified before the pin moved, in my own tree (ONEBIT_NPU_RT_DIR pointing at my checkout, not at the shared ~/wt/npu-k): * build: [0/2] Re-checking globbed directories... [1/17] Building CXX object CMakeFiles/onebit_laya.dir/laya/policy.cpp.o In file included from /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/json.hpp:57, from /home/bcloud/wt/cl-npurt-amdcol/laya/policy.cpp:23: /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/detail/output/binary_writer.hpp: In static member function ‘static CharType nlohmann::json_abi_v3_11_3::detail::binary_writer<BasicJsonType, CharType>::to_char_type(uint8_t)’: /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/detail/output/binary_writer.hpp:1805:28: warning: ‘template<class _Tp> struct std::is_trivial’ is deprecated: use 'is_trivially_default_constructible && is_trivially_copyable' instead [-Wdeprecated-declarations] 1805 | static_assert(std::is_trivial<CharType>::value, "CharType must be trivial"); | ^~~~~~~~~~ In file included from /usr/include/c++/16/bits/cpp_type_traits.h:42, from /usr/include/c++/16/bits/stl_algobase.h:60, from /usr/include/c++/16/bits/stl_tree.h:65, from /usr/include/c++/16/map:64, from /home/bcloud/wt/cl-npurt-amdcol/laya/policy.h:20, from /home/bcloud/wt/cl-npurt-amdcol/laya/policy.cpp:16: /usr/include/c++/16/type_traits:960:5: note: declared here 960 | is_trivial | ^~~~~~~~~~ [2/17] Linking CXX static library libonebit_laya.a [3/17] Linking CXX executable laya_eval_test [4/17] Linking CXX executable laya_models_test [5/17] Building CXX object CMakeFiles/onebit_npu_forward.dir/npu/forward/src/q4nx_forward.cpp.o /home/bcloud/wt/cl-npurt-amdcol/npu/forward/src/q4nx_forward.cpp: In lambda function: /home/bcloud/wt/cl-npurt-amdcol/npu/forward/src/q4nx_forward.cpp:2540:33: warning: ‘ B is not a kind, and no pad...’ directive output may be truncated writing 82 bytes into a region of size between 0 and 196 [-Wformat-truncation=] 2540 | "(chunk %zu B is not a kind, and no padded grid fits): the container and " | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2541 | "config.json disagree", d->name, (size_t)d->data_size, rows, cols, tiles, | ~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/stdio.h:974, from /usr/include/c++/16/cstdio:47, from /usr/include/c++/16/ext/string_conversions.h:47, from /usr/include/c++/16/bits/basic_string.h:4499, from /usr/include/c++/16/string:58, from /usr/include/c++/16/bits/locale_classes.h:43, from /usr/include/c++/16/bits/ios_base.h:43, from /usr/include/c++/16/ios:46, from /usr/include/c++/16/bits/ostream.h:43, from /usr/include/c++/16/bits/unique_ptr.h:42, from /usr/include/c++/16/memory:80, from /home/bcloud/wt/cl-npurt-amdcol/npu/forward/include/q4nx_forward.h:36, from /home/bcloud/wt/cl-npurt-amdcol/npu/forward/src/q4nx_forward.cpp:26: In function ‘int snprintf(char*, size_t, const char*, ...)’, inlined from ‘Q4nxNpuForward::load_layer(int)::<lambda(TensorDesc*, float*, int, int)>’ at /home/bcloud/wt/cl-npurt-amdcol/npu/forward/src/q4nx_forward.cpp:2539:21, inlined from ‘Q4nxNpuForward::load_layer(int)::<lambda(TensorDesc*, float*, int, int)>’ at /home/bcloud/wt/cl-npurt-amdcol/npu/forward/src/q4nx_forward.cpp:2532:16: /usr/include/x86_64-linux-gnu/bits/stdio2.h:68:35: note: ‘__builtin___snprintf_chk’ output between 143 and 347 bytes into a destination of size 256 68 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 69 | __glibc_objsize (__s), __fmt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 70 | __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~ [6/17] Linking CXX static library libonebit_npu_forward.a [7/17] Linking CXX executable npu_gemm_shape_guard_test [8/17] Building CXX object CMakeFiles/onebit_npu_forward_syntax.dir/npu/forward/src/q4nx_forward.cpp.o In file included from /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/json.hpp:57, from /home/bcloud/wt/cl-npurt-amdcol/npu/plan/plan.h:59, from /home/bcloud/wt/cl-npurt-amdcol/npu/forward/include/q4nx_forward.h:42, from /home/bcloud/wt/cl-npurt-amdcol/npu/forward/src/q4nx_forward.cpp:26: /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/detail/output/binary_writer.hpp: In static member function ‘static CharType nlohmann::json_abi_v3_11_3::detail::binary_writer<BasicJsonType, CharType>::to_char_type(uint8_t)’: /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/detail/output/binary_writer.hpp:1805:28: warning: ‘template<class _Tp> struct std::is_trivial’ is deprecated: use 'is_trivially_default_constructible && is_trivially_copyable' instead [-Wdeprecated-declarations] 1805 | static_assert(std::is_trivial<CharType>::value, "CharType must be trivial"); | ^~~~~~~~~~ In file included from /usr/include/c++/16/bits/move.h:37, from /usr/include/c++/16/bits/new_allocator.h:36, from /usr/include/x86_64-linux-gnu/c++/16/bits/c++allocator.h:33, from /usr/include/c++/16/bits/allocator.h:46, from /usr/include/c++/16/memory:67, from /home/bcloud/wt/cl-npurt-amdcol/npu/forward/include/q4nx_forward.h:36: /usr/include/c++/16/type_traits:960:5: note: declared here 960 | is_trivial | ^~~~~~~~~~ /home/bcloud/wt/cl-npurt-amdcol/npu/forward/src/q4nx_forward.cpp: In lambda function: /home/bcloud/wt/cl-npurt-amdcol/npu/forward/src/q4nx_forward.cpp:2540:33: warning: ‘ B is not a kind, and no pad...’ directive output may be truncated writing 82 bytes into a region of size between 0 and 196 [-Wformat-truncation=] 2540 | "(chunk %zu B is not a kind, and no padded grid fits): the container and " | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2541 | "config.json disagree", d->name, (size_t)d->data_size, rows, cols, tiles, | ~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/stdio.h:974, from /usr/include/c++/16/cstdio:47, from /usr/include/c++/16/ext/string_conversions.h:47, from /usr/include/c++/16/bits/basic_string.h:4499, from /usr/include/c++/16/string:58, from /usr/include/c++/16/bits/locale_classes.h:43, from /usr/include/c++/16/bits/ios_base.h:43, from /usr/include/c++/16/ios:46, from /usr/include/c++/16/bits/ostream.h:43, from /usr/include/c++/16/bits/unique_ptr.h:42, from /usr/include/c++/16/memory:80: In function ‘int snprintf(char*, size_t, const char*, ...)’, inlined from ‘Q4nxNpuForward::load_layer(int)::<lambda(TensorDesc*, float*, int, int)>’ at /home/bcloud/wt/cl-npurt-amdcol/npu/forward/src/q4nx_forward.cpp:2539:21, inlined from ‘Q4nxNpuForward::load_layer(int)::<lambda(TensorDesc*, float*, int, int)>’ at /home/bcloud/wt/cl-npurt-amdcol/npu/forward/src/q4nx_forward.cpp:2532:16: /usr/include/x86_64-linux-gnu/bits/stdio2.h:68:35: note: ‘__builtin___snprintf_chk’ output between 143 and 347 bytes into a destination of size 256 68 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 69 | __glibc_objsize (__s), __fmt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 70 | __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~ [9/17] Building CXX object CMakeFiles/onebit.dir/app/main.cpp.o [10/17] Building CXX object CMakeFiles/onebit.dir/app/recipes.cpp.o In file included from /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/json.hpp:57, from /home/bcloud/wt/cl-npurt-amdcol/app/recipes.cpp:20: /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/detail/output/binary_writer.hpp: In static member function ‘static CharType nlohmann::json_abi_v3_11_3::detail::binary_writer<BasicJsonType, CharType>::to_char_type(uint8_t)’: /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/detail/output/binary_writer.hpp:1805:28: warning: ‘template<class _Tp> struct std::is_trivial’ is deprecated: use 'is_trivially_default_constructible && is_trivially_copyable' instead [-Wdeprecated-declarations] 1805 | static_assert(std::is_trivial<CharType>::value, "CharType must be trivial"); | ^~~~~~~~~~ In file included from /usr/include/c++/16/bits/char_traits.h:52, from /usr/include/c++/16/string:45, from /home/bcloud/wt/cl-npurt-amdcol/app/recipes.h:23, from /home/bcloud/wt/cl-npurt-amdcol/app/recipes.cpp:16: /usr/include/c++/16/type_traits:960:5: note: declared here 960 | is_trivial | ^~~~~~~~~~ [11/17] Building CXX object CMakeFiles/onebit.dir/app/laya_first.cpp.o In file included from /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/json.hpp:57, from /home/bcloud/wt/cl-npurt-amdcol/app/laya_first.cpp:26: /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/detail/output/binary_writer.hpp: In static member function ‘static CharType nlohmann::json_abi_v3_11_3::detail::binary_writer<BasicJsonType, CharType>::to_char_type(uint8_t)’: /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/detail/output/binary_writer.hpp:1805:28: warning: ‘template<class _Tp> struct std::is_trivial’ is deprecated: use 'is_trivially_default_constructible && is_trivially_copyable' instead [-Wdeprecated-declarations] 1805 | static_assert(std::is_trivial<CharType>::value, "CharType must be trivial"); | ^~~~~~~~~~ In file included from /usr/include/c++/16/bits/move.h:37, from /usr/include/c++/16/bits/exception_ptr.h:41, from /usr/include/c++/16/exception:182, from /usr/include/c++/16/stdexcept:40, from /usr/include/c++/16/system_error:45, from /usr/include/c++/16/bits/fs_fwd.h:35, from /usr/include/c++/16/filesystem:54, from /home/bcloud/wt/cl-npurt-amdcol/app/laya_first.cpp:20: /usr/include/c++/16/type_traits:960:5: note: declared here 960 | is_trivial | ^~~~~~~~~~ [12/17] Building CXX object CMakeFiles/onebit_serve_syntax.dir/app/forward_serve.cpp.o In file included from /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/json.hpp:57, from /home/bcloud/wt/cl-npurt-amdcol/npu/plan/plan.h:59, from /home/bcloud/wt/cl-npurt-amdcol/app/../npu/forward/include/q4nx_forward.h:42, from /home/bcloud/wt/cl-npurt-amdcol/app/forward_serve.cpp:42: /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/detail/output/binary_writer.hpp: In static member function ‘static CharType nlohmann::json_abi_v3_11_3::detail::binary_writer<BasicJsonType, CharType>::to_char_type(uint8_t)’: /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/detail/output/binary_writer.hpp:1805:28: warning: ‘template<class _Tp> struct std::is_trivial’ is deprecated: use 'is_trivially_default_constructible && is_trivially_copyable' instead [-Wdeprecated-declarations] 1805 | static_assert(std::is_trivial<CharType>::value, "CharType must be trivial"); | ^~~~~~~~~~ In file included from /usr/include/c++/16/bits/char_traits.h:52, from /usr/include/c++/16/string:45, from /home/bcloud/wt/cl-npurt-amdcol/app/forward_serve.h:22, from /home/bcloud/wt/cl-npurt-amdcol/app/forward_serve.cpp:36: /usr/include/c++/16/type_traits:960:5: note: declared here 960 | is_trivial | ^~~~~~~~~~ [13/17] Building CXX object CMakeFiles/onebit.dir/app/pm.cpp.o In file included from /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/json.hpp:57, from /home/bcloud/wt/cl-npurt-amdcol/app/pm.h:31, from /home/bcloud/wt/cl-npurt-amdcol/app/pm.cpp:17: /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/detail/output/binary_writer.hpp: In static member function ‘static CharType nlohmann::json_abi_v3_11_3::detail::binary_writer<BasicJsonType, CharType>::to_char_type(uint8_t)’: /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/detail/output/binary_writer.hpp:1805:28: warning: ‘template<class _Tp> struct std::is_trivial’ is deprecated: use 'is_trivially_default_constructible && is_trivially_copyable' instead [-Wdeprecated-declarations] 1805 | static_assert(std::is_trivial<CharType>::value, "CharType must be trivial"); | ^~~~~~~~~~ In file included from /usr/include/c++/16/bits/cpp_type_traits.h:42, from /usr/include/c++/16/bits/stl_algobase.h:60, from /usr/include/c++/16/algorithm:62, from /home/bcloud/wt/cl-npurt-amdcol/build/_deps/httplib-src/httplib.h:308, from /home/bcloud/wt/cl-npurt-amdcol/app/pm.h:30: /usr/include/c++/16/type_traits:960:5: note: declared here 960 | is_trivial | ^~~~~~~~~~ [14/17] Building CXX object CMakeFiles/onebit.dir/app/serve.cpp.o In file included from /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/json.hpp:57, from /home/bcloud/wt/cl-npurt-amdcol/app/pm.h:31, from /home/bcloud/wt/cl-npurt-amdcol/app/serve.cpp:75: /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/detail/output/binary_writer.hpp: In static member function ‘static CharType nlohmann::json_abi_v3_11_3::detail::binary_writer<BasicJsonType, CharType>::to_char_type(uint8_t)’: /home/bcloud/wt/cl-npurt-amdcol/build/_deps/json-src/include/nlohmann/detail/output/binary_writer.hpp:1805:28: warning: ‘template<class _Tp> struct std::is_trivial’ is deprecated: use 'is_trivially_default_constructible && is_trivially_copyable' instead [-Wdeprecated-declarations] 1805 | static_assert(std::is_trivial<CharType>::value, "CharType must be trivial"); | ^~~~~~~~~~ In file included from /usr/include/c++/16/bits/move.h:37, from /usr/include/c++/16/bits/exception_ptr.h:41, from /usr/include/c++/16/exception:182, from /usr/include/c++/16/stdexcept:40, from /usr/include/c++/16/system_error:45, from /usr/include/c++/16/bits/fs_fwd.h:35, from /usr/include/c++/16/filesystem:54, from /home/bcloud/wt/cl-npurt-amdcol/app/built_path.h:17, from /home/bcloud/wt/cl-npurt-amdcol/app/serve.cpp:66: /usr/include/c++/16/type_traits:960:5: note: declared here 960 | is_trivial | ^~~~~~~~~~ [15/17] Building CXX object CMakeFiles/onebit.dir/app/forward_serve.cpp.o [16/17] Linking CXX executable 1bit clean, 4 require_completed symbols in the archive; * device, inside npu-hold tickets on a quiet box: npu_batch_decode_test passes ("3 requests x 4 steps = 12 steps in 7 pass(es)", staggered requests bit-identical) -- so the two new refusals do not trip the engine's batched decode path -- and step_users_test passes after engine#2979 (whose defect this verification found: the slot-reset path was unreachable). Co-authored-by: bong-water-water-bong <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1bit serve --device onnxserves ONNX Runtime GenAI models, the format of Lemonade's ONNX models. A directory with agenai_config.jsongoes there on its own. Seedocs/onnx.md.How it works
third_party/ryzenai-server(lemonade-sdk/ryzenai-server, MIT) is pinned at 69765cc. It is an OpenAI-compatible server around ONNX Runtime GenAI, and the engine runs it as a child process, exactly as it runs llama-server.scripts/build-onnx.shbuilds it against Microsoft's ONNX Runtime GenAI 0.11.2 and ONNX Runtime 1.23.2 (MIT), fetched pinned and sha256-checked, which gives CPU execution.-DONEBIT_ONNX=ONruns the script during the engine build.RYZENAI_INSTALL_PATHset, the same script builds against the user's install.DT_RPATH $ORIGIN, so ONNX Runtime GenAI's run-timedlopenoflibonnxruntime.sofinds the copy beside it.Tested on Strix Halo, from a clean clone with
-DONEBIT_ONNX=ON, onamd/Qwen2.5-0.5B-Instruct-quantized_int4-float16-cpu-onnx(CPU int4), with no--device:1bit serve -m <dir>choseonnx. It answered "The capital of France is Paris." and a list of three colors at 125–129 tok/s, and streamed SSE./v1/modelsreports deviceonnx, and stopping1bit servestopped the backend.The next step is
ryzenai-server.exeinscripts/build-windows.sh(ONNX Runtime GenAI's Windows builds add DirectML).🤖 Generated with Claude Code