The `use_reentrant=True` override for PEFT + ZeRO-3
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.
thanks, yes, please gate it on the deepspeed version