The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(neuron): build the vector tool apart from the server on Windows and Linux
purpleb6a66a2c971a
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 80df17c8..8e936c0d 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -543,12 +543,13 @@ jobs:esacecho "OK: sidecar boots from $moved, loads a real model, /health answers, and has a libggml-cpu-*.so from $moved/llama mapped, nowhere near the build directory it was compiled in"- # FEHLER-P11 #7: the vector tool links the same libllama/libggml*/- # libllama-common the server does, and the app starts it the way it- # starts the server (cwd and LD_LIBRARY_PATH on the companions- # directory, engine.rs prepare_tool_command). Same moved-directory- # proof as above, with a real run: two example lines each way through- # the tiny model, and the control vector it writes must be there.+ # FEHLER-P11 #7/#8: the vector tool is a static baseline build of its+ # own (build-llama.sh cvector_cmake_flags_for); the app starts it the+ # way it starts the server (cwd and LD_LIBRARY_PATH on the companions+ # directory, engine.rs prepare_tool_command), which it does not need+ # but must not trip over. Same moved-directory proof as above, with a+ # real run: two example lines each way through the tiny model, and the+ # control vector it writes must be there.- name: "Vector tool computes from a moved directory (P11)"if: matrix.sidecar_triple == 'x86_64-unknown-linux-gnu'shell: bashdiff --git a/scripts/build-llama-flags.test.mjs b/scripts/build-llama-flags.test.mjsindex 75a92bed..2843ab25 100644--- a/scripts/build-llama-flags.test.mjs+++ b/scripts/build-llama-flags.test.mjs@@ -63,3 +63,41 @@ test('mac and Linux cmake flags are untouched by the Windows -MAP fix', () => {assert.doesNotMatch(cmakeFlagsFor('x86_64-apple-darwin'), /MAP/);assert.doesNotMatch(cmakeFlagsFor('x86_64-unknown-linux-gnu'), /MAP/);});++// FEHLER-P11 #8: the pinned llama.cpp defines the cvector-generator target+// only with GGML_BACKEND_DL OFF (tools/CMakeLists.txt:35-39), which the+// Windows/Linux server build needs ON (K1). The vector tool gets a cmake run+// of its own there: static, CPU only, every ISA option off by name, since+// GGML_NATIVE=OFF alone turns AVX/AVX2 on (INS_ENB). The server flags stay+// as they were.+function sourced(call) {+ return execFileSync('bash', ['-c', `source "${SCRIPT}"; ${call}`], { encoding: 'utf8' }).trim();+}++const ISA_OPTIONS = ['SSE42', 'AVX', 'AVX_VNNI', 'AVX2', 'BMI2', 'FMA', 'F16C', 'AVX512', 'AVX512_VBMI', 'AVX512_VNNI', 'AVX512_BF16', 'AMX_TILE', 'AMX_INT8', 'AMX_BF16'];++for (const triple of ['x86_64-pc-windows-msvc', 'x86_64-unknown-linux-gnu']) {+ test(`P11 #8: ${triple} builds the vector tool apart from the server`, () => {+ assert.equal(sourced(`cvector_separate_build_for ${triple} && echo yes || echo no`), 'yes');+ const flags = sourced(`cvector_cmake_flags_for ${triple}`);+ for (const f of ['BUILD_SHARED_LIBS=OFF', 'GGML_BACKEND_DL=OFF', 'GGML_CPU_ALL_VARIANTS=OFF', 'GGML_VULKAN=OFF', 'GGML_OPENMP=OFF', 'GGML_NATIVE=OFF']) {+ assert.match(flags, new RegExp(`-D${f}\\b`), f);+ }+ for (const isa of ISA_OPTIONS) assert.match(flags, new RegExp(`-DGGML_${isa}=OFF\\b`), `GGML_${isa} must be off by name`);+ assert.doesNotMatch(flags, /=ON\b/, 'nothing in the vector tool build is switched on');+ assert.notEqual(sourced(`cvector_build_dir_for ${triple}`), sourced(`echo "$CACHE_DIR/build-${triple}"`), 'its own build directory');+ // The server build is the K1 one, untouched.+ assert.match(cmakeFlagsFor(triple), /-DGGML_BACKEND_DL=ON\b/);+ assert.match(cmakeFlagsFor(triple), /-DGGML_CPU_ALL_VARIANTS=ON\b/);+ });+}++test('P11 #8: the Windows vector tool keeps its linker map for the ISA guard', () => {+ assert.match(sourced('cvector_cmake_flags_for x86_64-pc-windows-msvc'), /-DCMAKE_EXE_LINKER_FLAGS=-MAP\b/);+ assert.doesNotMatch(sourced('cvector_cmake_flags_for x86_64-unknown-linux-gnu'), /MAP/);+});++test('P11 #8: the Mac builds the vector tool in its server build (static there already)', () => {+ assert.equal(sourced('cvector_separate_build_for aarch64-apple-darwin && echo yes || echo no'), 'no');+ assert.equal(sourced('cvector_ships_for aarch64-apple-darwin && echo yes || echo no'), 'yes');+});diff --git a/scripts/build-llama.sh b/scripts/build-llama.shindex a99055fc..9a2286b4 100755--- a/scripts/build-llama.sh+++ b/scripts/build-llama.sh@@ -229,13 +229,11 @@ quantize_out_name_for() {# llama-cvector-generator (3.0.9, P11 Neuron tweaker) ships on all three# desktop platforms: it turns two short lists of example prompts into a# control vector for the model the user has, which llama-server then applies-# with --control-vector. Same pinned source tree, same flags as the server.-# On Windows and Linux it links the same llama/ggml/llama-common libraries-# the server already has staged in resources/llama/<triple>/ (every .dll/.so-# cmake writes beside the binaries goes there, see-# stage_dynamic_isa_companions), and the app starts it with the server's own-# library path (engine.rs prepare_tool_command), so it needs nothing of its-# own. FEHLER-P11 #7: everything a feature needs must come with the install.+# with --control-vector. Same pinned source tree. On the Mac it comes out of+# the server's own static build; on Windows and Linux out of a static build+# of its own (cvector_cmake_flags_for below, FEHLER-P11 #8), one file that+# needs no library beside it. FEHLER-P11 #7: everything a feature needs must+# come with the install.cvector_ships_for() {case "$1" in*-apple-darwin | x86_64-pc-windows-msvc | x86_64-unknown-linux-gnu) return 0 ;;@@ -243,6 +241,48 @@ cvector_ships_for() {esac}+# FEHLER-P11 #8: the pinned llama.cpp only defines the cvector-generator+# target when GGML_BACKEND_DL is OFF (tools/CMakeLists.txt:35-39, "these+# tools use backends directly ... and depend on CPU backend symbols"). The+# server build on Windows and Linux needs BACKEND_DL ON (K1, the dynamic+# CPU variants), so there the generator gets a cmake run of its own, in its+# own build directory, and the server build is left exactly as it was.+#+# What that run builds, and why:+# - static (BUILD_SHARED_LIBS=OFF): one self-contained file, no companion+# library to stage, find or keep in step with the server's;+# - CPU only (no GGML_VULKAN): no hard link to vulkan-1.dll/libvulkan.so,+# so the tool starts on a machine without a GPU driver as well. It reads+# some 40 short example pairs once per slider; the strength check after+# it runs on the engine (GPU), not here;+# - the K1 baseline: GGML_NATIVE=OFF alone switches SSE4.2/AVX/AVX2/FMA/+# F16C/BMI2 ON (ggml/CMakeLists.txt:141-166, INS_ENB), the exact K1+# crash on older CPUs, and a static build has no CPU variants to fall+# back on. So every ISA option is set OFF by name, and+# verify-sidecar-isa.sh checks the built file like the server exe+# (baseline: no AVX instruction);+# - no OpenMP: ggml's own thread pool, so no vcomp140.dll/libgomp.so is+# needed beside it;+# - Windows keeps -MAP, the ISA guard reads the linker map.+cvector_separate_build_for() {+ is_dynamic_isa_triple "$1"+}++cvector_cmake_flags_for() {+ local triple="$1"+ local common="-DLLAMA_OPENSSL=OFF -DLLAMA_BUILD_UI=OFF -DLLAMA_USE_PREBUILT_UI=OFF -DCMAKE_BUILD_TYPE=Release"+ local cpu="-DBUILD_SHARED_LIBS=OFF -DGGML_BACKEND_DL=OFF -DGGML_CPU_ALL_VARIANTS=OFF -DGGML_VULKAN=OFF -DGGML_OPENMP=OFF -DGGML_NATIVE=OFF -DGGML_SSE42=OFF -DGGML_AVX=OFF -DGGML_AVX_VNNI=OFF -DGGML_AVX2=OFF -DGGML_BMI2=OFF -DGGML_FMA=OFF -DGGML_F16C=OFF -DGGML_AVX512=OFF -DGGML_AVX512_VBMI=OFF -DGGML_AVX512_VNNI=OFF -DGGML_AVX512_BF16=OFF -DGGML_AMX_TILE=OFF -DGGML_AMX_INT8=OFF -DGGML_AMX_BF16=OFF"+ case "$triple" in+ x86_64-pc-windows-msvc) echo "$common $cpu -DCMAKE_EXE_LINKER_FLAGS=-MAP" ;;+ x86_64-unknown-linux-gnu) echo "$common $cpu" ;;+ *) die "no separate vector-tool build for $triple" ;;+ esac+}++cvector_build_dir_for() {+ echo "$CACHE_DIR/build-$1-cvector"+}+cvector_out_name_for() {case "$1" in*-windows-*) echo "lu-llama-cvector-generator-$1.exe" ;;@@ -451,8 +491,16 @@ build_triple() {if quantize_ships_for "$triple"; thencmake --build "$build_dir" --config Release --target llama-quantize -j "${BUILD_JOBS:-4}"fi+ local cv_build_dir="$build_dir"if cvector_ships_for "$triple"; then- cmake --build "$build_dir" --config Release --target llama-cvector-generator -j "${BUILD_JOBS:-4}"+ if cvector_separate_build_for "$triple"; then+ cv_build_dir="$(cvector_build_dir_for "$triple")"+ local cv_flags; cv_flags="$(cvector_cmake_flags_for "$triple")"+ log "configuring the vector tool for $triple apart from the server ($cv_flags)"+ # shellcheck disable=SC2086+ cmake -S "$SRC_DIR" -B "$cv_build_dir" $cv_flags+ fi+ cmake --build "$cv_build_dir" --config Release --target llama-cvector-generator -j "${BUILD_JOBS:-4}"fi# Locate the produced binary (path differs by generator/platform).local built@@ -471,8 +519,8 @@ build_triple() {fiif cvector_ships_for "$triple"; thenlocal built_cv- built_cv="$(find "$build_dir" -type f \( -name 'llama-cvector-generator' -o -name 'llama-cvector-generator.exe' \) -print -quit)"- [ -n "$built_cv" ] || die "llama-cvector-generator binary not found under $build_dir"+ built_cv="$(find "$cv_build_dir" -type f \( -name 'llama-cvector-generator' -o -name 'llama-cvector-generator.exe' \) -print -quit)"+ [ -n "$built_cv" ] || die "llama-cvector-generator binary not found under $cv_build_dir"cp "$built_cv" "$BIN_DIR/$(cvector_out_name_for "$triple")"chmod +x "$BIN_DIR/$(cvector_out_name_for "$triple")"fidiff --git a/scripts/verify-sidecar-isa.sh b/scripts/verify-sidecar-isa.shindex 9514ab53..7c46e55e 100755--- a/scripts/verify-sidecar-isa.sh+++ b/scripts/verify-sidecar-isa.sh@@ -546,6 +546,24 @@ if [[ "$TRIPLE" == *-windows-* ]]; thenvlog "no exe found at $exe_path, skipping the exe-itself check (build first for the full check)"fi+ # FEHLER-P11 #8: the Neuron tweaker's vector tool is a static exe of its+ # own (build-llama.sh cvector_cmake_flags_for), so every ggml-cpu line it+ # carries is the baseline one and must hold the same rule as the server+ # exe. Its map lies in its own build directory.+ cv_path="$BIN_DIR/$(cvector_out_name_for "$TRIPLE")"+ if [ -f "$cv_path" ]; then+ cv_map="$(find "${WIN_CVEC_MAP_DIR_OVERRIDE:-$(cvector_build_dir_for "$TRIPLE")}" -type f -iname 'llama-cvector-generator.map' -print -quit 2>/dev/null)"+ [ -n "$cv_map" ] || vdie "no llama-cvector-generator.map found for $cv_path, rebuild with scripts/build-llama.sh $TRIPLE first"+ disasm_tmp="$(mktemp)"+ disassemble_windows "$cv_path" > "$disasm_tmp"+ if ! "$NODE_BIN" "$WIN_GUARD" check --module "$(basename "$cv_path")" --disasm "$disasm_tmp" --map "$cv_map"; then+ win_fail_count=$((win_fail_count + 1))+ fi+ rm -f "$disasm_tmp"+ else+ vlog "no vector tool at $cv_path, skipping its check (build first for the full check)"+ fi+# R4, control 1/3 (positive control): independent of win-isa-guard.mjs, a# raw opcode-byte grep straight on dumpbin's own output. haswell is the# first AVX2 tier, so SOME VEX/EVEX byte pattern must show up, if it does@@ -908,6 +926,23 @@ elsevlog "no exe found at $exe_path, skipping the exe-itself check (build first for the full check)"fi+# FEHLER-P11 #8: the vector tool, a static baseline exe of its own (see the+# Windows branch above), holds the server exe's rule.+cv_path="$BIN_DIR/$(cvector_out_name_for "$TRIPLE")"+if [ -f "$cv_path" ]; then+ asm="$(disassemble "$cv_path")"+ cv_label="$(basename "$cv_path") ($cv_path)"+ if lines_verdict="$(check_min_disasm_lines "$asm" "$cv_label")" && verdict="$(evaluate_module_asm baseline "$asm" "$cv_label")"; then+ vlog "$verdict"+ else+ printf '\033[1;31m[verify-sidecar-isa] FAIL:\033[0m %s\n' "${verdict:-$lines_verdict}" >&2+ grep -E '%[xyz]mm[0-9]+|%k[0-7]\b|[[:space:]]v[a-z0-9]{2,}([[:space:]]|$)|[[:space:]]k[a-z]{2,}([[:space:]]|$)' <<<"$asm" | head -5 >&2 || true+ fail_count=$((fail_count + 1))+ fi+else+ vlog "no vector tool at $cv_path, skipping its check (build first for the full check)"+fi+# Positive control: without this, a broken disassembler invocation (a typo'd# flag, a tool that silently prints nothing) would make every check above# pass vacuously. haswell is the first tier with AVX2, so it MUST show up.