unsloth checkpointing fix for latest transformers==4.52.x #2674
+11
−1
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.
transformers==4.52.x introduced a GradientCheckpointingLayer and refactored the checkpointing logic. This adjusts FastLanguageModel to bypass our custom checkpoint logic when decoder layers are an instance of GradientCheckpointingLayer.
I have 3 notebooks to compare.
transformers==4.51.3
https://colab.research.google.com/drive/19tEe55Z-b3oz61S6R5diBoHAxHZVnOlp?usp=sharing
transformers==4.52.4
https://colab.research.google.com/drive/1IQZGdYYoF73NqG3WtO_ar7rfunllWGSr?usp=sharing
transformers==4.52.4 + checkpointing fix
https://colab.research.google.com/drive/1nfA9Sc20lBAbTzmo2S2VgAW-P6ZkOkMq?usp=sharing
as you can see in the second notebook the loss remains the same but timing is longer. In the final notebook loss and speed matches original transformers.