Skip to content

Conversation

@minettekaum
Copy link
Contributor

Description

I added padding_pruning algorithm and flux_tiny_random_with_tokenizer to fixtures to be able to test padded_pruning

  • You can find padding_pruning algorithm in src/pruna/algorithms/padding_pruning.py
  • You can find tests for padding_pruning algorithm in tests/algorithms/testers/padding_pruning.py
  • You can find flux_tiny_random_with_tokenizer added in tests/fixtures.py so that padding_pruning algorithm can be tested.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Yes, by tests for padding_pruning.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Comment @cursor review or bugbot run to trigger another review on this PR


prompts = self._extract_prompts(args, kwargs)
max_num_tokens = max(len(self.tokenizer.encode(p)) for p in prompts)

Copy link

Choose a reason for hiding this comment

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

Bug: Fails when prompts are not strings

wrapped_call computes max_num_tokens via max(... for p in prompts), but _extract_prompts can return an empty list (e.g., callers pass prompt_embeds/no prompt strings). This triggers a runtime ValueError and breaks inference for valid diffusers call patterns.

Fix in Cursor Fix in Web

sequence_length *= 2
if sequence_length >= max_sequence_length:
sequence_length = max_sequence_length
kwargs["max_sequence_length"] = sequence_length
Copy link

Choose a reason for hiding this comment

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

Bug: Assumes max_sequence_length has a default

default_max_sequence_length is read from inspect.signature(...).parameters["max_sequence_length"].default. If that default is inspect._empty (or the user passes max_sequence_length=None), comparisons like sequence_length >= max_sequence_length can raise TypeError, causing runtime failures on pipelines with a required max_sequence_length.

Fix in Cursor Fix in Web

"""Disable prompt pruning by unwrapping the pipe."""
if self.pipe_call:
self.pipe.__call__ = self.pipe_call

Copy link

Choose a reason for hiding this comment

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

Bug: Helper disable may crash before enable

disable accesses self.pipe_call without initializing it in __init__. If disable is called before enable/wrap_pipe runs (or after partial initialization failures), this can raise AttributeError and prevent cleanup/saving flows that call .disable() on helpers.

Fix in Cursor Fix in Web

@minettekaum minettekaum changed the title feat/pruner-algroithm: added padding_pruning algorithm feat: add pruner-algroithm Dec 19, 2025
@minettekaum minettekaum changed the title feat: add pruner-algroithm feat: add pruner algroithm Dec 19, 2025
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.

2 participants