Skip to content
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

Add singularity function for maximum and minimum #1642

Merged
merged 4 commits into from
Jan 14, 2025
Merged

Conversation

beverlylytle
Copy link
Collaborator

@beverlylytle beverlylytle commented Jan 13, 2025

Flakiness has recently been observed in maximum. The provided logs do not give a clear indication of the cause of the failure. However, the test for maximum can be induced to fail when one entry of one tensor is very near the corresponding entry of the other tensor. The rarity of such an event for these randomly generated tensors is consistent with the rarity of failure for these tests. This PR introduces a singularity function for these operators to avoid such a situation.

@beverlylytle beverlylytle changed the title WIP Add singularity function for maximum and minimum Jan 14, 2025
@beverlylytle beverlylytle marked this pull request as ready for review January 14, 2025 08:41
Copy link
Collaborator

@t-vi t-vi left a comment

Choose a reason for hiding this comment

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

Thank you @beverlylytle

@t-vi t-vi merged commit c92d5f0 into main Jan 14, 2025
48 checks passed
@t-vi t-vi deleted the maximum_singularities branch January 14, 2025 09:52

def min_max_singularity_fn_producer(sample):
a, b = sample.args
if a.shape == b.shape or b.shape == ():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you add a comment explaining what's happening with minimum and maximum and singularities?

@@ -208,10 +198,24 @@ def _to(x):
args, kwargs = tree_map(_to, self.args), tree_map(_to, self.kwargs)
return SampleInput(*args, **kwargs)

def remove_singularities(self, singularity_fn, eps):
def remove_singularities(self, op, eps):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you add a comment about the current singularity specifying patterns and how they work? There have been a few changes.

One thing that'd be neat in the future is if a SampleInput could be bound to a signature, like

ba = si.bind_for(ltorch.maximum)

Where ba could be a BoundArguments object (https://docs.python.org/3/library/inspect.html#inspect.BoundArguments), so that the args and kwargs in the sample input could be accessed in some canonical fashion. That would make it easier to inspect and manipulate the sample inputs.

We might also want to replace singularity_fn_producer with something like singularity_handler that just takes a SampleInput and maybe returns a different or modified SampleInput, with complete control over its analysis. That might make the maximum and minimum stuff more readable.

What are your thoughts, @beverlylytle?

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