Commit c94b062
committed
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 87e65ac commit c94b062
1 file changed
Lines changed: 98 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 | | |
| |||
131 | 132 | | |
132 | 133 | | |
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 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
134 | 206 | | |
135 | 207 | | |
136 | 208 | | |
| |||
285 | 357 | | |
286 | 358 | | |
287 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
288 | 384 | | |
289 | 385 | | |
290 | 386 | | |
| |||
303 | 399 | | |
304 | 400 | | |
305 | 401 | | |
306 | | - | |
| 402 | + | |
| 403 | + | |
307 | 404 | | |
308 | 405 | | |
309 | 406 | | |
| |||
0 commit comments