Skip to content

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.

PatchRL

Daniel Han5e69427fdaa9
diff --git a/unsloth/models/__init__.py b/unsloth/models/__init__.py
index c52d14f4028..3478dfc31a0 100644
--- a/unsloth/models/__init__.py
+++ b/unsloth/models/__init__.py
@@ -20,3 +20,4 @@ from .mistral import FastMistralModel
from .qwen2 import FastQwen2Model
from .dpo import PatchDPOTrainer, PatchKTOTrainer
from ._utils import is_bfloat16_supported
+from .rl import PatchRL
diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py
index efe2d33e01f..2aa8f026597 100644
--- a/unsloth/models/rl.py
+++ b/unsloth/models/rl.py
@@ -13,14 +13,15 @@
# limitations under the License.
__all__ = [
- "patch_rl",
+ "PatchRL",
]
-from trl.models.utils import unwrap_model_for_generation
-from contextlib import contextmanager
+def PatchRL(FastLanguageModel):
-def patch_rl(FastLanguageModel):
+ from trl.models.utils import unwrap_model_for_generation
+ from contextlib import contextmanager
+
@contextmanager
def unsloth_unwrap_model_for_generation(model, *args, **kwargs):
FastLanguageModel.for_inference(model)