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(models): der Standby-Zwilling faellt auch ohne Quant im Namen
purplef6593ffe916a
diff --git a/src/lib/__tests__/the-standby-twin-falls-without-a-quant.test.ts b/src/lib/__tests__/the-standby-twin-falls-without-a-quant.test.tsnew file mode 100644index 00000000..df7a3902--- /dev/null+++ b/src/lib/__tests__/the-standby-twin-falls-without-a-quant.test.ts@@ -0,0 +1,100 @@+/**+ * A17 (Windows counter-check 03.09.), the first durchfaller: "Ein Modell, das+ * beide haben, steht zweimal da."+ *+ * After the switch to the LU Engine, Models > Installed showed+ *+ * mlabonne_gemma-3-4b-it-abliterated-Q4_K_M LU Engine+ * mlabonne_gemma-3-4b-it-abliterated LM Studio, standby, OFF+ *+ * one file of 2 489 894 304 bytes under two names, on two different disks+ * (AppData\Roaming\Locally Uncensored\models and .lmstudio\models). The Qwen+ * pair right beside it collapsed correctly, and the only difference was that+ * LM Studio spelled "@q4_k_m" there.+ *+ * Route 3 of the matcher required that NEITHER side name a quant. That rule+ * was written for the other direction, where the row that goes is ours and its+ * file would then be reachable from nowhere. In this direction the row that+ * goes is a standby row, which hides no file at all, so the same evidence buys+ * a different answer. This file pins both halves of that asymmetry.+ *+ * Run: npx vitest run src/lib/__tests__/the-standby-twin-falls-without-a-quant.test.ts+ */+import { describe, it, expect } from 'vitest'+import { dropStandbyRowsServedByLuEngine, dropDuplicateLuEngineRows } from '../lu-engine-rows'++/** A GGUF in the LU Engine folder, as `bundledToAIModels` stamps it. */+const ours = (stem: string, dir = 'C:\\Users\\ddrob\\AppData\\Roaming\\Locally Uncensored\\models') => ({+ name: `openai::${stem}`, model: stem, path: `${dir}\\${stem}.gguf`,+ provider: 'openai', providerName: 'LU Engine',+})++/** A row of the backend waiting beside the slot, as `cloudModelRow` builds it:+ * no path and no size, because a `/v1/models` listing carries neither. */+const standbyRow = (id: string) => ({+ name: `openai::${id}`, model: id, provider: 'openai', providerName: 'LM Studio',+})++describe('the standby twin of a file the LU Engine is serving', () => {+ // THE FINDING, with the pair from the report.+ it('falls even when only our side names the quant', () => {+ const gemma = ours('mlabonne_gemma-3-4b-it-abliterated-Q4_K_M')+ const kept = dropStandbyRowsServedByLuEngine(+ [standbyRow('mlabonne_gemma-3-4b-it-abliterated')],+ [gemma],+ )+ expect(kept).toEqual([])+ })++ // The pair beside it, which always worked, still works: this is not a fix+ // that trades one collapse for another.+ it('and still falls when LM Studio spells the quant out', () => {+ const qwen = ours('Qwen3-4B-Q4_K_M')+ expect(dropStandbyRowsServedByLuEngine([standbyRow('qwen/qwen3-4b@q4_k_m')], [qwen])).toEqual([])+ })++ // NEGATIVE CONTROL for the count, which is the whole of the evidence here.+ // Two quants of one model on our side and one nameless standby row: nothing+ // says which of the two it means, so it stays and the user keeps both.+ it('stays when we hold two quants of the same model', () => {+ const rows = [standbyRow('mlabonne_gemma-3-4b-it-abliterated')]+ const kept = dropStandbyRowsServedByLuEngine(rows, [+ ours('mlabonne_gemma-3-4b-it-abliterated-Q4_K_M'),+ ours('mlabonne_gemma-3-4b-it-abliterated-Q8_0'),+ ])+ expect(kept).toEqual(rows)+ })++ // A standby row that DOES name a quant is not nameless, so the count route+ // never applies to it: it is dropped only when the quants actually agree.+ it('stays when it names a quant we do not hold', () => {+ const rows = [standbyRow('mlabonne_gemma-3-4b-it-abliterated@q8_0')]+ expect(dropStandbyRowsServedByLuEngine(rows, [ours('mlabonne_gemma-3-4b-it-abliterated-Q4_K_M')]))+ .toEqual(rows)+ })++ // A different model is still a different model. The relaxed route asks for+ // the same identity before it asks anything else.+ it('leaves a standby row for a model we do not have at all', () => {+ const rows = [standbyRow('meta/llama-3.2-3b-instruct')]+ expect(dropStandbyRowsServedByLuEngine(rows, [ours('Qwen3-4B-Q4_K_M')])).toEqual(rows)+ })+})++describe('the other direction is untouched', () => {+ // THE ASYMMETRY, stated as one pair of assertions. The same two names, the+ // same quant on our side, opposite answers, because a dropped standby row+ // hides nothing while a dropped LU Engine row hides a file.+ it('keeps our named quant behind a collapsed LM Studio row, as it always did', () => {+ const gemma = ours('mlabonne_gemma-3-4b-it-abliterated-Q4_K_M')+ const collapsed = [standbyRow('mlabonne_gemma-3-4b-it-abliterated')]+ expect(dropDuplicateLuEngineRows([gemma], collapsed), 'our file went missing').toEqual([gemma])+ // And the very same inputs, read the other way round, collapse.+ expect(dropStandbyRowsServedByLuEngine(collapsed, [gemma])).toEqual([])+ })++ it('still drops our row when LM Studio names the quant we hold', () => {+ const q8 = ours('Qwen2.5-0.5B-Instruct-Q8_0')+ expect(dropDuplicateLuEngineRows([q8], [standbyRow('qwen2.5-0.5b-instruct@q8_0')])).toEqual([])+ })+})diff --git a/src/lib/lu-engine-rows.ts b/src/lib/lu-engine-rows.tsindex 8f4a83d6..e6852ec4 100644--- a/src/lib/lu-engine-rows.ts+++ b/src/lib/lu-engine-rows.ts@@ -121,6 +121,35 @@ export function dropDuplicateLuEngineRows<T extends InstalledModelLike>(** `alreadyListed` is the whole list; the LU Engine rows are picked out of it* here, exactly as `dropDuplicateLuEngineRows` picks out the LM Studio ones.+ *+ * A17 counter-check 03.09., the asymmetry route 3 has and did not use: the+ * three routes were the same in both directions, and route 3 asked that+ * NEITHER side name a quant. On the Windows box that left+ *+ * mlabonne_gemma-3-4b-it-abliterated-Q4_K_M LU Engine+ * mlabonne_gemma-3-4b-it-abliterated LM Studio, standby, OFF+ *+ * standing side by side, one file of 2 489 894 304 bytes under two names. The+ * Qwen pair beside it collapsed only because LM Studio happened to spell+ * "@q4_k_m" there.+ *+ * "Our own quant is evidence" was written for the other direction, where the+ * row that goes is OUR row and its file would then be reachable nowhere. Here+ * the row that goes is a standby row: it hides no file, LM Studio stays+ * reachable through every other row it has, and the backend holding the slot+ * is the one whose row works right now. So in this direction route 3 asks only+ * what it can actually answer, the count. One file of that identity on our+ * side and one nameless row on the other can only be each other. Two quants of+ * ours and a nameless row cannot be told apart, and then the standby row+ * stays, exactly as before.+ *+ * A fourth route on file size was considered and left out rather than written+ * blind. A standby row is built by `cloudModelRow` out of a `ProviderModel`,+ * and neither carries a size: every one of them is `size: 0`. A byte+ * comparison would therefore never fire on a real pair, and worse, "same size"+ * would be true of every standby row against every other, because they all+ * carry the same zero. The day the standby listing learns a real size is the+ * day that route is worth writing.*/export function dropStandbyRowsServedByLuEngine<T extends InstalledModelLike>(standby: T[],@@ -136,7 +165,7 @@ export function dropStandbyRowsServedByLuEngine<T extends InstalledModelLike>(const id = identityOf(row)if (id) ownByIdentity.set(id, (ownByIdentity.get(id) ?? 0) + 1)}- return standby.filter((row) => !luEngine.some((ours) => sameFile(ours, row, ownByIdentity)))+ return standby.filter((row) => !luEngine.some((ours) => sameFile(ours, row, ownByIdentity, true)))}/** Every id a row can be recognised by. LM Studio reports its own key, our own@@ -183,11 +212,19 @@ function namesAQuant(m: InstalledModelLike): boolean {return idsOf(m).some((id) => extractQuant(id) !== null)}-/** Two rows pointing at one file on disk. */+/**+ * Two rows pointing at one file on disk.+ *+ * `otherHidesNoFile` is the one asymmetry between the two directions, and it+ * only touches route 3. See the paragraph on+ * `dropStandbyRowsServedByLuEngine` for why the same evidence is worth+ * different things depending on which row would disappear.+ */function sameFile(ours: InstalledModelLike,other: InstalledModelLike,ownByIdentity: Map<string, number>,+ otherHidesNoFile = false,): boolean {// Route 1: the same path, spelled either way round.const ourPath = normalisePath(pathOf(ours))@@ -201,11 +238,19 @@ function sameFile(// Route 2: our file IS in LM Studio's store, so the identity settles it.if (sameModel && livesInLmStudioStore(ours)) return true- // Route 3: neither side names a quant and we hold exactly one such file.- // Our own quant, where we have one, is evidence and not noise: a collapsed- // LM Studio row could be any quant at any path, so it cannot be shown to be- // our Q8_0. Route 2 above is the way that case is settled honestly.- if (sameModel && !namesAQuant(other) && !namesAQuant(ours) && ownByIdentity.get(ourIdentity) === 1) return true+ // Route 3: the other side names no quant and we hold exactly one file of+ // that identity.+ //+ // Whether OUR quant has to be missing too is the asymmetry. Where dropping+ // the row would hide a file (the LU Engine direction), our own quant is+ // evidence and not noise: a collapsed LM Studio row could be any quant at+ // any path, so it cannot be shown to be our Q8_0, and route 2 is the honest+ // way that case is settled. Where dropping the row hides nothing (the+ // standby direction), the count is the whole question: one file of that+ // identity on our side and one nameless row on the other can only be each+ // other, and our quant says nothing against it.+ if (sameModel && !namesAQuant(other) && (otherHidesNoFile || !namesAQuant(ours))+ && ownByIdentity.get(ourIdentity) === 1) return true// Otherwise the strict rule: same filename, or the same quant named on both// sides. A missing quant on either side is not evidence.