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 function for retrieving fallback operations. #7116

Merged
merged 5 commits into from
May 29, 2024

Conversation

ysiraichi
Copy link
Collaborator

This PR introduces GetFallbackOperations function, which sweeps through the fallback counter map _cpu_fallback_counters and returns the name of the functions whose counter is not zero, i.e. name of the fallbacks that were run.

There was a bug within the dynamo bridge that only classified as fallback operation those that came from the aten namespace. Other fallback operations, such as those that came from torchvision:: were being passed on to the next steps, even though they were fallback operations.

This bug is one of the reasons of the issue #5967.

cc @miladm @JackCaoG

@@ -79,3 +79,8 @@ def short_metrics_report(counter_names: list = None, metric_names: list = None):
'TransferToDeviceTime', 'TransferFromDeviceTime'
]
return torch_xla._XLAC._short_xla_metrics_report(counter_names, metric_names)


def executed_fallback_ops():
Copy link
Collaborator

Choose a reason for hiding this comment

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

cc @alanwaketan we can start using this new api which is better than do a string assertIn from the metrics_report,

# Run torchvision operations as fallback.
import torchvision
scores = torch.rand(N).to(xm.xla_device())
# NMS doesn't have a PyTorch/XLA implementation without dynamic shapes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe do an assert that dynamic shape is not enabled?

Copy link
Collaborator

@alanwaketan alanwaketan left a comment

Choose a reason for hiding this comment

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

Cool. LGTM.

Copy link
Collaborator

@alanwaketan alanwaketan left a comment

Choose a reason for hiding this comment

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

Cool. LGTM.

@ysiraichi ysiraichi force-pushed the ysiraichi/make-fallback-retrieval-easier branch from a70a8f2 to 5f985b3 Compare May 28, 2024 23:40
@ysiraichi ysiraichi merged commit 6d27123 into master May 29, 2024
19 checks passed
yitongh pushed a commit to AlibabaPAI/xla that referenced this pull request Oct 11, 2024
yitongh pushed a commit to AlibabaPAI/xla that referenced this pull request Dec 11, 2024
yitongh pushed a commit to AlibabaPAI/xla that referenced this pull request Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants