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
remove gguf shard controls introduced by #6107 (#11315)
Maheswar Kumaref6ae0b5aba2
diff --git a/studio/backend/core/export/export.py b/studio/backend/core/export/export.pyindex 107a8f84e8a..4c779f7eb27 100644--- a/studio/backend/core/export/export.py+++ b/studio/backend/core/export/export.py@@ -268,17 +268,6 @@ def _supports_kwarg(fn, name):)-def _gguf_shard_export_supported(fn):- """True when the exporter explicitly implements GGUF shard-size control."""- import inspect-- try:- params = inspect.signature(fn).parameters- except (TypeError, ValueError):- return False- return _accepts_by_keyword(params, "gguf_shard_size")--def _imatrix_export_supported(save_fn):"""True when this build can apply an imatrix, not merely swallow the keyword: the MLX bindingtakes `**kwargs` and filters them, so only unsloth_zoo itself settles it."""@@ -1330,14 +1319,12 @@ class ExportBackend:hf_token: HfTokenArg = None,imatrix_file = None,private: bool = False,- gguf_shard_size: Optional[str] = None,) -> Tuple[bool, str, Optional[str]]:"""Export the model in GGUF format.``quantization_method`` is a single GGUF quant method ("Q4_K_M") or a list of them; a listproduces one GGUF per quant from a single model load, since unsloth save_to_gguf loops- internally. ``imatrix_file`` is an importance matrix path or boolean, and- ``gguf_shard_size`` caps the final full-precision GGUF shard size.+ internally. ``imatrix_file`` is an importance matrix path or boolean."""if not _export_runtime_available():return False, _export_runtime_message(), None@@ -1354,21 +1341,6 @@ class ExportBackend:)# Truthiness, as above: a disabled imatrix must not reach an exporter without the kwarg.imatrix_kw = {"imatrix_file": imatrix_file} if imatrix_file else {}- shard_hooks = []- if save_directory:- shard_hooks.append(self.current_model.save_pretrained_gguf)- elif push_to_hub:- shard_hooks.append(self.current_model.push_to_hub_gguf)- if gguf_shard_size is not None and not all(- _gguf_shard_export_supported(hook) for hook in shard_hooks- ):- return (- False,- "This Unsloth build does not support GGUF shard-size control. "- "Upgrade unsloth and unsloth_zoo, or clear the shard-size option.",- None,- )- shard_kw = {"gguf_shard_size": gguf_shard_size} if gguf_shard_size is not None else {}# Resolution reads a Hub repo, so the local save needs the token; kept out of imatrix_kw, which the# push shares and names token= itself.local_token_kw = (@@ -1422,7 +1394,6 @@ class ExportBackend:quantization_method = quant_method,**imatrix_kw,**local_token_kw,- **shard_kw,)# Scan only the owned root; exact reported paths cover external outputs.@@ -1609,7 +1580,6 @@ class ExportBackend:token = hf_token,private = private,**imatrix_kw,- **shard_kw,)logger.info(f"GGUF model pushed successfully to {repo_id}")diff --git a/studio/backend/core/export/orchestrator.py b/studio/backend/core/export/orchestrator.pyindex 3695de545a9..f7b5dc2a9f3 100644--- a/studio/backend/core/export/orchestrator.py+++ b/studio/backend/core/export/orchestrator.py@@ -623,7 +623,6 @@ class ExportOrchestrator:hf_token: HfTokenArg = None,imatrix_file = None,private: bool = False,- gguf_shard_size: Optional[str] = None,) -> Tuple[bool, str, Optional[str]]:"""Export model in GGUF format. `quantization_method` may be a single method or a list."""return self._run_export(@@ -636,7 +635,6 @@ class ExportOrchestrator:"hf_token": hf_token,"imatrix_file": imatrix_file,"private": private,- "gguf_shard_size": gguf_shard_size,},)diff --git a/studio/backend/core/export/worker.py b/studio/backend/core/export/worker.pyindex 2771d2e2f3d..e95cbc90ce3 100644--- a/studio/backend/core/export/worker.py+++ b/studio/backend/core/export/worker.py@@ -456,7 +456,6 @@ def _handle_export(backend, cmd: dict, resp_queue: Any) -> None:hf_token = cmd.get("hf_token"),imatrix_file = cmd.get("imatrix_file"),private = cmd.get("private", False),- gguf_shard_size = cmd.get("gguf_shard_size"),)elif export_type == "lora":success, message, output_path = backend.export_lora_adapter(diff --git a/studio/backend/hub/schemas/inventory.py b/studio/backend/hub/schemas/inventory.pyindex d136fe03ae6..253747c7922 100644--- a/studio/backend/hub/schemas/inventory.py+++ b/studio/backend/hub/schemas/inventory.py@@ -35,7 +35,6 @@ class GgufVariantDetail(BaseModel):pending_drafter_size_bytes: int = Field(0, description = "Remote size of pending_drafter_filename")- shard_count: int = Field(0, description = "Part count for a complete canonical split GGUF")download_remaining_bytes: Optional[int] = Field(None,description = (diff --git a/studio/backend/hub/services/models/gguf_variants.py b/studio/backend/hub/services/models/gguf_variants.pyindex 50e6ef4e061..44e8da5a271 100644--- a/studio/backend/hub/services/models/gguf_variants.py+++ b/studio/backend/hub/services/models/gguf_variants.py@@ -1124,7 +1124,6 @@ async def get_gguf_variants_answer(quant = v.quant,display_label = v.display_label,size_bytes = v.size_bytes,- shard_count = int(getattr(v, "shard_count", 0) or 0),download_size_bytes = v.size_bytes,download_remaining_bytes = (None@@ -1156,7 +1155,6 @@ async def get_gguf_variants_answer(quant = v.quant,display_label = v.display_label,size_bytes = v.size_bytes,- shard_count = int(getattr(v, "shard_count", 0) or 0),download_size_bytes = v.download_size_bytes or v.size_bytes,download_remaining_bytes = variant_remaining_bytes_from_state(response_repo_id,@@ -1283,7 +1281,6 @@ async def get_gguf_variants_answer(quant = v.quant,display_label = v.display_label,size_bytes = v.size_bytes,- shard_count = int(getattr(v, "shard_count", 0) or 0),download_size_bytes = v.download_size_bytes or v.size_bytes,download_remaining_bytes = variant_remaining_bytes_from_state(repo_id,@@ -1348,14 +1345,6 @@ async def get_gguf_variants_answer(# The load resolver's own extractor over the context it reads, so the quant is what the echoed load# resolves; the hub one differs on F16-checkpoint-Q4_K_M.from utils.models.model_config import _extract_quant_label- from utils.models.model_config import colocated_split_shards-- shards, split_complete = colocated_split_shards(local_target)- if split_complete and len(shards) > 1:- try:- size = sum(shard.stat().st_size for shard in shards)- except OSError:- size = 0variants = [GgufVariantInfo(@@ -1364,7 +1353,6 @@ async def get_gguf_variants_answer(f"{local_target.parent.name}/{local_target.name}"),size_bytes = size,- shard_count = len(shards) if split_complete and len(shards) > 1 else 0,)]# The shard scan resolves a file to its marked parent, so an unmarked one walks a bare file and@@ -1864,7 +1852,6 @@ async def get_gguf_variants_answer(quant = v.quant,display_label = v.display_label,size_bytes = v.size_bytes,- shard_count = int(getattr(v, "shard_count", 0) or 0),download_size_bytes = (requirement.download_size_bytes if requirement is not None else v.size_bytes),diff --git a/studio/backend/hub/tests/test_custom_gguf_discovery.py b/studio/backend/hub/tests/test_custom_gguf_discovery.pyindex 6ca496d14e2..54b9aea7f87 100644--- a/studio/backend/hub/tests/test_custom_gguf_discovery.py+++ b/studio/backend/hub/tests/test_custom_gguf_discovery.py@@ -331,42 +331,6 @@ def test_incomplete_direct_split_is_not_collapsed(tmp_path):assert {Path(row.path) for row in rows} == {first, third}-def test_grouped_split_reports_parts_without_counting_companions(tmp_path):- root = tmp_path / "root"- model = root / "model"- _write_gguf(model / "model-F16-00001-of-00002.gguf", 11)- _write_gguf(model / "model-F16-00002-of-00002.gguf", 7)- _write_gguf(model / "model-mmproj-F16.gguf", 3)- _write_gguf(model / "mtp-model.gguf", 2)-- rows = _custom_rows(root)- variants, _has_vision = gguf.list_local_gguf_variants(str(model), model_root = str(root))-- assert len(rows) == 1- assert [(variant.quant, variant.shard_count) for variant in variants] == [("F16", 2)]---def test_mixed_split_and_ordinary_models_stay_separate(tmp_path):- root = tmp_path / "root"- model = root / "model"- _write_gguf(model / "alpha-F16-00001-of-00002.gguf")- _write_gguf(model / "alpha-F16-00002-of-00002.gguf")- _write_gguf(model / "beta-Q8_0.gguf")-- rows = _custom_rows(root)- variants, _has_vision = gguf.list_local_gguf_variants(str(model), model_root = str(root))-- assert len(rows) == 2- split_row = next(row for row in rows if Path(row.path).name.startswith("alpha-F16-00001"))- ordinary_row = next(row for row in rows if Path(row.path).name == "beta-Q8_0.gguf")- assert Path(split_row.path).name == "alpha-F16-00001-of-00002.gguf"- assert Path(ordinary_row.path).name == "beta-Q8_0.gguf"- assert {(variant.quant, variant.shard_count) for variant in variants} == {- ("F16", 2),- ("Q8_0", 0),- }--def test_two_digit_split_like_names_stay_separate(tmp_path):root = tmp_path / "root"holder = root / "holder"diff --git a/studio/backend/hub/utils/gguf.py b/studio/backend/hub/utils/gguf.pyindex fc9c38b2977..97d90564e82 100644--- a/studio/backend/hub/utils/gguf.py+++ b/studio/backend/hub/utils/gguf.py@@ -31,7 +31,6 @@ class GgufVariantInfo:size_bytes: intdisplay_label: Optional[str] = Nonedownload_size_bytes: int = 0- shard_count: int = 0GGUF_QUANT_PREFERENCE = [@@ -74,10 +73,6 @@ GGUF_QUANT_PREFERENCE = []_GGUF_SPLIT_SUFFIX_RE = re.compile(r"-\d{3,}-of-\d{3,}", re.IGNORECASE)-_GGUF_CANONICAL_SPLIT_RE = re.compile(- r"^(?P<prefix>.+)-(?P<index>\d{5})-of-(?P<total>\d{5})\.gguf$",- re.IGNORECASE,-)_GGUF_QUANT_RE = re.compile(r"(UD-)?"r"(MXFP[0-9]+(?:_[A-Z0-9]+)*"@@ -362,29 +357,6 @@ def gguf_variant_family(filename: str) -> str:return _unknown_gguf_variant_key(filename)-def complete_gguf_shard_count(filenames: Sequence[str], first_filename: str) -> int:- """Return a complete canonical split's part count, otherwise zero."""- normalized_first = first_filename.replace("\\", "/")- first_match = _GGUF_CANONICAL_SPLIT_RE.match(normalized_first.rsplit("/", 1)[-1])- if first_match is None or int(first_match.group("index")) != 1:- return 0- total = int(first_match.group("total"))- if total < 2:- return 0-- family = gguf_variant_family(normalized_first).casefold()- indices: list[int] = []- for filename in filenames:- normalized = filename.replace("\\", "/")- if gguf_variant_family(normalized).casefold() != family:- continue- match = _GGUF_CANONICAL_SPLIT_RE.match(normalized.rsplit("/", 1)[-1])- if match is None or match.group("total") != first_match.group("total"):- return 0- indices.append(int(match.group("index")))- return total if sorted(indices) == list(range(1, total + 1)) else 0--def gguf_checkpoint_family(filename: str) -> Optional[str]:"""the exact checkpoint name shared by quant variants, or ``None`` when unnamed."""path = filename.replace("\\", "/")@@ -1074,7 +1046,6 @@ def list_partial_gguf_variants_from_state())main_filename: Optional[str] = None- main_filenames: list[str] = []size_bytes = 0companion_bytes = 0imatrix_only = False@@ -1096,7 +1067,6 @@ def list_partial_gguf_variants_from_state(continueif main_filename is None:main_filename = expected.path- main_filenames.append(expected.path)size_bytes += max(0, int(expected.size or 0))if main_filename is None:# An older build could download the imatrix as a variant of its own, so naming the synthetic file after the variant would put that interrupted row back in the menu at zero bytes. Only when NOTHING eligible was found.@@ -1109,7 +1079,6 @@ def list_partial_gguf_variants_from_state(quant = variant,size_bytes = size_bytes,download_size_bytes = size_bytes + companion_bytes,- shard_count = complete_gguf_shard_count(main_filenames, main_filename),))@@ -1215,12 +1184,7 @@ def list_gguf_variants(main_files.append((filename, int(getattr(sibling, "size", 0) or 0)))variants = [- GgufVariantInfo(- filename = filename,- quant = quant,- size_bytes = size,- shard_count = complete_gguf_shard_count([path for path, _size in main_files], filename),- )+ GgufVariantInfo(filename = filename, quant = quant, size_bytes = size)for quant, (filename, size) in group_gguf_variant_files(main_files).items()]@@ -1313,12 +1277,7 @@ def list_local_gguf_variants(main_files.append((rel, size))variants = [- GgufVariantInfo(- filename = filename,- quant = quant,- size_bytes = size,- shard_count = complete_gguf_shard_count([path for path, _size in main_files], filename),- )+ GgufVariantInfo(filename = filename, quant = quant, size_bytes = size)for quant, (filename, size) in group_gguf_variant_files(main_files).items()]variants.sort(key = lambda variant: -variant.size_bytes)diff --git a/studio/backend/mcp_server.py b/studio/backend/mcp_server.pyindex b18d4d17a16..35b2109318c 100644--- a/studio/backend/mcp_server.py+++ b/studio/backend/mcp_server.py@@ -232,7 +232,6 @@ def create_studio_mcp() -> FastMCP:imatrix: bool = False,imatrix_path: str | None = None,private: bool = False,- gguf_shard_size: str | None = None,) -> dict[str, Any]:"""Export the loaded model to GGUF using Unsloth's existing path validation.@@ -253,7 +252,6 @@ def create_studio_mcp() -> FastMCP:imatrix = imatrix,imatrix_path = imatrix_path,private = private,- gguf_shard_size = gguf_shard_size,)return _dump(await export(request, current_subject = "mcp", allow_ambient = False))diff --git a/studio/backend/models/export.py b/studio/backend/models/export.pyindex 49eb7b049fb..deb62ef2301 100644--- a/studio/backend/models/export.py+++ b/studio/backend/models/export.py@@ -3,8 +3,6 @@"""Pydantic schemas for Export API."""-import re-import sysfrom pathlib import Path, PureWindowsPathfrom pydantic import BaseModel, Field, field_validator@@ -35,31 +33,6 @@ def _validate_save_directory(value: str) -> str:return raw-_GGUF_SHARD_SIZE_RE = re.compile(r"^(\d+)\s*([MG])B?$", re.IGNORECASE)---def _validate_gguf_shard_size(value: Optional[str]) -> Optional[str]:- """Validate and normalize a Studio GGUF shard-size request."""- if value is None:- return None- if not isinstance(value, str):- raise ValueError("gguf_shard_size must be a string or null")- raw = value.strip()- if raw.casefold() in ("", "0", "none"):- return "0"- match = _GGUF_SHARD_SIZE_RE.fullmatch(raw)- if match is None:- raise ValueError("gguf_shard_size must be a positive whole number in MB or GB, or '0'")- magnitude = int(match.group(1))- unit = match.group(2).upper()- if magnitude == 0:- raise ValueError("gguf_shard_size must be positive, or exactly '0'")- multiplier = 1_000_000 if unit == "M" else 1_000_000_000- if magnitude > sys.maxsize // multiplier:- raise ValueError("gguf_shard_size is too large for this platform")- return f"{magnitude}{unit}B"--class LoadCheckpointRequest(BaseModel):"""Request for loading a checkpoint into the export backend."""@@ -248,17 +221,6 @@ class ExportGGUFRequest(BaseModel):None,description = "Path to a custom imatrix file; overrides the auto-download when set.",)- gguf_shard_size: Optional[str] = Field(- None,- description = "Maximum final f32, f16 or bf16 GGUF shard size in MB or GB. "- "Pass '0' for one file. Quantized outputs remain single-file.",- )-- @field_validator("gguf_shard_size", mode = "before")- @classmethod- def _check_gguf_shard_size(cls, value):- return _validate_gguf_shard_size(value)-private: bool = Field(False,description = "If True, create a private Hugging Face Hub repository",diff --git a/studio/backend/models/models.py b/studio/backend/models/models.pyindex 336347db21b..39e26252997 100644--- a/studio/backend/models/models.py+++ b/studio/backend/models/models.py@@ -168,7 +168,6 @@ class GgufVariantDetail(BaseModel):pending_drafter_size_bytes: int = Field(0, description = "Remote size of pending_drafter_filename")- shard_count: int = Field(0, description = "Part count for a complete canonical split GGUF")downloaded: bool = Field(False, description = "Whether this variant is already in the local HF cache")diff --git a/studio/backend/routes/export.py b/studio/backend/routes/export.pyindex c6dfcf08441..789bd253dd7 100644--- a/studio/backend/routes/export.py+++ b/studio/backend/routes/export.py@@ -542,7 +542,6 @@ async def export_gguf(),imatrix_file = imatrix_file,private = request.private,- gguf_shard_size = request.gguf_shard_size,)if not success:diff --git a/studio/backend/routes/models.py b/studio/backend/routes/models.pyindex b67837b78d5..5e9f6a090c2 100644--- a/studio/backend/routes/models.py+++ b/studio/backend/routes/models.py@@ -4520,7 +4520,6 @@ async def get_gguf_variants(# the row reads as its whole relative path.display_label = getattr(v, "display_label", None),size_bytes = v.size_bytes,- shard_count = int(getattr(v, "shard_count", 0) or 0),download_size_bytes = int(getattr(v, "download_size_bytes", v.size_bytes) or v.size_bytes),diff --git a/studio/backend/tests/test_account_variant_preflight_token.py b/studio/backend/tests/test_account_variant_preflight_token.pyindex 1cb88483094..071d895ade0 100644--- a/studio/backend/tests/test_account_variant_preflight_token.py+++ b/studio/backend/tests/test_account_variant_preflight_token.py@@ -50,7 +50,6 @@ def isolated(monkeypatch, tmp_path):quant = "Q4_K_M",display_label = "Q4_K_M",size_bytes = 1234,- shard_count = 0,)],False,diff --git a/studio/backend/tests/test_export_gguf_hub_upload.py b/studio/backend/tests/test_export_gguf_hub_upload.pyindex 304ff68aa06..f630b1a86d5 100644--- a/studio/backend/tests/test_export_gguf_hub_upload.py+++ b/studio/backend/tests/test_export_gguf_hub_upload.py@@ -790,7 +790,6 @@ def test_push_only_gguf_export_still_delegates_to_push_to_hub_gguf(tmp_path, monquantization_method,imatrix_file = None,token = None,- gguf_shard_size = None,):calls.append("save_pretrained_gguf")@@ -802,7 +801,6 @@ def test_push_only_gguf_export_still_delegates_to_push_to_hub_gguf(tmp_path, montoken = None,private = None,imatrix_file = None,- gguf_shard_size = None,):calls.append("push_to_hub_gguf")seen["push"] = {@@ -811,7 +809,6 @@ def test_push_only_gguf_export_still_delegates_to_push_to_hub_gguf(tmp_path, mon"token": token,"private": private,"imatrix_file": imatrix_file,- "gguf_shard_size": gguf_shard_size,}hf_api, model_card = _hub_doubles(calls, seen)@@ -828,7 +825,6 @@ def test_push_only_gguf_export_still_delegates_to_push_to_hub_gguf(tmp_path, monhf_token = "token",private = True,imatrix_file = True,- gguf_shard_size = "512MB",)assert success is True, message@@ -842,7 +838,6 @@ def test_push_only_gguf_export_still_delegates_to_push_to_hub_gguf(tmp_path, mon"token": "token","private": True,"imatrix_file": True,- "gguf_shard_size": "512MB",}diff --git a/studio/backend/tests/test_export_gguf_sharding.py b/studio/backend/tests/test_export_gguf_sharding.pydeleted file mode 100644index 0565b3d2a01..00000000000--- a/studio/backend/tests/test_export_gguf_sharding.py+++ /dev/null@@ -1,240 +0,0 @@-# 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 importlib.util-from pathlib import Path--import pytest-from pydantic import ValidationError--from models.export import ExportGGUFRequest---_HELPERS_SPEC = importlib.util.spec_from_file_location(- "export_absolute_path_helpers",- Path(__file__).with_name("test_export_absolute_paths.py"),-)-assert _HELPERS_SPEC is not None and _HELPERS_SPEC.loader is not None-_HELPERS = importlib.util.module_from_spec(_HELPERS_SPEC)-_HELPERS_SPEC.loader.exec_module(_HELPERS)-_install_export_backend_stubs = _HELPERS._install_export_backend_stubs-_load_module = _HELPERS._load_module--- "value, expected",- [- (None, None),- ("", "0"),- ("none", "0"),- ("0", "0"),- ("500m", "500MB"),- (" 4 GB ", "4GB"),- ],-)-def test_gguf_request_normalizes_shard_size(value, expected):- request = ExportGGUFRequest(save_directory = "/tmp/export", gguf_shard_size = value)- assert request.gguf_shard_size == expected--- "value",- ["0MB", "0GB", "1.5GB", "512", "64KB", "-2GB", "4TB", "4GBx"],-)-def test_gguf_request_rejects_invalid_shard_size(value):- with pytest.raises(ValidationError, match = "gguf_shard_size"):- ExportGGUFRequest(save_directory = "/tmp/export", gguf_shard_size = value)---def test_orchestrator_preserves_shard_size_in_command():- from core.export.orchestrator import ExportOrchestrator-- orchestrator = ExportOrchestrator.__new__(ExportOrchestrator)- seen = {}-- def run_export(kind, params):- seen.update(kind = kind, params = params)- return True, "ok", None-- orchestrator._run_export = run_export-- result = orchestrator.export_gguf("output", gguf_shard_size = "2GB", private = True)-- assert result == (True, "ok", None)- assert seen["kind"] == "gguf"- assert seen["params"]["gguf_shard_size"] == "2GB"- assert seen["params"]["private"] is True---def test_worker_passes_shard_size_to_backend():- from core.export import worker-- seen = {}-- class Backend:- def export_gguf(self, **kwargs):- seen.update(kwargs)- return True, "ok", "/output"-- class Queue:- def __init__(self):- self.items = []-- def put(self, item):- self.items.append(item)-- queue = Queue()- worker._handle_export(- Backend(),- {- "export_type": "gguf",- "save_directory": "/output",- "gguf_shard_size": "512MB",- "private": True,- },- queue,- )-- assert seen["gguf_shard_size"] == "512MB"- assert seen["private"] is True- assert queue.items[-1]["success"] is True---def test_backend_forwards_shard_size_to_the_local_export_it_then_uploads(tmp_path, monkeypatch):- _install_export_backend_stubs(monkeypatch)- export_module = _load_module(- "test_export_gguf_shard_backend",- "core/export/export.py",- monkeypatch,- )- save_directory = tmp_path / "export with spaces ü"- seen = {}-- class Model:- def save_pretrained_gguf(- self,- model_save_path,- tokenizer,- quantization_method,- gguf_shard_size = None,- ):- seen["local"] = gguf_shard_size- output = Path(f"{model_save_path}_gguf")- output.mkdir(parents = True)- shard = output / "model.F16-00001-of-00002.gguf"- shard.write_bytes(b"GGUF")- return {"gguf_files": [str(shard)]}-- def push_to_hub_gguf(self, *args, **kwargs):- seen["hub"] = kwargs-- class _RepoUrl(str):- repo_id = "owner/model"-- class _HfApi:- def __init__(self, token = None):- seen["token"] = token-- def create_repo(- self,- repo_id,- private = False,- exist_ok = False,- ):- seen["repo"] = {"repo_id": repo_id, "private": private}- return _RepoUrl("https://huggingface.co/owner/model")-- def update_repo_settings(- self,- repo_id,- private = None,- repo_type = None,- ):- seen["visibility"] = {"repo_id": repo_id, "private": private}-- def repo_info(- self,- repo_id,- repo_type = None,- ):- return None-- def upload_folder(- self,- folder_path,- repo_id,- repo_type,- allow_patterns = None,- ignore_patterns = None,- ):- seen["upload"] = folder_path-- class _ModelCard:- def __init__(self, content):- pass-- def push_to_hub(- self,- repo_id,- token = None,- commit_message = None,- ):- pass-- monkeypatch.setattr(export_module, "HfApi", _HfApi)- monkeypatch.setattr(export_module, "ModelCard", _ModelCard)- monkeypatch.setattr(export_module, "resolve_export_write_dir", lambda value: Path(value))- backend = export_module.ExportBackend.__new__(export_module.ExportBackend)- backend.current_model = Model()- backend.current_tokenizer = object()- backend.current_checkpoint = None-- success, message, output_path = backend.export_gguf(- str(save_directory),- "F16",- push_to_hub = True,- repo_id = "owner/model",- hf_token = "token",- private = True,- gguf_shard_size = "512MB",- )-- assert success is True, message- assert output_path == str(save_directory.resolve())- assert seen["local"] == "512MB"- assert "hub" not in seen- assert seen["upload"] == output_path- assert seen["repo"] == {"repo_id": "owner/model", "private": True}---def test_backend_rejects_old_exporter_only_when_option_is_set(tmp_path, monkeypatch):- _install_export_backend_stubs(monkeypatch)- export_module = _load_module(- "test_export_gguf_old_backend",- "core/export/export.py",- monkeypatch,- )-- class OldModel:- def save_pretrained_gguf(self, model_save_path, tokenizer, quantization_method):- output = Path(f"{model_save_path}_gguf")- output.mkdir(parents = True)- (output / "model.Q4_K_M.gguf").write_bytes(b"GGUF")-- monkeypatch.setattr(export_module, "resolve_export_write_dir", lambda value: Path(value))- backend = export_module.ExportBackend.__new__(export_module.ExportBackend)- backend.current_model = OldModel()- backend.current_tokenizer = object()- backend.current_checkpoint = None-- unsupported = backend.export_gguf(- str(tmp_path / "unsupported"),- gguf_shard_size = "0",- )- compatible = backend.export_gguf(str(tmp_path / "compatible"))-- assert unsupported[0] is False- assert "does not support GGUF shard-size control" in unsupported[1]- assert compatible[0] is Truediff --git a/studio/backend/tests/test_gguf_variants_local_resolution.py b/studio/backend/tests/test_gguf_variants_local_resolution.pyindex ccb9ad13b19..2dbdd826717 100644--- a/studio/backend/tests/test_gguf_variants_local_resolution.py+++ b/studio/backend/tests/test_gguf_variants_local_resolution.py@@ -45,16 +45,6 @@ def test_direct_gguf_file_is_a_loadable_variant(in_tmp_cwd):assert response.variants[0].partial is False-def test_direct_complete_split_reports_the_whole_family_size(in_tmp_cwd):- first = in_tmp_cwd / "foo-Q4_K_M-00001-of-00002.gguf"- first.write_bytes(b"GGUF")- (in_tmp_cwd / "foo-Q4_K_M-00002-of-00002.gguf").write_bytes(b"GGUF" * 2)-- row = _variants(os.fspath(first)).variants[0]- assert row.size_bytes == 12- assert row.shard_count == 2--def test_markerless_relative_gguf_file_resolves_locally(in_tmp_cwd):(in_tmp_cwd / "models").mkdir()(in_tmp_cwd / "models" / "foo.gguf").write_bytes(b"GGUF")diff --git a/studio/backend/tests/test_mcp_server.py b/studio/backend/tests/test_mcp_server.pyindex 968af081fa2..8fd63768a2e 100644--- a/studio/backend/tests/test_mcp_server.py+++ b/studio/backend/tests/test_mcp_server.py@@ -176,7 +176,7 @@ def test_clamp_restricts_to_inclusive_bounds():def test_export_and_checkpoint_tools_expose_forwarded_fields():export_props = set(_get_tool("export_gguf").parameters["properties"])- assert {"hf_token", "imatrix", "imatrix_path", "private", "gguf_shard_size"} <= export_props+ assert {"hf_token", "imatrix", "imatrix_path", "private"} <= export_propscheckpoint_props = set(_get_tool("load_checkpoint").parameters["properties"])assert {"hf_token", "approved_remote_code_fingerprint"} <= checkpoint_props@@ -220,7 +220,6 @@ def test_export_gguf_forwards_hf_token_and_imatrix(monkeypatch):imatrix = True,imatrix_path = "/tmp/imatrix.dat",private = True,- gguf_shard_size = "2GB",))@@ -229,7 +228,6 @@ def test_export_gguf_forwards_hf_token_and_imatrix(monkeypatch):assert captured["imatrix_path"] == "/tmp/imatrix.dat"assert captured["quantization_method"] == ["Q4_K_M", "Q8_0"]assert captured["private"] is True- assert captured["gguf_shard_size"] == "2GB"assert result["current_subject"] == "mcp"# A direct call skips FastAPI, so the route's Depends default never resolves; MCP has to# name the policy itself or allow_ambient arrives as a truthy Depends object.diff --git a/studio/frontend/src/features/chat/types/api.ts b/studio/frontend/src/features/chat/types/api.tsindex 81cd62427df..61ad5e3ac85 100644--- a/studio/frontend/src/features/chat/types/api.ts+++ b/studio/frontend/src/features/chat/types/api.ts@@ -168,7 +168,6 @@ export interface GgufVariantDetail {/** The only missing artifact when the main GGUF is already cached. */pending_drafter_filename?: string | null;pending_drafter_size_bytes?: number;- shard_count?: number;downloaded?: boolean;update_available?: boolean;/** An interrupted download: some shards are missing, so it cannot load yet. */diff --git a/studio/frontend/src/features/export/api/export-api.ts b/studio/frontend/src/features/export/api/export-api.tsindex eb238159b6a..9763b0d6729 100644--- a/studio/frontend/src/features/export/api/export-api.ts+++ b/studio/frontend/src/features/export/api/export-api.ts@@ -169,7 +169,6 @@ export async function exportGGUF(params: {imatrix?: boolean;imatrix_path?: string | null;private?: boolean;- gguf_shard_size?: string | null;}): Promise<ExportOperationResponse> {const response = await authFetch("/api/export/export/gguf", {method: "POST",diff --git a/studio/frontend/src/features/export/components/export-run-panel.tsx b/studio/frontend/src/features/export/components/export-run-panel.tsxindex 4af46402df5..aeb23ae288a 100644--- a/studio/frontend/src/features/export/components/export-run-panel.tsx+++ b/studio/frontend/src/features/export/components/export-run-panel.tsx@@ -9,13 +9,6 @@ import {InputGroupInput,} from "@/components/ui/input-group";import { Progress } from "@/components/ui/progress";-import {- Select,- SelectContent,- SelectItem,- SelectTrigger,- SelectValue,-} from "@/components/ui/select";import { Spinner } from "@/components/ui/spinner";import { Switch } from "@/components/ui/switch";import {@@ -24,7 +17,6 @@ import {TooltipTrigger,} from "@/components/ui/tooltip";import { FolderBrowser } from "@/features/model-picker";-import { cn } from "@/lib/utils";import {AlertCircleIcon,CancelCircleIcon,@@ -44,11 +36,6 @@ import {type ExportMethod,findMergedFormat,} from "../constants";-import {- GGUF_SHARD_SIZE_PRESETS,- type GgufShardMode,- isValidGgufShardSize,-} from "../lib/gguf-shard-size";import { getExportLogLineClass } from "../lib/log-style";import {type ExportDestination,@@ -128,11 +115,6 @@ export interface ExportRunPanelProps {onHfTokenChange: (v: string) => void;privateRepo: boolean;onPrivateRepoChange: (v: boolean) => void;- supportsGgufSharding: boolean;- ggufShardMode: GgufShardMode;- onGgufShardModeChange: (v: GgufShardMode) => void;- ggufShardSize: string;- onGgufShardSizeChange: (v: string) => void;/** Kick off the export (the page assembles params and calls the store). */onStart: () => void;/** Collapse the panel; only offered before a run or after a terminal one. */@@ -160,11 +142,6 @@ export function ExportRunPanel(props: ExportRunPanelProps) {onHfTokenChange,privateRepo,onPrivateRepoChange,- supportsGgufSharding,- ggufShardMode,- onGgufShardModeChange,- ggufShardSize,- onGgufShardSizeChange,onStart,onClose,} = props;@@ -237,13 +214,6 @@ export function ExportRunPanel(props: ExportRunPanelProps) {(v) => findMergedFormat(v)?.label ?? v,);const showProgress = isExporting || isTerminal;- const shardSizeValid =- !supportsGgufSharding ||- ggufShardMode === "single" ||- isValidGgufShardSize(ggufShardSize);- const customShardSize = !GGUF_SHARD_SIZE_PRESETS.some(- (preset) => preset === ggufShardSize,- );return (<div className="flex flex-col gap-4 rounded-2xl border border-border/50 bg-muted/20 p-4">@@ -348,91 +318,6 @@ export function ExportRunPanel(props: ExportRunPanelProps) {</div>)}- {supportsGgufSharding && (- <fieldset className="flex flex-col gap-1.5">- <legend className="text-xs font-medium text-muted-foreground">- Full-precision GGUF files- </legend>- <div className="flex gap-2">- <Button- type="button"- variant={ggufShardMode === "single" ? "dark" : "outline"}- onClick={() => onGgufShardModeChange("single")}- aria-pressed={ggufShardMode === "single"}- className="flex-1"- >- Single file- </Button>- <Button- type="button"- variant={ggufShardMode === "split" ? "dark" : "outline"}- onClick={() => onGgufShardModeChange("split")}- aria-pressed={ggufShardMode === "split"}- className="flex-1"- >- Split into shards- </Button>- </div>- {ggufShardMode === "split" ? (- <>- <Select- value={customShardSize ? "custom" : ggufShardSize}- onValueChange={(value) =>- onGgufShardSizeChange(value === "custom" ? "" : value)- }- >- <SelectTrigger className="w-full">- <SelectValue placeholder="Choose a shard size" />- </SelectTrigger>- <SelectContent>- {GGUF_SHARD_SIZE_PRESETS.map((preset) => (- <SelectItem key={preset} value={preset}>- {preset.replace("GB", " GB").replace("MB", " MB")}- </SelectItem>- ))}- <SelectItem value="custom">Custom</SelectItem>- </SelectContent>- </Select>- {customShardSize && (- <Input- className={cn(- "font-mono text-ui-12",- !shardSizeValid &&- "border-destructive focus-visible:ring-destructive",- )}- value={ggufShardSize}- onChange={(event) =>- onGgufShardSizeChange(event.target.value)- }- spellCheck={false}- aria-invalid={!shardSizeValid}- aria-describedby="gguf-shard-size-help"- maxLength={24}- placeholder="e.g. 512MB or 6GB"- />- )}- <p- id="gguf-shard-size-help"- className={cn(- "text-ui-11",- shardSizeValid- ? "text-muted-foreground/70"- : "text-destructive",- )}- >- {shardSizeValid- ? "F16 and BF16 outputs use this limit. Quantized outputs and companion files stay single-file."- : "Enter a positive whole number in MB or GB, such as 512MB or 4GB."}- </p>- </>- ) : (- <p className="text-ui-11 text-muted-foreground/70">- F16 and BF16 outputs stay in one file regardless of size.- </p>- )}- </fieldset>- )}-{destination === "hub" && (<div className="flex flex-col gap-4 px-0.5"><div className="grid grid-cols-1 gap-3 sm:grid-cols-2">@@ -614,16 +499,6 @@ export function ExportRunPanel(props: ExportRunPanelProps) {</span></div>)}- {summaryMethod === "gguf" && summary?.ggufShardSize && (- <div className="flex justify-between">- <span>Full-precision files</span>- <span className="font-medium text-foreground">- {summary.ggufShardSize === "0"- ? "Single file"- : `Shards up to ${summary.ggufShardSize}`}- </span>- </div>- )}</div>{/* Progress */}@@ -732,9 +607,7 @@ export function ExportRunPanel(props: ExportRunPanelProps) {<Button variant="outline" onClick={onClose}>Cancel</Button>- <Button onClick={onStart} disabled={!shardSizeValid}>- Start Export- </Button>+ <Button onClick={onStart}>Start Export</Button></>)}{isExporting && (diff --git a/studio/frontend/src/features/export/export-page.tsx b/studio/frontend/src/features/export/export-page.tsxindex 88972be1730..6b4c32facbf 100644--- a/studio/frontend/src/features/export/export-page.tsx+++ b/studio/frontend/src/features/export/export-page.tsx@@ -85,12 +85,6 @@ import {refreshLocalModels,} from "./export-navigation-cache";import { useExportSizeEstimate } from "./hooks/use-export-size-estimate";-import {- type GgufShardMode,- ggufShardSaveDirectory,- isValidGgufShardSize,- normalizeGgufShardSize,-} from "./lib/gguf-shard-size";import {isExportPanelActive,useExportRuntimeStore,@@ -281,8 +275,6 @@ export function ExportPage() {const [hfUsername, setHfUsername] = useState("");const [modelName, setModelName] = useState("");const [privateRepo, setPrivateRepo] = useState(false);- const [ggufShardMode, setGgufShardMode] = useState<GgufShardMode>("single");- const [ggufShardSize, setGgufShardSize] = useState("4GB");// Export run state lives in the global runtime store so it keeps streaming in the background.const runExport = useExportRuntimeStore((s) => s.runExport);@@ -591,7 +583,7 @@ export function ExportPage() {const estimatedSize = getEstimatedSize(exportMethod, quantLevels, fp16Bytes);const selectedExportSource =sourceMode === "checkpoint" ? checkpoint : selectedSourceModel;- const baseDefaultSaveDirectory = useMemo(() => {+ const defaultSaveDirectory = useMemo(() => {const relative = buildRelativeSaveDirectory(exportMethod,sourceMode,@@ -624,6 +616,7 @@ export function ExportPage() {sourceBaseModelName,sourceMode,]);+ const saveDirectory = customSaveDirectory?.trim() || defaultSaveDirectory;// Each merged format uploads a full model to the repo root, so several to one repo would collide.// GGUF method exporting an adapter checkpoint as a GGUF LoRA; reuses the LoRA export path.const ggufAsLora =@@ -631,25 +624,6 @@ export function ExportPage() {ggufTarget === "lora" &&effectiveIsAdapter &&!isMacHost;- const supportsGgufSharding =- exportMethod === "gguf" &&- !ggufAsLora &&- quantLevels.some((quant) => quant === "f16" || quant === "bf16");- const normalizedGgufShardSize =- supportsGgufSharding && ggufShardMode === "split"- ? normalizeGgufShardSize(ggufShardSize)- : supportsGgufSharding- ? "0"- : null;- const defaultSaveDirectory = ggufShardSaveDirectory(- baseDefaultSaveDirectory,- normalizedGgufShardSize,- );- const saveDirectory = customSaveDirectory?.trim() || defaultSaveDirectory;- const ggufShardSizeValid =- !supportsGgufSharding ||- ggufShardMode === "single" ||- isValidGgufShardSize(ggufShardSize);// Restrict a Hub merged export to a single format; multi-format stays available for local export.const hubMultiFormat =@@ -662,7 +636,6 @@ export function ExportPage() {exportMethod &&!exportUnsupported &&!hubMultiFormat &&- ggufShardSizeValid &&(exportMethod !== "gguf" || ggufAsLora || quantLevels.length > 0) &&(exportMethod !== "merged" || selectedFormats.length > 0));@@ -742,7 +715,6 @@ export function ExportPage() {if (exportMethod === "gguf" && !ggufAsLora && quantLevels.length === 0)return;if (exportMethod === "merged" && selectedFormats.length === 0) return;- if (!ggufShardSizeValid) return;// A Hub merged push writes each format to the repo root; several would collide (mirrors canExport).if (hubMultiFormat) return;@@ -806,7 +778,6 @@ export function ExportPage() {isAdapter: adapterExport,quantLevels,useImatrix: effectiveImatrix,- ggufShardSize: normalizedGgufShardSize,mergedSelections: selectedFormats.map((v) => ({...mergedFormatPayload(v),label: MERGED_FORMATS.find((f) => f.value === v)?.label ?? v,@@ -825,7 +796,6 @@ export function ExportPage() {methodLabel,method: effectiveMethod,quantLevels,- ggufShardSize: normalizedGgufShardSize,mergedFormats: exportMethod === "merged" ? selectedFormats : [],destination,},@@ -842,8 +812,6 @@ export function ExportPage() {isAdapter,quantLevels,effectiveImatrix,- normalizedGgufShardSize,- ggufShardSizeValid,selectedFormats,hubMultiFormat,ggufAsLora,@@ -1734,11 +1702,6 @@ export function ExportPage() {onHfTokenChange={setHfToken}privateRepo={privateRepo}onPrivateRepoChange={setPrivateRepo}- supportsGgufSharding={supportsGgufSharding}- ggufShardMode={ggufShardMode}- onGgufShardModeChange={setGgufShardMode}- ggufShardSize={ggufShardSize}- onGgufShardSizeChange={setGgufShardSize}onStart={handleStart}onClose={handleClosePanel}/>diff --git a/studio/frontend/src/features/export/lib/gguf-shard-size.ts b/studio/frontend/src/features/export/lib/gguf-shard-size.tsdeleted file mode 100644index 4356d42eaa9..00000000000--- a/studio/frontend/src/features/export/lib/gguf-shard-size.ts+++ /dev/null@@ -1,47 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-only-// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0--export type GgufShardMode = "single" | "split";--export const GGUF_SHARD_SIZE_PRESETS = [- "256MB",- "512MB",- "1GB",- "2GB",- "4GB",- "8GB",- "16GB",-] as const;--const GGUF_SHARD_SIZE_RE = /^(\d+)\s*([MG])B?$/i;-const MAX_PATH_COMPONENT_LENGTH = 255;--export function normalizeGgufShardSize(value: string): string | null {- const match = GGUF_SHARD_SIZE_RE.exec(value.trim());- if (!match || BigInt(match[1]) === 0n) {- return null;- }- return `${BigInt(match[1])}${match[2].toUpperCase()}B`;-}--export function isValidGgufShardSize(value: string): boolean {- return normalizeGgufShardSize(value) !== null;-}--export function ggufShardSaveDirectory(- baseDirectory: string,- shardSize: string | null,-): string {- if (!shardSize || shardSize === "0") {- return baseDirectory;- }-- const suffix = `-split-${shardSize}`;- const separator = Math.max(- baseDirectory.lastIndexOf("/"),- baseDirectory.lastIndexOf("\\"),- );- const parent = baseDirectory.slice(0, separator + 1);- const name = baseDirectory.slice(separator + 1);- return `${parent}${name.slice(0, MAX_PATH_COMPONENT_LENGTH - suffix.length)}${suffix}`;-}diff --git a/studio/frontend/src/features/export/stores/export-runtime-store.ts b/studio/frontend/src/features/export/stores/export-runtime-store.tsindex 77f518ebbec..f512df47c25 100644--- a/studio/frontend/src/features/export/stores/export-runtime-store.ts+++ b/studio/frontend/src/features/export/stores/export-runtime-store.ts@@ -118,7 +118,6 @@ export interface ExportRunSummary {methodLabel: string;method: ExportMethod;quantLevels: string[];- ggufShardSize?: string | null;/** Merged: the selected format values (for the summary "Formats" row and to reseed the picker). */mergedFormats: string[];destination: ExportDestination;@@ -142,8 +141,6 @@ export interface RunExportParams {quantLevels: string[];/** GGUF: use an importance matrix (auto-download); required for the IQ quants. */useImatrix?: boolean;- /** gguf: maximum size for full-precision shards, or "0" for one file. */- ggufShardSize?: string | null;/** Merged: precision formats, each exported to its own sibling directory. Defaults to 16-bit.* `label` is the display name for the success banner's per-format output line. */mergedSelections?: {@@ -498,7 +495,6 @@ export const useExportRuntimeStore = create<ExportRuntimeStore>()((set, get) =>hf_token: params.token ?? params.loadToken ?? null,imatrix: params.useImatrix,private: params.privateRepo,- gguf_shard_size: params.ggufShardSize ?? null,}),);if (outputPath) outputs.push({ label: "GGUF", path: outputPath });diff --git a/studio/frontend/src/features/hub/inventory/api.ts b/studio/frontend/src/features/hub/inventory/api.tsindex 4cf8ee38965..efb5974ad25 100644--- a/studio/frontend/src/features/hub/inventory/api.ts+++ b/studio/frontend/src/features/hub/inventory/api.ts@@ -185,7 +185,6 @@ export interface GgufVariantDetail {/** The only missing artifact when the main GGUF is already cached. */pending_drafter_filename?: string | null;pending_drafter_size_bytes?: number;- shard_count?: number;/** Bytes a resume still has to fetch. Set only on a partial variant. */download_remaining_bytes?: number | null;downloaded?: boolean;diff --git a/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx b/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsxindex b2e1fd04686..670baea02f2 100644--- a/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx+++ b/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx@@ -1414,9 +1414,6 @@ function isValidGgufVariant(variant: unknown): variant is GgufVariantDetail {typeof candidate.size_bytes === "number" &&Number.isFinite(candidate.size_bytes) &&candidate.size_bytes >= 0 &&- (candidate.shard_count === undefined ||- (Number.isSafeInteger(candidate.shard_count) &&- candidate.shard_count >= 0)) &&(candidate.downloaded === undefined ||typeof candidate.downloaded === "boolean") &&(candidate.pending_drafter_filename === undefined ||@@ -2160,11 +2157,6 @@ function GgufVariantExpander({hideH3PrunedBuild,})}</span>- {(v.shard_count ?? 0) > 1 ? (- <span className="ml-1.5 text-ui-9 font-sans font-medium text-sky-700 dark:text-sky-300">- Sharded · {v.shard_count} parts- </span>- ) : null}{unusableLocal ? (<span className="ml-1.5 text-ui-9 font-sans font-medium text-amber-700 dark:text-amber-300">incompletediff --git a/studio/frontend/tests/export-gguf-shard-size.test.ts b/studio/frontend/tests/export-gguf-shard-size.test.tsdeleted file mode 100644index 810fd183e22..00000000000--- a/studio/frontend/tests/export-gguf-shard-size.test.ts+++ /dev/null@@ -1,111 +0,0 @@-// 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 assert from "node:assert/strict";-import { register } from "node:module";-import test from "node:test";--import {- ggufShardSaveDirectory,- isValidGgufShardSize,- normalizeGgufShardSize,-} from "../src/features/export/lib/gguf-shard-size.ts";--register("./helpers/export-store-resolver.mjs", import.meta.url);--const stub = await import("./helpers/export-api-stub.mjs");-const { useExportRuntimeStore } = await import(- "../src/features/export/stores/export-runtime-store.ts"-);--test("shard sizes match backend normalization", () => {- for (const [value, expected] of [- ["500m", "500MB"],- [" 4 GB ", "4GB"],- ["0002gb", "2GB"],- ["1MB", "1MB"],- ] as const) {- assert.equal(normalizeGgufShardSize(value), expected);- assert.equal(isValidGgufShardSize(value), true);- }-});--test("invalid and empty split sizes fail validation", () => {- for (const value of [- "",- "0",- "none",- "0MB",- "0GB",- "1.5GB",- "512",- "64KB",- "-2GB",- "4TB",- "4GBx",- ]) {- assert.equal(normalizeGgufShardSize(value), null, value);- assert.equal(isValidGgufShardSize(value), false, value);- }-});--test("split defaults use a separate save directory", () => {- assert.equal(- ggufShardSaveDirectory("Qwen-GGUF", "512MB"),- "Qwen-GGUF-split-512MB",- );- assert.equal(ggufShardSaveDirectory("Qwen-GGUF", "0"), "Qwen-GGUF");- assert.equal(ggufShardSaveDirectory("Qwen-GGUF", null), "Qwen-GGUF");-});--test("split defaults keep the final path component within 255 characters", () => {- for (const base of [- `models/${"m".repeat(250)}-GGUF`,- `C:\\models\\${"m".repeat(250)}-GGUF`,- ]) {- const directory = ggufShardSaveDirectory(base, "512MB");- const separator = Math.max(- directory.lastIndexOf("/"),- directory.lastIndexOf("\\"),- );- const component = directory.slice(separator + 1);- assert.equal(component.length, 255);- assert.equal(component.endsWith("-split-512MB"), true);- }-});--function params(ggufShardSize: string | null) {- return {- sourceMode: "model",- checkpointPath: null,- source: "unsloth/Qwen3-0.6B",- modelSource: "hf",- trustRemoteCode: false,- exportMethod: "gguf",- isAdapter: false,- quantLevels: ["f16"],- ggufShardSize,- saveDirectory: "out",- destination: "local",- privateRepo: false,- summary: {},- } as unknown as Parameters<- ReturnType<typeof useExportRuntimeStore.getState>["runExport"]- >[0];-}--async function request(ggufShardSize: string | null) {- stub.resetStub();- await useExportRuntimeStore.getState().runExport(params(ggufShardSize));- const call = stub.calls.find((entry) => entry.name === "exportGGUF");- if (!call) {- throw new Error("no gguf export request was made");- }- return call.args[0] as Record<string, unknown>;-}--test("the runtime preserves split, single-file, and legacy values", async () => {- assert.equal((await request("512MB")).gguf_shard_size, "512MB");- assert.equal((await request("0")).gguf_shard_size, "0");- assert.equal((await request(null)).gguf_shard_size, null);-});diff --git a/tests/saving/test_gguf_shard_size.py b/tests/saving/test_gguf_shard_size.pydeleted file mode 100644index e4bdc5a6eb3..00000000000--- a/tests/saving/test_gguf_shard_size.py+++ /dev/null@@ -1,221 +0,0 @@-# SPDX-License-Identifier: AGPL-3.0-only-# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.--from __future__ import annotations--import subprocess-from pathlib import Path--import pytest--import unsloth.save as save_mod--- "value, expected",- [- (None, "50GB"),- ("", "0"),- (" ", "0"),- ("0", "0"),- ("none", "0"),- ("NONE", "0"),- ("1MB", "1MB"),- ("256m", "256MB"),- ("512 MB", "512MB"),- ("4G", "4GB"),- (" 8gb ", "8GB"),- ],-)-def test_resolve_gguf_shard_size(value, expected):- assert save_mod._resolve_gguf_shard_size(value) == expected--- "value",- [- "0MB",- "0GB",- "-1GB",- "1.5GB",- "512",- "64KB",- "GB",- "2TB",- "2GBx",- ],-)-def test_invalid_gguf_shard_sizes_fail_before_conversion(value):- with pytest.raises(ValueError, match = "gguf_shard_size"):- save_mod._resolve_gguf_shard_size(value)--[email protected]("value", [0, False, 512, object()])-def test_non_string_gguf_shard_sizes_are_rejected(value):- with pytest.raises(TypeError, match = "string or None"):- save_mod._resolve_gguf_shard_size(value)---def test_oversized_gguf_shard_size_is_rejected(monkeypatch):- monkeypatch.setattr(save_mod.sys, "maxsize", 2_147_483_647)- with pytest.raises(ValueError, match = "too large"):- save_mod._resolve_gguf_shard_size("3GB")---def test_public_save_rejects_invalid_size_before_model_work():- with pytest.raises(ValueError, match = "gguf_shard_size"):- save_mod.unsloth_save_pretrained_gguf(- object(),- "unused",- tokenizer = object(),- gguf_shard_size = "1.5GB",- )--- "first_conversion, methods, is_vlm, expected",- [- ("f16", ["f16"], False, "256MB"),- ("bf16", ["bf16", "q4_k_m"], False, "256MB"),- ("f32", ["f32"], False, "256MB"),- ("q8_0", ["q8_0"], False, "0"),- ("bf16", ["q4_k_m"], False, "0"),- ("f16", ["f16"], True, "0"),- ],-)-def test_converter_only_shards_final_full_precision_outputs(- first_conversion, methods, is_vlm, expected-):- assert (- save_mod._converter_gguf_shard_size(- "256MB",- first_conversion,- methods,- is_vlm,- )- == expected- )--- "name, expected",- [- ("model.F16-mmproj.gguf", True),- ("mmproj-model.F16.gguf", True),- ("mtp-model.Q8_0.gguf", True),- ("model.Q8_0-MTP.gguf", True),- ("ordinary-mmprojector-model.gguf", False),- ("ordinary-mtp-model.gguf", False),- ("attempt.gguf", False),- ("model-00001-of-00002.gguf", False),- ],-)-def test_gguf_companion_detection_uses_exact_name_shapes(name, expected):- assert save_mod._is_gguf_companion(name) is expected---def test_vlm_split_only_replaces_main_model(tmp_path, monkeypatch):- main = tmp_path / "vision model ü.F16.gguf"- mmproj = tmp_path / "vision model ü.BF16-mmproj.gguf"- mtp = tmp_path / "mtp-vision model ü.Q8_0.gguf"- main.write_bytes(b"m" * 2_000_001)- mmproj.write_bytes(b"projector")- mtp.write_bytes(b"drafter")-- monkeypatch.setattr(save_mod, "_find_llama_gguf_split", lambda _: "splitter")-- def fake_run(args, **kwargs):- assert args[2:4] == ["--split-max-size", "1M"]- prefix = Path(args[-1])- (prefix.parent / f"{prefix.name}-00001-of-00002.gguf").write_bytes(b"one")- (prefix.parent / f"{prefix.name}-00002-of-00002.gguf").write_bytes(b"two")- return subprocess.CompletedProcess(args, 0, stdout = "ok", stderr = "")-- monkeypatch.setattr(save_mod.subprocess, "run", fake_run)- output = save_mod._split_main_gguf(- [str(main), str(mmproj), str(mtp)],- "1MB",- "quantizer",- )-- assert [Path(path).name for path in output] == [- "vision model ü.F16-00001-of-00002.gguf",- "vision model ü.F16-00002-of-00002.gguf",- mmproj.name,- mtp.name,- ]- assert not main.exists()- assert mmproj.read_bytes() == b"projector"- assert mtp.read_bytes() == b"drafter"---def test_vlm_main_below_boundary_stays_single_file(tmp_path, monkeypatch):- main = tmp_path / "model.F16.gguf"- mmproj = tmp_path / "model.BF16-mmproj.gguf"- main.write_bytes(b"main")- mmproj.write_bytes(b"projector")- monkeypatch.setattr(- save_mod,- "_find_llama_gguf_split",- lambda _: pytest.fail("splitter should not be required"),- )-- output = save_mod._split_main_gguf([str(main), str(mmproj)], "1MB", "quantizer")-- assert output == [str(main), str(mmproj)]---def test_vlm_split_failure_keeps_single_file(tmp_path, monkeypatch):- main = tmp_path / "model.F16.gguf"- mmproj = tmp_path / "model.BF16-mmproj.gguf"- main.write_bytes(b"m" * 2_000_001)- mmproj.write_bytes(b"projector")- monkeypatch.setattr(save_mod, "_find_llama_gguf_split", lambda _: "splitter")-- def fail_run(args, **kwargs):- raise subprocess.CalledProcessError(1, args, stderr = "invalid gguf")-- monkeypatch.setattr(save_mod.subprocess, "run", fail_run)-- with pytest.raises(RuntimeError, match = "invalid gguf"):- save_mod._split_main_gguf([str(main), str(mmproj)], "1MB", "quantizer")- assert main.exists()- assert mmproj.exists()---def test_vlm_incomplete_split_keeps_single_file(tmp_path, monkeypatch):- main = tmp_path / "model.F16.gguf"- main.write_bytes(b"m" * 2_000_001)- monkeypatch.setattr(save_mod, "_find_llama_gguf_split", lambda _: "splitter")-- def incomplete_run(args, **kwargs):- prefix = Path(args[-1])- (prefix.parent / f"{prefix.name}-00001-of-00002.gguf").write_bytes(b"one")- return subprocess.CompletedProcess(args, 0, stdout = "ok", stderr = "")-- monkeypatch.setattr(save_mod.subprocess, "run", incomplete_run)-- with pytest.raises(RuntimeError, match = "incomplete shard set"):- save_mod._split_main_gguf([str(main)], "1MB", "quantizer")- assert main.exists()---def test_vlm_split_does_not_overwrite_existing_shards(tmp_path, monkeypatch):- main = tmp_path / "model.F16.gguf"- existing = tmp_path / "model.F16-00001-of-00002.gguf"- main.write_bytes(b"m" * 2_000_001)- existing.write_bytes(b"existing")- monkeypatch.setattr(save_mod, "_find_llama_gguf_split", lambda _: "splitter")-- def fake_run(args, **kwargs):- prefix = Path(args[-1])- (prefix.parent / f"{prefix.name}-00001-of-00002.gguf").write_bytes(b"one")- (prefix.parent / f"{prefix.name}-00002-of-00002.gguf").write_bytes(b"two")- return subprocess.CompletedProcess(args, 0, stdout = "ok", stderr = "")-- monkeypatch.setattr(save_mod.subprocess, "run", fake_run)-- with pytest.raises(FileExistsError, match = "refusing to overwrite"):- save_mod._split_main_gguf([str(main)], "1MB", "quantizer")- assert main.exists()- assert existing.read_bytes() == b"existing"diff --git a/tests/saving/test_gguf_single_pass_export.py b/tests/saving/test_gguf_single_pass_export.pyindex 9d79d72a785..c7c25fa78df 100644--- a/tests/saving/test_gguf_single_pass_export.py+++ b/tests/saving/test_gguf_single_pass_export.py@@ -17,7 +17,6 @@ import contextlibimport osimport threadingimport time-from pathlib import Pathimport pytest@@ -117,11 +116,10 @@ class _Harness:def _run(tmp_path, methods, **kwargs):model_dir = tmp_path / "model_dir"model_dir.mkdir(exist_ok = True)- model_dtype = kwargs.pop("model_dtype", "float16")return save_mod.save_to_gguf(model_name = "testmodel",model_type = "llama",- model_dtype = model_dtype,+ model_dtype = "float16",model_directory = str(model_dir),quantization_method = methods,**kwargs,@@ -134,6 +132,7 @@ def test_q8_0_only_is_single_pass(monkeypatch, tmp_path):assert len(h.convert_calls) == 1assert h.convert_calls[0]["quantization_type"] == "q8_0"+ assert h.convert_calls[0]["max_shard_size"] == "50GB"assert h.quantize_calls == [], "single-pass export must not launch llama-quantize"assert want_full_precision is True, "the converted file IS the requested output"assert len(locations) == 1 and locations[0].endswith("testmodel.Q8_0.gguf")@@ -167,45 +166,13 @@ def test_k_quant_keeps_two_pass(monkeypatch, tmp_path):locations, want_full_precision, _ = _run(tmp_path, ["q4_k_m"])assert h.convert_calls[0]["quantization_type"] == "f16"+ assert h.convert_calls[0]["max_shard_size"] == "50GB"assert [c["quant_type"] for c in h.quantize_calls] == ["q4_k_m"]assert want_full_precision is False# The 16-bit intermediate must be cleaned up.assert len(locations) == 1 and locations[0].endswith("testmodel.Q4_K_M.gguf")-def test_bf16_fallback_shards_the_final_output(monkeypatch, tmp_path):- h = _Harness(monkeypatch, tmp_path)- monkeypatch.setattr(save_mod.torch.cuda, "is_bf16_supported", lambda: False)- split_calls = []-- def split(files, shard_size, quantizer_location):- split_calls.append((files, shard_size, quantizer_location))- return [files[0].replace(".gguf", f"-0000{i}-of-00002.gguf") for i in (1, 2)]-- monkeypatch.setattr(save_mod, "_split_main_gguf", split)- locations, _, _ = _run(- tmp_path,- ["bf16"],- model_dtype = "bfloat16",- gguf_shard_size = "256MB",- )-- assert h.convert_calls[0]["quantization_type"] == "f16"- assert h.convert_calls[0]["max_shard_size"] == "0"- assert [call["quant_type"] for call in h.quantize_calls] == ["bf16"]- assert split_calls == [- (- [str(tmp_path / "model_dir_gguf" / "testmodel.BF16.gguf")],- "256MB",- "llama-quantize",- )- ]- assert [Path(path).name for path in locations] == [- "testmodel.BF16-00001-of-00002.gguf",- "testmodel.BF16-00002-of-00002.gguf",- ]--def test_mixed_methods_share_16bit_base(monkeypatch, tmp_path):h = _Harness(monkeypatch, tmp_path)_run(tmp_path, ["q4_k_m", "q8_0"])@@ -242,6 +209,7 @@ def test_parallel_quants_env_kill_switch(monkeypatch, tmp_path):def test_duplicate_methods_quantize_once(monkeypatch, tmp_path):h = _Harness(monkeypatch, tmp_path)_run(tmp_path, ["q4_k_m", "q4_k_m"])+ assert h.convert_calls[0]["max_shard_size"] == "50GB"assert [c["quant_type"] for c in h.quantize_calls] == ["q4_k_m"]diff --git a/tests/saving/test_sentence_transformer_gguf_shards.py b/tests/saving/test_sentence_transformer_gguf_shards.pydeleted file mode 100644index eed2cb9a6b9..00000000000--- a/tests/saving/test_sentence_transformer_gguf_shards.py+++ /dev/null@@ -1,89 +0,0 @@-# SPDX-License-Identifier: AGPL-3.0-only-# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.--from __future__ import annotations--import os-import types--import pytest---def sentence_transformer_module():- return pytest.importorskip("unsloth.models.sentence_transformer")---class _FakeSentenceTransformer:- tokenizer = object()-- def save_pretrained(self, path):- os.makedirs(os.path.join(path, "0_Transformer"), exist_ok = True)-- def __getitem__(self, index):- assert index == 0- return types.SimpleNamespace(auto_model = object())---def test_sentence_transformer_save_forwards_gguf_shard_size(- sentence_transformer_module, tmp_path, monkeypatch-):- seen = {}- monkeypatch.setattr(- sentence_transformer_module,- "unsloth_save_pretrained_gguf",- lambda *args, **kwargs: (seen.update(kwargs), {"gguf_files": []})[1],- )-- sentence_transformer_module._save_pretrained_gguf(- _FakeSentenceTransformer(),- str(tmp_path / "sentence model ü"),- gguf_shard_size = "512MB",- )-- assert seen["gguf_shard_size"] == "512MB"- assert seen["merge_is_disposable"] is False---def test_sentence_transformer_push_forwards_gguf_shard_size(- sentence_transformer_module, monkeypatch-):- seen = {}-- class FakeApi:- def __init__(self, token):- assert token == "token"-- def create_repo(self, **kwargs):- return None-- def upload_file(self, **kwargs):- return None-- def add_tags(self, **kwargs):- return None-- monkeypatch.setattr(sentence_transformer_module, "HfApi", FakeApi)- monkeypatch.setattr(- sentence_transformer_module,- "_save_pretrained_gguf",- lambda *args, **kwargs: (- seen.update(kwargs),- {- "gguf_files": [],- "modelfile_location": None,- "is_vlm": False,- "fix_bos_token": False,- },- )[1],- )-- result = sentence_transformer_module._push_to_hub_gguf(- object(),- "owner/model",- token = "token",- gguf_shard_size = "2GB",- )-- assert result == "owner/model"- assert seen["gguf_shard_size"] == "2GB"diff --git a/unsloth/models/sentence_transformer.py b/unsloth/models/sentence_transformer.pyindex a4841aac5be..931eb10343d 100644--- a/unsloth/models/sentence_transformer.py+++ b/unsloth/models/sentence_transformer.py@@ -182,7 +182,6 @@ def _save_pretrained_gguf(temporary_location = "_unsloth_temporary_saved_buffers",maximum_memory_usage = 0.85,imatrix_file = None,- gguf_shard_size = None,**kwargs,):"""Saves the SentenceTransformer model to GGUF format by saving the inner transformer model, converting it, and placing the resulting GGUF files in the save directory."""@@ -228,7 +227,6 @@ def _save_pretrained_gguf(# transformer_dir is the ST's own 0_Transformer module, not a throwaway: reclaiming it would hand back a folder that no longer loads as a SentenceTransformer, so a short disk fails loudly.merge_is_disposable = False,imatrix_file = imatrix_file,- gguf_shard_size = gguf_shard_size,)gguf_files = result.get("gguf_files", [])@@ -310,7 +308,6 @@ def _push_to_hub_gguf(revision = None,tags = None,imatrix_file = None,- gguf_shard_size = None,**kwargs,):"""@@ -356,7 +353,6 @@ def _push_to_hub_gguf(create_pr (bool): Whether to create a pull request instead of pushing directly.revision (str, optional): Branch/revision to push to.tags (list, optional): Additional tags for the repo.- gguf_shard_size (str, optional): Maximum final f32, f16 or bf16 GGUF shard size.Returns:str: The full repo ID on Hugging Face Hub.@@ -403,7 +399,6 @@ def _push_to_hub_gguf(temporary_location = temporary_location,maximum_memory_usage = maximum_memory_usage,imatrix_file = imatrix_file,- gguf_shard_size = gguf_shard_size,)gguf_files = result.get("gguf_files", [])diff --git a/unsloth/save.py b/unsloth/save.pyindex bef031ba567..4da135f8ddc 100644--- a/unsloth/save.py+++ b/unsloth/save.py@@ -1827,201 +1827,6 @@ def get_executable(executables):# Output types convert_hf_to_gguf.py can emit directly via --outtype._DIRECT_CONVERT_OUTTYPES = ("f32", "f16", "bf16", "q8_0")-_FULL_PRECISION_GGUF_TYPES = ("f32", "f16", "bf16")-_GGUF_DEFAULT_SHARD_SIZE = "50GB"-_GGUF_NO_SHARDING = "0"-_GGUF_SHARD_SIZE_RE = re.compile(r"^(\d+)\s*([MG])B?$", re.IGNORECASE)---def _resolve_gguf_shard_size(gguf_shard_size: Optional[str]) -> str:- """Validate and normalize the final GGUF shard size."""- if gguf_shard_size is None:- return _GGUF_DEFAULT_SHARD_SIZE- if not isinstance(gguf_shard_size, str):- raise TypeError("Unsloth: gguf_shard_size must be a string or None.")-- value = gguf_shard_size.strip()- if value.casefold() in ("", "0", "none"):- return _GGUF_NO_SHARDING-- match = _GGUF_SHARD_SIZE_RE.fullmatch(value)- if match is None:- raise ValueError(- f"Unsloth: gguf_shard_size={gguf_shard_size!r} is invalid. "- "Use a positive whole number in MB or GB, such as '500MB' or '4GB', "- "or pass '0' for one file."- )-- magnitude = int(match.group(1))- unit = match.group(2).upper()- if magnitude == 0:- raise ValueError(- "Unsloth: gguf_shard_size must be positive. Pass '0' without a unit "- "to request one file."- )- multiplier = 1_000_000 if unit == "M" else 1_000_000_000- if magnitude > sys.maxsize // multiplier:- raise ValueError("Unsloth: gguf_shard_size is too large for this platform.")- return f"{magnitude}{unit}B"---def _converter_gguf_shard_size(- gguf_shard_size: str, first_conversion: str, quantization_methods, is_vlm: bool-) -> str:- """Choose the converter limit without splitting final quantized files or VLM companions."""- keeps_converter_output = first_conversion in quantization_methods- if not is_vlm and keeps_converter_output and first_conversion in _FULL_PRECISION_GGUF_TYPES:- return gguf_shard_size- return _GGUF_NO_SHARDING---def _gguf_shard_size_bytes(gguf_shard_size: str) -> int:- """Convert a normalized GGUF shard size to decimal bytes."""- if gguf_shard_size == _GGUF_NO_SHARDING:- return 0- match = _GGUF_SHARD_SIZE_RE.fullmatch(gguf_shard_size)- if match is None:- raise ValueError(f"Unsloth: invalid normalized GGUF shard size {gguf_shard_size!r}.")- multiplier = 1_000_000 if match.group(2).upper() == "M" else 1_000_000_000- return int(match.group(1)) * multiplier---def _is_gguf_companion(path: Union[str, os.PathLike]) -> bool:- """Return whether a GGUF is a vision or speculative-decoding companion."""- file_path = Path(path)- name = file_path.name.casefold()- stem = name[:-5] if name.endswith(".gguf") else name- return (- stem.endswith("-mmproj")- or stem.startswith("mmproj-")- or stem.startswith("mtp-")- or stem.endswith("-mtp")- or file_path.parent.name.casefold() == "mtp"- )---def _find_llama_gguf_split(quantizer_location: str) -> str:- """Find the llama.cpp split utility beside supported install layouts."""- executable = "llama-gguf-split.exe" if IS_WINDOWS else "llama-gguf-split"- candidates = [shutil.which(executable)]- quantizer_dir = os.path.dirname(os.path.abspath(quantizer_location))- candidates.extend(- [- os.path.join(quantizer_dir, executable),- os.path.join(LLAMA_CPP_DEFAULT_DIR, executable),- os.path.join(LLAMA_CPP_DEFAULT_DIR, "build", "bin", executable),- os.path.join(- LLAMA_CPP_DEFAULT_DIR,- "build",- "bin",- "Release",- executable,- ),- ]- )- for candidate in dict.fromkeys(path for path in candidates if path):- if os.path.isfile(candidate) and (IS_WINDOWS or os.access(candidate, os.X_OK)):- return candidate- raise RuntimeError(- "Unsloth: post-conversion GGUF sharding requires llama-gguf-split. "- "Upgrade unsloth_zoo and reinstall llama.cpp, then retry."- )---def _split_main_gguf(initial_files, gguf_shard_size: str, quantizer_location: str):- """Split one main GGUF while leaving mmproj and MTP companions untouched."""- max_bytes = _gguf_shard_size_bytes(gguf_shard_size)- if max_bytes == 0:- return initial_files-- main_files = [os.fspath(path) for path in initial_files if not _is_gguf_companion(path)]- if len(main_files) != 1:- raise RuntimeError(- "Unsloth: expected one unsharded main GGUF before companion-safe "- f"splitting, found {len(main_files)}."- )- main_file = main_files[0]- if os.path.getsize(main_file) <= max_bytes:- return initial_files-- splitter = _find_llama_gguf_split(quantizer_location)- parent = os.path.dirname(os.path.abspath(main_file))- import tempfile-- with tempfile.TemporaryDirectory(prefix = ".unsloth_gguf_split_", dir = parent) as temp_dir:- output_prefix = os.path.join(temp_dir, Path(main_file).stem)- split_size = gguf_shard_size[:-1]- try:- result = subprocess.run(- [- splitter,- "--split",- "--split-max-size",- split_size,- main_file,- output_prefix,- ],- check = True,- capture_output = True,- text = True,- # Windows defaults to cp1252 and crashes on the child's output (#2660).- encoding = "utf-8",- errors = "replace",- )- except subprocess.CalledProcessError as exception:- details = (exception.stderr or exception.stdout or "").strip()- suffix = f"\n{details}" if details else ""- raise RuntimeError(f"Unsloth: llama-gguf-split failed.{suffix}") from exception-- pattern = re.compile(- rf"^{re.escape(Path(output_prefix).name)}-(\d{{5}})-of-(\d{{5}})\.gguf$"- )- shards = []- for candidate in Path(temp_dir).iterdir():- match = pattern.fullmatch(candidate.name)- if match is not None:- shards.append((int(match.group(1)), int(match.group(2)), candidate))- shards.sort(key = lambda item: item[0])- if not shards:- details = (result.stderr or result.stdout or "").strip()- suffix = f"\n{details}" if details else ""- raise RuntimeError(f"Unsloth: llama-gguf-split produced no shards.{suffix}")-- total = shards[0][1]- indices = [index for index, declared_total, _ in shards if declared_total == total]- if len(indices) != len(shards) or indices != list(range(1, total + 1)):- raise RuntimeError("Unsloth: llama-gguf-split produced an incomplete shard set.")- if total == 1:- return initial_files-- destinations = [os.path.join(parent, shard.name) for _, _, shard in shards]- existing = [path for path in destinations if os.path.exists(path)]- if existing:- raise FileExistsError(- "Unsloth: refusing to overwrite an existing GGUF shard set: " + ", ".join(existing)- )-- moved = []- try:- for (_, _, source), destination in zip(shards, destinations):- os.replace(source, destination)- moved.append(destination)- os.unlink(main_file)- except Exception:- for destination in moved:- try:- os.unlink(destination)- except OSError:- pass- raise-- output_files = []- for path in initial_files:- if os.path.abspath(os.fspath(path)) == os.path.abspath(main_file):- output_files.extend(destinations)- else:- output_files.append(path)- return output_filesdef _choose_first_conversion(@@ -2052,7 +1857,6 @@ def save_to_gguf(gguf_directory: Optional[Union[str, os.PathLike]] = None,merge_is_disposable: bool = False,preexisting_weights = None,- gguf_shard_size: Optional[str] = None,):"""Orchestrate the HF to GGUF conversion: install, convert, quantize. `imatrix` is a resolved local importance-matrix path, forwarded to llama-quantize and required for the IQ types. `gguf_directory` places outputs separately from the model input directory. `merge_is_disposable` says `model_directory` was written by this export purely to feed the converter, so its weights may be reclaimed if the quants would not otherwise fit; off by default."""if os.environ.get("UNSLOTH_ENABLE_LOGGING", "0") == "1":@@ -2138,13 +1942,6 @@ def save_to_gguf(first_conversion = "f16"first_conversion_dtype = "" if first_conversion == "None" else first_conversion- gguf_shard_size = _resolve_gguf_shard_size(gguf_shard_size)- converter_shard_size = _converter_gguf_shard_size(- gguf_shard_size,- first_conversion,- quantization_method,- is_vlm,- )needs_quantize_pass = any(m != first_conversion for m in quantization_method)if needs_quantize_pass:second_step = f"[2] Converting GGUF {first_conversion_dtype} to {quantization_method} might take 10 minutes each."@@ -2196,7 +1993,7 @@ def save_to_gguf(supported_vision_archs = supported_vision_archs,is_vlm = is_vlm,is_gpt_oss = is_gpt_oss,- max_shard_size = converter_shard_size,+ max_shard_size = "50GB",print_output = print_output,)is_vlm = is_vlm_update@@ -2230,17 +2027,6 @@ def save_to_gguf(moved_files.append(dst)initial_files = moved_files- if (- is_vlm- and first_conversion in _FULL_PRECISION_GGUF_TYPES- and first_conversion in quantization_method- ):- initial_files = _split_main_gguf(- initial_files,- gguf_shard_size,- quantizer_location,- )-print(f"Unsloth: Initial conversion completed! Files: {initial_files}")all_saved_locations = initial_files.copy()@@ -2311,7 +2097,8 @@ def save_to_gguf(sum(os.path.getsize(f)for f in initial_files- if os.path.isfile(f) and not _is_gguf_companion(f)+ if os.path.isfile(f)+ and "-mmproj" not in os.path.basename(f).lower())* _ratio)@@ -2388,7 +2175,11 @@ def save_to_gguf(}# Each llama-quantize pass loads the whole base GGUF into RAM, so run two at once only with headroom for two copies, else a multi-quant export that fit sequentially OOMs.try:- base_bytes = sum(os.path.getsize(f) for f in initial_files if not _is_gguf_companion(f))+ base_bytes = sum(+ os.path.getsize(f)+ for f in initial_files+ if "-mmproj" not in os.path.basename(f).lower()+ )mem_ok = psutil.virtual_memory().available >= int(2.5 * base_bytes)except Exception:mem_ok = False@@ -2447,8 +2238,8 @@ def save_to_gguf(print("Unsloth: Model files cleanup...")want_full_precision = first_conversion in quantization_methodif quants_created:- # convert_to_gguf can return main shards plus companion files.- base_files = [f for f in initial_files if not _is_gguf_companion(f)]+ # exclude the projector from the base shards during cleanup.+ base_files = [f for f in initial_files if "-mmproj" not in os.path.basename(f).lower()]if not want_full_precision:for f in base_files:if f in all_saved_locations:@@ -2465,17 +2256,6 @@ def save_to_gguf(all_saved_locations.remove(f)for i, f in enumerate(base_files):all_saved_locations.insert(1 + i, f)-- for quant_method, quantized_file in zip(methods_to_quantize, quantized_files):- if quant_method not in _FULL_PRECISION_GGUF_TYPES:- continue- split_files = _split_main_gguf(- [quantized_file],- gguf_shard_size,- quantizer_location,- )- index = all_saved_locations.index(quantized_file)- all_saved_locations[index : index + 1] = split_fileselse:print("Unsloth: GPT-OSS model - skipping additional quantizations")want_full_precision = True@@ -4046,7 +3826,6 @@ def unsloth_save_pretrained_gguf(save_method: str = None,imatrix_file = None,merge_is_disposable: bool = True,- gguf_shard_size: Optional[str] = None,):"""Same as .save_pretrained(...) except 4bit weights are auto@@ -4061,9 +3840,6 @@ def unsloth_save_pretrained_gguf(to keep the weights when `save_directory` is part of the caller's own deliverable (theSentenceTransformer export writes its module directory there).- gguf_shard_size: maximum final f32, f16 or bf16 GGUF shard size in MB or GB. Pass- "0" for one file. None preserves the historical 50GB converter limit.-Choose for `quantization_method` to be:"not_quantized" : "Recommended. Fast conversion. Slow inference, big files.","fast_quantized" : "Recommended. Fast conversion. OK inference, OK file size.",@@ -4097,7 +3873,6 @@ def unsloth_save_pretrained_gguf(if isinstance(tokenizer, (PreTrainedTokenizerBase, ProcessorMixin)):tokenizer = patch_saving_functions(tokenizer)save_directory = os.path.normpath(os.fspath(save_directory))- gguf_shard_size = _resolve_gguf_shard_size(gguf_shard_size)# save_method="lora" exports the adapter itself as a GGUF LoRA, not a merged model.if save_method is not None and str(save_method).lower() == "lora":@@ -4193,7 +3968,6 @@ def unsloth_save_pretrained_gguf(del arguments["imatrix_file"] # only used by the gguf quantize step, not the 16bit mergedel arguments["_gguf_prewarm_ok"] # a local decision, not a save_pretrained kwargdel arguments["merge_is_disposable"] # decides reclamation, not how the merge is written- del arguments["gguf_shard_size"] # only used by the gguf converter# Preserve the requested output before reusing a non-PEFT checkpoint as input. Same definition the preflight sized, so it measured the disk these files land on.gguf_directory = _gguf_output_directory(save_directory)@@ -4338,7 +4112,6 @@ def unsloth_save_pretrained_gguf(gguf_directory = gguf_directory,merge_is_disposable = merge_is_disposable,preexisting_weights = preexisting_weights,- gguf_shard_size = gguf_shard_size,)except Exception as e:if _gguf_child_was_oom_killed(e):@@ -4613,11 +4386,11 @@ def _free_merge_if_disk_is_tight(if not quant_methods:return 0try:- # llama-quantize copies companions rather than quantizing them, so they are excluded from the output and memory estimates.+ # llama-quantize copies the projector, so exclude it from the output and memory estimates.base_bytes = sum(os.path.getsize(f)for f in initial_files- if os.path.isfile(f) and not _is_gguf_companion(f)+ if os.path.isfile(f) and "-mmproj" not in os.path.basename(f).lower())except OSError:return 0@@ -4696,7 +4469,6 @@ def unsloth_push_to_hub_gguf(save_method: str = None,imatrix_file = None,is_main_process: bool = True,- gguf_shard_size: Optional[str] = None,):"""Same as .push_to_hub(...) except 4bit weights are auto converted to float16 then converted to GGUF / llama.cpp format.@@ -4767,7 +4539,6 @@ def unsloth_push_to_hub_gguf(temporary_location = temporary_location,maximum_memory_usage = maximum_memory_usage,imatrix_file = imatrix_file,- gguf_shard_size = gguf_shard_size,)all_file_locations = result["gguf_files"]