-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
fix: broadcasting issue in compositional set_item #28181
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.
Any ideas on if it's possibe with hypothesis to add a very specifc example to a test, like my example. I imagine it being a lot more complicated to get examples like this to appear in a property based way, but i don't think property based testing is really that important here and just testing one specific example would be sufficient. Is this possible @vedpatwardhan @Ishticode ?
One thing we can do is use hypothesis.example
which can be used alongside @given
in our tests. Could you please check if this works with the current tests as well? Also, what do you think should be the criteria to decide when to add a strategy and when to add an explicit example for a particular example? I'll add that as an explanation to the docs as well.
As for the changes to set_item
, I'll leave those with @Ishticode to review as he's already working on some other issues with get_item
and set_item
. Thanks @mattbarrett98 😄
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.
looks good
Thanks for the suggestion @vedpatwardhan, i've added a As for criteria i'm not too sure. I think in this scenario it's just far simpler to add an example, and also I think accomplishes everything a full-blown strategy approach would. Since the problem in question here was some broadcasting issue, which occurs in a fairly specific situation of the shapes being a certain way, with the dtypes and values of the arrays not being relevant at all here. This way seems far more efficient to me, as trying to change the strategies to include examples like this would probably expand the search space more than necessary for this specific example. Whereas with this approach the exact problematic example will be tested each time, for a more efficient, deterministic CI. Let me know if i'm good to merge @vedpatwardhan 😁 |
Yep sounds good! I'll create a task for adding a new decorator that uses |
Sounds good 😁 I think you linked the same failure twice, but i checked this one and it is indeed unrelated and fails with the same without my change (although it does look very related). Also went through the some other failures that look set_item related and none were due to this change. Think we're good to merge @vedpatwardhan ? |
Yep sure, let's get the PR merged, thanks @mattbarrett98 😄 |
This fixes the following for tf and jax (already works for torch/numpy):
I suspect the expanding dims logic maybe isn't necessary before the broadcasting but not sure.
Any ideas on if it's possibe with hypothesis to add a very specifc example to a test, like my example. I imagine it being a lot more complicated to get examples like this to appear in a property based way, but i don't think property based testing is really that important here and just testing one specific example would be sufficient. Is this possible @vedpatwardhan @Ishticode ?