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.

Fix bugs

Daniel Han2e9724f2796e
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index dfaf36a7138..a6596d4a66e 100644
--- a/unsloth/models/_utils.py
+++ b/unsloth/models/_utils.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-__version__ = "2025.6.2"
+__version__ = "2025.6.3"
__all__ = [
"SUPPORTS_BFLOAT16",
@@ -755,24 +755,10 @@ exec(BitsAndBytesConfig__init__, globals())
if torch.cuda.device_count() == 1:
from accelerate.utils.dataclasses import DistributedType
- def _prepare_backend(
- self, cpu = False, sagemaker_dp = False, backend: str = None,
- ) -> tuple[str, DistributedType]:
- return None, DistributedType.NO
- pass
+ def _prepare_backend(self, *args, **kwargs): return None, DistributedType.NO
import accelerate.state
accelerate.state.PartialState._prepare_backend = _prepare_backend
-
- import accelerate.accelerator
- prepare = inspect.getsource(accelerate.accelerator.Accelerator.prepare)
- prepare = prepare.split("\n")
- spaces = prepare[0].find("def")
- prepare = "\n".join(x[spaces:] for x in prepare)
- x = "for obj in args:"
- s = " "*spaces
- prepare = prepare.replace(x, f'self.state.distributed_type = DistributedType.NO\n{s}{x}', 1)
- exec(prepare, globals())
- accelerate.accelerator.Accelerator.prepare = prepare
+ accelerate.accelerator.Accelerator.distributed_type = lambda *args, **kwargs: DistributedType.NO
pass
import transformers.utils.quantization_config
diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py
index 3fa3fe71329..08d7cbf38b3 100644
--- a/unsloth/models/rl.py
+++ b/unsloth/models/rl.py
@@ -645,6 +645,18 @@ def patch_functions(RLTrainer, trainer_file, RLTrainer_name, all_imports, import
init = inspect.getsource(RLTrainer.__init__)
old_init = init
+ # Remove brackets in comments since it interferes ie (...)
+ comments = re.findall(r"\#[^\n]{1,}\n", init)
+ bracketed_comments = [x for x in comments if "(" in x or ")" in x]
+ # Replace with [...] instead
+ for bracketed_comment in bracketed_comments:
+ init = init.replace(
+ bracketed_comment,
+ bracketed_comment.replace("(", "[").replace(")", "]"),
+ )
+ pass
+
+
# Remove peft_config
init = init.replace("elif peft_config is None:", "elif False:")
init = init.replace("elif peft_config is not None:", "elif False:")