Commit 65cb290
optimize group based partitioner to not try to merge partitions we already determined were not supposed to be merged (pytorch#12798)
### Summary
In the group based partitioner we had a case where we would try to merge
partitions we already determined couldn't be merged, which was causing a
lot more checks to be done. This pr creates a set that tracks the
partitions that we determined cant be merged and ensures that when
considering 2 new partitions either id isnt in this set. Find below the
number of checks on whether each partition can be merged before and
after respectively which has a runtime of O(n^2) where n represents the
number of nodes in a partition.
<img width="84" height="772" alt="image"
src="https://github.com/user-attachments/assets/e1f7b47f-9006-494f-afe1-4da0726362f0"
/>
<img width="68" height="766" alt="image"
src="https://github.com/user-attachments/assets/45d4dbe0-f292-4f80-8e66-53aa68ef3cdb"
/>
### Test plan
I added cnt print logs to check to see the number of times we entered
the check both before and after the change.1 parent 38990c1 commit 65cb290
1 file changed
+28
-26
lines changedLines changed: 28 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
| 207 | + | |
| 208 | + | |
211 | 209 | | |
212 | | - | |
213 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
214 | 222 | | |
215 | 223 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
236 | 238 | | |
237 | 239 | | |
238 | 240 | | |
| |||
0 commit comments