-
Notifications
You must be signed in to change notification settings - Fork 75
feat: add pruner algroithm #470
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| sequence_length *= 2 | ||
| if sequence_length >= max_sequence_length: | ||
| sequence_length = max_sequence_length | ||
| kwargs["max_sequence_length"] = sequence_length |
There was a problem hiding this comment.
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.
| """Disable prompt pruning by unwrapping the pipe.""" | ||
| if self.pipe_call: | ||
| self.pipe.__call__ = self.pipe_call | ||
|
|
There was a problem hiding this comment.
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.
Description
I added
padding_pruningalgorithm andflux_tiny_random_with_tokenizerto fixtures to be able to testpadded_pruningpadding_pruningalgorithm insrc/pruna/algorithms/padding_pruning.pypadding_pruningalgorithm intests/algorithms/testers/padding_pruning.pyflux_tiny_random_with_tokenizeradded intests/fixtures.pyso thatpadding_pruningalgorithm can be tested.Type of Change
How Has This Been Tested?
Yes, by tests for
padding_pruning.Checklist