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): the vector tool reads Qwen3.5 (and every model) over its real blocks
purplea51e98fe86c4
diff --git a/scripts/build-llama.sh b/scripts/build-llama.shindex 7048fd0a..12a20757 100755--- a/scripts/build-llama.sh+++ b/scripts/build-llama.sh@@ -339,7 +339,81 @@ ensure_src() {have="$(git -C "$SRC_DIR" rev-parse HEAD)"[ "$have" = "$LLAMA_COMMIT" ] \|| die "llama.cpp checkout is at $have, expected $LLAMA_COMMIT ($LLAMA_TAG) — upstream tag moved, or the build cache is stale"- assert_clean_tree+ # A clean tree gets LU's patches; a tree that carries them already (a+ # cache from an earlier run) is checked to carry exactly them.+ if [ -z "$(git -C "$SRC_DIR" status --porcelain --untracked-files=all 2>/dev/null)" ]; then+ apply_lu_patches+ fi+ assert_patched_tree+}++# LU's own changes to the pinned source, reviewed in this repo+# (scripts/llama-patches/*.patch). They only touch tools/cvector-generator,+# so the server binary is the pinned source unchanged.+#+# P11 FEHLER 10 (David's test build, 31.10.2026): the vector tool aborted+# on Qwen3.5 (GGML_ASSERT diff_filtered.size() == n_layers - 1): b9949 keeps+# the last block's full rows there, so one layer too many came through.+LU_PATCH_DIR="${LLAMA_LU_PATCH_DIR:-$REPO_ROOT/scripts/llama-patches}"++lu_patches() {+ [ -d "$LU_PATCH_DIR" ] || return 0+ find "$LU_PATCH_DIR" -maxdepth 1 -name '*.patch' | LC_ALL=C sort+}++apply_lu_patches() {+ local p+ for p in $(lu_patches); do+ log "applying $(basename "$p")"+ git -C "$SRC_DIR" apply "$p" || die "LU patch $(basename "$p") does not apply to $LLAMA_COMMIT ($LLAMA_TAG)"+ done+}++# The files LU's patches touch, one per line.+lu_patched_files() {+ local p+ for p in $(lu_patches); do+ sed -n 's|^+++ b/||p' "$p"+ done | LC_ALL=C sort -u+}++# What is compiled is the pinned commit plus LU's patches and nothing else:+# every change in the tree is a file a patch touches, and each such file is+# byte for byte the pinned file with the patches applied.+assert_patched_tree() {+ git -C "$SRC_DIR" update-index -q --really-refresh >/dev/null 2>&1 || true+ local dirty allowed line path+ dirty="$(git -C "$SRC_DIR" status --porcelain --untracked-files=all 2>/dev/null || true)"+ allowed="$(lu_patched_files)"+ while IFS= read -r line; do+ [ -n "$line" ] || continue+ path="${line:3}"+ case "$line" in+ " M "*) printf '%s\n' "$allowed" | grep -qxF "$path" && continue ;;+ esac+ die "llama.cpp source tree does not match $LLAMA_COMMIT ($LLAMA_TAG) plus LU's patches — the checkout carries local changes, so the build would not be the pinned source:+$dirty"+ done <<EOF_DIRTY+$dirty+EOF_DIRTY+ [ -n "$allowed" ] || return 0+ local tmp p f+ tmp="$(mktemp -d)"+ while IFS= read -r f; do+ mkdir -p "$tmp/$(dirname "$f")"+ git -C "$SRC_DIR" show "HEAD:$f" > "$tmp/$f"+ done <<EOF_FILES+$allowed+EOF_FILES+ for p in $(lu_patches); do+ (cd "$tmp" && git apply "$p") || { rm -rf "$tmp"; die "LU patch $(basename "$p") does not apply to $LLAMA_COMMIT ($LLAMA_TAG)"; }+ done+ while IFS= read -r f; do+ cmp -s "$tmp/$f" "$SRC_DIR/$f" || { rm -rf "$tmp"; die "llama.cpp source tree does not match $LLAMA_COMMIT ($LLAMA_TAG) plus LU's patches: $f differs"; }+ done <<EOF_FILES+$allowed+EOF_FILES+ rm -rf "$tmp"}# rev-parse only proves where HEAD POINTS. cmake does not compile HEAD, itdiff --git a/scripts/llama-patches/0001-cvector-generator-real-blocks.patch b/scripts/llama-patches/0001-cvector-generator-real-blocks.patchnew file mode 100644index 00000000..4e4f3f15--- /dev/null+++ b/scripts/llama-patches/0001-cvector-generator-real-blocks.patch@@ -0,0 +1,33 @@+--- a/tools/cvector-generator/cvector-generator.cpp++++ b/tools/cvector-generator/cvector-generator.cpp+@@ -339,6 +339,16 @@+ return true;+ }+++ // LU: only the outputs of the real blocks before the last one. Some++ // graphs keep the full rows in the last block (Qwen3.5 in b9949 does), so++ // the row count alone let a last layer through and the layer count no++ // longer matched; extra blocks such as MTP/NextN are never l_out here.++ const char * il_str = t->name + strlen(l_out_name);++ const int il = *il_str == '-' ? atoi(il_str + 1) : -1;++ if (il < 0 || il >= cb_data->n_layers - 1) {++ return true;++ }+++ // save the tensor to current context+ cb_data->save_tensor_for_layer(t);+ return true;+@@ -479,6 +489,13 @@+ // calculate diff and remove all zero rows+ auto v_diff_filtered = cb_data.calc_diff();+++ // LU: a model whose layers cannot be read this way gets a clear line++ // instead of an abort.++ if ((int) v_diff_filtered.size() != n_layers - 1) {++ fprintf(stderr, "LU: unsupported model: %d layer outputs for %d blocks\n", (int) v_diff_filtered.size(), n_layers - 1);++ return 1;++ }+++ // save & concat the filtered v_diff to ctx_train+ ctx_train.concat_diff_tmp(v_diff_filtered);+diff --git a/src-tauri/src/commands/neuron/mod.rs b/src-tauri/src/commands/neuron/mod.rsindex ab973a46..2077a7b5 100644--- a/src-tauri/src/commands/neuron/mod.rs+++ b/src-tauri/src/commands/neuron/mod.rs@@ -393,6 +393,11 @@ pub fn parse_progress(line: &str) -> Option<(u64, u64)> {/// own output (a backtrace on an abort) goes to the log, not on the page;/// only a missing library is named, since that is what the user can act on.pub fn tool_failure(stderr: &str) -> String {+ // LU's patch to the generator says so instead of aborting when a model's+ // layers do not come out the way it reads them (P11 FEHLER 10).+ if stderr.contains("LU: unsupported model") {+ return "The vector tool cannot read this model's layers, so ready-made and own sliders do not work on it. Other models and feature sliders still work.".into();+ }let missing = stderr.lines().map(str::trim).find(|l| {let low = l.to_lowercase();// Linux's loader says "error while loading shared libraries: x.so";@@ -937,6 +942,15 @@ mod tests {assert!(frame.contains("app log"), "{frame}");}+ /// P11 FEHLER 10: a model the patched generator cannot read is named as+ /// such, not as a tool that "stopped without a result".+ #[test]+ fn a_model_the_tool_cannot_read_is_said_plainly() {+ let msg = super::tool_failure("llama_print_build_info: build = 1 (049326a)\nLU: unsupported model: 32 layer outputs for 31 blocks\n");+ assert!(msg.contains("cannot read this model's layers"), "{msg}");+ assert!(!msg.contains("without a result"), "{msg}");+ }+use super::*;#[test]diff --git a/src/api/__tests__/build-llama-script.test.ts b/src/api/__tests__/build-llama-script.test.tsindex cd3df957..0c64ee1a 100644--- a/src/api/__tests__/build-llama-script.test.ts+++ b/src/api/__tests__/build-llama-script.test.ts@@ -13,6 +13,9 @@ const REPO_ROOT = resolve(__dirname, '../../..')// Not the bare name 'bash': on Windows that resolves to the WSL alias stub in// WindowsApps and never reaches a shell. See bash-interpreter.ts.const BASH = bashInterpreter()+// The repo's own llama.cpp patches only apply to the real pinned source; the+// fake upstreams below get none unless a test hands some in.+const NO_PATCHES = mkdtempSync(join(tmpdir(), 'lu-no-patches-'))/** Run a snippet with the script sourced. Returns stdout+stderr, both wanted:* the pin guards report through die(), which writes to stderr. */@@ -24,7 +27,7 @@ function runScript(const out = execFileSync(BASH, ['-c', `source '${SCRIPT}'; ${snippet}`], {encoding: 'utf8',stdio: ['ignore', 'pipe', 'pipe'],- env: { ...process.env, ...env },+ env: { ...process.env, LLAMA_LU_PATCH_DIR: NO_PATCHES, ...env },})return { code: 0, out: out.trim() }} catch (err) {@@ -403,6 +406,67 @@ describe('build-llama.sh — the llama.cpp revision is pinned to a commit', { tiexpect(extra.out).toContain('extra.cmake')})+ // P11 FEHLER 10 (David's test build, 31.10.2026): the vector tool aborted+ // on Qwen3.5. The fix is LU's own patch to the generator, so the build+ // applies reviewed patches and still compiles nothing but the pinned+ // commit plus exactly those patches.+ it('applies LU\'s patches to a clean checkout and accepts exactly that tree again', () => {+ const up = fakeUpstream()+ const cache = tmp('llama-cache-patched-')+ const patches = tmp('llama-patches-')+ writeFileSync(join(patches, '0001-lu.patch'), '--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -1 +1,2 @@\n project(fake)\n+# LU\n')+ const env = { LLAMA_BUILD_CACHE: cache, LLAMA_REPO: up.path, LLAMA_TAG: up.tag, LLAMA_COMMIT: up.sha, LLAMA_LU_PATCH_DIR: patches }+ const first = runScript('ensure_src', env)+ expect(first.code, first.out).toBe(0)+ expect(readFileSync(join(cache, 'llama.cpp', 'CMakeLists.txt'), 'utf8')).toBe('project(fake)\n# LU\n')+ // The cached, already patched tree is checked, not patched twice.+ const again = runScript('ensure_src', env)+ expect(again.code, again.out).toBe(0)+ expect(readFileSync(join(cache, 'llama.cpp', 'CMakeLists.txt'), 'utf8')).toBe('project(fake)\n# LU\n')+ // A change on top of the patch in the patched file is refused.+ writeFileSync(join(cache, 'llama.cpp', 'CMakeLists.txt'), 'project(fake)\n# LU\nadd_definitions(-DBACKDOOR)\n')+ const tampered = runScript('ensure_src', env)+ expect(tampered.code).not.toBe(0)+ expect(tampered.out).toContain('CMakeLists.txt differs')+ })++ it('refuses a patched tree that carries a change in a file no patch touches', () => {+ const up = fakeUpstream()+ const cache = tmp('llama-cache-patched-extra-')+ const patches = tmp('llama-patches-extra-')+ writeFileSync(join(patches, '0001-lu.patch'), '--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -1 +1,2 @@\n project(fake)\n+# LU\n')+ const env = { LLAMA_BUILD_CACHE: cache, LLAMA_REPO: up.path, LLAMA_TAG: up.tag, LLAMA_COMMIT: up.sha, LLAMA_LU_PATCH_DIR: patches }+ expect(runScript('ensure_src', env).code).toBe(0)+ writeFileSync(join(cache, 'llama.cpp', 'extra.cmake'), '# not in the pinned commit\n')+ const smuggled = runScript('ensure_src', env)+ expect(smuggled.code).not.toBe(0)+ expect(smuggled.out).toContain('does not match')+ })++ it('stops when a patch does not apply to the pinned source', () => {+ const up = fakeUpstream()+ const patches = tmp('llama-patches-bad-')+ writeFileSync(join(patches, '0001-lu.patch'), '--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -1 +1,2 @@\n project(other)\n+# LU\n')+ const env = { LLAMA_BUILD_CACHE: tmp('llama-cache-bad-'), LLAMA_REPO: up.path, LLAMA_TAG: up.tag, LLAMA_COMMIT: up.sha, LLAMA_LU_PATCH_DIR: patches }+ const r = runScript('ensure_src', env)+ expect(r.code).not.toBe(0)+ expect(r.out).toContain('0001-lu.patch does not apply')+ })++ it('the repo\'s generator patch keeps the vector on the real blocks and exits cleanly on a model it cannot read', () => {+ const dir = join(REPO_ROOT, 'scripts', 'llama-patches')+ const patch = readFileSync(join(dir, '0001-cvector-generator-real-blocks.patch'), 'utf8')+ // It touches the generator only, so the server stays the pinned source.+ expect([...patch.matchAll(/^\+\+\+ b\/(.+)$/gm)].map((m) => m[1])).toEqual(['tools/cvector-generator/cvector-generator.cpp'])+ // Only the blocks before the last one, picked by their layer index.+ expect(patch).toContain('+ if (il < 0 || il >= cb_data->n_layers - 1) {')+ // A mismatch is a line and exit 1, not GGML_ASSERT's abort.+ expect(patch).toContain('+ fprintf(stderr, "LU: unsupported model:')+ expect(patch).toContain('+ return 1;')+ // And it is what the build applies.+ expect(runScript('printf "%s" "$LU_PATCH_DIR"', { LLAMA_LU_PATCH_DIR: '' }).out).toBe(`${REPO_ROOT}/scripts/llama-patches`.replace(/\\/g, '/'))+ })+it('hashes a digest of the binary it installed', () => {const probe = join(tmp('llama-digest-'), 'artifact')writeFileSync(probe, 'llama-server')