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
Export: add save_pretrained_openvino and push_to_hub_openvino support (#11907)
Aleksei Boklag8de51b191712
diff --git a/.github/workflows/consolidated-tests-ci.yml b/.github/workflows/consolidated-tests-ci.ymlindex e00ac0f8319..760d96dea3d 100644--- a/.github/workflows/consolidated-tests-ci.yml+++ b/.github/workflows/consolidated-tests-ci.yml@@ -330,6 +330,7 @@ jobs:tests/saving/test_fix_sentencepiece_tokenizer_guard.py \tests/saving/test_compressed_export_schemes.py \tests/saving/test_export_api_surface.py \+ tests/saving/test_openvino_export.py \tests/saving/test_export_dispatch.py \tests/saving/test_imatrix_export.py \tests/saving/test_gguf_single_pass_export.py \@@ -481,6 +482,7 @@ jobs:tests/saving/test_fix_sentencepiece_tokenizer_guard.py \tests/saving/test_compressed_export_schemes.py \tests/saving/test_export_api_surface.py \+ tests/saving/test_openvino_export.py \tests/saving/test_export_dispatch.py \tests/saving/test_imatrix_export.py \tests/saving/test_gguf_single_pass_export.py \diff --git a/tests/saving/test_export_api_surface.py b/tests/saving/test_export_api_surface.pyindex 2ea8e8752e8..703ef8aab73 100644--- a/tests/saving/test_export_api_surface.py+++ b/tests/saving/test_export_api_surface.py@@ -31,6 +31,8 @@ PUBLIC_EXPORT_METHODS = ("save_pretrained_gguf","push_to_hub_gguf","save_pretrained_torchao",+ "save_pretrained_openvino",+ "push_to_hub_openvino","save_pretrained_ggml","push_to_hub_ggml",)diff --git a/tests/saving/test_openvino_export.py b/tests/saving/test_openvino_export.pynew file mode 100644index 00000000000..9e0eba93054--- /dev/null+++ b/tests/saving/test_openvino_export.py@@ -0,0 +1,134 @@+from __future__ import annotations++import argparse+import functools+import os+import subprocess+import sys+from types import SimpleNamespace++import pytest++import unsloth.save as save_mod++_REAL_PARSER, _REAL_BOUNDS = save_mod._openvino_cli_parser, save_mod._openvino_transformers_mismatch+_OUT = ("openvino_model.xml", "openvino_tokenizer.xml")+_CASES = {"nf5": {"quantization_type": "nf5"}, "typo": {"group_sise": 64}, "out": {"output": "x"}}+_BOUNDS = {'[null, "0.1"]': "transformers <= 0.1", '["99.0", null]': "transformers >= 99.0"}+_llama = lambda: SimpleNamespace(config = SimpleNamespace(model_type = "llama"))+++def _parser():+ parser = argparse.ArgumentParser()+ for flag in ("output", "--model", "--weight-format", "--group-size", "--library", "--task"):+ parser.add_argument(flag)+ for flag in ("--sym", "--trust-remote-code"):+ parser.add_argument(flag, action = "store_true")+ return parser+++def _write(cmd, env, *names):+ os.makedirs(cmd[-1], exist_ok = True)+ for name in names or _OUT:+ open(os.path.join(cmd[-1], name), "w").close()+++def run(monkeypatch, tmp_path):+ seen = SimpleNamespace(merges = [], cmds = [], envs = [])+ monkeypatch.setattr(save_mod, "_openvino_cli_parser", _parser)+ monkeypatch.setattr(save_mod, "_openvino_transformers_mismatch", lambda *args: None)+ monkeypatch.setattr(save_mod, "unsloth_generic_save", lambda **kw: seen.merges.append(kw))+ call = lambda cmd, env: (seen.cmds.append(cmd), seen.envs.append(env), _write(cmd, env))+ monkeypatch.setattr(save_mod.subprocess, "check_call", call)++ def export(*model, **kwargs):+ out, kwargs["token"] = str(tmp_path / kwargs.pop("out", "out")), kwargs.get("token", False)+ return save_mod._unsloth_save_openvino(*(model or [_llama()]), out, **kwargs)++ export.seen, export.left = seen, lambda: [p for p in os.listdir(tmp_path) if p[0] == "."]+ return export++[email protected]("quantization_type", [None, "F16", "int8", "4bit"])+def test_exports_the_merge_in_a_child_process(run, tmp_path, quantization_type):+ # In-process export traces classes Unsloth patched; no weight format int8s models over 1B.+ assert run(quantization_type = quantization_type) == str(tmp_path / "out")+ (cmd,), (merge,) = run.seen.cmds, run.seen.merges+ fmt = {None: "fp16", "F16": "fp16", "int8": "int8", "4bit": "int4"}[quantization_type]+ assert cmd[:5] == [sys.executable, "-m", "optimum.commands.optimum_cli", "export", "openvino"]+ assert cmd[5:9] == ["--model", merge["save_directory"], "--weight-format", fmt]+ assert ("--sym" in cmd, "--group-size" in cmd) == (fmt != "fp16", fmt == "int4")+ assert "--trust-remote-code" not in cmd # only for models loaded through remote code+ assert cmd[-3:] == ["--task", "text-generation-with-past", str(tmp_path / "out")]+ assert os.path.dirname(os.path.dirname(cmd[6])) == str(tmp_path) and not run.left()+++def test_options_vlm_task_remote_code_token_and_missing_tokenizer(run, monkeypatch):+ vlm = SimpleNamespace(config = SimpleNamespace(model_type = "qwen2_vl", vision_config = {}))+ monkeypatch.setattr(save_mod, "_loaded_via_remote_code", lambda obj: obj is vlm)+ monkeypatch.setattr(save_mod.logger, "warning_once", (warnings := []).append)+ monkeypatch.setattr(save_mod, "_openvino_transformers_mismatch", _REAL_BOUNDS)+ monkeypatch.setattr(save_mod, "_OPENVINO_BOUNDS_PROBE", "raise SystemExit(3)") # defers+ monkeypatch.setenv("HF_TOKEN", "hf_parent")+ run(vlm, quantization_type = "int4", sym = False, group_size = 64, token = "hf_explicit")+ (cmd,), (env,) = run.seen.cmds, run.seen.envs+ assert "--sym" not in cmd and cmd[cmd.index("--group-size") + 1] == "64"+ assert cmd[cmd.index("--task") + 1] == "image-text-to-text" and "--trust-remote-code" in cmd+ assert not {"hf_parent", "hf_explicit"} & {*env.values()} # the child reads a local checkpoint+ t5 = SimpleNamespace(config = SimpleNamespace(model_type = "t5", is_encoder_decoder = True))+ with pytest.raises(ValueError, match = "encoder-decoder"):+ run(t5) # its task cannot be assumed, so the caller must name it+ run(t5, task = "text2text-generation-with-past")+ assert run(is_main_process = False) is None and len(run.seen.merges) == 2 and not warnings+ monkeypatch.setattr(save_mod.subprocess, "check_call", lambda c, env: _write(c, env, _OUT[0]))+ run(out = "no_tokenizer")+ assert len(warnings) == 1 and "openvino_tokenizer.xml" in warnings[0]++[email protected]("case", [*_CASES, *_BOUNDS, "no optimum", "child fails", "no model"])+def test_failures_come_before_the_merge_or_clean_up(run, monkeypatch, case):+ if case in _BOUNDS: # optimum-intel's transformers bounds for this architecture+ monkeypatch.setattr(save_mod, "_openvino_transformers_mismatch", _REAL_BOUNDS)+ monkeypatch.setattr(save_mod, "_OPENVINO_BOUNDS_PROBE", f"print({case!r})")+ if case == "no optimum":+ monkeypatch.setattr(save_mod, "_openvino_cli_parser", _REAL_PARSER)+ monkeypatch.setitem(sys.modules, "optimum.commands.export.openvino", None)+ fail = lambda cmd, env: subprocess.run([sys.executable, "-c", "exit(1)"], check = True)+ child = {"child fails": fail, "no model": lambda c, env: _write(c, env, "x")}.get(case)+ monkeypatch.setattr(save_mod.subprocess, "check_call", child or save_mod.subprocess.check_call)+ with pytest.raises((ValueError, RuntimeError, ImportError), match = _BOUNDS.get(case, "Unsloth")):+ run(**_CASES.get(case, {}))+ assert len(run.seen.merges) == bool(child) and not run.left()+++def test_push_checks_the_repo_first_and_forwards_hub_arguments(run, monkeypatch):+ calls = []+ create = lambda **kw: calls.append((kw, len(run.seen.merges)))+ upload = lambda **kw: calls.append((kw, os.listdir(kw["folder_path"])))+ api = SimpleNamespace(create_repo = create, upload_folder = upload)+ monkeypatch.setattr(save_mod, "HfApi", lambda token: api)+ hub = dict(private = True, commit_message = "mine", create_pr = True, revision = "dev")+ assert save_mod.unsloth_push_to_hub_openvino(_llama(), "me/m", token = False, **hub) == "me/m"+ (created, merges_before), (uploaded, files) = calls+ assert created["private"] and merges_before == 0 and "openvino_model.xml" in files+ assert all(uploaded[k] == hub[k] for k in hub if k != "private")+ assert not os.path.exists(uploaded["folder_path"])+++def test_real_export_with_the_forward_patched_in_process(monkeypatch, tmp_path):+ pytest.importorskip("optimum.intel")+ import transformers++ tiny = "hf-internal-testing/tiny-random-LlamaForCausalLM"+ try:+ model = transformers.AutoModelForCausalLM.from_pretrained(tiny)+ tokenizer = transformers.AutoTokenizer.from_pretrained(tiny)+ except OSError:+ pytest.skip(f"{tiny} is not reachable")+ # Unsloth's forward reads max_seq_length, which only models it loaded carry.+ forward = transformers.LlamaModel.forward+ patched = lambda self, *a, **k: (self.max_seq_length, forward(self, *a, **k))[1]+ monkeypatch.setattr(transformers.LlamaModel, "forward", functools.wraps(forward)(patched))+ save_mod._unsloth_save_openvino(model, str(tmp_path / "o"), tokenizer = tokenizer, token = False)+ assert {"openvino_tokenizer.xml", "openvino_detokenizer.xml"} <= {*os.listdir(tmp_path / "o")}diff --git a/unsloth/save.py b/unsloth/save.pyindex a501b2cff6a..ca6849776e9 100644--- a/unsloth/save.py+++ b/unsloth/save.py@@ -89,6 +89,8 @@ __all__ = ["save_to_gguf","patch_saving_functions","create_huggingface_repo",+ "unsloth_save_pretrained_openvino",+ "unsloth_push_to_hub_openvino",]# llama.cpp specific targets: all takes 90s, the below 60s.@@ -6907,6 +6909,319 @@ def unsloth_save_pretrained_torchao(gc.collect()+# quantization_type -> `optimum-cli export openvino` options. None and "fp16" still name a weight format: with none, optimum-intel int8-compresses every model over 1B parameters.+_OPENVINO_QUANTIZATION_PRESETS = {+ "fp16": {"weight_format": "fp16"},+ "int8": {"weight_format": "int8", "sym": True},+ "int4": {"weight_format": "int4", "sym": True, "group_size": 128},+}+_OPENVINO_QUANTIZATION_ALIASES = {+ "none": "fp16",+ "fp16": "fp16",+ "f16": "fp16",+ "int8": "int8",+ "8bit": "int8",+ "8": "int8",+ "int4": "int4",+ "4bit": "int4",+ "4": "int4",+}+++def _openvino_cli_parser():+ """optimum-intel's own `export openvino` argument parser, or ImportError when OpenVINO export is not installed. Only argparse definitions are imported; torch and openvino stay out of this process."""+ import argparse+ import importlib.util++ try:+ from optimum.commands.export.openvino import parse_args_openvino+ except ImportError:+ parse_args_openvino = None+ if parse_args_openvino is None or importlib.util.find_spec("openvino") is None:+ raise ImportError(+ "Unsloth: Exporting to OpenVINO requires `optimum-intel` and `openvino`.\n"+ "Please install them via: pip install 'optimum[openvino]'"+ )+ parser = argparse.ArgumentParser(prog = "optimum-cli export openvino")+ parse_args_openvino(parser)+ return parser+++def _openvino_export_args(quantization_type, export_kwargs):+ """The `optimum-cli export openvino` options for this export: the quantization_type preset, overridden by any option passed as a keyword (group_size = 64 -> --group-size 64, True -> bare flag, False or None -> omitted). Checked with optimum-intel's parser so a bad option fails before the merge."""+ import contextlib+ import io++ key = "none" if quantization_type is None else str(quantization_type).strip().lower()+ if key not in _OPENVINO_QUANTIZATION_ALIASES:+ raise ValueError(+ f"Unsloth: Unknown OpenVINO quantization_type '{quantization_type}'. "+ "Expected 'int4', 'int8', 'fp16', or None."+ )+ if "output" in export_kwargs:+ raise ValueError(+ "Unsloth: `output` is set by save_pretrained_openvino itself and cannot be passed "+ "as an OpenVINO export option."+ )+ options = dict(_OPENVINO_QUANTIZATION_PRESETS[_OPENVINO_QUANTIZATION_ALIASES[key]])+ options.update(export_kwargs)+ args = []+ for name, value in options.items():+ if value is None or value is False:+ continue+ flag = "--" + name.replace("_", "-")+ args += [flag] if value is True else [flag, str(value)]++ parser = _openvino_cli_parser()+ errors = io.StringIO()+ try:+ with contextlib.redirect_stderr(errors):+ parser.parse_args(["output", "--model", "model", *args])+ except SystemExit:+ message = errors.getvalue().strip().splitlines()+ raise ValueError(+ "Unsloth: Invalid OpenVINO export option: "+ + (message[-1] if message else " ".join(args))+ )+ return args+++# Prints the [min, max] transformers bounds optimum-intel's OpenVINO exporter declares for one architecture and task.+_OPENVINO_BOUNDS_PROBE = """+import json, sys+import optimum.exporters.openvino.model_configs+from optimum.exporters.tasks import TasksManager+c = TasksManager.get_exporter_config_constructor(+ exporter = "openvino", model_type = sys.argv[1], task = sys.argv[2], library_name = "transformers"+)+c = getattr(c, "func", c)+bounds = (getattr(c, "MIN_TRANSFORMERS_VERSION", None), getattr(c, "MAX_TRANSFORMERS_VERSION", None))+print(json.dumps([None if v is None else str(getattr(v, "base_version", v)) for v in bounds]))+"""+++def _openvino_transformers_mismatch(model_type, task):+ """Why optimum-intel will refuse to export this architecture under the installed transformers, or None. It checks its per-architecture bounds only inside the export, after the 16bit merge is written (qwen2_vl, qwen3_vl and gemma3_text stop at transformers 5.0 in optimum-intel 2.2), so ask first, as the compressed export does for llm-compressor's ceiling. The probe runs in a child process because optimum's export registry loads the OpenVINO runtime; any failure defers to the export."""+ import transformers++ try:+ probe = subprocess.run(+ [sys.executable, "-c", _OPENVINO_BOUNDS_PROBE, model_type, task],+ capture_output = True,+ text = True,+ timeout = 300,+ )+ low, high = json.loads(probe.stdout.strip().splitlines()[-1])+ installed = Version(transformers.__version__)+ too_old = low is not None and installed < Version(low)+ too_new = high is not None and installed > Version(high)+ except Exception:+ return None+ if not (too_old or too_new):+ return None+ needed = f"transformers >= {low}" if too_old else f"transformers <= {high.replace('99', '*')}"+ return (+ f"Unsloth: optimum-intel cannot export {model_type} under transformers "+ f"{transformers.__version__}; it needs {needed}. Install a supported transformers, or an "+ "optimum-intel that supports this one, before exporting."+ )+++def _unsloth_save_openvino(+ model,+ save_directory: Union[str, os.PathLike],+ tokenizer = None,+ quantization_type: Optional[str] = None,+ push_to_hub: bool = False,+ token: Optional[Union[str, bool]] = None,+ is_main_process: bool = True,+ private: Optional[bool] = None,+ commit_message: Optional[str] = "Export model to OpenVINO IR with Unsloth",+ commit_description: Optional[str] = None,+ create_pr: bool = False,+ revision: Optional[str] = None,+ **export_kwargs,+):+ """Merge to 16bit in a staging directory, then convert it with `optimum-cli export openvino` in a separate process. Exporting in this process cannot work: optimum-intel traces the reloaded checkpoint through transformers classes whose forwards Unsloth has already patched (Llama's reads `self.max_seq_length`, which only Unsloth-loaded instances carry), so every trace fails. The CLI also converts the tokenizer to openvino_tokenizer.xml, which openvino_genai pipelines need."""+ import tempfile++ if isinstance(tokenizer, (PreTrainedTokenizerBase, ProcessorMixin)):+ tokenizer = patch_saving_functions(tokenizer)+ token = _clean_save_token(token)+ if token is None or token is True:+ token = get_token()++ if not is_main_process:+ return None++ # Everything that can reject the request runs before the merge, which writes a full 16bit checkpoint. Remote code is trusted only when the model or tokenizer was already loaded through it.+ export_kwargs = dict(export_kwargs)+ if _loaded_via_remote_code(model) or _loaded_via_remote_code(tokenizer):+ export_kwargs.setdefault("trust_remote_code", True)+ export_kwargs.setdefault("library", "transformers")+ # optimum-cli cannot infer the task from a local directory. Same VLM test as the torchao and compressed exports: a bare *ForConditionalGeneration also matches text seq2seq.+ config = getattr(model, "config", None)+ archs = getattr(config, "architectures", None) or []+ is_vlm = hasattr(config, "vision_config") or any(+ x.endswith("ForVisionText2Text") for x in archs+ )+ # T5/BART export as text2text-generation, Whisper as speech recognition: no default fits them all.+ if not is_vlm and getattr(config, "is_encoder_decoder", False) and "task" not in export_kwargs:+ raise ValueError(+ f"Unsloth: {getattr(config, 'model_type', 'this model')} is an encoder-decoder model, so "+ "its OpenVINO export task must be given, e.g. task = 'text2text-generation-with-past'."+ )+ export_kwargs.setdefault(+ "task", "image-text-to-text" if is_vlm else "text-generation-with-past"+ )+ cli_args = _openvino_export_args(quantization_type, export_kwargs)+ model_type = getattr(config, "model_type", None)+ if isinstance(model_type, str):+ mismatch = _openvino_transformers_mismatch(model_type, export_kwargs["task"])+ if mismatch:+ raise RuntimeError(mismatch)++ if push_to_hub:+ repo_id = os.fspath(save_directory)+ work_tmp = tempfile.mkdtemp(prefix = "unsloth-openvino-")+ final_dir = os.path.join(work_tmp, "openvino")+ else:+ repo_id = None+ final_dir = os.path.abspath(os.fspath(save_directory))+ # Stage beside the destination, not in TMPDIR: /tmp is often a RAM-backed tmpfs, and the staging merge holds 2 bytes per parameter.+ os.makedirs(os.path.dirname(final_dir), exist_ok = True)+ work_tmp = tempfile.mkdtemp(prefix = ".unsloth-openvino-", dir = os.path.dirname(final_dir))+ staging = os.path.join(work_tmp, "merged_16bit")++ try:+ # Validate Hub access before the merge; create_repo is idempotent.+ api = None+ if push_to_hub:+ api = HfApi(token = token)+ api.create_repo(repo_id = repo_id, repo_type = "model", private = private, exist_ok = True)++ print("Unsloth: Merging to 16bit before OpenVINO export...")+ unsloth_generic_save(+ model = model,+ tokenizer = tokenizer,+ save_directory = staging,+ save_method = "merged_16bit",+ push_to_hub = False,+ token = token,+ is_main_process = is_main_process,+ )++ # Run the CLI module under this interpreter; it never imports Unsloth, so the trace sees stock transformers. It only reads the local staging checkpoint, so it gets no Hub credential.+ cmd = [+ sys.executable,+ "-m",+ "optimum.commands.optimum_cli",+ "export",+ "openvino",+ "--model",+ staging,+ *cli_args,+ final_dir,+ ]+ env = os.environ.copy()+ _apply_token_to_child_env(env, False, explicit = True)+ print("Unsloth: Exporting to OpenVINO IR in a separate process...")+ try:+ subprocess.check_call(cmd, env = env)+ except subprocess.CalledProcessError as e:+ raise RuntimeError(+ f"Unsloth: OpenVINO export failed (optimum-cli exit {e.returncode}). "+ "See the output above for details."+ )+ exported = os.listdir(final_dir) if os.path.isdir(final_dir) else []+ if not any(f.startswith("openvino_") and f.endswith("model.xml") for f in exported):+ raise RuntimeError(f"Unsloth: OpenVINO export wrote no model to '{final_dir}'.")+ # A LoRA merge copies the base tokenizer even when none is passed, so check the output.+ if "openvino_tokenizer.xml" not in exported:+ logger.warning_once(+ "Unsloth: The OpenVINO export has no openvino_tokenizer.xml, so openvino_genai "+ "cannot load it. Pass `tokenizer = tokenizer` and install openvino-tokenizers."+ )++ if push_to_hub:+ print(f"Unsloth: Uploading OpenVINO model to '{repo_id}' ...")+ api.upload_folder(+ folder_path = final_dir,+ repo_id = repo_id,+ repo_type = "model",+ commit_message = commit_message,+ commit_description = commit_description,+ create_pr = create_pr,+ revision = revision,+ )+ print(f"Unsloth: Saved OpenVINO model to https://huggingface.co/{repo_id}")+ return repo_id+ print(f"Unsloth: Saved OpenVINO model to '{final_dir}'.")+ return os.fspath(save_directory)+ finally:+ shutil.rmtree(work_tmp, ignore_errors = True)+ for _ in range(3):+ gc.collect()+++def unsloth_save_pretrained_openvino(+ self,+ save_directory: Union[str, os.PathLike],+ tokenizer = None,+ quantization_type: Optional[str] = None,+ push_to_hub: bool = False,+ token: Optional[Union[str, bool]] = None,+ is_main_process: bool = True,+ private: Optional[bool] = None,+ **kwargs,+):+ """Save the model in OpenVINO IR format for OpenVINO Runtime, optimum-intel and openvino_genai on Intel CPUs, GPUs and NPUs. LoRA adapters are merged into a 16bit copy first, which `optimum-cli export openvino` converts in a separate process. Needs `pip install 'optimum[openvino]'`.++ Parameters:+ - save_directory: Local output directory, or a Hugging Face Hub repo id when push_to_hub=True.+ - tokenizer: Tokenizer or processor to export alongside the model; openvino_genai needs it.+ - quantization_type: "int4" (symmetric, group size 128), "int8" (symmetric), or None / "fp16" for unquantized 16bit weights (a bfloat16 merge stays bfloat16).+ - push_to_hub, token, private: Upload the export to the Hub instead of keeping it locally. commit_message, commit_description, create_pr and revision are also accepted.+ - is_main_process: Only the main process exports under multi-GPU / DDP.+ - **kwargs: Other `optimum-cli export openvino` options, with underscores for dashes, e.g. group_size = 64, ratio = 0.8, sym = False, awq = True, dataset = "wikitext2". They override the quantization_type preset.+ """+ return _unsloth_save_openvino(+ model = self,+ save_directory = save_directory,+ tokenizer = tokenizer,+ quantization_type = quantization_type,+ push_to_hub = push_to_hub,+ token = token,+ is_main_process = is_main_process,+ private = private,+ **kwargs,+ )+++def unsloth_push_to_hub_openvino(+ self,+ repo_id: str,+ tokenizer = None,+ quantization_type: Optional[str] = None,+ token: Optional[Union[str, bool]] = None,+ is_main_process: bool = True,+ private: Optional[bool] = None,+ **kwargs,+):+ """Export the model to OpenVINO IR format and push it to the Hugging Face Hub. Takes the same options as save_pretrained_openvino."""+ return _unsloth_save_openvino(+ model = self,+ save_directory = repo_id,+ tokenizer = tokenizer,+ quantization_type = quantization_type,+ push_to_hub = True,+ token = token,+ is_main_process = is_main_process,+ private = private,+ **kwargs,+ )++def not_implemented_save(*args, **kwargs):raise NotImplementedError("Unsloth: Sorry GGUF is currently not supported for vision models!")@@ -7105,6 +7420,10 @@ def patch_saving_functions(model, vision = False):model.push_to_hub_gguf = types.MethodType(unsloth_push_to_hub_gguf, model)model.save_pretrained_gguf = types.MethodType(unsloth_save_pretrained_gguf, model)model.save_pretrained_torchao = types.MethodType(unsloth_save_pretrained_torchao, model)+ model.save_pretrained_openvino = types.MethodType(+ unsloth_save_pretrained_openvino, model+ )+ model.push_to_hub_openvino = types.MethodType(unsloth_push_to_hub_openvino, model)model.push_to_hub_ggml = types.MethodType(unsloth_convert_lora_to_ggml_and_push_to_hub, model)@@ -7119,6 +7438,8 @@ def patch_saving_functions(model, vision = False):model.push_to_hub_gguf = types.MethodType(unsloth_push_to_hub_gguf, model)model.save_pretrained_gguf = types.MethodType(unsloth_save_pretrained_gguf, model)model.save_pretrained_torchao = types.MethodType(unsloth_save_pretrained_torchao, model)+ model.save_pretrained_openvino = types.MethodType(unsloth_save_pretrained_openvino, model)+ model.push_to_hub_openvino = types.MethodType(unsloth_push_to_hub_openvino, model)return model