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 drafter: split TRL packed rows at seq_lengths, reattach a Hub full fine-tune's MTP head on export (#14911)
Daniel Han40290cf194fd
diff --git a/studio/backend/core/export/drafter_export.py b/studio/backend/core/export/drafter_export.pyindex 709a9357ce3..1368b209ce0 100644--- a/studio/backend/core/export/drafter_export.py+++ b/studio/backend/core/export/drafter_export.py@@ -33,17 +33,27 @@ def _read_json(path: str) -> Optional[dict]:return data if isinstance(data, dict) else None-def _hub_adapter_snapshot(repo_id: str, token = None) -> Optional[str]:- """A Hub adapter's cached files (its manifest and MTP head): the loader re-attached that head."""+def _hub_adapter_snapshot(+ repo_id: str,+ token = None,+ revision = None,+ local_files_only = False,+) -> Optional[str]:+ """A Hub adapter's cached files (its manifest and MTP head), read at the load's commit."""if os.path.isabs(repo_id) or repo_id.count("/") != 1:return None+ kwargs = {"token": token}+ if revision:+ kwargs["revision"] = revision+ if local_files_only:+ kwargs["local_files_only"] = Truetry:from huggingface_hub import hf_hub_download- path = hf_hub_download(repo_id, DRAFTER_MANIFEST, token = token)+ path = hf_hub_download(repo_id, DRAFTER_MANIFEST, **kwargs)for name in ("adapter_config.json", "mtp_head.safetensors"):try:- hf_hub_download(repo_id, name, token = token)+ hf_hub_download(repo_id, name, **kwargs)except Exception:passreturn os.path.dirname(path)@@ -51,11 +61,16 @@ def _hub_adapter_snapshot(repo_id: str, token = None) -> Optional[str]:return None-def training_manifest(checkpoint_dir: Optional[str], token = None) -> Optional[dict]:+def training_manifest(+ checkpoint_dir: Optional[str],+ token = None,+ revision = None,+ local_files_only = False,+) -> Optional[dict]:"""The manifest the training run wrote, when its drafter is still complete on disk. `token` isthe credential the checkpoint was loaded with (a private Hub adapter)."""if checkpoint_dir and not os.path.isdir(checkpoint_dir):- checkpoint_dir = _hub_adapter_snapshot(checkpoint_dir, token)+ checkpoint_dir = _hub_adapter_snapshot(checkpoint_dir, token, revision, local_files_only)if not checkpoint_dir or not os.path.isdir(checkpoint_dir):return Nonemanifest = _read_json(os.path.join(checkpoint_dir, DRAFTER_MANIFEST))@@ -144,13 +159,15 @@ def package_merged(verifier: Optional[str] = None,allow_mtp: bool = True,token = None,+ revision = None,+ local_files_only = False,) -> Optional[dict]:"""Write `drafter.json` (and copy the EAGLE-3 drafter) into a merged export. None when the runtrained no drafter. `verifier` is what the drafter's config names as its target: the Hub repo on apush, else the base model id (vLLM refuses a local verifier path inside a speculators config, solocal serving passes the target explicitly). `allow_mtp` is False for exports that cannot carrya stitched head (compressed-tensors, torchao): only an EAGLE-3 drafter ships with those."""- manifest = training_manifest(checkpoint_dir, token)+ manifest = training_manifest(checkpoint_dir, token, revision, local_files_only)if manifest is None or (manifest["strategy"] == "mtp" and not allow_mtp):clear_stale(final_dir)return None@@ -203,11 +220,13 @@ def package_gguf(gguf_dir: str,ggufs: list[str],token = None,+ revision = None,+ local_files_only = False,) -> tuple[Optional[dict], list[str]]:"""(drafter info, extra files written into gguf_dir). The MTP head is already inside each GGUF; anEAGLE-3 drafter is converted beside them against the merged target (the converter reads its configand tokenizer). Raises when the drafter cannot be converted: a pair missing its drafter is incomplete."""- manifest = training_manifest(checkpoint_dir, token)+ manifest = training_manifest(checkpoint_dir, token, revision, local_files_only)engines = _engines(manifest) if manifest else {}if manifest is None or not engines["llama_cpp"]:clear_stale(gguf_dir, ggufs)@@ -261,11 +280,13 @@ def package_lora(adapter_dir: str,head_saved: Optional[bool] = None,token = None,+ revision = None,+ local_files_only = False,) -> Optional[dict]:"""Carry the training manifest with a LoRA export that kept the trained MTP head beside it, so alater merge / GGUF of that adapter still marks the head as trained (Studio's MTP launch policy).`head_saved` overrides the sidecar check (a Hub push saves the adapter elsewhere)."""- manifest = training_manifest(checkpoint_dir, token)+ manifest = training_manifest(checkpoint_dir, token, revision, local_files_only)if head_saved is None:head_saved = os.path.isfile(os.path.join(adapter_dir, "mtp_head.safetensors"))if manifest is None or manifest["strategy"] != "mtp" or not head_saved:diff --git a/studio/backend/core/export/export.py b/studio/backend/core/export/export.pyindex 8f64cfde099..61badd5f3e5 100644--- a/studio/backend/core/export/export.py+++ b/studio/backend/core/export/export.py@@ -9,6 +9,7 @@ import structlogimport tempfilefrom loggers import get_loggerimport os+import reimport sysimport shutilimport contextlib@@ -783,6 +784,23 @@ def _checkpoint_load_refusal(checkpoint_path, pinned_base) -> Optional[str]:return None+def _cached_hub_adapter_commit(checkpoint_path: str) -> Optional[str]:+ """The commit of a Hub adapter's cached snapshot (the one its load just used), else None."""+ if not checkpoint_path or os.path.isdir(checkpoint_path):+ return None+ if os.path.isabs(checkpoint_path) or checkpoint_path.count("/") != 1:+ return None+ try:+ from huggingface_hub import try_to_load_from_cache+ path = try_to_load_from_cache(checkpoint_path, "adapter_config.json")+ except Exception:+ return None+ if not isinstance(path, str):+ return None+ commit = os.path.basename(os.path.dirname(path))+ return commit if re.fullmatch(r"[0-9a-f]{40}", commit) else None++class ExportBackend:# {"layout", "adapter_only"} for a decision checkpoint (GGUF only), else None.decision: Optional[dict] = None@@ -791,6 +809,7 @@ class ExportBackend:self.inference_backend = get_inference_backend()self.current_checkpoint = Noneself._checkpoint_token = None+ self._checkpoint_local_files_only = Falseself.current_model = Noneself.current_tokenizer = Noneself.is_vision = False@@ -820,6 +839,7 @@ class ExportBackend:self.current_tokenizer = Noneself.current_checkpoint = Noneself._checkpoint_token = None+ self._checkpoint_local_files_only = Falseself._audio_type = Noneself.decision = None@@ -1126,6 +1146,13 @@ class ExportBackend:self.current_tokenizer = tokenizerself.current_checkpoint = checkpoint_pathself._checkpoint_token = token+ self._checkpoint_local_files_only = bool(local_files_only)+ # The base config's _commit_hash names the base repo, not the adapter's.+ self._adapter_commit = (+ (checkpoint_path, _cached_hub_adapter_commit(checkpoint_path))+ if self.is_peft+ else None+ )if not self.is_peft and not _IS_MLX:self._attach_full_checkpoint_mtp_head(checkpoint_path)@@ -2166,20 +2193,67 @@ class ExportBackend:try:from core.export.drafter_export import training_manifest- if not os.path.isdir(checkpoint_path) or os.path.isfile(- os.path.join(checkpoint_path, "adapter_config.json")- ):- return- manifest = training_manifest(checkpoint_path)+ token = getattr(self, "_checkpoint_token", None)+ manifest = training_manifest(+ checkpoint_path,+ token,+ revision = self._loaded_commit(),+ local_files_only = getattr(self, "_checkpoint_local_files_only", False),+ )if not manifest or manifest.get("strategy") != "mtp":return+ source = checkpoint_path+ if not os.path.isdir(source):+ source = self._loaded_hub_snapshot(checkpoint_path, token)+ if source is None:+ logger.warning(+ f"Could not find the cached files of {checkpoint_path} to attach its trained MTP head"+ )+ return+ if os.path.isfile(os.path.join(source, "adapter_config.json")):+ returnfrom unsloth import FastModel- FastModel.get_mtp_head(self.current_model, source = checkpoint_path)+ FastModel.get_mtp_head(self.current_model, source = source)logger.info(f"Attached the trained MTP head from {checkpoint_path}")except Exception as exception:logger.warning(f"Could not attach the trained MTP head: {exception}")+ def _loaded_commit(self) -> Optional[str]:+ """The Hub commit current_checkpoint was loaded at; None for a local folder, or a Hub adapter+ whose commit is unknown (no pin beats the base's commit)."""+ if getattr(self, "is_peft", False):+ recorded = getattr(self, "_adapter_commit", None)+ if recorded and recorded[0] == getattr(self, "current_checkpoint", None):+ return recorded[1]+ return None+ return getattr(getattr(self.current_model, "config", None), "_commit_hash", None)++ def _loaded_manifest_kwargs(self) -> dict:+ """The load's commit and offline decision for a Hub id's drafter manifest read."""+ kwargs = {}+ revision = self._loaded_commit()+ if revision:+ kwargs["revision"] = revision+ if getattr(self, "_checkpoint_local_files_only", False):+ kwargs["local_files_only"] = True+ return kwargs++ def _loaded_hub_snapshot(self, repo_id: str, token) -> Optional[str]:+ """The local snapshot folder of a Hub checkpoint the current model was loaded from."""+ revision = self._loaded_commit()+ try:+ from huggingface_hub import hf_hub_download++ # Not snapshot_download: offline it refuses a snapshot lacking files the load never needed.+ config = hf_hub_download(+ repo_id, "config.json", revision = revision, token = token, local_files_only = True+ )+ except Exception:+ return None+ path = os.path.dirname(config)+ return path if os.path.isdir(path) else None+def _package_drafter_merged(self,final_dir: str,@@ -2196,6 +2270,7 @@ class ExportBackend:verifier = repo_id,allow_mtp = allow_mtp,token = self._checkpoint_token,+ **self._loaded_manifest_kwargs(),)if info:logger.info(f"Packaged the trained {info['strategy']} drafter into {final_dir}")@@ -2211,7 +2286,11 @@ class ExportBackend:from core.export.drafter_export import package_lorareturn (package_lora(- self.current_checkpoint, adapter_dir, head_saved, token = self._checkpoint_token+ self.current_checkpoint,+ adapter_dir,+ head_saved,+ token = self._checkpoint_token,+ **self._loaded_manifest_kwargs(),)is not None)@@ -2241,7 +2320,12 @@ class ExportBackend:from core.export.drafter_export import package_ggufinfo, files = package_gguf(- self.current_checkpoint, merged_dir, gguf_dir, ggufs, token = self._checkpoint_token+ self.current_checkpoint,+ merged_dir,+ gguf_dir,+ ggufs,+ token = self._checkpoint_token,+ **self._loaded_manifest_kwargs(),)if info:logger.info(f"Packaged the trained {info['strategy']} drafter with the GGUF export")diff --git a/studio/backend/core/training/drafter.py b/studio/backend/core/training/drafter.pyindex 076d4c6d79f..5dcb8dd3ee1 100644--- a/studio/backend/core/training/drafter.py+++ b/studio/backend/core/training/drafter.py@@ -336,10 +336,16 @@ def _row_examples(row: dict, max_len: int) -> list[tuple[list[int], list[int]]]:labels = [t if m else -100 for t, m in zip(ids, row["assistant_masks"])]else:labels = list(ids)- # Packed rows restart position_ids at every example; split there so no draft crosses a boundary.- positions = row.get("position_ids")+ # Split packed rows so no draft crosses an example: TRL's packed dataset records `seq_lengths`+ # (its collator builds position_ids later); older layouts restart `position_ids` at 0.cuts = [0]- if positions is not None:+ lengths = row.get("seq_lengths")+ positions = row.get("position_ids")+ if lengths is not None and len(lengths) and sum(int(n) for n in lengths) == len(ids):+ for n in lengths:+ cuts.append(cuts[-1] + int(n))+ cuts.pop()+ elif positions is not None:cuts = [i for i, p in enumerate(positions) if p == 0] or [0]cuts.append(len(ids))out = []diff --git a/studio/backend/tests/test_drafter_training.py b/studio/backend/tests/test_drafter_training.pyindex a3db4c37b83..e70cba89b7f 100644--- a/studio/backend/tests/test_drafter_training.py+++ b/studio/backend/tests/test_drafter_training.py@@ -141,6 +141,50 @@ def test_examples_respect_masks_and_packing():assert len(collect_examples(rows, 2, 2048)) == 2+def test_examples_split_trl_packed_rows_at_seq_lengths():+ """TRL's packed dataset keeps the boundaries in `seq_lengths` (position_ids come later, in its+ collator): each packed document is its own drafter example and keeps its own prompt."""+ from datasets import Dataset++ pack_dataset = pytest.importorskip("trl.data_utils").pack_dataset++ from core.training.drafter import _prompt_end, collect_examples++ docs = Dataset.from_dict(+ {+ "input_ids": [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12, 13]],+ "completion_mask": [[0, 0, 1, 1], [0, 0, 1, 1], [0, 0, 0, 1, 1]],+ }+ )+ packed = pack_dataset(docs, seq_length = 9, strategy = "bfd")+ assert "seq_lengths" in packed.column_names and "position_ids" not in packed.column_names+ out = collect_examples(packed, 100, 2048)+ assert sorted(ex["input_ids"] for ex in out) == [+ [1, 2, 3, 4],+ [5, 6, 7, 8],+ [9, 10, 11, 12, 13],+ ]+ by_first = {ex["input_ids"][0]: ex["labels"] for ex in out}+ assert by_first == {+ 1: [-100, -100, 3, 4],+ 5: [-100, -100, 7, 8],+ 9: [-100, -100, -100, 12, 13],+ }+ # Regenerate finds one prompt per packed document, not one per packed row.+ assert [_prompt_end(ex["input_ids"], ex["labels"], []) for ex in out] == [+ len(ex["labels"]) - 2 for ex in out+ ]++ row = {"input_ids": [10, 11, 12, 13, 20, 21, 22, 23], "seq_lengths": [4, 4]}+ assert [ex["input_ids"] for ex in collect_examples([row], 100, 2048)] == [+ [10, 11, 12, 13],+ [20, 21, 22, 23],+ ]+ # Lengths that do not describe the row are ignored rather than trusted.+ bad = dict(row, seq_lengths = [4, 3])+ assert len(collect_examples([bad], 100, 2048)) == 1++# ---------------------------------------------------------------- the phase, with a fake trainer@@ -1179,6 +1223,229 @@ def test_export_reattaches_a_full_fine_tunes_stitched_head(tmp_path, monkeypatchassert len(calls) == 1+def test_export_reattaches_the_head_of_a_hub_full_fine_tune(tmp_path, monkeypatch):+ """A full fine-tune loaded by Hub id: its manifest is read from the Hub with the load's token and+ the head is attached from the snapshot the load cached, at the loaded commit."""+ from core.export import export as export_module+ import huggingface_hub++ calls = []+ unsloth = types.ModuleType("unsloth")+ unsloth.FastModel = types.SimpleNamespace(+ get_mtp_head = lambda model, source = None: calls.append((model, source))+ )+ monkeypatch.setitem(sys.modules, "unsloth", unsloth)+ manifest_dir = tmp_path / "manifest"+ manifest_dir.mkdir()+ snapshot = tmp_path / "snapshot"+ snapshot.mkdir()+ downloads, snapshots = [], []++ def fake_download(+ repo_id,+ filename,+ token = None,+ revision = None,+ local_files_only = False,+ ):+ if local_files_only:+ snapshots.append((repo_id, filename, revision, token))+ (snapshot / filename).write_text("{}")+ return str(snapshot / filename)+ downloads.append((repo_id, filename, token))+ if filename != "drafter.json":+ raise FileNotFoundError(filename)+ (manifest_dir / filename).write_text(json.dumps({"strategy": "mtp"}))+ return str(manifest_dir / filename)++ monkeypatch.setattr(huggingface_hub, "hf_hub_download", fake_download)+ model = types.SimpleNamespace(config = types.SimpleNamespace(_commit_hash = "abc123"))+ backend = object.__new__(export_module.ExportBackend)+ backend.current_model = model+ backend._checkpoint_token = "hf_secret"+ backend._attach_full_checkpoint_mtp_head("org/trained-full-mtp")+ assert calls == [(model, str(snapshot))]+ assert snapshots == [("org/trained-full-mtp", "config.json", "abc123", "hf_secret")]+ assert downloads and all(token == "hf_secret" for _, _, token in downloads)++ # No manifest on the Hub (an ordinary full checkpoint): nothing is attached.+ calls.clear()+ monkeypatch.setattr(+ huggingface_hub,+ "hf_hub_download",+ lambda *a, **k: (_ for _ in ()).throw(FileNotFoundError("drafter.json")),+ )+ backend._attach_full_checkpoint_mtp_head("org/plain-full")+ assert calls == []+++def _hub_full_fine_tune_backend(tmp_path, monkeypatch, local_files_only):+ """An export backend holding a full fine-tune loaded by Hub id at commit abc123, whose manifest+ and config are cached; records every hf_hub_download call."""+ from core.export import export as export_module+ import huggingface_hub++ attached = []+ unsloth = types.ModuleType("unsloth")+ unsloth.FastModel = types.SimpleNamespace(+ get_mtp_head = lambda model, source = None: attached.append(source)+ )+ monkeypatch.setitem(sys.modules, "unsloth", unsloth)+ snapshot = tmp_path / "snapshot"+ snapshot.mkdir()+ (snapshot / "drafter.json").write_text(json.dumps({"strategy": "mtp"}))+ (snapshot / "config.json").write_text("{}")+ calls = []++ def fake_download(+ repo_id,+ filename,+ token = None,+ revision = None,+ local_files_only = False,+ ):+ calls.append((filename, revision, local_files_only))+ if not (snapshot / filename).is_file():+ raise FileNotFoundError(filename)+ return str(snapshot / filename)++ monkeypatch.setattr(huggingface_hub, "hf_hub_download", fake_download)+ backend = object.__new__(export_module.ExportBackend)+ backend.current_model = types.SimpleNamespace(+ config = types.SimpleNamespace(_commit_hash = "abc123")+ )+ backend._checkpoint_token = None+ backend._checkpoint_local_files_only = local_files_only+ return backend, calls, attached, snapshot+++def test_hub_full_fine_tune_manifest_is_read_at_the_loaded_commit(tmp_path, monkeypatch):+ """The manifest and the head's shards come from the same commit, not the branch head."""+ backend, calls, attached, snapshot = _hub_full_fine_tune_backend(tmp_path, monkeypatch, False)+ backend._attach_full_checkpoint_mtp_head("org/trained-full-mtp")+ assert attached == [str(snapshot)]+ assert calls and all(revision == "abc123" for _, revision, _ in calls)+++def test_offline_hub_full_fine_tune_keeps_the_manifest_probe_offline(tmp_path, monkeypatch):+ """A cached load chosen because the Hub is unreachable must not touch the network for drafter.json."""+ backend, calls, attached, snapshot = _hub_full_fine_tune_backend(tmp_path, monkeypatch, True)+ backend._attach_full_checkpoint_mtp_head("org/trained-full-mtp")+ assert attached == [str(snapshot)]+ assert calls and all(offline for _, _, offline in calls)+++def _package_through_backend(backend, path, out):+ out.mkdir()+ if path == "merged":+ backend._package_drafter_merged(str(out), None)+ elif path == "gguf":+ gguf = out / "model.Q8_0.gguf"+ gguf.write_bytes(b"g")+ backend._package_drafter_gguf(str(out), str(out), [str(gguf)])+ else:+ assert backend._package_drafter_lora(str(out), head_saved = True)+ return json.loads((out / "drafter.json").read_text())++[email protected]("path", ["merged", "gguf", "lora"])[email protected]("offline", [False, True])+def test_drafter_packaging_reads_the_manifest_at_the_loaded_commit(+ tmp_path, monkeypatch, path, offline+):+ """Merged, GGUF and LoRA packaging read a Hub id's manifest at the commit the load resolved+ (not the branch head) and stay offline when the load did."""+ backend, calls, _, _ = _hub_full_fine_tune_backend(tmp_path, monkeypatch, offline)+ backend.current_checkpoint = "org/trained-full-mtp"+ info = _package_through_backend(backend, path, tmp_path / "out")+ assert info["strategy"] == "mtp"+ assert calls and all(revision == "abc123" for _, revision, _ in calls)+ assert all(local is offline for _, _, local in calls)+++_ADAPTER_SHA = "a" * 40++[email protected]("path", ["merged", "gguf", "lora"])[email protected]("adapter_commit", [_ADAPTER_SHA, None])+def test_hub_adapter_packaging_never_pins_the_base_commit(+ tmp_path, monkeypatch, path, adapter_commit+):+ """A Hub LoRA adapter's current_model.config is the base's, so its _commit_hash names the base+ repo: the adapter's manifest is read at the adapter's own commit, or unpinned when unknown."""+ backend, calls, _, _ = _hub_full_fine_tune_backend(tmp_path, monkeypatch, False)+ backend.current_checkpoint = "org/trained-adapter"+ backend.is_peft = True+ backend._adapter_commit = ("org/trained-adapter", adapter_commit)+ info = _package_through_backend(backend, path, tmp_path / "out")+ assert info["strategy"] == "mtp"+ assert calls and all(revision == adapter_commit for _, revision, _ in calls)+++def test_hub_adapter_commit_of_another_checkpoint_is_not_reused(tmp_path, monkeypatch):+ backend, calls, _, _ = _hub_full_fine_tune_backend(tmp_path, monkeypatch, False)+ backend.current_checkpoint = "org/other-adapter"+ backend.is_peft = True+ backend._adapter_commit = ("org/trained-adapter", _ADAPTER_SHA)+ assert backend._loaded_commit() is None+++def test_full_fine_tune_keeps_the_base_commit(tmp_path, monkeypatch):+ backend, _, _, _ = _hub_full_fine_tune_backend(tmp_path, monkeypatch, False)+ backend.current_checkpoint = "org/trained-full-mtp"+ backend.is_peft = False+ backend._adapter_commit = None+ assert backend._loaded_commit() == "abc123"+++def test_hub_adapter_commit_comes_from_the_local_cache(tmp_path, monkeypatch):+ """The adapter's commit is the cached snapshot its adapter_config.json sits in, read offline."""+ import huggingface_hub+ from core.export import export as export_module++ repo = tmp_path / "models--org--trained-adapter"+ (repo / "snapshots" / _ADAPTER_SHA).mkdir(parents = True)+ (repo / "snapshots" / _ADAPTER_SHA / "adapter_config.json").write_text("{}")+ (repo / "refs").mkdir()+ (repo / "refs" / "main").write_text(_ADAPTER_SHA)+ monkeypatch.setattr(huggingface_hub.constants, "HF_HUB_CACHE", str(tmp_path))+ assert export_module._cached_hub_adapter_commit("org/trained-adapter") == _ADAPTER_SHA+ assert export_module._cached_hub_adapter_commit("org/not-cached") is None+ assert export_module._cached_hub_adapter_commit(str(tmp_path)) is None+++def test_load_records_the_adapter_commit_for_a_peft_checkpoint():+ src = _source("core/export/export.py")+ assert "(checkpoint_path, _cached_hub_adapter_commit(checkpoint_path))" in src+++def test_drafter_packaging_without_a_hub_load_passes_no_revision(tmp_path, monkeypatch):+ """A local checkpoint (no resolved commit, online load) calls the helpers exactly as before."""+ from core.export import drafter_export+ from core.export import export as export_module++ seen = []+ for name in ("package_merged", "package_lora"):+ monkeypatch.setattr(drafter_export, name, lambda *a, **k: seen.append(sorted(k)) or None)+ monkeypatch.setattr(+ drafter_export, "package_gguf", lambda *a, **k: seen.append(sorted(k)) or (None, [])+ )+ backend = object.__new__(export_module.ExportBackend)+ backend.current_model = types.SimpleNamespace(config = types.SimpleNamespace())+ backend.current_checkpoint = str(tmp_path)+ backend._checkpoint_token = None+ backend._checkpoint_local_files_only = False+ backend._package_drafter_merged(str(tmp_path), None)+ backend._package_drafter_gguf(str(tmp_path), str(tmp_path), [])+ backend._package_drafter_lora(str(tmp_path), head_saved = True)+ assert seen == [["allow_mtp", "token", "verifier"], ["token"], ["token"]]+++def test_load_records_its_offline_decision_for_the_manifest_probe():+ src = _source("core/export/export.py")+ assert "self._checkpoint_local_files_only = bool(local_files_only)" in src++def test_in_place_eagle3_export_keeps_the_only_drafter_copy(tmp_path):"""An export into the training folder itself must not delete eagle3/ before copying it."""from core.export.drafter_export import package_merged