From fdc32212f8234a79c29bd2a56ed203314d6acfe7 Mon Sep 17 00:00:00 2001 From: DoubleMathew Date: Wed, 6 Aug 2025 14:13:35 -0500 Subject: [PATCH] gpt-oss manually call temporary patch (#3104) Co-authored-by: Mathew Mathew --- unsloth/models/loader.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py index b3218d2498..77f953a5a3 100644 --- a/unsloth/models/loader.py +++ b/unsloth/models/loader.py @@ -592,6 +592,19 @@ class FastModel(FastBaseModel): "os.environ['TRITON_F32_DEFAULT'] = 'ieee';" elif "gpt-oss" in lowered_model_name: os.environ["UNSLOTH_DISABLE_STATIC_GENERATION"] = "1" + # the temporary patches for init need UNSLOTH_MODEL_NAME to be set + # which doesn't happen at import so manually call here + # before creating the compiled cache + try: + from unsloth_zoo.temporary_patches.gpt_oss import ( + patch_GptOssExperts_MXFP4, + patch_GptOssExperts_bitsandbytes, + ) + + patch_GptOssExperts_MXFP4() + patch_GptOssExperts_bitsandbytes() + except: + pass else: for check_model_name in DISABLE_COMPILE_MODEL_NAMES: if check_model_name in lowered_model_name: