Compare commits

..
2 Commits
Author SHA1 Message Date
Pascal LinxweilerandClaude Opus 5.5 4f05ee165c Release 0.14.2: steady download progress
Release / release (push) Successful in 6m29s
A progress sample that missed a partial file showed 0 B while hf kept
downloading. Walk the download cache tolerating vanished folders and
never let a file's progress go backwards within a run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 11:03:33 +02:00
Pascal LinxweilerandClaude Opus 5.5 22a54f731d Release 0.14.1: use Xet for files over 50 GB
Release / release (push) Successful in 3m27s
huggingface_hub 2.1.1 refuses files over MAX_HTTP_DOWNLOAD_SIZE (50 GB)
without Xet; Kaname disables Xet by default for steady progress, so such
downloads failed. A download that includes a file over the limit now
runs hf with Xet enabled and says so in the job log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 09:39:41 +02:00
8 changed files with 133 additions and 21 deletions

No files matched your search

+19
View File
@@ -4,6 +4,25 @@ All notable changes to this project are documented here.
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); each milestone of
step 1 (Hugging Face downloader) is released as a minor version.
## [0.14.2] - 2026-10-22
### Fixed
- A running download's progress could jump back and forth between the real value and 0 B while
`hf` kept downloading. A single progress reading that missed the partial file (a folder changing
while the worker listed it, or a stale size on a network share) counted as nothing downloaded.
Folders that vanish mid-listing are now skipped instead of failing the whole listing, and a file's
progress no longer goes backwards during a run.
## [0.14.1] - 2026-10-22
### Fixed
- Downloads with a file over 50 GB failed with "The file is too large to be downloaded using the
regular download method". `hf` (huggingface_hub 2.1.1) only downloads such files over Xet, which
Kaname turns off by default for steady progress; a download that includes one now uses Xet (noted
in the job log; its progress grows in bursts).
## [0.14.0] - 2026-10-21
A quality eval next to the speed benchmarks: a short, deterministic check of tool calling, coding and
+2 -1
View File
@@ -106,7 +106,8 @@ Notes on the `hf` CLI (huggingface_hub 2.1.1, pinned in the image):
- Interrupted files are **not resumed**: a re-run skips finished files and restarts unfinished ones.
Kaname cleans up the leftover partial files.
- With Xet transfers the partial file only grows in large bursts, so Kaname disables Xet by default
to show accurate progress.
to show accurate progress. Files over 50 GB can only be downloaded with Xet, so a download that
includes one uses Xet anyway.
- `hf` exits successfully even if nothing matched, so Kaname checks every file's size and hash
metadata after each download.
- Files that already exist in the target folder without hf's metadata (copied in by hand) are
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "kaname",
"version": "0.14.0",
"version": "0.14.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "kaname",
"version": "0.14.0",
"version": "0.14.2",
"dependencies": {
"@base-ui/react": "^1.8.0",
"@libsql/client": "^0.18.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "kaname",
"version": "0.14.0",
"version": "0.14.2",
"private": true,
"scripts": {
"dev": "concurrently -k -n web,worker -c blue,magenta \"npm:dev:web\" \"npm:dev:worker\"",
+14 -3
View File
@@ -20,11 +20,14 @@ import { escapeGlob } from "@/lib/selection";
import {
bytesOnDisk,
type ExpectedFile,
type FileProgress,
listIncomplete,
fileSize,
modelDir,
removeLocalFile,
removeStaleIncomplete,
steadyProgress,
xetFor,
} from "./hf-layout";
import { JobLog } from "./job-log";
import { log } from "./log";
@@ -248,6 +251,12 @@ export class DownloadRunner implements Runner {
expected: ExpectedFile[],
): Promise<{ code: number | null; signal: NodeJS.Signals | null; error?: string }> {
const env = coreEnv();
const xet = xetFor(expected, env.HF_HUB_DISABLE_XET);
if (xet.forcedBy.length) {
this.jobLog.system(
`Using Xet for this download: ${xet.forcedBy.slice(0, 3).join(", ")}${xet.forcedBy.length > 3 ? ", …" : ""} is over 50 GB, which hf only downloads with Xet (progress grows in bursts).`,
);
}
const args = [
"download",
this.model.repoId,
@@ -264,7 +273,7 @@ export class DownloadRunner implements Runner {
if (v !== undefined) childEnv[k] = v;
}
Object.assign(childEnv, {
HF_HUB_DISABLE_XET: env.HF_HUB_DISABLE_XET ? "1" : "0",
HF_HUB_DISABLE_XET: xet.useXet ? "0" : "1",
HF_HUB_DISABLE_PROGRESS_BARS: "1",
HF_HUB_DISABLE_TELEMETRY: "1",
NO_COLOR: "1",
@@ -275,7 +284,7 @@ export class DownloadRunner implements Runner {
this.jobLog.system(
`$ hf download ${this.model.repoId} --revision ${this.job.targetSha} --local-dir ${dir} ` +
`(${expected.length} --include pattern(s); xet ${env.HF_HUB_DISABLE_XET ? "off" : "on"}; token ${env.HF_TOKEN ? "set" : "not set"})`,
`(${expected.length} --include pattern(s); xet ${xet.useXet ? "on" : "off"}; token ${env.HF_TOKEN ? "set" : "not set"})`,
);
return new Promise((resolve) => {
@@ -311,11 +320,13 @@ export class DownloadRunner implements Runner {
// Progress from bytes on disk, written to the DB once per second.
const speed = new SpeedMeter();
let busy = false;
let last: FileProgress[] | null = null;
const timer = setInterval(async () => {
if (busy) return;
busy = true;
try {
const progress = await this.sample(dir, expected);
const progress = steadyProgress(last, await this.sample(dir, expected));
last = progress;
const doneBytes = progress.reduce((s, p) => s + p.done, 0);
speed.add(Date.now(), doneBytes);
await this.writeProgress(progress, doneBytes, speed);
+45 -14
View File
@@ -61,24 +61,41 @@ export type IncompleteFile = { path: string; etag: string | null; size: number }
/** All partial files under the local dir's download cache. */
export async function listIncomplete(dir: string): Promise<IncompleteFile[]> {
const root = join(dir, DOWNLOAD_DIR);
let entries;
try {
entries = await readdir(root, { recursive: true, withFileTypes: true });
} catch {
return [];
}
const out: IncompleteFile[] = [];
for (const e of entries) {
if (!e.isFile() || !e.name.endsWith(".incomplete")) continue;
const full = join(e.parentPath, e.name);
const size = await fileSize(full);
if (size == null) continue; // finished and moved between readdir and stat
out.push({ path: full, etag: etagFromIncompleteName(e.name), size });
}
// Walked by hand: readdir's `recursive` fails as a whole when hf removes a folder mid-walk,
// which read as "nothing downloaded" for that sample.
const walk = async (path: string) => {
let entries;
try {
entries = await readdir(path, { withFileTypes: true });
} catch {
return;
}
for (const e of entries) {
const full = join(path, e.name);
if (e.isDirectory()) await walk(full);
if (!e.isFile() || !e.name.endsWith(".incomplete")) continue;
const size = await fileSize(full);
if (size == null) continue; // finished and moved between readdir and stat
out.push({ path: full, etag: etagFromIncompleteName(e.name), size });
}
};
await walk(join(dir, DOWNLOAD_DIR));
return out;
}
export type FileProgress = { done: number; complete: boolean };
/**
* Progress that never goes backwards within one run. A sample can miss a partial file that is
* still being written (a folder renamed mid-walk, a stale size from a network share), and showing
* 0 B for a second is wrong; hf doesn't restart a file within a run.
*/
export function steadyProgress(prev: FileProgress[] | null, next: FileProgress[]): FileProgress[] {
if (!prev) return next;
return next.map((p, i) => (p.complete || !prev[i] ? p : { done: Math.max(p.done, prev[i].done), complete: false }));
}
/** Delete leftover partial files from earlier runs. Only call while no hf process uses the dir. */
export async function removeStaleIncomplete(dir: string): Promise<{ count: number; bytes: number }> {
const files = await listIncomplete(dir);
@@ -137,3 +154,17 @@ export async function listLocalFiles(dir: string): Promise<{ path: string; size:
}
return out.sort((a, b) => a.path.localeCompare(b.path));
}
/** huggingface_hub's MAX_HTTP_DOWNLOAD_SIZE (2.1.1): larger files can only come over Xet. */
export const MAX_HTTP_DOWNLOAD_BYTES = 50 * 1000 * 1000 * 1000;
/**
* Whether hf may use Xet for these files. Kaname turns Xet off for steady progress, but hf refuses
* files over 50 GB without it ("too large to be downloaded using the regular download method"), so
* such a job uses Xet regardless. Returns the files that forced it, for the log.
*/
export function xetFor(files: ExpectedFile[], disabledBySetting: boolean): { useXet: boolean; forcedBy: string[] } {
if (!disabledBySetting) return { useXet: true, forcedBy: [] };
const big = files.filter((f) => f.size > MAX_HTTP_DOWNLOAD_BYTES).map((f) => f.path);
return { useXet: big.length > 0, forcedBy: big };
}
+31
View File
@@ -0,0 +1,31 @@
import assert from "node:assert/strict";
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { describe, it } from "node:test";
import { listIncomplete, steadyProgress } from "./hf-layout";
const ETAG = "b139949c5bd74937ad8ed8c8cf3d9ffb1e99c866c823204dc42c0d91fa181897";
describe("download progress", () => {
it("never goes backwards for a file that isn't complete", () => {
const a = steadyProgress(null, [{ done: 300e6, complete: false }, { done: 0, complete: false }]);
const b = steadyProgress(a, [{ done: 0, complete: false }, { done: 5e6, complete: false }]);
assert.deepEqual(b, [{ done: 300e6, complete: false }, { done: 5e6, complete: false }]);
const c = steadyProgress(b, [{ done: 400e6, complete: true }, { done: 6e6, complete: false }]);
assert.deepEqual(c, [{ done: 400e6, complete: true }, { done: 6e6, complete: false }]);
});
it("finds partial files in subfolders and skips folders that are gone", async () => {
const dir = await mkdtemp(join(tmpdir(), "kaname-progress-"));
try {
const sub = join(dir, ".cache", "huggingface", "download", "Q4_K_M");
await mkdir(sub, { recursive: true });
await writeFile(join(sub, `abc=.${ETAG}.905d6ccf.incomplete`), Buffer.alloc(1234));
assert.deepEqual((await listIncomplete(dir)).map((f) => [f.etag, f.size]), [[ETAG, 1234]]);
assert.deepEqual(await listIncomplete(join(dir, "missing")), []);
} finally {
await rm(dir, { recursive: true, force: true });
}
});
});
+19
View File
@@ -0,0 +1,19 @@
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { MAX_HTTP_DOWNLOAD_BYTES, xetFor } from "./hf-layout";
const f = (path: string, size: number) => ({ path, size, etags: [] });
describe("Xet for files over 50 GB", () => {
it("stays off for ordinary files when the setting disables it", () => {
assert.deepEqual(xetFor([f("a.gguf", 20e9), f("b.gguf", MAX_HTTP_DOWNLOAD_BYTES)], true), { useXet: false, forcedBy: [] });
});
it("turns on for a job with a file hf only downloads over Xet", () => {
assert.deepEqual(xetFor([f("small.json", 1000), f("Huge-BF16.gguf", 54e9)], true), { useXet: true, forcedBy: ["Huge-BF16.gguf"] });
});
it("is on whenever the setting allows Xet", () => {
assert.deepEqual(xetFor([f("a.gguf", 1)], false), { useXet: true, forcedBy: [] });
});
});