-
Notifications
You must be signed in to change notification settings - Fork 736
Open
Labels
PyTorch (traced)bugUnexpected behaviour that should be corrected (type)Unexpected behaviour that should be corrected (type)triagedReviewed and examined, release as been assigned if applicable (status)Reviewed and examined, release as been assigned if applicable (status)
Description
🐞Describing the bug
When converting a model with a minimal pipeline, adding 16-bit passes causes the conversion to hang indefinitely, and it can only be stopped with an external kill. This also happens in the default pipeline when compute_precision=ct.precision.FLOAT16 is specified.
To Reproduce
import coremltools as ct
def convert_to_coreml_with_consistent_results(model):
pipeline = ct.PassPipeline(
pass_names=[
"common::const_elimination",
"common::const_deduplication",
"common::remove_symbolic_reshape",
"common::noop_elimination",
"common::merge_consecutive_relus",
"common::merge_consecutive_reshapes",
"common::merge_consecutive_transposes",
"common::dedup_op_and_var_names",
"common::dead_code_elimination", # always end with dce
],
pipeline_name="minimal_pipeline",
)
ml_model = ct.convert(
model,
outputs=[
ct.TensorType(
name="depth_b1hw",
),
ct.TensorType(
name="mask_logits_b1hw",
),
],
debug=False,
compute_units=ct.ComputeUnit.ALL,
compute_precision=ct.precision.FLOAT32,
minimum_deployment_target=ct.target.iOS17,
pass_pipeline=pipeline,
)
ml_model.save("ConsistentResults.mlmodel")
def convert_to_coreml_hangs(model):
pipeline = ct.PassPipeline(
pass_names=[
"common::const_elimination",
"common::const_deduplication",
"common::remove_symbolic_reshape",
"common::noop_elimination",
"common::merge_consecutive_relus",
"common::merge_consecutive_reshapes",
"common::merge_consecutive_transposes",
"common::dedup_op_and_var_names",
"common::add_fp16_cast",
"common::add_int16_cast",
"common::update_output_dtypes",
"common::dead_code_elimination",
],
pipeline_name="minimal_pipeline",
)
ml_model = ct.convert(
model,
outputs=[
ct.TensorType(
name="depth_b1hw",
),
ct.TensorType(
name="mask_logits_b1hw",
),
],
compute_units=ct.ComputeUnit.ALL,
compute_precision=ct.precision.FLOAT16,
minimum_deployment_target=ct.target.iOS17,
pass_pipeline=pipeline,
)
# we never get here but just in case
ml_model.save("Hangs.mlmodel")
System environment (please complete the following information):
- coremltools version: 8.3.0
- OS (e.g. MacOS version or Linux type): MacOS Version 15.7.1 (24G231)
- Any other relevant version information (e.g. PyTorch or TensorFlow version):
torch==2.5.1
torchvision==0.20.1
Metadata
Metadata
Assignees
Labels
PyTorch (traced)bugUnexpected behaviour that should be corrected (type)Unexpected behaviour that should be corrected (type)triagedReviewed and examined, release as been assigned if applicable (status)Reviewed and examined, release as been assigned if applicable (status)