From b76ac12e31e7364a0d4c2328e70983d0021c7a0b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 11:37:47 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- unsloth/models/rl.py | 1 + unsloth/models/rl_replacements.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py index 1427ca747f..80ddbf19a4 100644 --- a/unsloth/models/rl.py +++ b/unsloth/models/rl.py @@ -1587,6 +1587,7 @@ def _patch_prepare_multimodal_messages(): # Also patch in grpo_trainer module if imported try: import trl.trainer.grpo_trainer as _gt + if hasattr(_gt, "prepare_multimodal_messages"): _gt.prepare_multimodal_messages = _safe_prepare_multimodal_messages except ImportError: diff --git a/unsloth/models/rl_replacements.py b/unsloth/models/rl_replacements.py index 06969227b4..883a5392f5 100755 --- a/unsloth/models/rl_replacements.py +++ b/unsloth/models/rl_replacements.py @@ -29,16 +29,20 @@ from unsloth_zoo.rl_replacements import RL_REPLACEMENTS, left_pack_padding from unsloth_zoo.utils import Version from importlib.metadata import version as importlib_version from unsloth_zoo.log import logger + # device_synchronize may not exist in older unsloth_zoo versions try: from unsloth_zoo.device_type import device_synchronize except ImportError: import torch + def device_synchronize(): if torch.cuda.is_available(): torch.cuda.synchronize() elif hasattr(torch, "xpu") and torch.xpu.is_available(): torch.xpu.synchronize() + + import importlib.util from ..device_type import ( is_hip,