fix: correct gpt-oss Ollama generation prompt and add quantization wa… (#4087)

* 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 <danielhanchen@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Irfan Ali 2026-02-25 13:39:16 +01:00 committed by GitHub
commit 30fac638ad

View file

@ -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"