…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]>
Fixes #95.
Problem
tests/serve_e2e.sh build/1bit <model> hrxreturned HTTP 500{"error":{"code":500,"message":"Compute error."}}for MoE models whose full context exceeds HRX0's flash-attention KV cap (32768 tokens). At 262144 tokens HRX0 declines flash attention, llama.cpp disables FA for the whole model, and the non-FA attention path fails to compile on HRX0:Root cause & fix (in the
llama.cppsubmodule,1bit-MONSTER/llama.cpp@d7ff3afb9)Three bugs in the HRX backend's non-FA path:
Zero-byte alias validation —
tensor_storage_relative_offsetrejected a zero-byte (empty) source tensor whenever a degenerate view into it had a non-zero offset (relative_offset > ggml_nbytes(source)→8192 > 0). Empty per-expert FFN views then failed graph-cache validation withmetadata does not match. Fixed by accepting a zero-byte source when the view is also zero-byte.Invalid in-place alias — the fused attention-output and routed-FFN dispatches requested an in-place buffer alias (
residual_input → output) whose target is the layer output (l_out), an external/persistent buffer, soalias_storagefailed withvalue alias target is not transient. The dispatches now only request the in-place alias when both source and target are transient, otherwise they fall back to non-fused ops.Sigmoid-router SUM_ROWS — GLM-4.7-Flash's sigmoid MoE router left an unsupported
SUM_ROWSon HRX0. Narrowed theSUM_ROWS/CLAMPclaim to the top-k router chain (SOFT_MAX → ARGSORT → GET_ROWS), so a sigmoid router leaves those nodes to another backend.Verification
tests/serve_e2e.sh build/1bit <model> hrxpasses (answers "Paris") on Qwen3-Coder-30B-A3B-Instruct Q4_K_M and Qwen3.6-35B-A3B Q8_0 (no regression).Notes / remaining gaps
answers Parischeck: the 500 is gone (HTTP 200), but the reply is wrong. This is a separate correctness bug in a fused batched dispatch (correct at small ubatch, wrong at larger ubatch), being investigated in parallel — it is not the 500 "Compute error." this PR fixes.-fa offflag still fails on the non-FA attention postprocess (qwen attention postprocess matcher rejected node): the non-FA attention input reshape has no standalone dispatch. The default serve (FA declined at full context) exercises the non-FA path and works.