- Notifications
You must be signed in to change notification settings - Fork26.3k
Commit422d151
committed
[precompile] Support external data for serialization.
Under some corner cases, users don't directly pass us a free functionor module.forward. Instead, there're multiple levels of wrappers andcaptured closures applied to module.forward, so we end up serialzing quitea few captured data from the compiled function's closure. This is not greatwhen things like torch.nn.Module end up being captured in function's closure,and we shouldn't serialize the whole module in this case.To solve this issue, we specially handle the common cases when the followingobjects are being saved:1. torch.nn.Module2. Nested functions.When these data are being serialized, we will mark these as "external data"since they may contain unserialzable and untrackable states which isusually easier to be maintained from user side. So the a call to save_compiled_function()looks like the following:```result: AOTCompileSaveResult = compiled_fn.save_compiled_function("/path")```On the loading side, user are supposed to provide the external data dict. If any keyis missing, load_compiled_function will throw an error.```torch.compiler.load_compiled_function(f, external_data={...})```Note that it's not ideal for user to compile a typical function like this, so thisis only meant for power users for whom rewriting model is harder than maintainingthis data map.ghstack-source-id:a393674Pull Requestresolved:#1708461 parent363e8e1 commit422d151
File tree
3 files changed
+179
-12
lines changed- test/dynamo
- torch
- _dynamo
- compiler
3 files changed
+179
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
302 | 310 | | |
303 | 311 | | |
304 | 312 | | |
| |||
929 | 937 | | |
930 | 938 | | |
931 | 939 | | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
932 | 1007 | | |
933 | 1008 | | |
934 | 1009 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
63 | 92 | | |
64 | 93 | | |
65 | 94 | | |
| |||
68 | 97 | | |
69 | 98 | | |
70 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
71 | 104 | | |
72 | 105 | | |
73 | 106 | | |
| |||
78 | 111 | | |
79 | 112 | | |
80 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
81 | 129 | | |
82 | 130 | | |
83 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
84 | 154 | | |
85 | 155 | | |
86 | 156 | | |
87 | 157 | | |
88 | 158 | | |
89 | 159 | | |
90 | | - | |
| 160 | + | |
91 | 161 | | |
92 | 162 | | |
93 | 163 | | |
| |||
99 | 169 | | |
100 | 170 | | |
101 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
102 | 176 | | |
103 | 177 | | |
104 | 178 | | |
| |||
125 | 199 | | |
126 | 200 | | |
127 | 201 | | |
128 | | - | |
| 202 | + | |
129 | 203 | | |
130 | 204 | | |
131 | 205 | | |
132 | 206 | | |
133 | 207 | | |
134 | 208 | | |
135 | 209 | | |
136 | | - | |
| 210 | + | |
137 | 211 | | |
138 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
139 | 215 | | |
140 | 216 | | |
141 | | - | |
| 217 | + | |
142 | 218 | | |
143 | 219 | | |
144 | 220 | | |
| |||
156 | 232 | | |
157 | 233 | | |
158 | 234 | | |
159 | | - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
160 | 239 | | |
161 | 240 | | |
162 | 241 | | |
163 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
164 | 246 | | |
165 | 247 | | |
166 | 248 | | |
167 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
168 | 254 | | |
169 | 255 | | |
170 | 256 | | |
| |||
339 | 425 | | |
340 | 426 | | |
341 | 427 | | |
342 | | - | |
| 428 | + | |
343 | 429 | | |
344 | 430 | | |
345 | 431 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
712 | 712 | | |
713 | 713 | | |
714 | 714 | | |
715 | | - | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
716 | 719 | | |
717 | 720 | | |
718 | 721 | | |
| |||
723 | 726 | | |
724 | 727 | | |
725 | 728 | | |
726 | | - | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
727 | 733 | | |
728 | 734 | | |
729 | 735 | | |
730 | 736 | | |
731 | 737 | | |
732 | 738 | | |
733 | 739 | | |
734 | | - | |
| 740 | + | |
0 commit comments
Comments
(0)