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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Fix auto padding free logic to respect user passed False (#4128)
DoubleMathewa835b266ef6b
diff --git a/unsloth/models/rl.py b/unsloth/models/rl.pyindex eb5d4be1718..e4f34c908ec 100755--- a/unsloth/models/rl.py+++ b/unsloth/models/rl.py@@ -1037,6 +1037,7 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):"include_num_input_tokens_seen": False,"auto_find_batch_size": False, # Auto /2 batch size - too many people complained so removing"dataloader_pin_memory": True,+ "padding_free": None, # None = user didn't set it, allows auto-enable detection# Might fail so disable for now# "dataloader_persistent_workers" : True, # Keeps dataloader in RAM# "dataloader_prefetch_factor" : 2,diff --git a/unsloth/trainer.py b/unsloth/trainer.pyindex cb36b8639d2..65abe6801fc 100644--- a/unsloth/trainer.py+++ b/unsloth/trainer.py@@ -73,7 +73,7 @@ def _should_auto_padding_free(config) -> bool:or getattr(config, "packing", False)):return False- return not getattr(config, "padding_free", False)+ return getattr(config, "padding_free", None) is Nonedef _disable_sample_packing(config):@@ -392,6 +392,7 @@ def _patch_sft_trainer_auto_packing(trl_module):packing_active = Truelogger.info("Unsloth: Sample packing enabled for SFTTrainer instance.")+ # Resolve padding_free: None (default) = auto-enable unless env-disabled or packingauto_padding_free_active = Falsepadding_free_requested = getattr(config_arg, "padding_free", None) is Trueif not blocked: