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

未关闭
#25,774 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@themanoj-025 已经在做这个了。

开始于 2026年11月27日。

  • #25775 来自 @themanoj-025 —— 未关闭
  • #25793 来自 @Roxen-AS —— 已关闭,未合并

评估

难度
3/5
预计耗时
1-2 天
新手友好度
70/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python, pytorch

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Python
星标
5.2k
派生
1.3k
平均合并
1 天 7 小时
30 天内合并 PR
644

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pytorch/executorch 的其他 Issue

查看 pytorch/executorch 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。