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

[sym_shapes][perf] Optimize bound_sympy avoiding sympy equals #124211

Closed

Conversation

IvanKobzarev
Copy link
Contributor

@IvanKobzarev IvanKobzarev commented Apr 16, 2024

Copy link

pytorch-bot bot commented Apr 16, 2024

🔗 Helpful Links

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

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

❌ 28 New Failures, 5 Unrelated Failures

As of commit 1ab00e5 with merge base 42e22bb (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

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

@pytorch-bot pytorch-bot bot added the module: cpu CPU specific problem (e.g., perf, algorithm) label Apr 16, 2024
IvanKobzarev added a commit that referenced this pull request Apr 16, 2024
ghstack-source-id: 149f11b60ca49c364bd3ca120e32cd30921efcc1
Pull Request resolved: #124211
for r in ranges.keys():
if r.name == name:
found = True
break
Copy link
Contributor

Choose a reason for hiding this comment

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

It's so nuts that this is faster. cc @lezcano

Copy link
Collaborator

Choose a reason for hiding this comment

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

lol cc @asmeurer @isuruf

Also, if not any(...): add

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a possibility to have different symbols with different properties (like is_Integer) to have the same name?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, a symbol is identified by its name in dynamo/inductor.

Copy link
Collaborator

Choose a reason for hiding this comment

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

As Isuru noted, Symbols are compared by name + assumptions. That comparison should be fast, but I suppose it's possible there is some performance issue somewhere. It would be useful to have more precise timing information here.

@ezyang
Copy link
Contributor

ezyang commented Apr 16, 2024

Oh, this string thing! Crazy stuff! Will need to be debugged, sounds like a preexisting problem

@IvanKobzarev
Copy link
Contributor Author

@IvanKobzarev has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@ezyang
Copy link
Contributor

ezyang commented Apr 17, 2024

@IvanKobzarev I did a simple microbenchmark to try to reproduce this problem but I didn't see as big an effect:

import sympy
import itertools

N = 50000

x = set(sympy.Symbol(f"s{i}", integer=True) for i in range(N*2))
y = set(sympy.Symbol(f"s{i}", integer=True) for i in range(N))

print(len(x - y))

Is it possible to get printouts of the inputs into this expression on the slow run?

@IvanKobzarev
Copy link
Contributor Author

Ok. Will try to repro it on the original run with printouts.

@ezyang
Copy link
Contributor

ezyang commented Apr 18, 2024

This isn't blocking for this PR, but it's not obvious to me that we should be going out and rewriting all of our sympy symbol sets

Comment on lines +880 to +883
ranges_names = [r.name for r in ranges.keys()]
for fs in expr.free_symbols:
if fs.name not in ranges_names:
unbounded_vars.add(fs)
Copy link
Collaborator

@lezcano lezcano Apr 18, 2024

Choose a reason for hiding this comment

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

Make range_names a set and add range_names - expr.free_symbols,

Copy link

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 Jun 22, 2024
@github-actions github-actions bot closed this Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: cpu CPU specific problem (e.g., perf, algorithm) Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants