Skip to content

Conversation

jansel
Copy link
Contributor

@jansel jansel commented Mar 1, 2025

Stack from ghstack (oldest at bottom):

Microbenchmarking fx.symbolic_trace(lambda x: functools.reduce(operator.add, [x, *range(100000)])), before:

30603618 function calls (29403419 primitive calls) in 13.744 seconds

after:

25203549 function calls (24403352 primitive calls) in 12.090 seconds

cc @ezyang @SherlockNoMad @EikanWang @jgong5 @wenzhe-nrv @voznesenskym @penguinwu @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @jiayisunx @chenyang78 @kadeng @chauhang @amjames

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Mar 1, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit 8348536 with merge base b958890 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@pytorch-bot pytorch-bot bot added the release notes: fx release notes category label Mar 1, 2025
jansel added a commit that referenced this pull request Mar 1, 2025
ghstack-source-id: 651ad20
Pull Request resolved: #148243
[ghstack-poisoned]
[ghstack-poisoned]
jansel added 3 commits March 1, 2025 17:37
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Copy link
Collaborator

@XuehaiPan XuehaiPan left a comment

Choose a reason for hiding this comment

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

I wonder if there is any plan to reimplement map_aggregate to reuse the pytree infra.

Comment on lines -923 to -926
elif isinstance(a, list):
result = immutable_list([map_aggregate(elem, fn) for elem in a])
elif isinstance(a, dict):
result = immutable_dict([(k, map_aggregate(v, fn)) for k, v in a.items()])
Copy link
Collaborator

Choose a reason for hiding this comment

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

One blocker to use the pytree tree_map is that pytree uses type(a) is list / type(a) is dict rather than isinstance(a, list) / isinstance(a, dict). How do we want to support user subclasses, such as collections.UserList / collections.UserDict? Or we can just support list (immutable_list), dict (immutable_dict), defaultdict, OrderedDict only.

@jansel
Copy link
Contributor Author

jansel commented Mar 2, 2025

@XuehaiPan map_aggregate is a backwards compatibility surface for FX and the public API and behavior can't be changed. It implicitly converts all list subclasses to immutable_list.

@jansel jansel requested a review from oulgen March 2, 2025 17:26
@jansel jansel marked this pull request as ready for review March 2, 2025 17:31
@jansel jansel requested a review from zou3519 as a code owner March 2, 2025 17:31
@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #148261

pytorchmergebot pushed a commit that referenced this pull request Mar 2, 2025
Microbenchmarking `fx.symbolic_trace(lambda x: functools.reduce(operator.add, [x, *range(100000)]))`, before:
```
25203549 function calls (24403352 primitive calls) in 12.090 seconds
```
after:
```
24303536 function calls (23503339 primitive calls) in 10.726 seconds
```

Pull Request resolved: #148260
Approved by: https://github.com/oulgen
ghstack dependencies: #148243
pytorchmergebot pushed a commit that referenced this pull request Mar 2, 2025
Microbenchmarking `fx.symbolic_trace(lambda x: functools.reduce(operator.add, [x, *range(100000)]))`, before:
```
24303536 function calls (23503339 primitive calls) in 10.726 seconds
```
after:
```
20003454 function calls (19203257 primitive calls) in 8.936 seconds
```

Pull Request resolved: #148261
Approved by: https://github.com/oulgen
ghstack dependencies: #148243, #148260
pytorchmergebot added a commit that referenced this pull request Mar 4, 2025
This reverts commit edaff88.

Reverted #148243 on behalf of https://github.com/jovianjaison due to breaking internal builds [T216910920] ([comment](#148243 (comment)))
@pytorchmergebot
Copy link
Collaborator

@jansel your PR has been successfully reverted.

@pytorchmergebot pytorchmergebot added Reverted ci-no-td Do not run TD on this PR labels Mar 4, 2025
pytorchmergebot pushed a commit to min-jean-cho/pytorch that referenced this pull request Mar 5, 2025
pytorchmergebot pushed a commit to min-jean-cho/pytorch that referenced this pull request Mar 5, 2025
…ch#148292)

Before: 19502951 function calls (18702776 primitive calls) in 8.533 seconds
After: 16402551 function calls (15602452 primitive calls) in 7.701 seconds

Pull Request resolved: pytorch#148292
Approved by: https://github.com/oulgen
ghstack dependencies: pytorch#148243, pytorch#148260, pytorch#148261, pytorch#148303, pytorch#148288
jansel added 2 commits March 8, 2025 19:28
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@jansel jansel added the ciflow/trunk Trigger trunk jobs on your pull request label Mar 9, 2025
jansel added 3 commits March 9, 2025 18:03
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #148292

pytorchmergebot pushed a commit that referenced this pull request Mar 10, 2025
Microbenchmarking `fx.symbolic_trace(lambda x: functools.reduce(operator.add, [x, *range(100000)]))`, before:
```
25203549 function calls (24403352 primitive calls) in 12.090 seconds
```
after:
```
24303536 function calls (23503339 primitive calls) in 10.726 seconds
```

Pull Request resolved: #148260
Approved by: https://github.com/oulgen
ghstack dependencies: #148243
pytorchmergebot pushed a commit that referenced this pull request Mar 10, 2025
Microbenchmarking `fx.symbolic_trace(lambda x: functools.reduce(operator.add, [x, *range(100000)]))`, before:
```
24303536 function calls (23503339 primitive calls) in 10.726 seconds
```
after:
```
20003454 function calls (19203257 primitive calls) in 8.936 seconds
```

Pull Request resolved: #148261
Approved by: https://github.com/oulgen
ghstack dependencies: #148243, #148260
pytorchmergebot pushed a commit that referenced this pull request Mar 10, 2025
Before: 19502951 function calls (18702776 primitive calls) in 8.533 seconds
After: 16402551 function calls (15602452 primitive calls) in 7.701 seconds

Pull Request resolved: #148292
Approved by: https://github.com/oulgen
ghstack dependencies: #148243, #148260, #148261, #148288
clee2000 added a commit that referenced this pull request Apr 2, 2025
This reverts commit bec7bda.

ghstack-source-id: 3604b06
Pull Request resolved: #150500
@github-actions github-actions bot deleted the gh/jansel/507/head branch April 12, 2025 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-no-td Do not run TD on this PR ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request fx Merged module: dynamo release notes: fx release notes category Reverted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants