Skip to content

Commit 0016340

Browse files
committed
doc change
1 parent ef87a8b commit 0016340

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

docs-guides/source/mlmodel-utilities.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,20 @@ compressed_mlmodel = cto.coreml.palettize_weights(mlmodel, config)
175175

176176
## Bisect Model
177177

178-
When working with large Core ML models, for instance a big [Stable Diffusion](https://github.com/apple/ml-stable-diffusion) model, the process might be killed due to memory issues. You can solve the issue by chunking the previously exported model into two pieces, and combine them into a Core ML pipeline model.
178+
In certain scenarios, you may want to break a large Core ML model into two smaller models. For instance, if you are deploying a model to run on neural engine on an iPhone, it cannot be larger than 1 GB. If you are working with, say, [Stable Diffusion](https://github.com/apple/ml-stable-diffusion) 1.5 model which is 1.72 GB large (Float 16 precision), then it needs to be broken up into two chunks, each less than 1 GB. The utility `ct.models.utils.bisect_model` will allow you to do exactly that. When using this API, you can also opt-in to package the two chunks of the model into a pipeline model, so that its still a single mlpackage file, with the two models arranged in a sequential manner.
179179

180-
The example below shows how to bisect a model, test the accuracy, and savethem on disk.
180+
The example below shows how to bisect a model, test the accuracy, and save them on disk.
181181

182182
```python
183+
183184
import coremltools as ct
184185

185186
model_path = "my_model.mlpackage"
186187
output_dir = "./output/"
187188

188189
# The following code will produce two chunks models:
189190
# `./output/my_model_chunk1.mlpackage` and `./output/my_model_chunk2.mlpackage`
191+
# It also compares the output numerical of the original Core ML model with the chunked models.
190192
ct.models.utils.bisect_model(
191193
model_path,
192194
output_dir,
@@ -199,15 +201,6 @@ ct.models.utils.bisect_model(
199201
merge_chunks_to_pipeline=True,
200202
)
201203

202-
# If you want to compare the output numerical of the original Core ML model with the chunked models / pipeline,
203-
# the following code will do so and report the PSNR in dB.
204-
# Please note that, this feature is going to use more memory.
205-
ct.models.utils.bisect_model(
206-
model_path,
207-
output_dir,
208-
check_output_correctness=True,
209-
)
210-
211204
# You can also pass the MLModel object directly
212205
mlmodel = ct.models.MLModel(model_path)
213206
ct.models.utils.bisect_model(

0 commit comments

Comments
 (0)