Refactor the model chunking script to work with all version of coremltools#354
Merged
TobyRoseman merged 3 commits intoapple:mainfrom Aug 23, 2024
Merged
Conversation
aseemw
approved these changes
Aug 22, 2024
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.
8.0b2, they introduced an utilct.models.utils.bisect_model(Add bisect_model API under ct.models.utils coremltools#2286),in which does the same thing as
chunk_mlprogram.py, with a more robust implementation.For instance, taking the source CoreML model spec version into account.
chunk_mlprogram.pyworks on oldercoremltools, like7.2, which has been reported a bug (chunk unet does not work with coremltool>7.1 #333).coremltoolsversion>=8.0b2, we refactor the script to directly call intobisect_modelAPI.coremltools>=8.0Testing:
python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --convert-text-encoder --convert-vae-decoder --convert-safety-checker --model-version CompVis/stable-diffusion-v1-4 -o ../../model_zoo --chunk-unetran on both
coremltools==8.0b2andcoremltools==7.2