trl icon indicating copy to clipboard operation
trl copied to clipboard

The `use_reentrant=True` override for PEFT + ZeRO-3

Open cm8908 opened this issue 1 month ago • 1 comments

I hit an OOM when running SFT on Qwen/Qwen3.8-Flash-Next with LoRA, ZeRO-3, and gradient checkpointing. I explicitly set use_reentrant=False, It turns out TRL overrides this setting and forces use_reentrant=True for PEFT + ZeRO-3 settings. However, even though I removed that override, the same run worked with use_reentrant=False on DeepSpeed >= 0.19.5, with no CheckpointError.

The OOM appears to be related to DeepSpeed#8481, where parameters gathered again during checkpoint recomputation aren't released.

Looking at #4951 and #6356, the guard was intended as a workaround until DeepSpeed#8130 was released. That PR was superseded by DeepSpeed#8148, which shipped in 0.19.3, but the guard still applies to all versions.

Could we limit it to DeepSpeed < 0.19.3, or allow an explicit use_reentrant=False to override it? Happy to send a PR.

cm8908 avatar Oct 23 '26 03:10 cm8908

thanks, yes, please gate it on the deepspeed version

qgallouedec avatar Nov 04 '26 23:11 qgallouedec