Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions backends/apple/coreml/recipes/coreml_recipe_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def create_recipe(
recipe_type, activation_dtype=torch.float32, **kwargs
)
elif recipe_type == CoreMLRecipeType.TORCHAO_INT4_WEIGHT_ONLY_PER_CHANNEL:
self._validate_and_set_deployment_target(kwargs, ct.target.iOS18, "torchao")
return self._build_torchao_quantized_recipe(
recipe_type,
weight_dtype=torch.int4,
Expand All @@ -77,6 +78,7 @@ def create_recipe(
)
elif recipe_type == CoreMLRecipeType.TORCHAO_INT4_WEIGHT_ONLY_PER_GROUP:
group_size = kwargs.pop("group_size", 32)
self._validate_and_set_deployment_target(kwargs, ct.target.iOS18, "torchao")
return self._build_torchao_quantized_recipe(
recipe_type,
weight_dtype=torch.int4,
Expand All @@ -85,11 +87,14 @@ def create_recipe(
**kwargs,
)
elif recipe_type == CoreMLRecipeType.TORCHAO_INT8_WEIGHT_ONLY_PER_CHANNEL:
self._validate_and_set_deployment_target(kwargs, ct.target.iOS16, "torchao")
return self._build_torchao_quantized_recipe(
recipe_type, weight_dtype=torch.int8, is_per_channel=True, **kwargs
)
elif recipe_type == CoreMLRecipeType.TORCHAO_INT8_WEIGHT_ONLY_PER_GROUP:
group_size = kwargs.pop("group_size", 32)
# override minimum_deployment_target to ios18 for torchao (GH issue #13122)
self._validate_and_set_deployment_target(kwargs, ct.target.iOS18, "torchao")
return self._build_torchao_quantized_recipe(
recipe_type,
weight_dtype=torch.int8,
Expand Down Expand Up @@ -312,8 +317,6 @@ def _build_torchao_quantized_recipe(
ao_quantization_configs=[config],
)

# override minimum_deployment_target to ios18 for torchao (GH issue #13122)
self._validate_and_set_deployment_target(kwargs, ct.target.iOS18, "torchao")
lowering_recipe = self._get_coreml_lowering_recipe(**kwargs)

return ExportRecipe(
Expand Down
2 changes: 1 addition & 1 deletion backends/apple/coreml/test/test_coreml_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def test_minimum_deployment_target_validation(self):
(CoreMLRecipeType.TORCHAO_INT4_WEIGHT_ONLY_PER_GROUP, ct.target.iOS18, {}),
(
CoreMLRecipeType.TORCHAO_INT8_WEIGHT_ONLY_PER_CHANNEL,
ct.target.iOS18,
ct.target.iOS16,
{},
),
(CoreMLRecipeType.TORCHAO_INT8_WEIGHT_ONLY_PER_GROUP, ct.target.iOS18, {}),
Expand Down
Loading