From a28991ee08f0c22c3ba0918fec7653d07787a740 Mon Sep 17 00:00:00 2001 From: Kunwar Satyam Singh Date: Wed, 29 Jul 2026 14:22:44 +0530 Subject: [PATCH] fix: pin padding_free=False to keep max_length enforced (trl 1.6+) Newer Unsloth versions auto-enable SFTConfig's padding_free when it's left unset, which conflicts with an explicit max_length + packing=False and raises a ValueError at SFTTrainer init. Verified end-to-end on a GTX 1650 (4GB VRAM): 60 steps complete cleanly, peak reserved memory 1.543 GB (42% of total), train_loss 1.662 -> 1.264. --- examples/train_4gb_vram.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/train_4gb_vram.py b/examples/train_4gb_vram.py index 61a2c446da..35307f87cf 100644 --- a/examples/train_4gb_vram.py +++ b/examples/train_4gb_vram.py @@ -94,6 +94,8 @@ def main(): max_length = max_seq_length, dataset_num_proc = 2, packing = False, # True can spike VRAM on variable-length samples + padding_free = False, # Unsloth auto-enables this when unset, which conflicts + # with an explicit max_length + packing=False (trl 1.6+) ) # ── 5. Initialize trainer ─────────────────────────────────────────────────