Skip to content

CoreML floor_divide crashes process #11714

Open
@GregoryComer

Description

@GregoryComer

🐛 Describe the bug

The following model reliably crashes the process on M1 Pro.

Repro:

## import torch

from executorch.backends.apple.coreml.partition import CoreMLPartitioner
from executorch.exir import to_edge_transform_and_lower, EdgeCompileConfig, 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, y):
        return torch.floor_divide(x, y)

model = Model()
inputs = (
    torch.randint(-100, 100, (10, 10)),
    torch.full((10, 10), 2),
)

eager_outputs = model(*inputs)
#print(f"Eager: {eager_outputs.shape} {eager_outputs}")

ep = torch.export.export(model.eval(), inputs)
print(ep)

print(f"EP: {ep.module()(*inputs)}")

lowered = to_edge_transform_and_lower(
    ep,
    partitioner=[CoreMLPartitioner()],
    compile_config=EdgeCompileConfig(_check_ir_validity=False)
).to_executorch()

print(lowered.exported_program())

et_model = _load_for_executorch_from_buffer(lowered.buffer)
et_outputs = et_model([*inputs])[0]

et_outputs - eager_outputs

Output:

[ETCoreMLModelManager.mm:528] Cache Miss: Model with identifier=executorch_76735a7d-45bb-436a-af25-3e8f32949377_all was not found in the models cache.
python(25645,0x1f978df00) malloc: *** error for object 0x16d2a1af0: pointer being freed was not allocated
python(25645,0x1f978df00) malloc: *** set a breakpoint in malloc_error_break to debug
zsh: abort      python -m unittest

Versions

coremltools version 8.3
executorch commit 67b6009 (Jun 14)

cc @kimishpatel @YifanShenSZ @cymbalrush @metascroy

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend testerThis bug was found by the backend test suite.module: coremlIssues related to Apple's Core ML delegation and code under backends/apple/coreml/

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions