Skip to content

Core ML llama export ignores enable_state and preserve_sdpa #22352

Description

@shoumikhin

Summary

Two Core ML options in the llama export config are parsed, stored, and then read by nothing:

backend.coreml.enable_state
backend.coreml.preserve_sdpa

The command line accepts --coreml-enable-state and --coreml-preserve-sdpa, LlmConfig holds
both, and from_args assigns both. No exporter ever reads them, so setting either has no effect.

This is not theoretical. The Core ML config shipped in this repository for lfm2 sets both to true:

    enable_state: True
    preserve_sdpa: True

So that config exports without stateful Core ML models and without the preserved SDPA op, silently,
and has presumably been doing so since the options were added.

Why it surfaced now

Until recently a Core ML llama export could not run at all: the branch selecting the Core ML lowering
read a backend field that no longer existed and raised AttributeError first. With that fixed, this
path executes for the first time, which is what makes the dropped options observable.

What to decide

Either wire both options into the Core ML lowering, or remove them from the parser and the config so
nobody sets something that does nothing. Leaving a shipped config setting them to true while they are
ignored is the worst of the three.

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