fix: raise CoreMLExportError on incompatible palettization configs#44
Draft
guru-desh wants to merge 6 commits into
Draft
fix: raise CoreMLExportError on incompatible palettization configs#44guru-desh wants to merge 6 commits into
guru-desh wants to merge 6 commits into
Conversation
Weight/activation/LUT dtype checks and the activation-granularity check were duplicated across the eager, graph, and palettization export paths. Consolidate them into validate_coreml_compatibility() so CoreML's actual export constraints live in one place, including the per-channel/per-block activation restriction: an upstream coremltools MIL optimizer pass can silently corrupt per-channel-quantized activations across reshape boundaries, so CoreML export now rejects that configuration outright instead of letting it through to a numerics-level failure.
…eML export CoreML export now rejects these configs outright instead of letting them through to a numerics-level SNR failure. Replace the xfail-based coverage with direct CoreMLExportError assertions, and collapse the now-redundant per-axis/per-dtype combinatorial sweeps since the rejection doesn't depend on any of those variables.
…clarity assert_coreml_finalize_rejects_unsupported_dtype and COREML_DTYPE_REJECTION_MATCH are now used for granularity rejections too, not just dtype ones, so their names no longer matched what they check.
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.skipsome incompatible palettization configs, but this doesn't prevent users from using these configs.We refactor the test by removing
pytest.skipand changing the tests to check thatCoreMLExportErroris raised. We also createvalidate_coreml_palettization_compatibilitythat contains the logic that decides whenCoremlExportErroris raised.