From fc4ad33493b3a739e775a983e3a85439b0f5bf19 Mon Sep 17 00:00:00 2001 From: Datta Nimmaturi Date: Fri, 6 Feb 2026 15:01:52 +0000 Subject: [PATCH] Patch before compile? --- unsloth/models/_utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index 48e5683076..b01cb4113b 100644 --- a/unsloth/models/_utils.py +++ b/unsloth/models/_utils.py @@ -1966,6 +1966,12 @@ def unsloth_compile_transformers( return model_types, False supports_sdpa = [True] + + # Run patches BEFORE compiler so class replacements (e.g. GptOssTopKRouter, + # GptOssExperts) are in place before the compiler caches references to them. + for temporary_patch in TEMPORARY_PATCHES: + temporary_patch() + for model_type in model_types: _unsloth_compile_transformers( model_type,