Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: stop the stall watchdog from killing Xet downloads that are still receiving data (#11594)
Nilay249e5373adbb
diff --git a/studio/backend/hub/services/download_lifecycle.py b/studio/backend/hub/services/download_lifecycle.pyindex b654dca18ee..9649702a9e0 100644--- a/studio/backend/hub/services/download_lifecycle.py+++ b/studio/backend/hub/services/download_lifecycle.py@@ -19,6 +19,7 @@ from hub.services.models import account_accessfrom utils.account_context import OWNER_ACCOUNT_ID, account_thread, current_account_idfrom hub.schemas.downloads import ActiveDownload, DownloadJobState+from hub.utils import download_heartbeatfrom hub.utils import download_manifestfrom hub.utils import download_registryfrom hub.utils import inventory_scan as hf_cache_scan@@ -433,7 +434,11 @@ def spawn_worker(env["PYTHONPATH"] = f"{cwd}{os.pathsep}{existing_path}" if existing_path else str(cwd)proc = Nonefiles_manifest = None+ heartbeat = Nonetry:+ if use_xet:+ heartbeat = download_heartbeat.new_path()+ args = [*args, "--heartbeat", heartbeat]if files:files_manifest = write_files_manifest(files)args = [*args, "--files-json", files_manifest]@@ -456,6 +461,8 @@ def spawn_worker()return procfinally:+ if proc is None:+ download_heartbeat.remove(heartbeat)if proc is None and files_manifest is not None:try:Path(files_manifest).unlink(missing_ok = True)@@ -534,15 +541,24 @@ def classify_exit(rc: int, *, cancel_requested: bool = False) -> str:return "error"-def _cleanup_worker_files_manifest(proc: subprocess.Popen) -> None:+def _worker_arg(proc: subprocess.Popen, flag: str) -> Optional[str]:args = getattr(proc, "args", None)- if not isinstance(args, (list, tuple)) or "--files-json" not in args:+ if not isinstance(args, (list, tuple)) or flag not in args:+ return None+ index = args.index(flag) + 1+ return str(args[index]) if index < len(args) else None+++def _cleanup_worker_files(proc: subprocess.Popen) -> None:+ heartbeat = _worker_arg(proc, "--heartbeat")+ files_manifest = _worker_arg(proc, "--files-json")+ if (heartbeat is None and files_manifest is None) or proc.poll() is None:return- index = args.index("--files-json") + 1- if index >= len(args) or proc.poll() is None:+ download_heartbeat.remove(heartbeat)+ if files_manifest is None:returntry:- Path(args[index]).unlink(missing_ok = True)+ Path(files_manifest).unlink(missing_ok = True)except OSError:logger.warning("Could not remove the exited worker's download files manifest")@@ -570,7 +586,7 @@ def finalize_worker_exit("""stderr_data = drain_stderr_excerpt(proc.stderr)rc = proc.wait()- _cleanup_worker_files_manifest(proc)+ _cleanup_worker_files(proc)cancel_requested = registry.cancel_requested(key)if not registry.drop_process(key, proc):return "idle"@@ -988,7 +1004,7 @@ def kill_and_reap_process(logger.warning(f"Cancelled worker for {label} did not exit after SIGKILL")except Exception:pass- _cleanup_worker_files_manifest(proc)+ _cleanup_worker_files(proc)def _record_xet_failure(reason: str, logger) -> None:@@ -1058,6 +1074,38 @@ def _record_xet_success(logger) -> None:logger.debug("could not record Xet outcome: %s", exc)+def _stall_window() -> float:+ import importlib++ default = float(+ getattr(importlib.import_module("utils.hf_xet_fallback"), "DEFAULT_STALL_TIMEOUT", 30.0)+ )+ try:+ value = float(os.environ.get("UNSLOTH_XET_STALL_TIMEOUT") or default)+ except ValueError:+ return default+ return value if 0 < value < float("inf") else default+++class _WatchdogHandle:+ def __init__(self) -> None:+ self._inner = None+ self._stopped = False+ self._lock = threading.Lock()++ def bind(self, inner) -> None:+ with self._lock:+ self._inner = inner+ if self._stopped and inner is not None:+ inner.set()++ def set(self) -> None:+ with self._lock:+ self._stopped = True+ if self._inner is not None:+ self._inner.set()++def _start_stall_watchdog(registry: download_registry.DownloadRegistry,key: str,@@ -1079,10 +1127,42 @@ def _start_stall_watchdog(metadata = registry.get_job_metadata(key)cache_dir = getattr(metadata, "hub_cache", None) if metadata is not None else None+ heartbeat = _worker_arg(proc, "--heartbeat")+ handle = _WatchdogHandle()+ window = _stall_window()+ last_beat = download_heartbeat.read(heartbeat) or 0++ def _transfer_advanced() -> bool:+ nonlocal last_beat+ beat = download_heartbeat.read(heartbeat)+ age = download_heartbeat.age(heartbeat)+ if beat is None or age is None or beat <= last_beat or age > window:+ return False+ last_beat = beat+ return Truedef _on_stall(message: str) -> None:+ if _transfer_advanced():+ rearmed = _arm()+ if rearmed is not None:+ logger.info(+ "%s %s for %s, but the worker is still receiving data; re-arming the watchdog",+ log_prefix,+ message,+ label,+ )+ handle.bind(rearmed)+ return+ logger.warning(+ "%s could not re-arm the stall watchdog for %s; treating the verdict as final",+ log_prefix,+ label,+ )logger.warning(- "%s %s for %s; killing the worker to retry over HTTP", log_prefix, message, label+ "%s %s for %s; killing the worker so the recovery ladder can retry",+ log_prefix,+ message,+ label,)on_stall(message)try:@@ -1093,22 +1173,29 @@ def _start_stall_watchdog(except Exception:logger.exception("%s failed to kill stalled worker for %s", log_prefix, label)- try:- return start_watchdog(- repo_ids = [repo_id],- repo_type = repo_type,- cache_dir = cache_dir,- on_stall = _on_stall,- child_pid = proc.pid,- # Scope the measurement to partials this worker holds open; otherwise the shared helper stays repo-wide, child_pid does nothing, and two concurrent same-transport GGUF variants of one repo reset each other's stall timer. The DATA clock only: before its first byte a variant is still covered by the repo-wide peer-progress check.- watch_new_partials_only = True,- # The shared 90s zero-byte default assumes a single-file download whose pre-byte phase is one HEAD; snapshot_download(max_workers=1) does a model_info lookup plus one sequential HEAD per file, which for an already-cached repo is the entire job with no byte written.- connect_timeout = 600.0,- xet_disabled = False,- )- except Exception as exc: # noqa: BLE001- logger.debug("%s could not start stall watchdog for %s: %s", log_prefix, label, exc)+ def _arm():+ try:+ return start_watchdog(+ repo_ids = [repo_id],+ repo_type = repo_type,+ cache_dir = cache_dir,+ on_stall = _on_stall,+ child_pid = proc.pid,+ # Scope the measurement to partials this worker holds open; otherwise the shared helper stays repo-wide, child_pid does nothing, and two concurrent same-transport GGUF variants of one repo reset each other's stall timer. The DATA clock only: before its first byte a variant is still covered by the repo-wide peer-progress check.+ watch_new_partials_only = True,+ # The shared 90s zero-byte default assumes a single-file download whose pre-byte phase is one HEAD; snapshot_download(max_workers=1) does a model_info lookup plus one sequential HEAD per file, which for an already-cached repo is the entire job with no byte written.+ connect_timeout = 600.0,+ xet_disabled = False,+ )+ except Exception as exc: # noqa: BLE001+ logger.debug("%s could not start stall watchdog for %s: %s", log_prefix, label, exc)+ return None++ inner = _arm()+ if inner is None:return None+ handle.bind(inner)+ return handledef register_worker(diff --git a/studio/backend/hub/tests/test_download_heartbeat.py b/studio/backend/hub/tests/test_download_heartbeat.pynew file mode 100644index 00000000000..222bfbe1970--- /dev/null+++ b/studio/backend/hub/tests/test_download_heartbeat.py@@ -0,0 +1,243 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import logging+import os+import time++from hub.services import download_lifecycle+from hub.utils import download_heartbeat, download_registry+from hub.workers import hf_download++VERDICT = "Download appears stalled (xet transport) -- no progress for 30s"+++class _Proc:+ pid = 4242++ def __init__(+ self,+ heartbeat,+ rc = None,+ ):+ self.args = ["python", "--heartbeat", str(heartbeat)]+ self.killed = False+ self.rc = rc++ def poll(self):+ return self.rc++ def kill(self):+ self.killed = True+++class _Stop:+ def __init__(self):+ self.stopped = False++ def set(self):+ self.stopped = True+++def _watchdog(monkeypatch, proc, on_stall):+ import utils.hf_xet_fallback as shim++ started = []++ def fake_start(*, on_stall, **_kwargs):+ stop = _Stop()+ started.append((on_stall, stop))+ return stop++ monkeypatch.setattr(shim, "start_watchdog", fake_start)+ registry = download_registry.DownloadRegistry()+ key = download_registry.normalize_job_key("Org/Model")+ handle = download_lifecycle._start_stall_watchdog(+ registry,+ key,+ proc,+ repo_type = "model",+ repo_id = "Org/Model",+ label = "Org/Model",+ log_prefix = "Download",+ logger = logging.getLogger("test"),+ on_stall = on_stall,+ )+ return handle, started+++def test_a_verdict_is_overruled_while_the_worker_still_receives(monkeypatch, tmp_path):+ beat = tmp_path / "beat"+ beat.write_text("100")+ proc = _Proc(beat)+ stalled = []+ _handle, started = _watchdog(monkeypatch, proc, stalled.append)+ beat.write_text("250")+ started[0][0](VERDICT)+ assert not proc.killed+ assert stalled == []+ assert len(started) == 2+ started[1][0](VERDICT)+ assert proc.killed+ assert stalled == [VERDICT]+ assert len(started) == 2+++def test_a_heartbeat_older_than_the_stall_window_does_not_save_the_worker(monkeypatch, tmp_path):+ beat = tmp_path / "beat"+ beat.write_text("100")+ proc = _Proc(beat)+ stalled = []+ _handle, started = _watchdog(monkeypatch, proc, stalled.append)+ beat.write_text("250")+ stale = time.time() - 600+ os.utime(beat, (stale, stale))+ started[0][0](VERDICT)+ assert proc.killed+ assert stalled == [VERDICT]+ assert len(started) == 1+++def test_a_failed_re_arm_lets_the_verdict_stand(monkeypatch, tmp_path):+ import utils.hf_xet_fallback as shim++ beat = tmp_path / "beat"+ beat.write_text("100")+ proc = _Proc(beat)+ stalled = []+ calls = []++ def fake_start(*, on_stall, **_kwargs):+ calls.append(on_stall)+ if len(calls) > 1:+ raise RuntimeError("no watchdog")+ return _Stop()++ monkeypatch.setattr(shim, "start_watchdog", fake_start)+ registry = download_registry.DownloadRegistry()+ key = download_registry.normalize_job_key("Org/Model")+ download_lifecycle._start_stall_watchdog(+ registry,+ key,+ proc,+ repo_type = "model",+ repo_id = "Org/Model",+ label = "Org/Model",+ log_prefix = "Download",+ logger = logging.getLogger("test"),+ on_stall = stalled.append,+ )+ beat.write_text("250")+ calls[0](VERDICT)+ assert proc.killed+ assert stalled == [VERDICT]+++def test_a_verdict_with_no_heartbeat_kills_as_before(monkeypatch, tmp_path):+ proc = _Proc(tmp_path / "missing")+ stalled = []+ _handle, started = _watchdog(monkeypatch, proc, stalled.append)+ started[0][0](VERDICT)+ assert proc.killed+ assert stalled == [VERDICT]+ assert len(started) == 1+++def test_stopping_the_handle_stops_the_re_armed_watchdog(monkeypatch, tmp_path):+ beat = tmp_path / "beat"+ beat.write_text("1")+ proc = _Proc(beat)+ handle, started = _watchdog(monkeypatch, proc, lambda _m: None)+ beat.write_text("2")+ started[0][0](VERDICT)+ handle.set()+ assert started[1][1].stopped+ beat.write_text("3")+ started[1][0](VERDICT)+ assert not proc.killed+ assert started[2][1].stopped+++def test_the_worker_progress_class_reports_transfer_bytes(tmp_path):+ beat = tmp_path / "beat"+ cls = hf_download._progress_class(str(beat))+ bar = cls(total = 10, disable = True)+ bar.update(4)+ bar.update(-3)+ bar.close()+ assert download_heartbeat.read(str(beat)) == 4+ assert hf_download._progress_class(None) is None+++def test_the_stall_window_follows_the_environment(monkeypatch):+ monkeypatch.delenv("UNSLOTH_XET_STALL_TIMEOUT", raising = False)+ assert download_lifecycle._stall_window() == 30.0+ monkeypatch.setenv("UNSLOTH_XET_STALL_TIMEOUT", "12")+ assert download_lifecycle._stall_window() == 12.0+ monkeypatch.setenv("UNSLOTH_XET_STALL_TIMEOUT", "junk")+ assert download_lifecycle._stall_window() == 30.0+++def test_heartbeat_writer_throttles_and_reader_rejects_garbage(tmp_path):+ beat = tmp_path / "beat"+ writer = download_heartbeat.HeartbeatWriter(str(beat), interval = 3600.0)+ writer.add(5)+ writer.add(7)+ assert download_heartbeat.read(str(beat)) == 5+ beat.write_text("not a number")+ assert download_heartbeat.read(str(beat)) is None+ assert download_heartbeat.read(None) is None+++def test_worker_files_are_removed_once_the_worker_exits(tmp_path):+ beat = tmp_path / "beat"+ beat.write_text("1")+ (tmp_path / "beat.tmp").write_text("")+ proc = _Proc(beat)+ download_lifecycle._cleanup_worker_files(proc)+ assert beat.exists()+ proc.rc = 0+ download_lifecycle._cleanup_worker_files(proc)+ assert not beat.exists()+ assert not (tmp_path / "beat.tmp").exists()+++def test_an_orphaned_worker_removes_its_own_heartbeat(monkeypatch, tmp_path):+ beat = tmp_path / "beat"+ beat.write_text("1")+ (tmp_path / "beat.tmp").write_text("")++ def _exit(code):+ raise SystemExit(code)++ monkeypatch.setattr(hf_download.os, "_exit", _exit)+ try:+ hf_download._terminate_orphaned_self(str(beat))+ except SystemExit as exc:+ assert exc.code == 130+ assert not beat.exists()+ assert not (tmp_path / "beat.tmp").exists()+++def test_only_xet_workers_get_a_heartbeat(monkeypatch, tmp_path):+ spawned = []+ real_popen = download_lifecycle.subprocess.Popen++ def fake_popen(args, **kwargs):+ if "hub.workers.hf_download" not in args:+ return real_popen(args, **kwargs)+ spawned.append(args)+ return _Proc(tmp_path / "unused", rc = 0)++ monkeypatch.setattr(download_lifecycle.subprocess, "Popen", fake_popen)+ monkeypatch.setattr("huggingface_hub.utils.get_token_to_send", lambda token: None)+ monkeypatch.setattr("tempfile.tempdir", str(tmp_path))+ download_lifecycle.spawn_worker(+ ["--repo-id", "Org/Model"], None, use_xet = True, allow_ambient_token = False+ )+ download_lifecycle.spawn_worker(+ ["--repo-id", "Org/Model"], None, use_xet = False, allow_ambient_token = False+ )+ assert "--heartbeat" in spawned[0]+ assert spawned[0][spawned[0].index("--heartbeat") + 1].startswith(str(tmp_path))+ assert "--heartbeat" not in spawned[1]diff --git a/studio/backend/hub/tests/test_model_services.py b/studio/backend/hub/tests/test_model_services.pyindex 6504c6bfa0f..35f48f990e1 100644--- a/studio/backend/hub/tests/test_model_services.py+++ b/studio/backend/hub/tests/test_model_services.py@@ -3045,6 +3045,7 @@ def test_download_dataset_continues_without_metadata_manifest(monkeypatch, tmp_p"token": False,"repo_type": "dataset","max_workers": 1,+ "tqdm_class": None,}]assert verified == [("dataset", "Org/Data", None, str(tmp_path))]@@ -6511,6 +6512,7 @@ def test_download_dataset_writes_manifest_for_xet(monkeypatch, tmp_path):"token": False,"repo_type": "dataset","max_workers": 1,+ "tqdm_class": None,"revision": "dataset-commit",}]diff --git a/studio/backend/hub/utils/download_heartbeat.py b/studio/backend/hub/utils/download_heartbeat.pynew file mode 100644index 00000000000..c1bc80ef26d--- /dev/null+++ b/studio/backend/hub/utils/download_heartbeat.py@@ -0,0 +1,73 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++from __future__ import annotations++import os+import tempfile+import threading+import time+import uuid+from pathlib import Path+from typing import Optional+++def new_path() -> str:+ return os.path.join(tempfile.gettempdir(), f"unsloth-dl-heartbeat-{uuid.uuid4().hex}")+++def read(path: Optional[str]) -> Optional[int]:+ if not path:+ return None+ try:+ text = Path(path).read_text(encoding = "utf-8").strip()+ except OSError:+ return None+ return int(text) if text.isdigit() else None+++def age(path: Optional[str]) -> Optional[float]:+ if not path:+ return None+ try:+ return max(0.0, time.time() - Path(path).stat().st_mtime)+ except OSError:+ return None+++def remove(path: Optional[str]) -> None:+ if not path:+ return+ for candidate in (path, f"{path}.tmp"):+ try:+ Path(candidate).unlink(missing_ok = True)+ except OSError:+ pass+++class HeartbeatWriter:+ def __init__(+ self,+ path: str,+ interval: float = 1.0,+ ) -> None:+ self._path = path+ self._interval = interval+ self._total = 0+ self._flushed_at = float("-inf")+ self._lock = threading.Lock()++ def add(self, n: int) -> None:+ with self._lock:+ self._total += n+ now = time.monotonic()+ if now - self._flushed_at < self._interval:+ return+ self._flushed_at = now+ tmp = f"{self._path}.tmp"+ try:+ with open(tmp, "w", encoding = "utf-8") as handle:+ handle.write(str(self._total))+ os.replace(tmp, self._path)+ except OSError:+ passdiff --git a/studio/backend/hub/workers/hf_download.py b/studio/backend/hub/workers/hf_download.pyindex 7893b7f757d..f275d696098 100644--- a/studio/backend/hub/workers/hf_download.py+++ b/studio/backend/hub/workers/hf_download.py@@ -124,7 +124,7 @@ def _parent_is_alive(parent_pid: int) -> bool:return True-def _terminate_orphaned_self() -> None:+def _terminate_orphaned_self(heartbeat: str | None = None) -> None:# Hard exit from the watchdog thread: a self-SIGTERM would be deferred while the main thread is GIL-blocked in a C socket read, and the partial resumes byte-exact with atomic marker writes.try:print(@@ -134,10 +134,16 @@ def _terminate_orphaned_self() -> None:sys.stderr.flush()except Exception:pass+ # The parent owns heartbeat cleanup and is gone, so nobody else will remove it.+ try:+ from hub.utils.download_heartbeat import remove+ remove(heartbeat)+ except Exception:+ passos._exit(130)-def _install_parent_death_watchdog(parent_pid: int | None) -> None:+def _install_parent_death_watchdog(parent_pid: int | None, heartbeat: str | None = None) -> None:if not parent_pid or parent_pid <= 0:returninterval = _parent_poll_seconds()@@ -149,7 +155,7 @@ def _install_parent_death_watchdog(parent_pid: int | None) -> None:except Exception:alive = Trueif not alive:- _terminate_orphaned_self()+ _terminate_orphaned_self(heartbeat)returntime.sleep(interval)@@ -578,7 +584,12 @@ def _recover_manifest_after_download()-def _download_snapshot(repo_id: str, hf_token: str | None, mode: str) -> None:+def _download_snapshot(+ repo_id: str,+ hf_token: str | None,+ mode: str,+ tqdm_class: type | None = None,+) -> None:from huggingface_hub import snapshot_downloadfrom hub.utils.download_registry import prepare_cache_for_transportfrom hub.utils import download_manifest@@ -619,6 +630,7 @@ def _download_snapshot(repo_id: str, hf_token: str | None, mode: str) -> None:token = _hf_token_arg(hf_token),ignore_patterns = ignore_patterns,max_workers = 1,+ tqdm_class = tqdm_class,)if info is None:_recover_manifest_after_download(@@ -656,7 +668,13 @@ def _gguf_variant_target_plan(return plan_for_variant(build_gguf_variant_plans(list(info.siblings)), variant)-def _download_gguf_variant(repo_id: str, variant: str, hf_token: str | None, mode: str) -> None:+def _download_gguf_variant(+ repo_id: str,+ variant: str,+ hf_token: str | None,+ mode: str,+ tqdm_class: type | None = None,+) -> None:from huggingface_hub import snapshot_downloadfrom hub.utils.download_registry import prepare_cache_for_transportfrom hub.utils.hf_cache_state import has_active_incomplete_blobs@@ -761,6 +779,7 @@ def _download_gguf_variant(repo_id: str, variant: str, hf_token: str | None, modtoken = _hf_token_arg(hf_token),allow_patterns = targets,max_workers = 1,+ tqdm_class = tqdm_class,)_verify_completed_download("model",@@ -788,7 +807,12 @@ def _download_gguf_variant(repo_id: str, variant: str, hf_token: str | None, moddef _download_scoped_snapshot(- repo_id: str, scope: str, files: list[str], hf_token: str | None, mode: str+ repo_id: str,+ scope: str,+ files: list[str],+ hf_token: str | None,+ mode: str,+ tqdm_class: type | None = None,) -> None:"""Fetch exactly ``files`` from ``repo_id``, keyed under ``scope``. For consumers that read a deliberate subset of a repo (the diffusion loader skips the packaged root single, transformer/ shards and fp16 twins). Keyed apart from the repo's full snapshot so neither manifest describes the other, and the repo is not later judged partial against expectations it was never meant to meet."""from huggingface_hub import HfApi, snapshot_download@@ -856,6 +880,7 @@ def _download_scoped_snapshot(token = _hf_token_arg(hf_token),allow_patterns = files,max_workers = 1,+ tqdm_class = tqdm_class,)if info is None:# With no metadata there is no manifest, and snapshot_download RETURNS AN EXISTING SNAPSHOT FOLDER when repo_info also fails, flipping the job to complete with no weights.@@ -878,7 +903,12 @@ def _download_scoped_snapshot()-def _download_dataset(repo_id: str, hf_token: str | None, mode: str) -> None:+def _download_dataset(+ repo_id: str,+ hf_token: str | None,+ mode: str,+ tqdm_class: type | None = None,+) -> None:from huggingface_hub import snapshot_downloadfrom hub.utils.download_registry import prepare_cache_for_transportfrom hub.utils import download_manifest@@ -923,6 +953,7 @@ def _download_dataset(repo_id: str, hf_token: str | None, mode: str) -> None:"token": _hf_token_arg(hf_token),"repo_type": "dataset","max_workers": 1,+ "tqdm_class": tqdm_class,}if isinstance(commit_hash, str) and commit_hash.strip():download_kwargs["revision"] = commit_hash.strip()@@ -975,6 +1006,23 @@ def _force_stall_for_tests(repo_id: str, repo_type: str) -> None:time.sleep(3600)+def _progress_class(heartbeat: str | None) -> type | None:+ if not heartbeat:+ return None+ from huggingface_hub.utils import tqdm as hf_tqdm+ from hub.utils.download_heartbeat import HeartbeatWriter++ writer = HeartbeatWriter(heartbeat)++ class _Heartbeat(hf_tqdm):+ def update(self, n = 1):+ if n and n > 0:+ writer.add(int(n))+ return super().update(n)++ return _Heartbeat++def main() -> None:parser = argparse.ArgumentParser(description = "HuggingFace Hub download worker")parser.add_argument("--repo-id", required = True)@@ -987,6 +1035,7 @@ def main() -> None:default = None,help = "Temp JSON file holding a scoped job's exact file list (deleted after reading).",)+ parser.add_argument("--heartbeat", default = None)args = parser.parse_args()scoped_files: list[str] = []@@ -1002,24 +1051,25 @@ def main() -> None:pass_install_signal_handlers()- _install_parent_death_watchdog(args.parent_pid)+ _install_parent_death_watchdog(args.parent_pid, args.heartbeat)hf_token = os.environ.get("HF_TOKEN") or Noneif args.transport == "xet" and os.environ.get("UNSLOTH_HF_XET_FORCE_STALL") == "1":_force_stall_for_tests(args.repo_id, "dataset" if args.dataset else "model")+ progress = _progress_class(args.heartbeat)try:if args.dataset:- _download_dataset(args.repo_id, hf_token, args.transport)+ _download_dataset(args.repo_id, hf_token, args.transport, progress)elif scoped_files:_download_scoped_snapshot(- args.repo_id, args.variant, scoped_files, hf_token, args.transport+ args.repo_id, args.variant, scoped_files, hf_token, args.transport, progress)elif args.variant:- _download_gguf_variant(args.repo_id, args.variant, hf_token, args.transport)+ _download_gguf_variant(args.repo_id, args.variant, hf_token, args.transport, progress)else:- _download_snapshot(args.repo_id, hf_token, args.transport)+ _download_snapshot(args.repo_id, hf_token, args.transport, progress)sys.exit(0)except SystemExit:raise