Skip to content

Core ML segfault when running pybindingsΒ #12408

@GregoryComer

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:

import torch

from executorch.backends.apple.coreml.partition import CoreMLPartitioner
from executorch.exir import to_edge_transform_and_lower, to_edge
from executorch.extension.pybindings.portable_lib import _load_for_executorch_from_buffer

class Model(torch.nn.Module):
    def __init__(self):
        super().__init__()
    def forward(self, x):
        return x * 2

model = 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

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

    Status

    Done

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions