已关闭
[Requirement|需求建议]: AvgPool1d/AvgPoolV2 stride > 63 导致编译失败 #2120
gcw_Vjs9aJYP创建于 4月16日关闭于 7月24日
chenqi317
4月24日 评论:
4月24日 评论:
感谢反馈, 已安排committer 确认
assign @zhangyuxiang0119


4月30日 将 zhao_heng 设为负责人
4月30日 移除了负责人 zhangyuxiang0119
6月1日 将 yue-ma 设为负责人
6月1日 移除了负责人 chenyanbin8
7月17日 issue状态由 进行中 改变为 技术评审中
yue-ma
7月24日 评论:
7月24日 评论:
你好,该问题在3D模式下可以支持,静态图模式下建议可以先通过升维进行规避,动态图模式下将在9.2.0版本支持
def fn(t):
return torch.nn.functional.avg_pool3d(t.unsqueeze(-2).unsqueeze(-2), kernel_size=(1, 1, 100), stride=(1, 1, 100), ceil_mode=True).squeeze(-2).squeeze(-2)


Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.
Describe the current behavior / 问题描述 (Mandatory / 必填)
当在 Ascend NPU 上使用
torch.compile(torchair backend) 编译包含F.avg_pool1d(..., stride=seg_len)的计算图时,如果stride > 63(例如seg_len=100),编译阶段会直接报错并退出。该算子在 CUDA/CPU 后端可正常运行。Environment / 环境信息 (Mandatory / 必填)
Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)
repro_avgpool.py:import torch import torch_npu import torchair x = torch.randn(1, 256, 1000).npu() config = torchair.CompilerConfig() backend = torchair.get_npu_backend(compiler_config=config) def fn(t): return torch.nn.functional.avg_pool1d(t, kernel_size=100, stride=100, ceil_mode=True) compiled_fn = torch.compile(fn, backend=backend, dynamic=False) compiled_fn(x) 2. 运行脚本:python repro_avgpool.py 3. 观察编译阶段报错。 ### Describe the expected behavior / 预期结果 (Mandatory / 必填) F.avg_pool1d 在 stride > 63 时应像 CUDA/CPU 一样正常完成图编译并在 NPU 上执行,不应因 stride 范围限制而强制失败。 ### Related log / screenshot / 日志 / 截图 (Mandatory / 必填) 编译阶段典型报错(摘要): [ERROR] AvgPoolV2 stride value 100 is out of supported range [1, 63] ... [ERROR] Build graph failed, op type: AvgPoolV2 ... RuntimeError: torch.compile with torchair backend failed on Ascend NPU 当前 workaround 为手动将张量切回 CPU 执行池化,或改用 pad + view + mean 的纯 PyTorch 模拟实现,但这会引入额外的 Host-Device 同步开销。 ### Special notes for this issue/备注 (Optional / 选填) 影响模型 - CampPlus 说话人分离模型(speech_campplus_sv_zh-cn_16k-common):默认 seg_len=100,触发限制。 - F.avg_pool1d(x, kernel_size=100, stride=100, ceil_mode=True) 无法原生运行。 该限制在语音模型(如 CampPlus / speaker embedding 模型)中非常容易触发,因为默认 seg_len=100 的池化操作是标准实现。