Skip to content

CoreML delegate emits unloadable multi-method program (0x23 InvalidProgram); MLX and XNNPACK load the same graphs fine#21951

Description

@msluszniak

馃悰 Describe the bug

Lowering a multi-method program with CoreMLPartitioner produces a .pte that cannot be loaded: every method fails with 0x23 (Error::InvalidProgram). The same exported programs lowered with MLXPartitioner load and execute correctly, so the model and the multi-method plumbing are fine and the problem is specific to the Core ML delegate.

Model: the Kokoro TTS duration predictor, lowered as three methods (forward_32, forward_64, forward_128) differing only in token count.

programs = {f"forward_{n}": ep for n, ep in predictors.items()}   # n in {32, 64, 128}

prog = to_edge_transform_and_lower(
    programs,
    partitioner=[CoreMLPartitioner(compile_specs=specs, lower_full_graph=False)],
).to_executorch()
Path("dp.pte").write_bytes(prog.buffer)

Runtime.get().load_program("dp.pte").load_method("forward_32")
# RuntimeError: Failed to load method forward_32, error: 0x:23

to_executorch() succeeds and writes a plausible artifact (35.8 MB at fp16, 62.7 MB at fp32). The failure is at load, before any execution.

Observed

backend export load + run
XNNPACK OK OK (this is the shipping artifact)
MLX OK OK, all three methods, correct output shapes
Core ML OK fails 0x23 InvalidProgram, all three methods, fp16 and fp32

The MLX row is the useful control: identical exported programs, identical multi-method structure, same to_edge_transform_and_lower call shape, only the partitioner differs.

Reproduced at both compute_precision=FLOAT16 and FLOAT32, with minimum_deployment_target=ct.target.iOS18.

Versions

ExecuTorch 1.4.1, coremltools 9.0, torch 2.14.0.dev20260702, macOS arm64 (M4).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions