Skip to content

Use Gradient Checkpointing Layer in Jamba & Blip Related Models #38310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 23, 2025

Conversation

alex-jw-brooks
Copy link
Contributor

Updates a few models to use the new GradientCheckpointingLayer. The models changed in this PR are leveraged by IBM model architectures (granite vision / bamba) or share code, either directly or through modular. Happy to submit a follow-up with other models too if that would be helpful!

Updated models:

  • jamba
  • bamba
  • blip
  • blip2
  • instructblip
  • instructblipvideo

@ArthurZucker

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Happy to merge, unless you have time to move the warning to the layer itself! might be a bit too big

Comment on lines +882 to +884
if getattr(self.config, "gradient_checkpointing", False) and self.training and use_cache:
logger.warning(
"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I think the gradient checkpoint layer does should get use_cache as input and fallback to not do GC ! 🤗

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for merging this @ArthurZucker! I agree, I'll open a follow-up PR to take use_cache in the gcp layer and move the warning into it 😄

@ArthurZucker ArthurZucker merged commit e64ed03 into huggingface:main May 23, 2025
12 of 14 checks passed
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants