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.

Studio: fix misleading "increase max_seq_length" message for train-on-completions (#6664)

Daniel Hane1698e05c7df
diff --git a/studio/backend/core/training/trainer.py b/studio/backend/core/training/trainer.py
index a13a75a72e4..6f55daee391 100644
--- a/studio/backend/core/training/trainer.py
+++ b/studio/backend/core/training/trainer.py
@@ -3543,9 +3543,12 @@ class UnslothTrainer:
# ── Safety net: check if all samples were filtered out ──
# train_on_responses_only masks non-response tokens with -100;
- # if max_seq_length is too short the response is truncated away,
- # every sample becomes all -100, and Unsloth drops them, leaving
- # 0 usable samples. Skip this len()-based check for streaming.
+ # a row becomes all -100 (and Unsloth drops it) when the response
+ # template is not found in the formatted text. That is usually a
+ # dataset/template mismatch (already-formatted data, or 'Train on
+ # completions' applied to data that doesn't match the model's chat
+ # template), and only sometimes max_seq_length truncating the
+ # response away. Skip this len()-based check for streaming.
if detect_streaming_dataset(self.trainer.train_dataset):
logger.info("Skipping post-filter length check for streaming dataset\n")
else:
@@ -3560,13 +3563,18 @@ class UnslothTrainer:
if filtered_len == 0 or drop_pct > 30:
max_seq = training_args.get("max_seq_length", 2048)
error_msg = (
- f"{dropped}/{original_len} samples ({drop_pct}%) "
- f"were dropped after applying 'train on responses "
- f"only' — only {filtered_len} remain. This usually "
- f"means max_seq_length ({max_seq}) is too short "
- f"and the response portion is being truncated "
- f"away. Try increasing max_seq_length (e.g. 8192) "
- f"or disabling 'Train on completions'."
+ f"{dropped}/{original_len} samples ({drop_pct}%) were "
+ f"dropped after applying 'Train on completions': after "
+ f"masking, those rows had no trainable response tokens "
+ f"left. The usual cause is that this model's response "
+ f"template was not found in the formatted samples, so "
+ f"every token was masked out. That typically means the "
+ f"dataset is already formatted, or its structure does "
+ f"not match the model's chat template, so 'Train on "
+ f"completions' should be turned off for this dataset. "
+ f"Less commonly, a max_seq_length ({max_seq}) shorter "
+ f"than the prompt can truncate the response away; only "
+ f"raise it if your samples are actually longer than that."
)
logger.error(error_msg)
self._update_progress(error = error_msg, is_training = False)