Skip to content

fix: raise CoreMLExportError on incompatible palettization configs#44

Open
guru-desh wants to merge 3 commits into
apple:mainfrom
guru-desh:expand-coreml-export-error
Open

fix: raise CoreMLExportError on incompatible palettization configs#44
guru-desh wants to merge 3 commits into
apple:mainfrom
guru-desh:expand-coreml-export-error

Conversation

@guru-desh

@guru-desh guru-desh commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Stacked on #42 — this branch is rebased onto remove-coreml-export-tests, so this diff includes #42's commits plus 3 new ones on top. Once #42 merges, only the last 3 commits here will remain.

In our test suite, we had pytest.skip some incompatible palettization configs, but this doesn't prevent users from using these configs.

We refactor the test by removing pytest.skip and changing the tests to check that CoreMLExportError is raised. We also create validate_coreml_palettization_compatibility that contains the logic that decides when CoremlExportError is raised.

@guru-desh guru-desh added the bug Something isn't working label Jul 18, 2026
@guru-desh
guru-desh requested review from dengqiaoyu and u-simha July 18, 2026 07:25
…hecks

Vector palettization, LUT quantization, and per-channel scale are each
independently CoreML-exportable, but combining any two breaks CoreML/MIL's
constexpr_lut_to_dense op with a rank mismatch, a missing vector_axis, or an
indices/LUT divisibility error depending on the pair. Add a dedicated
validator (composing the existing LUT dtype check) so the kmeans export path
has one entry point to reject these combinations with a clear
CoreMLExportError, instead of relying on a test-side skip to hide them.
…port

Wire validate_coreml_palettization_compatibility into prepare_for_mil_export
so finalize(backend=CoreML) raises immediately for a combo it can't fuse
into a single compatible op chain, rather than emitting an invalid model or
crashing deep inside ct.convert.
Replace the pytest.skip-based _skip_unsupported_mil_configs with a predicate
(_has_unsupported_mil_combo) and assert finalize() raises CoreMLExportError,
mirroring the existing float-LUT-dtype rejection path. Rename
_assert_coreml_rejects_unsupported_lut to _assert_coreml_rejects since it's
now shared by both rejection cases.
@guru-desh
guru-desh force-pushed the expand-coreml-export-error branch from c5241ef to 3b64cc1 Compare July 20, 2026 21:41
@guru-desh
guru-desh marked this pull request as ready for review July 20, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants