Commit 5f597ab
fix(arm): validate partitions for dependency cycles after Q/DQ de-tagging
`_detag_boundary_nodes` removes Q/DQ nodes from partition boundaries
after `CapabilityBasedPartitioner` has produced cycle-free partitions.
However, this de-tagging can introduce dependency cycles for models
with complex attention blocks (e.g. MobileViT, where CNN and
Transformer ops are grouped into a single large partition).
The cycle occurs because removing Q/DQ bridge nodes creates paths
that exit the partition and re-enter it through the now-unpartitioned
nodes, making it impossible to extract the partition as a valid
subgraph.
This change adds cycle validation after `_detag_boundary_nodes`. When
a cycle is detected, the partition is split into connected components
of the surviving (still-tagged) nodes. Each component becomes a
separate partition that is individually cycle-free after de-tagging.
- Add `_validate_partition()`: BFS-based cycle detection (same
algorithm as `torch.fx.passes.utils.fuser_utils.validate_partition`)
- Add `_find_connected_components()`: undirected graph traversal to
split surviving nodes into disjoint sub-partitions
- Guard the nocompute-partition `tags.remove()` against already-removed
tags from the cycle-split path
Tested with MobileViT-S on Ethos-U85: previously failed with
`AssertionError: Invalid partition, found dependency cycles`, now
successfully produces a .pte file (5.7 MB). Nine attention-block
partitions are each split into 3 sub-partitions. All sub-partitions
remain on NPU (no CPU fallback). Existing CNN-only models (ResNet,
MobileNetV2, EfficientNet) are unaffected as their partitions have
no cycles after de-tagging.1 parent abc0237 commit 5f597ab
1 file changed
Lines changed: 99 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
121 | 192 | | |
122 | 193 | | |
123 | 194 | | |
| |||
255 | 326 | | |
256 | 327 | | |
257 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
258 | 355 | | |
259 | 356 | | |
260 | 357 | | |
| |||
272 | 369 | | |
273 | 370 | | |
274 | 371 | | |
275 | | - | |
| 372 | + | |
| 373 | + | |
276 | 374 | | |
277 | 375 | | |
278 | 376 | | |
| |||
0 commit comments