Skip to content

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.

fix(models): a split GGUF set with parts missing is not downloaded

purplea4d4421ef49a
diff --git a/src/api/discover.ts b/src/api/discover.ts
index 3a1f6b10..43a3539f 100644
--- a/src/api/discover.ts
+++ b/src/api/discover.ts
@@ -18,6 +18,7 @@ import { extractGgufQuant, hfUrlToTreePath, parseHfUrl } from '../lib/hf-to-prov
import { IMAGE_PART } from './image-parts'
import { kimiK3CatalogEntries } from './kimi-k3-catalog'
import { imagePartFileName, isUpstreamImagePart, pickUpstreamImagePart } from '../lib/image-part'
+import { shardSetGap, type ShardGap } from '../lib/gguf-shards'
import {
CUSTOM_NODE_REGISTRY,
getImageBundles, getVideoBundles, getAudioBundles, getLipsyncBundles, getMotionBundles, getUpscaleBundles,
@@ -1667,6 +1668,10 @@ export interface HfGgufResolution {
/** The image part the same repository ships, when it ships one. For a model
* the catalog does not know, this is what is offered with it. */
imagePart?: ImagePartSource
+ /** Set when the chosen file is a split set the repository holds only some
+ * parts of (an upload still running). `files` is empty then: llama.cpp
+ * cannot load the set, so nothing of it is downloaded. */
+ incomplete?: ShardGap
}
// 5-digit llama.cpp split convention: `<name>-00001-of-00002.gguf`. A few
@@ -1679,7 +1684,7 @@ const GGUF_QUANT_TOKEN = /(IQ\d_[A-Z0-9]+|Q\d_K(?:_[A-Z]+)?|Q\d_[01]|BF16|F16|F3
/** One downloadable unit of a repo tree: a single file, or every part of a
* split set. */
-interface GgufGroup { key: string; quant?: string; parts: HfTreeEntry[] }
+interface GgufGroup { key: string; quant?: string; parts: HfTreeEntry[]; gap?: ShardGap | null }
/**
* The group that holds the file the caller named, or undefined.
@@ -1740,14 +1745,25 @@ export function selectGgufFromTree(
}
const all = [...groups.values()]
+ for (const g of all) g.gap = shardSetGap(g.parts.map(p => p.path))
+ // A split set with parts missing never loads. A loadable group is taken
+ // over it wherever the choice is ours; when the caller's own file or quant
+ // is only there incomplete, the answer says so instead of fetching another.
+ const complete = all.filter(g => !g.gap)
const wanted = preferredQuant?.toUpperCase()
+ const byQuant = (g: GgufGroup) => g.quant === wanted
+ const byKey = (g: GgufGroup) => !!wanted && g.key.toUpperCase().includes(wanted)
const picked =
groupOfNamedFile(all, exactPath) ||
- (wanted ? all.find(g => g.quant === wanted) : undefined) ||
- (wanted ? all.find(g => g.key.toUpperCase().includes(wanted)) : undefined) ||
- all.find(g => g.quant === 'Q4_K_M') ||
+ (wanted ? complete.find(byQuant) || all.find(byQuant) : undefined) ||
+ (wanted ? complete.find(byKey) || all.find(byKey) : undefined) ||
+ complete.find(g => g.quant === 'Q4_K_M') ||
+ complete[0] ||
all[0]
if (!picked) return null
+ if (picked.gap) {
+ return { sharded: true, files: [], totalBytes: 0, quant: picked.quant, incomplete: picked.gap }
+ }
const sorted = [...picked.parts].sort((a, b) => {
const ai = parseInt(a.path.match(GGUF_SHARD_RE)?.[1] || '0', 10)
diff --git a/src/components/models/DiscoverModels.tsx b/src/components/models/DiscoverModels.tsx
index 4e2d7a92..184af7fb 100644
--- a/src/components/models/DiscoverModels.tsx
+++ b/src/components/models/DiscoverModels.tsx
@@ -765,6 +765,13 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0 }:
? await resolveHfGgufFiles(request.repoId, request.preferredQuant, request.exactPath)
: null
+ // A split set the uploader has not finished: llama.cpp loads it only with
+ // every part, so none of it is fetched.
+ if (resolution?.incomplete) {
+ setInstallError(`${model.name} is not complete on Hugging Face yet: only ${resolution.incomplete.have} of ${resolution.incomplete.of} parts are there, and the model loads only with all of them. Try again later.`)
+ return
+ }
+
const lmStudioEnabled = !!providers.openai?.enabled && (providers.openai?.name || '').toLowerCase().includes('lm studio')
const ollamaEnabledNow = !!providers.ollama?.enabled
diff --git a/src/components/models/HfLinkDialog.tsx b/src/components/models/HfLinkDialog.tsx
index e312b419..f29455b7 100644
--- a/src/components/models/HfLinkDialog.tsx
+++ b/src/components/models/HfLinkDialog.tsx
@@ -3,7 +3,7 @@ import { fetchExternal } from '../../api/backend'
import { selectGgufFromTree, type HfTreeEntry } from '../../api/discover'
import type { DiscoverModel } from '../../api/model-bundles'
import {
- choiceForFile, defaultChoice, ggufChoicesFromTree, hfRepoPage, hfTreeApi, linkModel, sizeLabel,
+ choiceForFile, defaultChoice, ggufChoicesFromTree, hfRepoPage, hfTreeApi, incompleteLabel, linkModel, sizeLabel,
type HfLinkChoice, type HfModelLink,
} from '../../lib/hf-link'
import { log } from '../../lib/logger'
@@ -93,8 +93,8 @@ export function HfLinkDialog({ link, onCancel, onConfirm }: Props) {
data-testid="hf-link-file-select"
>
{load.choices.map((c) => (
- <option key={c.path} value={c.path}>
- {c.path} · {c.quant ?? 'GGUF'} · {sizeLabel(c.bytes)}{c.parts > 1 ? ` · ${c.parts} parts` : ''}
+ <option key={c.path} value={c.path} disabled={!!c.incomplete}>
+ {c.path} · {c.quant ?? 'GGUF'} · {sizeLabel(c.bytes)}{c.incomplete ? ` · ${incompleteLabel(c.incomplete)}` : c.parts > 1 ? ` · ${c.parts} parts` : ''}
</option>
))}
</select>
@@ -110,6 +110,14 @@ export function HfLinkDialog({ link, onCancel, onConfirm }: Props) {
<dd className="text-gray-800 dark:text-gray-100" data-testid="hf-link-size">
{sizeLabel(choice.bytes)}{choice.parts > 1 ? ` in ${choice.parts} parts` : ''}
</dd>
+ {choice.incomplete && (
+ <>
+ <dt className="text-gray-500">Parts</dt>
+ <dd role="alert" className="text-gray-800 dark:text-gray-100" data-testid="hf-link-incomplete">
+ Only {choice.incomplete.have} of {choice.incomplete.of} parts are on Hugging Face yet, and the model loads only with all of them. Try again later.
+ </dd>
+ </>
+ )}
{resolution?.imagePart && (
<>
<dt className="text-gray-500">Image input</dt>
@@ -129,7 +137,7 @@ export function HfLinkDialog({ link, onCancel, onConfirm }: Props) {
<ModalButton variant="quiet" onClick={onCancel}>Cancel</ModalButton>
<ModalButton
variant="primary"
- disabled={!model || !armed}
+ disabled={!model || !armed || !!choice?.incomplete}
onClick={() => { if (model) onConfirm(model) }}
>
{choice ? `Download (${sizeLabel(choice.bytes)})` : 'Download'}
diff --git a/src/components/models/__tests__/an-incomplete-split-gguf-is-not-downloaded.test.tsx b/src/components/models/__tests__/an-incomplete-split-gguf-is-not-downloaded.test.tsx
new file mode 100644
index 00000000..61d00a19
--- /dev/null
+++ b/src/components/models/__tests__/an-incomplete-split-gguf-is-not-downloaded.test.tsx
@@ -0,0 +1,100 @@
+/**
+ * @vitest-environment jsdom
+ *
+ * Bug hunt C11 (Oktober 2026): a repository where the uploader is still
+ * uploading lists `Big-Model-Q4_K_M-00001-of-00003.gguf` and `-00002-of-00003`
+ * only. The Hugging Face link dialog offered "Q4_K_M · 74.5 GB · 2 parts" and
+ * the download started both parts. llama.cpp loads a split set only with
+ * every part, so the model was "installed" and never started. The same
+ * resolver serves the Discover cards and the HF search.
+ *
+ * Run: npx vitest run src/components/models/__tests__/an-incomplete-split-gguf-is-not-downloaded.test.tsx
+ */
+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
+import { render, screen, fireEvent, cleanup, act } from '@testing-library/react'
+
+const GB = 1_000_000_000
+const backend = vi.hoisted(() => ({
+ fetchExternal: vi.fn(async (_url: string) => ''),
+ backendCall: vi.fn(async (_cmd: string): Promise<unknown> => null),
+}))
+vi.mock('../../../api/backend', () => ({
+ ...backend,
+ isTauri: () => false,
+ isMacOS: () => false,
+ isWindows: () => false,
+ openExternal: vi.fn(),
+}))
+
+import { HfLinkDialog } from '../HfLinkDialog'
+import { selectGgufFromTree, type HfTreeEntry } from '../../../api/discover'
+import { ggufChoicesFromTree, defaultChoice } from '../../../lib/hf-link'
+import { shardSetGap } from '../../../lib/gguf-shards'
+
+const part = (path: string, oid: string): HfTreeEntry => ({ type: 'file', path, size: 40 * GB, lfs: { oid: oid.repeat(64), size: 40 * GB } })
+const P1 = part('Q4_K_M/Big-Model-Q4_K_M-00001-of-00003.gguf', 'a')
+const P2 = part('Q4_K_M/Big-Model-Q4_K_M-00002-of-00003.gguf', 'b')
+const P3 = part('Q4_K_M/Big-Model-Q4_K_M-00003-of-00003.gguf', 'c')
+const INCOMPLETE = [P1, P2]
+const REPO = 'uploader/Big-Model-GGUF'
+
+async function settle() {
+ await act(async () => { await Promise.resolve(); await Promise.resolve() })
+}
+
+beforeEach(() => { vi.useFakeTimers({ shouldAdvanceTime: true }) })
+afterEach(() => { cleanup(); vi.useRealTimers(); vi.clearAllMocks() })
+
+describe('a split GGUF set with parts missing', () => {
+ it('counts as loadable only with exactly the parts 1..N', () => {
+ expect(shardSetGap([P1.path, P2.path, P3.path])).toBeNull()
+ expect(shardSetGap(['x-Q4_K_M.gguf'])).toBeNull()
+ expect(shardSetGap([P1.path, P2.path])).toEqual({ have: 2, of: 3 })
+ expect(shardSetGap([P2.path, P3.path])).toEqual({ have: 2, of: 3 })
+ // A stale part of an older two-part upload under the same name.
+ expect(shardSetGap([P1.path, P2.path, P3.path, 'Q4_K_M/Big-Model-Q4_K_M-00001-of-00002.gguf'])).not.toBeNull()
+ })
+
+ it('the resolver hands out no file of it, for the named file and for its quant', () => {
+ const named = selectGgufFromTree(INCOMPLETE, REPO, undefined, P1.path)
+ expect(named?.files).toEqual([])
+ expect(named?.incomplete).toEqual({ have: 2, of: 3 })
+ const byQuant = selectGgufFromTree(INCOMPLETE, REPO, 'Q4_K_M')
+ expect(byQuant?.files).toEqual([])
+ expect(byQuant?.incomplete).toEqual({ have: 2, of: 3 })
+ })
+
+ it('a complete quant next to it is taken where the choice is the resolver\'s own', () => {
+ const tree = [...INCOMPLETE, part('Big-Model-Q3_K_M.gguf', 'd')]
+ const picked = selectGgufFromTree(tree, REPO)
+ expect(picked?.incomplete).toBeUndefined()
+ expect(picked?.files.map((f) => f.filename)).toEqual(['Big-Model-Q3_K_M.gguf'])
+ })
+
+ it('the complete set still downloads all three parts', () => {
+ const picked = selectGgufFromTree([P1, P2, P3], REPO, undefined, P1.path)
+ expect(picked?.incomplete).toBeUndefined()
+ expect(picked?.files).toHaveLength(3)
+ })
+
+ it('the link dialog lists it as incomplete and never preselects it over a complete file', () => {
+ const choices = ggufChoicesFromTree([...INCOMPLETE, part('Big-Model-Q3_K_M.gguf', 'd')])
+ expect(choices.find((c) => c.path === P1.path)?.incomplete).toEqual({ have: 2, of: 3 })
+ expect(defaultChoice(choices)?.path).toBe('Big-Model-Q3_K_M.gguf')
+ })
+
+ it('THE REPORT: the link dialog says so and Download stays off', async () => {
+ backend.fetchExternal.mockResolvedValue(JSON.stringify(INCOMPLETE))
+ const onConfirm = vi.fn()
+ render(<HfLinkDialog link={{ repo: REPO, file: null }} onCancel={vi.fn()} onConfirm={onConfirm} />)
+ await settle()
+ expect(screen.getByTestId('hf-link-incomplete').textContent).toContain('Only 2 of 3 parts')
+ const select = screen.getByTestId('hf-link-file-select') as HTMLSelectElement
+ expect(select.options[0].textContent).toContain('incomplete: 2 of 3 parts, try again later')
+ const button = screen.getByRole('button', { name: /^Download/ }) as HTMLButtonElement
+ await act(async () => { vi.advanceTimersByTime(1500) })
+ expect(button.disabled).toBe(true)
+ fireEvent.click(button)
+ expect(onConfirm).not.toHaveBeenCalled()
+ })
+})
diff --git a/src/lib/gguf-shards.ts b/src/lib/gguf-shards.ts
new file mode 100644
index 00000000..95f64656
--- /dev/null
+++ b/src/lib/gguf-shards.ts
@@ -0,0 +1,31 @@
+/**
+ * Split GGUF sets (`<name>-00001-of-00003.gguf`): llama.cpp loads a split set
+ * only when every part lies next to the first one. A repository whose uploader
+ * is still uploading lists some parts only, and a download of those is many
+ * gigabytes of a model that never starts.
+ */
+
+// 5-digit llama.cpp split convention, a few uploaders pad to 4.
+const SHARD_RE = /-(\d{4,5})-of-(\d{4,5})\.gguf$/i
+
+/** How many parts of a split set are there, and how many it needs. */
+export interface ShardGap { have: number; of: number }
+
+/**
+ * The paths of one file group: null when it can be loaded (a single file, or
+ * exactly the parts 1..N of "-of-N", each once), otherwise how many of the
+ * parts are there.
+ */
+export function shardSetGap(paths: readonly string[]): ShardGap | null {
+ const shards = paths.map((p) => SHARD_RE.exec(p))
+ if (shards.every((m) => !m)) return null
+ const of = Math.max(...shards.map((m) => (m ? parseInt(m[2], 10) : 0)))
+ const indices = new Set(
+ shards
+ .filter((m): m is RegExpExecArray => !!m && parseInt(m[2], 10) === of)
+ .map((m) => parseInt(m[1], 10))
+ .filter((i) => i >= 1 && i <= of),
+ )
+ const have = indices.size
+ return have === of && paths.length === of ? null : { have, of }
+}
diff --git a/src/lib/hf-link.ts b/src/lib/hf-link.ts
index 0b960590..e804e297 100644
--- a/src/lib/hf-link.ts
+++ b/src/lib/hf-link.ts
@@ -12,6 +12,7 @@
import type { DiscoverModel } from '../api/model-bundles'
import type { HfGgufResolution } from '../api/discover'
+import { shardSetGap, type ShardGap } from './gguf-shards'
export interface HfModelLink {
repo: string
@@ -81,6 +82,9 @@ export interface HfLinkChoice {
quant?: string
bytes: number
parts: number
+ /** A split set the repository holds only some parts of. It cannot be
+ * loaded, so it is shown but not downloaded. */
+ incomplete?: ShardGap
}
const SHARD_RE = /-(\d{4,5})-of-(\d{4,5})\.gguf$/i
@@ -96,7 +100,7 @@ interface TreeEntry { type?: string; path?: string; size?: number }
*/
export function ggufChoicesFromTree(entries: unknown): HfLinkChoice[] {
if (!Array.isArray(entries)) return []
- const groups = new Map<string, HfLinkChoice & { first: number }>()
+ const groups = new Map<string, HfLinkChoice & { first: number; paths: string[] }>()
for (const e of entries as TreeEntry[]) {
if (e?.type !== 'file' || typeof e.path !== 'string' || !/\.gguf$/i.test(e.path)) continue
if (IMAGE_PART_RE.test(e.path)) continue
@@ -104,14 +108,18 @@ export function ggufChoicesFromTree(entries: unknown): HfLinkChoice[] {
const key = e.path.replace(SHARD_RE, '')
const index = shard ? parseInt(shard[1], 10) : 0
const leaf = (e.path.split('/').pop() || '').replace(SHARD_RE, '.gguf')
- const g = groups.get(key) ?? { path: e.path, quant: (QUANT_RE.exec(leaf)?.[1] ?? QUANT_RE.exec(e.path)?.[1])?.toUpperCase(), bytes: 0, parts: 0, first: index }
+ const g = groups.get(key) ?? { path: e.path, quant: (QUANT_RE.exec(leaf)?.[1] ?? QUANT_RE.exec(e.path)?.[1])?.toUpperCase(), bytes: 0, parts: 0, first: index, paths: [] }
g.bytes += typeof e.size === 'number' ? e.size : 0
g.parts += 1
+ g.paths.push(e.path)
if (index < g.first) { g.first = index; g.path = e.path }
groups.set(key, g)
}
return [...groups.values()]
- .map(({ first: _first, ...c }) => c)
+ .map(({ first: _first, paths, ...c }) => {
+ const gap = shardSetGap(paths)
+ return gap ? { ...c, incomplete: gap } : c
+ })
.sort((a, b) => a.bytes - b.bytes || a.path.localeCompare(b.path))
}
@@ -126,9 +134,16 @@ export function choiceForFile(choices: readonly HfLinkChoice[], file: string): H
return choices.find((c) => c.path === file || c.path.replace(SHARD_RE, '') === key && SHARD_RE.test(file)) ?? null
}
-/** The row preselected when the link names no file: Q4_K_M, else the smallest. */
+/** The row preselected when the link names no file: Q4_K_M, else the
+ * smallest, a complete one before an incomplete split set. */
export function defaultChoice(choices: readonly HfLinkChoice[]): HfLinkChoice | null {
- return choices.find((c) => c.quant === 'Q4_K_M') ?? choices[0] ?? null
+ const loadable = choices.filter((c) => !c.incomplete)
+ return loadable.find((c) => c.quant === 'Q4_K_M') ?? loadable[0] ?? choices[0] ?? null
+}
+
+/** The line a split set with parts missing gets. */
+export function incompleteLabel(gap: ShardGap): string {
+ return `incomplete: ${gap.have} of ${gap.of} parts, try again later`
}
/** "1.2 GB", "380 MB". */
diff --git a/src/mobile/screens/models/parts/adapters/hf.ts b/src/mobile/screens/models/parts/adapters/hf.ts
index 8e769283..aad52ebf 100644
--- a/src/mobile/screens/models/parts/adapters/hf.ts
+++ b/src/mobile/screens/models/parts/adapters/hf.ts
@@ -41,12 +41,12 @@ export function variantsFromTree(entries: HfTreeEntry[], repo: string): HfVarian
const out: HfVariant[] = []
for (const quant of quants) {
const picked = selectGgufFromTree(models, repo, quant)
- if (!picked || picked.quant !== quant) continue
+ if (!picked || picked.incomplete || picked.quant !== quant) continue
out.push({ quant, files: picked.files, totalBytes: picked.totalBytes, sharded: picked.sharded })
}
if (out.length === 0) {
const any = selectGgufFromTree(models, repo)
- if (any) out.push({ quant: any.quant ?? 'GGUF', files: any.files, totalBytes: any.totalBytes, sharded: any.sharded })
+ if (any && !any.incomplete) out.push({ quant: any.quant ?? 'GGUF', files: any.files, totalBytes: any.totalBytes, sharded: any.sharded })
}
return out.sort((a, b) => a.totalBytes - b.totalBytes)
}