Skip to content

Conversation

@anijain2305
Copy link
Contributor

@anijain2305 anijain2305 commented Oct 11, 2024

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 11, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/137808

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure

As of commit 4dd2319 with merge base 3d0aa6f (image):

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

anijain2305 added a commit that referenced this pull request Oct 11, 2024
Comment on lines +1439 to +1449
if isinstance(func, torch._ops.HigherOrderOperator):
# For invoke_subgraph op, if the identifier is set then its safe to
# cache the fake tensor result.
from torch._higher_order_ops.utils import (
registered_hop_fake_tensor_cache_key_validation_fns,
)

if func in registered_hop_fake_tensor_cache_key_validation_fns:
return registered_hop_fake_tensor_cache_key_validation_fns[func](
self, *args, **kwargs
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I kind of forgot the discussion we had on Thursday. I remember we reasoned out that everything was safe? If that's the case, can we include the reasoning here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, we're going the conservative approach

Comment on lines +1409 to +1410
if isinstance(func, torch._ops.HigherOrderOperator):
# For invoke_subgraph, ignore the subgraph arg. We rely on
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to do this here ? cant the op impl / op caching handle this?

Copy link
Contributor

Choose a reason for hiding this comment

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

There's a subgraph here. We're trying to avoid needing to hash the subgraph everytime it is seen. So that's what the identifier is for.

Taking suggestions for how to make this better

Copy link
Contributor

Choose a reason for hiding this comment

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

If the subgraph is repeated, can we have FakeTensorCache cache the hashing of it ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I like that better, what say you @anijain2305 ?

As a part of this, you could define what it means for a "subgraph to be cacheable" to be what the current "invoke subgraph fake tensor cache validator function" is and get rid of the "fake tensor cache validator registration" thing.

Copy link
Contributor

@zou3519 zou3519 left a comment

Choose a reason for hiding this comment

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

I'm fine with the approach. I can imagine that we might want to dig it out and replace it with something better later (it's a bit conservative). Just want to poke on two points a bit (if we can remove the .tags from the HOP and I'm trying to figure out what the crossref thing is)

Comment on lines +36 to +37
self.tags = ()
self.is_view = False
Copy link
Contributor

Choose a reason for hiding this comment

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

@anijain2305 do we still need these?

Comment on lines +1440 to +1441
# For invoke_subgraph op, if the identifier is set then its safe to
# cache the fake tensor result.
Copy link
Contributor

Choose a reason for hiding this comment

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

this comment is not correct anymore right? It's only safe to cache the result if the validation fn returns True.

Comment on lines +1439 to +1449
if isinstance(func, torch._ops.HigherOrderOperator):
# For invoke_subgraph op, if the identifier is set then its safe to
# cache the fake tensor result.
from torch._higher_order_ops.utils import (
registered_hop_fake_tensor_cache_key_validation_fns,
)

if func in registered_hop_fake_tensor_cache_key_validation_fns:
return registered_hop_fake_tensor_cache_key_validation_fns[func](
self, *args, **kwargs
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I see, we're going the conservative approach

anijain2305 added a commit that referenced this pull request Oct 28, 2024
ghstack-source-id: 3b364d5
Pull Request resolved: #137808

[does not work] General hop fake tensor fn registration

ghstack-source-id: 3b364d5
Pull Request resolved: #138096
@github-actions
Copy link
Contributor

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
If you are unable to remove the Stale label please contact a maintainer in order to do so.
If you want the bot to never mark this PR stale again, add the no-stale label.
Stale pull requests will automatically be closed after 30 days of inactivity.

@github-actions github-actions bot added the Stale label Dec 28, 2024
@github-actions github-actions bot closed this Jan 27, 2025
@github-actions github-actions bot deleted the gh/anijain2305/541/head branch February 28, 2025 02:08
@anijain2305 anijain2305 restored the gh/anijain2305/541/head branch March 11, 2025 04:49
anijain2305 added a commit that referenced this pull request Mar 20, 2025
anijain2305 added a commit that referenced this pull request Mar 20, 2025
anijain2305 added a commit that referenced this pull request Mar 20, 2025
anijain2305 added a commit that referenced this pull request Mar 20, 2025
anijain2305 added a commit that referenced this pull request Mar 25, 2025
anijain2305 added a commit that referenced this pull request Mar 25, 2025
anijain2305 added a commit that referenced this pull request Mar 26, 2025
anijain2305 added a commit that referenced this pull request Mar 26, 2025
anijain2305 added a commit that referenced this pull request Mar 26, 2025
anijain2305 added a commit that referenced this pull request Mar 26, 2025
@github-actions github-actions bot deleted the gh/anijain2305/541/head branch April 11, 2025 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants