-
Notifications
You must be signed in to change notification settings - Fork 29.5k
fix: prevent input side-effects in processor text args #36866
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
Conversation
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. When it is ready for review, please click the |
For me it seems the problem is in how qwen2-vl is written. Other VLMs do not override the |
@zucchini-nlp - thanks for the comment! 😃 Just to be clear: I added the for sample in text:
sample = sample.replace(...) This isn't just Qwen-based processors. One example: Pixtral. So, if I understand correctly, you're saying it'd be preferrable to change all these processors to have something like: expanded_samples = []
for sample in text:
expanded_sample = sample.replace(...)
expanded_samples.append(expanded_sample) Correct? I must say: I don't find that cleaner 🤔 and if it's for the sake of consistency then I'd suggest adding the |
ha! 🤔 don't think that's true. My bad. Still, it seems a bit less readable to me. Again, happy to go either way if that's your suggestion. |
@molbap any thoughts here? This is a pretty tricky bug when encountered downstream that is hurting the larger ecosystem |
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.
Thanks for fixing! Agree, we should avoid modifying original inputs.
P.S. Let's merge main and resolve conflicts, to be able to merge the PR
Sorry, qwen has been fixed already as part of a different PR. We might not need this fix anymore, other VLMs don't do in-place modification |
@qubvel - apologies for the delay. I've just merged main. |
Missed out on this - I think we should not mutate inputs indeed. |
I think it was already fixed as part of another PR already for qwen models, and other models don't mutate input |
@zucchini-nlp - could you link the PR? I can't find it I'm not sure about the other models. I don't see why they wouldn't. I tried to include all of the processors that had in-place mutations. |
@nph4rd it was #37342 because some tests would fail otherwise (I think that test was modified right before merging though). And since the test passed for other models, I assume no other processor has in-place modifications. We usually save expanded inputs in a new list, and qwen was an more of an exception 😄 If you see other models doing in-place modification, feel free to rebase and update the PR. Will be very much welcome. And adding a test would be nice so we catch these processors before merging |
Ah, I see, @zucchini-nlp. Looks good! Thanks for the heads up. In that case, @molbap, I'll close this PR and the corresponding issue 👍 |
What does this PR do?
Fixes input side-effects in multiple processor classes when the
text
input is a list.Fixes #36865
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@ArthurZucker @qubvel