feat: Add activation checkpointing support for single GPU training #971
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces activation checkpointing for single-GPU fine-tuning, directly addressing issue #835. This feature allows developers to train models on hardware with less VRAM or to use larger batch sizes, improving throughput and hardware utilization.
Closes #835
Motivation
Currently, activation checkpointing in the repository is coupled with FSDP. By enabling it for standard single-GPU workflows, we unlock several benefits:
Implementation Details
gradient_checkpointing_enable()
API for maximum compatibility and robustness.use_reentrant=False
, which is the more memory-efficient checkpointing implementation.memory_utils.py
for easy monitoring of CPU/GPU memory consumption during training runs.Summary of Changes
--enable_activation_checkpointing
flag to the training arguments.Testing
The feature was tested locally and validated against the behavior described in the issue.
Local Testing (macOS, CPU):
Expected Results on GPU (based on issue #835):
Usage Example
To enable activation checkpointing, simply add the
--enable_activation_checkpointing
flag to your fine-tuning command.