59 Commits

Author SHA1 Message Date
Aseem Wadhwa e12202c1f6 Merge pull request #368 from Aintor/main
Fix for Mask Patch Failure and Quantization Issues in Latest `transformers` Versions
2025-07-03 11:01:02 -07:00
Kushvinth-Madhavan e17915a9cb Add --min-deployment-target argument for configurable iOS/macOS deployment targets
- Added --min-deployment-target argument with default value macOS13 for backward compatibility
- Supports macOS13, macOS14, macOS15, iOS16, iOS17, iOS18 targets
- Graceful fallback for newer targets not available in older coremltools versions
- Enables targeting iOS 18 for advanced quantization features while maintaining compatibility
- Includes comprehensive help text explaining usage and compatibility requirements
2025-06-14 08:27:06 -07:00
NehalBhandari f8e36141a9 Add support for mixed precision activation quantization for UNet model (#365) 2024-11-15 16:05:22 -08:00
Jason Wong 50bb4c43d0 Update torch2coreml.py 2024-11-12 11:19:16 +08:00
Jason Wong 7e3df29361 Update torch2coreml.py 2024-11-12 10:36:17 +08:00
Jason Wong 4ef83f13d0 Update torch2coreml.py 2024-11-12 10:31:26 +08:00
Jason Wong 244703046f Update torch2coreml.py 2024-11-11 00:13:05 +08:00
Toby Roseman 7505f91208 Add option for sequential unet predictions 2024-10-23 14:23:19 -07:00
Alex Kennedy 6365319010 fix: Remove duplicate logger instantiation 2024-10-15 19:41:54 -07:00
Toby Roseman e497107793 Allow not using classifier free guidance 2024-10-04 11:10:18 -07:00
Toby Roseman 3e04bcecf3 On macOS 15+, set fast prediction optimization hint for the unet. 2024-09-18 09:26:45 -07:00
Toby Roseman aa0ec6e569 Do not force zeros embeddings for empty prompt, unless using XL 2024-09-17 13:21:33 -07:00
HenryT c6884bf3b5 add some logging 2024-08-23 11:31:46 -07:00
HenryT 3fc577cc41 fix typo 2024-08-22 16:20:24 -07:00
HenryT f7b2618c0d refactor the model chunking script to work with all version of coremltools 2024-08-22 14:24:46 -07:00
Zach Nagengast c891f4357b Add SD3 Pipeline (#329)
* Add SD3 Pipeline

Co-authored-by: atiorh <atiorh@users.noreply.github.com>
Co-authored-by: arda-argmax <arda-argmax@users.noreply.github.com>

* Use swift-transformers for tokenization

* Use diffusionkit converters in torch2coreml

* Documentation and cleanup

* Add model link

* Consolidate batch prediction logic

* Remove DecoderSD3.swift and consolidate logic into Decoder.swift

* Remove DiffusionKit MLX inference reference from README

---------

Co-authored-by: atiorh <atiorh@users.noreply.github.com>
Co-authored-by: arda-argmax <arda-argmax@users.noreply.github.com>
Co-authored-by: atila <atiorh@icloud.com>
2024-07-22 21:16:50 -07:00
Toby Roseman 9a3d463397 Applying mixed bit compression using new optimize API 2024-01-17 15:43:08 -08:00
Toby Roseman 4c54204bb0 Compiled Models in Python 2023-11-07 12:13:31 -08:00
Toby Roseman d159b9254c Fix pipeline.py for Python 3.8 2023-10-23 10:27:56 -07:00
Atila Orhon 567dbf2757 fixes #281 2023-10-20 22:45:43 -07:00
Jiangdi f4466f0b73 fix error (#279) 2023-10-10 12:15:08 -07:00
Zach Nagengast 7fe1bf23b9 Cast safety_checker to float32 (#276) 2023-10-06 20:54:39 -07:00
Atila Orhon 11ba3a0965 Add custom_vae_version in MBP pre-analysis 2023-09-30 19:44:01 -07:00
Atila Orhon 081a8cb2cc v1.1 2023-09-28 07:26:41 -07:00
Atila Orhon d0d05ce44d Fix compute unit for chunk_mlprogram parity checks 2023-09-26 13:21:15 -07:00
Hector Lopez Hernandez, PhD f3a212491c Xl python inference (#261)
* Updated pipeline.py for XL inference

* cleaned up

* Add shape handling for UNET time_ids shape

* added support for loading from CompiledMLModel
2023-09-26 13:12:07 -07:00
Zach Nagengast 94dfc6b548 Support for SDXL refiner (#227)
* Initial support for SDXL refiner

* Cleanup

* Add arg for converting Unet in float32 precision

* Setup scale factor with pipeline in CLI

* Update cli arg and future warning

* Bundle refiner unet if specified

* Update script for bundled refiner

- Also skip loading model if check_output_correctness is missing, since the model does not require inferencing at conversion time

* Flip skip_model_load bool

* Cleanup

* Support bundled UnetRefiner

* Add seperate refiner config value

- Includes unloading base unet when swapping to refiner

* Update readme for SDXL refiner

* Add condition for new SDXL coreml input features

* Revert pipeline interface change, add extra logging on pipe load

* Reset model_version after refiner conversion

* Reset model_version before refiner conversion but after pipe init

* Add refiner chunking

* Ensure unets are unloaded for reduceMemory true

* Handle missing UnetRefiner.mlmodelc on pipeline load

Co-authored-by: Pedro Cuenca <pedro@huggingface.co>

* Prewarm refiner on load, unload on complete

* Force cpu_and_gpu for VAE until it can be fixed

* Include output dtype of np.float32 for all conversions

* Allow a custom VAE to be converted.

* Revert hardcoded reduceMemory

* Fix merge

* Default chunking arg for --merge-chunks-in-pipeline-model when called from torch2coreml

---------

Co-authored-by: Pedro Cuenca <pedro@huggingface.co>
2023-09-26 13:09:58 -07:00
Atila Orhon d22986190b Support pipeline model creation for chunks 2023-09-23 09:24:59 -07:00
Atila Orhon e3c1e36e18 SDXL refiner mixed-bit palettization pre-analysis 2023-09-23 09:24:59 -07:00
Toby Roseman cf4afe150b Fix boundary var issue when chunking model with coremltools 7.0 (#259) 2023-09-20 14:01:19 -07:00
Atila Orhon ebff5f7402 fixes #246 2023-08-29 06:43:07 -07:00
Aseem Wadhwa 35613e5d34 update chunking script to work with models that contains compressed weights, i.e. constexpr* ops (#245) 2023-08-29 04:57:30 -07:00
Atila Orhon 40ff5f5f1f fixes #244 2023-08-28 10:51:47 -07:00
Pedro Cuenca df1c41c373 Upgrade coremltools, transformers; remove attn workaround (#241) 2023-08-24 22:17:44 +03:00
Pedro Cuenca 27df66021d Remove mlpackage save workaround. (#240)
https://github.com/apple/coremltools/issues/1680 has been resolved in
coremltools 7.0b1, which is now required. The reason for addressing this
change now is that reloading the model before save may incur a
performance cost (specially on SDXL models) due to `ANECompilerService`
triggering and executing for a long time.
2023-08-24 22:16:28 +03:00
Thibault Castells dc8deb3b1e Fix multiple issues in mixed bit compression pre analysis (#231)
* fix multiple issues in mixed bit compression pre analysis: wrong dtype, cannot change default nbits and ImportError

* fixed dtype issue in fake_palettize function

---------

Co-authored-by: Thibault <thibault@Thibaults-Mac-mini.local>
2023-08-22 00:00:22 +03:00
Atila Orhon 7e106460e3 fix import 2023-08-02 20:30:45 -10:00
Atila Orhon 8cf34376f9 SDXL and other improvements
Co-authored-by: Pedro Cuenca <pedro@huggingface.co>
Co-authored-by: Zach Nagengast <zacharynagengast@gmail.com>
2023-07-27 09:08:30 -10:00
Atila Orhon a57d127606 Mixed-bit Palettization
Co-authored-by: Pedro Cuenca <pedro@huggingface.co>
2023-07-27 09:07:44 -10:00
Atila Orhon 7f9c58a6c1 WWDC23 update
Co-authored-by: davidfindlay1 <david.arthur.findlay@icloud.com>
2023-06-14 08:27:02 -07:00
Zsolt Váradi e3875a584b Add device parameter to overridden _build_causal_attention_mask (#184) 2023-05-16 21:17:44 +09:00
Atila Orhon efea9d3812 Fix encoder sdpa disable 2023-04-29 22:07:27 -07:00
Atila Orhon ef5aa89c45 Disable SDPA for vae_encoder 2023-04-28 21:15:57 -07:00
Pedro Cuenca 449a16d96e Disable SDPA (PyTorch 2.0) in the VAE (#174)
* Disable SDPA (PyTorch 2.0) in the VAE

Diffusers 0.16.0 made sdpa enabled by default in the vae. It had
previously been enabled for the UNet, but it didn't affect this repo
because it uses its own copy of the UNet.

This fix will not work for diffusers 0.16.0, but it will for main or
0.16.1 (to be released today).

* Link to coremltools issue.
2023-04-28 21:14:25 -07:00
Pedro Cuenca 41174b937b Minor: make --help work. (#175) 2023-04-28 21:13:36 -07:00
Pedro Cuenca 4aafa737ba Verify ControlNet base model. (#172)
We currently display a warning if the ControlNet repo does not contain a
`base_model` property and the `model-version` is not SD 1.5.

If the ControlNet repo does indicate a `base_model` property, then we
raise a hard error if the versions don't match.
2023-04-27 15:53:10 -07:00
Atila Orhon 412c679d25 Fixes #160 2023-04-24 12:13:30 -07:00
Atila Orhon ce0be82717 Fixes #165 2023-04-23 21:17:59 -07:00
Chimme 7f65e1c84b Support ControlNet (#153)
* add controlnet tentatively

* add controlnet in python code

* implement swift part

* support 8-bit quantization

* add controlnet unload when reduce memory

* remove irrelevant changes

* add more description about controlnet option in swift

* fix some for pr and update README

* pre-allocate zero shapedArray + make multi-controlnet faster
2023-04-18 16:17:59 -07:00
Atila Orhon d1a6888d43 fixes #155 2023-04-13 08:56:20 -07:00