[ET-VK] Conv2d with padding="valid" asserts in make_ivec2 (breaks every SigLIP/CLIP patch embed)
@giuliocorradi 已经在做这个了。
开始于 2026年9月16日。
评估
这个 Issue 还没有评估数据。
描述
🐛 Describe the bug
Summary
nn.Conv2d(..., padding="valid") exports a one-element padding list, and the
Vulkan convolution reads padding as an ivec2, so it aborts at the first
inference:
make_ivec2 at backends/vulkan/runtime/utils/VecUtils.h:367:
(ints.size() == 2) is false!
The identical convolution written with padding=0 lowers and runs correctly.
Reproduction
No model needed. The two modules differ only in how padding is spelled.
import torch
from executorch.exir import to_edge
from executorch.backends.vulkan.partitioner.vulkan_partitioner import VulkanPartitioner
from executorch.extension.pybindings.portable_lib import _load_for_executorch
class C(torch.nn.Module):
def __init__(self, pad):
super().__init__()
self.c = torch.nn.Conv2d(3, 64, kernel_size=3, stride=1, padding=pad)
def forward(self, x):
return self.c(x)
def run(pad, tag):
x = torch.randn(1, 3, 224, 224)
mod = C(pad)
low = to_edge(torch.export.export(mod, (x,))).to_backend(VulkanPartitioner())
path = f"/tmp/{tag}.pte"
with open(path, "wb") as f:
low.to_executorch().write_to_file(f)
out = _load_for_executorch(path).forward((x,))[0]
print(tag, "ok, max|d| =", (out - mod(x)).abs().max().item())
run(0, "pad_zero") # runs, max|d| 7.2e-07
run("valid", "pad_valid") # asserts in make_ivec2
Result
| padding | outcome |
|---|---|
0 |
runs, max|d| 7.2e-07 |
"valid" |
asserts, make_ivec2 ... (ints.size() == 2) is false |
Reproduced at kernel 3 stride 1 and at kernel 14 stride 14; the kernel geometry
is irrelevant, only the spelling of the padding.
Expected behaviour
padding="valid" means no padding, so it should lower identically to
padding=0.
Suggested fix
Normalise the padding list to the spatial rank where the Vulkan convolution
reads it — broadcast a length-1 list, as PyTorch does elsewhere — rather than
requiring exactly two elements. A length-1 padding list is a legal
representation of symmetric padding.
Impact
padding="valid" is how HuggingFace writes patch-embedding convolutions. In
particular SiglipVisionEmbeddings is:
self.patch_embedding = nn.Conv2d(
in_channels=config.num_channels,
out_channels=self.embed_dim,
kernel_size=self.patch_size,
stride=self.patch_size,
padding="valid",
)
so every SigLIP vision tower hits this, and with it PaliGemma, π₀.₅, and any
model using a SigLIP or similarly-written CLIP/ViT patch embed. The workaround
is trivial once known — rewrite the module's padding attribute to (0, 0)
before export — but the failure mode is an assert deep in the runtime with no
indication that padding spelling is the cause.
Versions
collect_env.py output
Collecting environment information...
PyTorch version: 2.12.1+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCm SDK used to build PyTorch: N/A
HIP used to build PyTorch: N/A
OS: Ubuntu 24.04.4 LTS (x86_64)
GCC version: Could not collect
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.39
Python version: 3.12.3 (main, Jul 15 2026, 23:46:41) [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-7.0.0-30-generic-x86_64-with-glibc2.39
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Caching allocator config: N/A
CPU: AMD RYZEN AI MAX+ 395 w/ Radeon 8060S, 16 cores / 32 threads (full lscpu elided)
Versions of relevant libraries:
[pip3] executorch==1.4.0a0+b20f16a
[pip3] numpy==2.4.6
[pip3] pytorch_tokenizers==1.4.1
[pip3] torch==2.12.1+cpu
[pip3] torchao==0.18.0.dev20260715+cpu
[conda] Could not collect
cc @SS-JIA @manuelcandales @digantdesai @cbilgin
- 主要语言
- Python
- 星标
- 5k
- 派生
- 1.2k
- 平均合并
- 2 天 12 小时
- 30 天内合并 PR
- 588
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pytorch/executorch 的其他 Issue
-
enhancement triaged
难度 2/5 半天 新手友好度 68/100
pytorch/executorch#21640 ·
-
enhancement module: cuda module: examples module: mlx module: vulkan module: xnnpack
难度 5/5 一周以上 新手友好度 25/100
pytorch/executorch#23131 · 1 个 reaction ·
-
bug module: qnn module: quantization
难度 4/5 3-5 天 新手友好度 55/100
pytorch/executorch#23108 ·
-
good first issue module: examples module: webgpu
难度 5/5 一周以上 新手友好度 35/100
pytorch/executorch#23099 ·
-
good first issue module: examples module: vulkan
难度 5/5 一周以上 新手友好度 30/100
pytorch/executorch#23098 ·
查看 pytorch/executorch 的全部 Issue
相似的 Issue
-
agent-ready documentation needs-triage
难度 1/5 1-3 小时 新手友好度 88/100
-
documentation
难度 1/5 1 小时以内 新手友好度 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
-
instance instance add
难度 1/5 1 小时以内 新手友好度 72/100
searxng/searx-instances#939 · 1 条评论 ·
-
area-deployment area-integrations triage:bot-seen
难度 2/5 半天 新手友好度 86/100