Sherlock Huang
10e69a6e17
Preserve user annotation in graph ( #163673 )
...
```
import torch
import torch.fx.traceback as fx_traceback
import torch.export
class M(torch.nn.Module):
def forward(self, x):
with fx_traceback.annotate({"pp_stage": 0}):
with fx_traceback.annotate({"fdsp_bucket": 0}):
x = x + 1
x = x - 2
with fx_traceback.annotate({"cuda_stream": 2, "fsdp_bucket": 1}):
x = x * 2
x = x / 3
return x
m = M()
with fx_traceback.preserve_node_meta():
ep = torch.export.export(m, (torch.randn(10),))
for node in ep.graph.nodes:
if node.op == "call_function":
print(f"{node.target}, {node.meta.get("custom", {})}")
```
prints
```
aten.add.Tensor, {'pp_stage': 0, 'fdsp_bucket': 0}
aten.sub.Tensor, {'pp_stage': 0}
aten.mul.Tensor, {'pp_stage': 0, 'cuda_stream': 2, 'fsdp_bucket': 1}
aten.div.Tensor, {}
```
TODOs:
- run_decomposition is failing
- Need to test with the new full graph capture + aot_export_joint apis
- Need to make the annotation propagate through autograd engine to reach the bw nodes. Sample impl here: https://github.com/pytorch/pytorch/pull/83558
- Edward want to restrict the key in custom field to be top-level singleton objects only
- also need to take care of metadata merging when passes are fusing nodes
Thanks @angelayi for contributing the dynamo fixes.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/163673
Approved by: https://github.com/albanD , https://github.com/angelayi
2025-09-25 15:50:15 +00:00
..
2025-09-22 21:01:27 +00:00
2025-04-16 21:35:19 +00:00
2025-09-12 23:53:17 +00:00
2025-07-24 04:42:33 +00:00
2025-09-22 21:01:27 +00:00
2025-08-12 20:08:49 +00:00
2025-09-09 02:08:13 +00:00
2025-09-04 17:21:26 +00:00
2025-04-27 09:56:42 +00:00
2025-07-24 20:59:06 +00:00
2025-09-03 03:12:18 +00:00
2025-08-08 17:41:22 +00:00
2025-06-12 02:55:06 +00:00
2025-06-12 02:55:06 +00:00
2025-08-26 20:03:59 +00:00
2025-06-12 02:55:06 +00:00
2025-06-16 17:48:23 +00:00
2025-06-16 17:24:37 +00:00
2025-09-21 05:50:50 +00:00
2025-09-25 13:47:46 +00:00
2025-06-13 20:58:57 +00:00
2025-02-16 16:50:59 +00:00
2025-07-15 21:14:18 +00:00
2023-10-11 05:13:10 +00:00
2024-02-15 21:41:38 +00:00
2022-10-31 19:31:56 +00:00
2025-09-21 22:28:27 +00:00
2025-09-21 22:28:27 +00:00
2025-06-13 20:24:34 +00:00
2021-09-21 11:09:47 -07:00
2025-04-27 09:56:42 +00:00
2025-06-13 20:24:34 +00:00
2025-06-06 22:44:50 +00:00
2025-06-06 22:44:50 +00:00
2025-06-06 22:44:50 +00:00
2025-07-30 04:09:41 +00:00
2025-06-06 22:44:50 +00:00
2025-09-04 01:09:53 +00:00
2025-07-25 21:19:49 +00:00
2025-06-17 10:03:19 +00:00
2025-09-04 01:09:53 +00:00
2025-06-16 20:46:09 +00:00
2025-08-14 14:58:35 +00:00
2025-09-18 06:41:02 +00:00
2025-09-09 22:10:37 +00:00
2025-06-13 22:08:37 +00:00
2025-06-13 22:08:37 +00:00
2020-05-04 14:32:35 -07:00
2025-09-06 03:02:58 +00:00
2025-06-13 05:19:43 +00:00
2025-06-11 23:00:52 +00:00
2025-06-11 23:00:52 +00:00
2025-06-11 23:00:52 +00:00
2025-06-11 23:00:52 +00:00
2025-06-11 23:00:52 +00:00
2025-06-12 00:21:22 +00:00
2025-06-12 00:21:22 +00:00
2025-06-12 00:21:22 +00:00
2025-06-12 00:21:22 +00:00
2025-09-18 23:26:28 +00:00
2025-09-25 15:50:15 +00:00
2025-06-13 04:39:55 +00:00
2025-08-13 14:56:04 +00:00
2025-07-16 20:01:34 +00:00
2025-07-15 20:16:53 +00:00
2025-07-15 20:57:23 +00:00
2025-07-15 21:14:18 +00:00
2025-07-16 20:01:34 +00:00
2025-06-26 21:09:46 +00:00
2025-07-16 20:01:34 +00:00
2025-08-13 21:00:59 +00:00
2025-06-17 15:08:14 +00:00
2025-06-17 15:08:14 +00:00
2025-06-17 15:08:14 +00:00
2019-10-09 16:45:09 -07:00
2025-06-17 15:08:14 +00:00
2025-06-17 15:08:14 +00:00
2025-06-11 22:16:04 +00:00
2025-06-11 22:16:04 +00:00
2025-06-11 22:16:04 +00:00
2025-06-11 22:16:04 +00:00
2025-06-11 22:16:04 +00:00
2025-06-08 21:17:31 +00:00
2025-09-16 17:01:06 +00:00
2025-07-29 17:03:24 +00:00
2025-06-08 21:17:31 +00:00
2025-06-08 21:17:31 +00:00
2025-06-14 03:32:00 +00:00
2025-09-12 05:56:25 +00:00
2025-06-14 03:32:00 +00:00
2025-07-25 22:03:55 +00:00
2025-06-14 03:32:00 +00:00
2025-06-14 03:32:00 +00:00
2025-09-16 00:13:56 +00:00
2024-10-29 17:05:22 +00:00
2024-03-29 18:05:28 +00:00
2022-07-07 17:19:29 +00:00
2025-07-25 22:03:55 +00:00
2025-04-16 21:35:19 +00:00
2025-08-22 22:15:27 +00:00
2025-06-20 23:54:57 +00:00
2025-09-10 01:40:24 +00:00
2025-09-02 16:10:30 +00:00
2025-09-10 01:40:24 +00:00
2025-07-19 07:27:15 +00:00
2025-08-24 08:03:04 +00:00
2025-07-15 21:14:18 +00:00
2025-06-13 05:02:54 +00:00
2025-09-18 12:08:13 +00:00
2025-06-18 18:46:04 +00:00
2025-08-19 10:54:08 +00:00
2025-06-18 18:46:04 +00:00
2025-07-10 14:15:37 +00:00
2025-06-18 01:27:04 +00:00
2025-06-18 01:27:04 +00:00
2025-06-21 02:47:32 +00:00
2025-06-18 01:27:04 +00:00
2025-04-14 16:47:40 +00:00
2025-06-27 13:10:23 +00:00
2025-02-26 01:30:03 +00:00
2022-03-10 22:26:29 +00:00
2025-06-27 13:10:23 +00:00
2025-06-10 20:38:36 +00:00
2025-06-10 20:38:36 +00:00
2025-09-02 02:06:54 +00:00
2025-06-10 20:38:36 +00:00
2025-06-10 20:38:36 +00:00
2025-07-25 17:19:01 +00:00
2025-08-14 23:42:17 +00:00
2025-06-13 22:54:27 +00:00
2025-08-14 23:42:17 +00:00
2025-06-24 04:59:49 +00:00
2025-06-27 14:58:58 +00:00
2025-07-30 17:01:10 +00:00
2025-06-10 20:51:05 +00:00
2025-09-22 21:01:27 +00:00
2025-08-12 08:53:33 +00:00
2025-06-13 18:02:28 +00:00
2025-06-13 18:02:28 +00:00
2025-06-16 00:44:44 +00:00
2025-06-16 00:44:44 +00:00
2025-06-16 00:44:44 +00:00
2025-06-10 01:12:11 +00:00
2025-09-16 19:09:06 +00:00
2025-07-16 19:53:12 +00:00
2025-06-10 01:12:11 +00:00
2025-06-10 01:12:11 +00:00
2025-07-11 07:56:45 +00:00
2025-06-11 18:55:30 +00:00
2025-08-02 23:23:17 +00:00
2025-08-14 23:42:17 +00:00
2025-06-11 18:55:30 +00:00
2025-09-22 21:01:27 +00:00
2025-06-06 20:16:13 +00:00
2025-07-25 17:19:01 +00:00
2025-08-14 01:49:35 +00:00
2025-09-23 04:27:10 +00:00
2025-09-21 22:28:27 +00:00
2025-09-21 22:28:27 +00:00