Xet holds downloaded data in memory and writes the file in large, late chunks, so on-disk sizes showed little or no progress. For Xet runs, force hf's progress bars on (TQDM_POSITION=-1), read its running byte count and keep the bars out of the job log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4f05ee165c
commit
1d2f908b75
8 files changed
+131
-8
No files matched your search
+11
-4
@@ -29,6 +29,7 @@ import {
|
||||
steadyProgress,
|
||||
xetFor,
|
||||
} from "./hf-layout";
|
||||
import { XetCounter } from "./hf-progress";
|
||||
import { JobLog } from "./job-log";
|
||||
import { log } from "./log";
|
||||
import { settleModelStatus } from "./model-status";
|
||||
@@ -201,7 +202,7 @@ export class DownloadRunner implements Runner {
|
||||
}
|
||||
if (this.stopReason) return { state: this.stopReason, message: "Stopped before hf started." };
|
||||
|
||||
const exit = await this.spawnHf(dir, expected);
|
||||
const exit = await this.spawnHf(dir, expected, expected.reduce((s, f, i) => s + (initial[i].complete ? f.size : 0), 0));
|
||||
if (this.stopReason) {
|
||||
return {
|
||||
state: this.stopReason,
|
||||
@@ -249,12 +250,13 @@ export class DownloadRunner implements Runner {
|
||||
private spawnHf(
|
||||
dir: string,
|
||||
expected: ExpectedFile[],
|
||||
alreadyDone: number,
|
||||
): 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).`,
|
||||
`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.`,
|
||||
);
|
||||
}
|
||||
const args = [
|
||||
@@ -274,7 +276,8 @@ export class DownloadRunner implements Runner {
|
||||
}
|
||||
Object.assign(childEnv, {
|
||||
HF_HUB_DISABLE_XET: xet.useXet ? "0" : "1",
|
||||
HF_HUB_DISABLE_PROGRESS_BARS: "1",
|
||||
// Xet: progress comes from hf's own byte counter (see hf-progress.ts), so force its bars on.
|
||||
...(xet.useXet ? { HF_HUB_DISABLE_PROGRESS_BARS: "0", TQDM_POSITION: "-1" } : { HF_HUB_DISABLE_PROGRESS_BARS: "1" }),
|
||||
HF_HUB_DISABLE_TELEMETRY: "1",
|
||||
NO_COLOR: "1",
|
||||
PYTHONUNBUFFERED: "1",
|
||||
@@ -296,6 +299,7 @@ export class DownloadRunner implements Runner {
|
||||
clearInterval(throttleTimer);
|
||||
running.delete(this);
|
||||
this.jobLog.end();
|
||||
this.jobLog.intercept = null;
|
||||
resolve(r);
|
||||
};
|
||||
|
||||
@@ -318,6 +322,8 @@ export class DownloadRunner implements Runner {
|
||||
const throttleTimer = this.throttle(dir, expected);
|
||||
|
||||
// Progress from bytes on disk, written to the DB once per second.
|
||||
const xetBytes = new XetCounter();
|
||||
if (xet.useXet) this.jobLog.intercept = (_stream, line) => xetBytes.feed(line);
|
||||
const speed = new SpeedMeter();
|
||||
let busy = false;
|
||||
let last: FileProgress[] | null = null;
|
||||
@@ -327,7 +333,8 @@ export class DownloadRunner implements Runner {
|
||||
try {
|
||||
const progress = steadyProgress(last, await this.sample(dir, expected));
|
||||
last = progress;
|
||||
const doneBytes = progress.reduce((s, p) => s + p.done, 0);
|
||||
const onDisk = progress.reduce((s, p) => s + p.done, 0);
|
||||
const doneBytes = Math.min(this.job.totalBytes, Math.max(onDisk, alreadyDone + xetBytes.bytes));
|
||||
speed.add(Date.now(), doneBytes);
|
||||
await this.writeProgress(progress, doneBytes, speed);
|
||||
await this.jobLog.flush();
|
||||
|
||||
Reference in new issue
Block a user