Skip to content

Core ML segfault when running pybindings #12408

Description

@GregoryComer

🐛 Describe the bug

Running a CoreML-delegated model using pybindings crashes with a segfault. This started within the last few weeks, and seems to be consistent. I can't reproduce the fault on XNNPACK or Vulkan, though from the initial bisect (see below), this might just be due to chance.

Repro:

importtorchfromexecutorch.backends.apple.coreml.partitionimportCoreMLPartitionerfromexecutorch.exirimportto_edge_transform_and_lower, to_edgefromexecutorch.extension.pybindings.portable_libimport_load_for_executorch_from_bufferclassModel(torch.nn.Module):
def__init__(self):
super().__init__()
defforward(self, x):
returnx*2model=Model()
inputs= (
torch.randn(1, 2024),
)
eager_outputs=model(*inputs)
ep=torch.export.export(model, inputs)
lowered=to_edge_transform_and_lower(
ep,
partitioner=[CoreMLPartitioner()],
).to_executorch()
print(ep)
et_model=_load_for_executorch_from_buffer(lowered.buffer)
et_outputs=et_model([*inputs])[0]
et_outputs-eager_outputs

Note that it repros when running the script standalone, but not from a notebook. From initial investigation, it appears to be faulting on cleanup.

From @metascroy:
"I bisected the error to #11391."

Versions

M1 Pro, reproduced on cd90531. coremltools version 8.3.0.

cc @larryliu0820@JacobSzwejbka@lucylq@kimishpatel@YifanShenSZ@cymbalrush@metascroy

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: coremlIssues related to Apple's Core ML delegation and code under backends/apple/coreml/module: runtimeIssues related to the core runtime and code under runtime/

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions