feat: compatibility with transformers 5#685
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 72de2fe. Configure here.
| if transformers_version < "5.0.0": | ||
| from transformers.pipelines.text2text_generation import Text2TextGenerationPipeline as TextGenerationPipeline | ||
| else: | ||
| from transformers.pipelines.text_generation import TextGenerationPipeline |
There was a problem hiding this comment.
Legacy causal pipeline check broken
High Severity
For transformers versions below 5, TextGenerationPipeline is imported from text2text_generation and aliased over the real causal TextGenerationPipeline. is_transformers_pipeline_with_causal_lm and is_transformers_pipeline_with_moe_lm then never match standard text-generation pipelines, so legacy installs misclassify those models.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 72de2fe. Configure here.
There was a problem hiding this comment.
This looks important indeed
begumcig
left a comment
There was a problem hiding this comment.
Thanks a lot for tackling this Sara! I really like theis_availablecheck, i think we should introduce some optional dependencies and conflicts to make installing pruna easier, but looks super good already!!!!
gsprochette
left a comment
There was a problem hiding this comment.
Already super clean and efficient code, great job this will get merged in no time 🫶 I think the unavailability error could be slightly more explicit, but the only big thing is we need to discuss the idea of having a old_transformers or legacy_transformers extra and what that would bring. At the moment I'm not super sure what is the justification for this is and where it is used 🙃
| if transformers_version < "5.0.0": | ||
| from transformers.pipelines.text2text_generation import Text2TextGenerationPipeline as TextGenerationPipeline | ||
| else: | ||
| from transformers.pipelines.text_generation import TextGenerationPipeline |
There was a problem hiding this comment.
This looks important indeed
begumcig
left a comment
There was a problem hiding this comment.
Looks amazing thank you so much Sara!!! I added one comment about the uv indexing strategy but looks super good!!! Let's get this to merging
gsprochette
left a comment
There was a problem hiding this comment.
Looks great ! One minor thing about a file that's only formatted, and the very important index thing :)
74940ce to
11dbba7
Compare
ec2b504 to
783358e
Compare
gsprochette
left a comment
There was a problem hiding this comment.
Let's remove full and let's gooooooooo
| full = [ | ||
| "pruna[stable-fast]", | ||
| ] | ||
| full = [] |
There was a problem hiding this comment.
full doesn't exist let's remove it
c691a7f to
8b5c713
Compare


Description
This PR includes updates to make pruna compatible with Transformers 5:
unpin transformers version (not sure if you had a minimum previously) and pin in extras
update hf command
add the is_available_algorithm to make the unavailable under certain circumstances (e.g. transformers 5)
small updates
Other PRs: fix: update moe tiny model for testing (transformers 5) #684 and fix: patch torchmetrics (transformers 5) #683
Pinning to 5.10.2 fixes the errors regarding pipelines on the HF side (pipelines do not have modelcard huggingface/transformers#44621). But I don't know the preferred approach.
Related Issue
Fixes #(issue number)
Type of Change
Testing
uv run pytest -m "cpu and not slow")For full setup and testing instructions, see the Contributing Guide.
Checklist
Thanks for contributing to Pruna! We're excited to review your work.
New to contributing? Check out our Contributing Guide for everything you need to get started.