Commit bc3972b
[reland] Add stack_trace on make_fx (pytorch#155486)
Summary:
Previosuly, we only add stack trace in class _ModuleStackTracer(PythonKeyTracer) for non-strict export. I moved this stack trace logic to the parent class PythonKeyTracer, this way the graph traced from Module using make_fx will have stack_trace as well.
Motivation: we've observed some uses cases where users first use make_fx on the Module, and then run export on the resulting graph. If the result of make_fx doesn't have stack trace, the stack trace information is lost.
**User needs to turn this on by passing in `stack_trace=True` to make_fx. We don't make this the default option since this might increase inductor compilation time (`make_fx` is used in inductor to trace graph patterns for pattern matching). It's also turned on if `_inductor.config.trace.enabled` is True.**
**preserving stack trace is on by default for ModuleStackTracer, which is used for non-strict export.**
Test Plan:
```
buck run test:test_export -- -r test_stack_trace
buck run fbcode//caffe2/test/dynamo:test_dynamo -- -k test_autocast_ordering
```
Rollback Plan:
Differential Revision: D76298692
Pull Request resolved: pytorch#155486
Approved by: https://github.com/angelayi, https://github.com/zou35191 parent 9bd0830 commit bc3972b
File tree
2 files changed
+98
-30
lines changed- test/export
- torch/fx/experimental
2 files changed
+98
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11473 | 11473 | | |
11474 | 11474 | | |
11475 | 11475 | | |
| 11476 | + | |
| 11477 | + | |
| 11478 | + | |
| 11479 | + | |
| 11480 | + | |
| 11481 | + | |
| 11482 | + | |
| 11483 | + | |
| 11484 | + | |
| 11485 | + | |
| 11486 | + | |
| 11487 | + | |
| 11488 | + | |
| 11489 | + | |
| 11490 | + | |
| 11491 | + | |
| 11492 | + | |
| 11493 | + | |
| 11494 | + | |
| 11495 | + | |
| 11496 | + | |
| 11497 | + | |
| 11498 | + | |
| 11499 | + | |
| 11500 | + | |
| 11501 | + | |
| 11502 | + | |
| 11503 | + | |
| 11504 | + | |
| 11505 | + | |
| 11506 | + | |
| 11507 | + | |
| 11508 | + | |
| 11509 | + | |
| 11510 | + | |
| 11511 | + | |
| 11512 | + | |
| 11513 | + | |
| 11514 | + | |
| 11515 | + | |
| 11516 | + | |
| 11517 | + | |
| 11518 | + | |
| 11519 | + | |
| 11520 | + | |
| 11521 | + | |
| 11522 | + | |
| 11523 | + | |
| 11524 | + | |
| 11525 | + | |
| 11526 | + | |
| 11527 | + | |
| 11528 | + | |
11476 | 11529 | | |
11477 | 11530 | | |
11478 | 11531 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1025 | 1025 | | |
1026 | 1026 | | |
1027 | 1027 | | |
| 1028 | + | |
1028 | 1029 | | |
1029 | 1030 | | |
1030 | 1031 | | |
| |||
1110 | 1111 | | |
1111 | 1112 | | |
1112 | 1113 | | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
1113 | 1147 | | |
1114 | 1148 | | |
1115 | 1149 | | |
| |||
1659 | 1693 | | |
1660 | 1694 | | |
1661 | 1695 | | |
| 1696 | + | |
1662 | 1697 | | |
1663 | 1698 | | |
1664 | 1699 | | |
| |||
1909 | 1944 | | |
1910 | 1945 | | |
1911 | 1946 | | |
1912 | | - | |
1913 | | - | |
1914 | | - | |
1915 | | - | |
1916 | | - | |
1917 | | - | |
1918 | | - | |
1919 | | - | |
1920 | | - | |
1921 | | - | |
1922 | | - | |
1923 | | - | |
1924 | | - | |
1925 | | - | |
1926 | | - | |
1927 | | - | |
1928 | | - | |
1929 | | - | |
1930 | | - | |
1931 | | - | |
1932 | | - | |
1933 | | - | |
1934 | | - | |
1935 | | - | |
1936 | | - | |
1937 | | - | |
1938 | | - | |
1939 | | - | |
1940 | | - | |
1941 | | - | |
1942 | 1947 | | |
1943 | 1948 | | |
1944 | 1949 | | |
| |||
1952 | 1957 | | |
1953 | 1958 | | |
1954 | 1959 | | |
| 1960 | + | |
1955 | 1961 | | |
1956 | 1962 | | |
1957 | 1963 | | |
| |||
1982 | 1988 | | |
1983 | 1989 | | |
1984 | 1990 | | |
| 1991 | + | |
1985 | 1992 | | |
1986 | 1993 | | |
1987 | 1994 | | |
| |||
2020 | 2027 | | |
2021 | 2028 | | |
2022 | 2029 | | |
| 2030 | + | |
2023 | 2031 | | |
2024 | 2032 | | |
2025 | 2033 | | |
| 2034 | + | |
2026 | 2035 | | |
2027 | 2036 | | |
2028 | 2037 | | |
| |||
2274 | 2283 | | |
2275 | 2284 | | |
2276 | 2285 | | |
| 2286 | + | |
2277 | 2287 | | |
2278 | 2288 | | |
2279 | 2289 | | |
2280 | 2290 | | |
2281 | 2291 | | |
| 2292 | + | |
| 2293 | + | |
2282 | 2294 | | |
2283 | 2295 | | |
2284 | 2296 | | |
2285 | 2297 | | |
| 2298 | + | |
| 2299 | + | |
2286 | 2300 | | |
2287 | 2301 | | |
2288 | 2302 | | |
| |||
2291 | 2305 | | |
2292 | 2306 | | |
2293 | 2307 | | |
| 2308 | + | |
2294 | 2309 | | |
2295 | 2310 | | |
2296 | 2311 | | |
| |||
0 commit comments