While verifying #21489 I exported a textbook CNN written as one top-level nn.Sequential (conv, batchnorm, relu, maxpool). With the pooling crash fixed, the same model now dies one pass later: FuseBatchNormPass crashes before any support decision is reached. The identical layers behind a named attribute lower fine.
Repro
import torch
import torch.nn as nn
from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner
from executorch.exir import to_edge_transform_and_lower
model = nn.Sequential(
nn.Conv2d(3, 16, 3, padding=1),
nn.BatchNorm2d(16),
nn.ReLU(),
).eval()
ep = torch.export.export(model, (torch.randn(1, 3, 32, 32),))
to_edge_transform_and_lower(ep, partitioner=[XnnpackPartitioner()])
Exception: An error occurred when running the 'FuseBatchNormPass' pass
...
ValueError: '0_weight_fused_bn' is not in list
backends/xnnpack/_passes/fuse_batch_norm.py:241, in create_constant_placeholder
backends/transforms/utils.py:151, in node_names.index(name)
Cause
A top-level nn.Sequential names its parameters 0.weight, 1.weight, so the fused weight placeholder is requested as 0_weight_fused_bn. torch.fx refuses a leading digit and assigns _0_weight_fused_bn instead, but create_constant_placeholder then looks the node up by the requested name:
node = graph.create_node(op="placeholder", name=name, target=name)
...
node_index = node_names.index(name) # ValueError: fx assigned node.name, not name
Any rename triggers it, not just leading digits. #14055 hits the same lines through Vulkan because torchvision regnet module names contain a hyphen. Models with named submodules produce FQNs that sanitize cleanly, which is why existing coverage never reaches this path.
runtime/test/test_runtime_xnnpack.py carries a test_conv_bn skipped on exactly this crash.
While verifying #21489 I exported a textbook CNN written as one top-level
nn.Sequential(conv, batchnorm, relu, maxpool). With the pooling crash fixed, the same model now dies one pass later:FuseBatchNormPasscrashes before any support decision is reached. The identical layers behind a named attribute lower fine.Repro
Cause
A top-level
nn.Sequentialnames its parameters0.weight,1.weight, so the fused weight placeholder is requested as0_weight_fused_bn. torch.fx refuses a leading digit and assigns_0_weight_fused_bninstead, butcreate_constant_placeholderthen looks the node up by the requested name:Any rename triggers it, not just leading digits. #14055 hits the same lines through Vulkan because torchvision regnet module names contain a hyphen. Models with named submodules produce FQNs that sanitize cleanly, which is why existing coverage never reaches this path.
runtime/test/test_runtime_xnnpack.pycarries atest_conv_bnskipped on exactly this crash.