Skip to content

Add function for retrieving fallback operations.#7116

Merged
ysiraichi merged 5 commits intomasterfrom
ysiraichi/make-fallback-retrieval-easier
May 29, 2024
Merged

Add function for retrieving fallback operations.#7116
ysiraichi merged 5 commits intomasterfrom
ysiraichi/make-fallback-retrieval-easier

Conversation

@ysiraichi
Copy link
Copy Markdown
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

return torch_xla._XLAC._short_xla_metrics_report(counter_names, metric_names)


def executed_fallback_ops():
Copy link
Copy Markdown
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,

Comment thread test/test_metrics.py Outdated
# 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
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