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.

Update rl_replacements.py

Daniel Han20acdcef3178
diff --git a/unsloth/models/rl_replacements.py b/unsloth/models/rl_replacements.py
index 2ea12f69c42..67027f0b4d1 100644
--- a/unsloth/models/rl_replacements.py
+++ b/unsloth/models/rl_replacements.py
@@ -125,12 +125,12 @@ def grpo_trainer__prepare_inputs(function_name, function):
if "with torch.inference_mode()" not in function: return function
function = function.replace(
- "with torch.inference_mode()",
+ "with torch.inference_mode():",
"with torch.inference_mode(), "\
"torch.amp.autocast(device_type = 'cuda', "\
"dtype = torch.float16 if os.environ.get('ACCELERATE_MIXED_PRECISION', 'fp16') == 'fp16' else torch.bfloat16) "\
- "if not torch.is_autocast_enabled('cuda') else nullcontext()",
+ "if not torch.is_autocast_enabled('cuda') else nullcontext():",
)
return function
pass