From 30fac638adb16a9cd6f1077a38978e567c7cb600 Mon Sep 17 00:00:00 2001 From: Irfan Ali Date: Wed, 25 Feb 2026 13:39:16 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20correct=20gpt-oss=20Ollama=20generation?= =?UTF-8?q?=20prompt=20and=20add=20quantization=20wa=E2=80=A6=20(#4087)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Warn when save_pretrained_gguf overrides quantization to MXFP4 for GPT-OSS GPT-OSS only supports MXFP4 format. If the user passes a different quantization_method, log a warning via logger.warning_once before overriding. Pass quantization_method=None to suppress the warning. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Daniel Han Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- unsloth/save.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/unsloth/save.py b/unsloth/save.py index a07575c35d..66d5ae2d60 100644 --- a/unsloth/save.py +++ b/unsloth/save.py @@ -1925,6 +1925,20 @@ def unsloth_save_pretrained_gguf( arguments["push_to_hub"] = False # We handle upload ourselves # GPT-OSS needs mxfp4 save method if is_gpt_oss: + if quantization_method is not None: + _qm = ( + quantization_method + if isinstance(quantization_method, (list, tuple)) + else [quantization_method] + ) + _ignored = [q for q in _qm if str(q).lower() != "mxfp4"] + if _ignored: + logger.warning_once( + f"Unsloth: GPT-OSS does not support GGUF quantization " + f"(requested: {', '.join(str(q) for q in _ignored)}). " + f"Overriding to MXFP4 format. " + f"Pass quantization_method=None to suppress this warning." + ) arguments["save_method"] = "mxfp4" else: arguments["save_method"] = "merged_16bit"