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 Han1ff75a7dc783
diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py
index 4c6d73ee842..752a9d9b2f4 100644
--- a/unsloth/models/rl.py
+++ b/unsloth/models/rl.py
@@ -97,7 +97,9 @@ def NotebookProgressCallback_on_log(Trainer_metrics):
if args.eval_strategy == IntervalStrategy.NO and "loss" in logs:
values = {"Training Loss": logs["loss"]}
for metric in Trainer_metrics:
- values[metric.replace("/", " / ")] = logs[metric]
+ # Sometimes metric is not inside logs
+ try: values[metric.replace("/", " / ")] = logs[metric]
+ except: pass
pass
# First column is necessarily Step since we're not in epoch eval strategy
values["Step"] = state.global_step
@@ -201,21 +203,6 @@ def get_trl_metrics():
left_prefix = 'prefix = "eval_" if train_eval == "eval" else ""' in file
if left_prefix: metrics += metrics_f
- # Remove optional items
- # if ...: metrics[...] =
- metrics_optional = re.findall(
- r"if[^\n]{1,}\n[\s]{4,}"\
- r"(?:metrics|stats)"\
- r"\["\
- r"(?:f[\"\']\{[^\}]{1,}\})?"\
- r"([^\"\']{1,})[\"\']"\
- r"\]",
- file,
- flags = re.MULTILINE,
- )
- metrics_optional = set(metrics_optional)
- metrics = [x for x in metrics if x not in metrics_optional]
-
# Remove all eval_ things
metrics = [x for x in metrics if not x.startswith("eval_")]