[Bug] RemoveCloneOpsTransform folds a clone onto an input that is also an output

Offen
#25,774 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@themanoj-025 arbeitet bereits daran.

Seit 27.11.2026.

  • #25775 von @themanoj-025 — offen
  • #25793 von @Roxen-AS — ohne Merge geschlossen

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
70/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python, pytorch

Rechercherichtung

Find RemoveCloneOpsTransform in the ExecuTorch codebase and read its implementation and nearby tests. Reproduce the issue with the supplied model and XNNPACK lowering command, then check how the transform handles graph outputs. Done when the clone is preserved when both it and its input are outputs, and the reproduction completes without the duplicate-output error.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Describe the bug

When a model returns both a value and its .contiguous()\ clone (hit by CLVP and PerceptionLM in Hugging Face Transformers), \RemoveCloneOpsTransform\ erases the clone and replaces all its uses with the clone's input.
Because both the clone and its input were returned in the graph output, replacing the clone with its input causes the same node to appear twice in the output tuple (e.g. (y, y)).

Subsequently, during backend lowering (such as XNNPACK's \generate_node_to_external_map), preprocessing fails with:
\RuntimeError: Output node 'aten_permute_copy_default' is already in the inputs. This is likely due to pass through arguments, which are not supported in XNNPACK Delegate.\

This issue tracks item 3 from https://github.com/huggingface/transformers/issues/51303.

Repro

\\python
import torch
from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner
from executorch.exir import to_edge_transform_and_lower

class M(torch.nn.Module):
def forward(self, x):
y = (x * 2).permute(0, 2, 1)
return y, y.contiguous()

ep = torch.export.export(M(), (torch.randn(1, 4, 8),))
to_edge_transform_and_lower(ep, partitioner=[XnnpackPartitioner()]).to_executorch()
\\

Expected behavior

\RemoveCloneOpsTransform\ should not fold a clone onto an input when both the clone node and its input node produce an output, preserving distinct nodes in the graph output tuple.

Vorherrschende Sprache
Python
Sterne
5.2k
Forks
1.3k
Ø Merge
1 T. 7 Std.
Gemergte PRs (30 T.)
644

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus pytorch/executorch

Alle Issues in pytorch/executorch

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.