Skip to content

feat: compatibility with transformers 5#685

Open
sdiazlor wants to merge 22 commits into
mainfrom
feat/transformers-500
Open

feat: compatibility with transformers 5#685
sdiazlor wants to merge 22 commits into
mainfrom
feat/transformers-500

Conversation

@sdiazlor

@sdiazlor sdiazlor commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR includes updates to make pruna compatible with Transformers 5:

FAILED tests/algorithms/test_algorithms.py::test_full_integration[TestIFW_whisper_tiny_random-cuda] - AttributeError: 'AutomaticSpeechRecognitionPipeline' object has no attribute 'modelcard'

Related Issue

Fixes #(issue number)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactor (no functional change)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Testing

  • I added or updated tests covering my changes
  • Existing tests pass locally (uv run pytest -m "cpu and not slow")

For full setup and testing instructions, see the Contributing Guide.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code, especially for agent-assisted changes
  • I updated the documentation where necessary

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.

Note:

  • Draft PRs or PRs without a clear and detailed overview may be delayed.
  • Please mark your PR as Ready for Review and ensure the sections above are filled out.
  • Contributions that are entirely AI-generated without meaningful human review are discouraged.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread src/pruna/engine/model_checks.py Outdated
if transformers_version < "5.0.0":
from transformers.pipelines.text2text_generation import Text2TextGenerationPipeline as TextGenerationPipeline
else:
from transformers.pipelines.text_generation import TextGenerationPipeline

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 72de2fe. Configure here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks important indeed

@sdiazlor sdiazlor requested review from begumcig and gsprochette June 15, 2026 13:49

@begumcig begumcig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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!!!!

Comment thread pyproject.toml
Comment thread src/pruna/smash.py Outdated
Comment thread src/pruna/algorithms/global_utils/recovery/perp_recoverer.py Outdated
Comment thread src/pruna/algorithms/token_merging.py Outdated
Comment thread src/pruna/engine/model_checks.py Outdated
Comment thread src/pruna/algorithms/token_merging.py Outdated
Comment thread pyproject.toml

@gsprochette gsprochette left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 🙃

Comment thread src/pruna/config/pre_smash_routines.py Outdated
Comment thread src/pruna/algorithms/base/pruna_base.py Outdated
Comment thread src/pruna/algorithms/token_merging.py Outdated
Comment thread src/pruna/engine/model_checks.py Outdated
if transformers_version < "5.0.0":
from transformers.pipelines.text2text_generation import Text2TextGenerationPipeline as TextGenerationPipeline
else:
from transformers.pipelines.text_generation import TextGenerationPipeline

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks important indeed

Comment thread pyproject.toml
Comment thread pyproject.toml

@begumcig begumcig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 gsprochette left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great ! One minor thing about a file that's only formatted, and the very important index thing :)

Comment thread pyproject.toml Outdated
Comment thread tests/config/test_pre_smash_routines.py Outdated
@sdiazlor sdiazlor force-pushed the feat/transformers-500 branch from 74940ce to 11dbba7 Compare June 17, 2026 15:47
@begumcig begumcig force-pushed the feat/transformers-500 branch 2 times, most recently from ec2b504 to 783358e Compare June 18, 2026 14:56

@gsprochette gsprochette left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's remove full and let's gooooooooo

Comment thread pyproject.toml Outdated
full = [
"pruna[stable-fast]",
]
full = []

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

full doesn't exist let's remove it

@begumcig begumcig force-pushed the feat/transformers-500 branch from c691a7f to 8b5c713 Compare June 18, 2026 16:52
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