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.py

Daniel Hancc6bb7d1db12
diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py
index 18b2415f2d3..02bc10c6feb 100644
--- a/unsloth/models/rl.py
+++ b/unsloth/models/rl.py
@@ -156,8 +156,10 @@ def NotebookTrainingTracker_write_line(Trainer_metrics):
pass
-def _PatchRLStatistics(metrics):
+def _PatchRLStatistics(metrics, algorithm):
if HAS_NOTEBOOK:
+ if len(metrics) == 0:
+ raise RuntimeError(f"Unsloth: RL statistics for {algorithm} failed with no metrics seen?")
from transformers.trainer import is_in_notebook
if is_in_notebook():
# Patch DPO notebook printing
@@ -210,7 +212,10 @@ def PatchRLStatistics(algorithm = "GRPO"):
algorithm = algorithm.upper()
all_metrics = get_trl_metrics()
if algorithm not in all_metrics:
- print(f"Unsloth for {algorithm.upper()} is not yet implemented! Just ignore this function.")
+ print(
+ f"Unsloth for {algorithm.upper()} is not yet implemented! Just ignore this function.\n"\
+ f"We support: `{list(all_metrics.keys())}`"
+ )
pass
- _PatchRLStatistics(all_metrics[algorithm])
+ _PatchRLStatistics(all_metrics[algorithm], algorithm)
pass