CoreML Performance Report Error on Xcode Beta

Error when trying to generate CoreML performance report, message says

The data couldn't be written because it isn't in the correct format.

Here is the code to replicate the issue

import numpy as np

import coremltools as ct
from coremltools.converters.mil import Builder as mb
import coremltools.converters.mil as mil

w = np.random.normal(size=(256, 128, 1))
wemb = np.random.normal(size=(1, 32000, 128)) # .astype(np.float16)
rope_emb = np.random.normal(size=(1, 2048, 128))

shapes = [(1, seqlen) for seqlen in (32, 64)]
enum_shape = mil.input_types.EnumeratedShapes(shapes=shapes)
fixed_shape = (1, 128)

max_length = 2048
dtype = np.float32

@mb.program(
    input_specs=[
        # mb.TensorSpec(enum_shape.symbolic_shape, dtype=mil.input_types.types.int32),
        mb.TensorSpec(enum_shape.symbolic_shape, dtype=mil.input_types.types.int32),
    ],
    opset_version=mil.builder.AvailableTarget.iOS17,
)
def flex_like(input_ids):
    indices = mb.fill_like(ref_tensor=input_ids, value=np.array(1, dtype=np.int32))
    causal_mask = np.expand_dims(
        np.triu(np.full((max_length, max_length), -np.inf, dtype=dtype), 1),
        axis=0,
    )
    mask = mb.gather(
        x=causal_mask,
        indices=indices,
        axis=2,
        batch_dims=1,
        name="mask_gather_0",
    )
    # mask = mb.gather(
    #     x=mask, indices=indices, axis=1, batch_dims=1, name="mask_gather_1"
    # )
    rope = mb.gather(x=rope_emb.astype(dtype), indices=indices, axis=1, batch_dims=1, name="rope")
    
    hidden_states = mb.gather(x=wemb.astype(dtype), indices=input_ids, axis=1, batch_dims=1, name="embedding")
    return (
        hidden_states,
        mask,
        rope,
    )

cml_flex_like = ct.convert(
    flex_like,
    compute_units=ct.ComputeUnit.ALL,
    compute_precision=ct.precision.FLOAT32,
    minimum_deployment_target=ct.target.iOS17,
    inputs=[
        ct.TensorType(name="input_ids", shape=enum_shape),
    ],
)

cml_flex_like.save("flex_like_32")

If I remove the hidden states from the return it does work, and it also works if I keep the hidden states, but remove both mask, and rope, i.e, the report is generated for both programs with either these returns:

return (
        # hidden_states,
        mask,
        rope,
)

and

return (
        hidden_states,
        # mask,
        # rope,
)

It also works if I use a static shape instead of an EnumeratedShape

I'm using macOS 15.0 and Xcode 16.0

Edit 1: Forgot to mention that although the performance report fails, the model is still able to make predictions

Hello, please give it a try with Xcode 16 beta 2 and if the issue is still there then please file a radar.

CoreML Performance Report Error on Xcode Beta
 
 
Q