-
Notifications
You must be signed in to change notification settings - Fork 646
Add coreml quant recipes #13265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gh/abhinaykukkadapu/4/head
Are you sure you want to change the base?
Add coreml quant recipes #13265
Conversation
Stack from ghstack (oldest at bottom): |
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/13265
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
) | ||
elif recipe_type == CoreMLRecipeType.INT4_WEIGHT_ONLY_PER_GROUP: | ||
group_size = kwargs.pop("group_size", 32) | ||
return self._build_torchao_quantized_recipe( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the compute precision used in these quantization recipes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@metascroy It is FLOAT16, see _get_coreml_lowering_recipe
function defaults.
# All TorchAO recipes accept filter_fn kwarg to control which layers are quantized | ||
# INT4 Weight-only Quantization, per-channel (axis=0) | ||
# Additional kwargs: filter_fn (default: None - quantizes linear layers) | ||
INT4_WEIGHT_ONLY_PER_CHANNEL = "coreml_int4_weight_only_per_channel" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add torchao somewhere in the name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add something like TORCHAO_ INT4_WEIGHT_ONLY_PER_CHANNEL format. I'm also modifying the xnnpack enums as well to this format.
INT8_WEIGHT_ONLY_PER_GROUP = "coreml_int8_weight_only_per_group" | ||
|
||
## Codebook/Palettization Quantization | ||
# Additional kwargs: bits (1-8, default: 3), block_size (default: [-1, 16]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we should have a default bitwidth/block_size for codebook. Similarly, I'm not sure if we should have default group_size for per-group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to remove both defaults, bit width and block_size
INT4_WEIGHT_ONLY_PER_CHANNEL = "coreml_int4_weight_only_per_channel" | ||
# INT4 Weight-only Quantization, per-group | ||
# Additional kwargs: group_size (default: 32), filter_fn (default: None - quantizes linear layers) | ||
INT4_WEIGHT_ONLY_PER_GROUP = "coreml_int4_weight_only_per_group" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if all the torchao recipes should use the same default filter_fn to be less confusing.
Right now, codebook is using nn.Linear/nn.Embedding, but the other ones are using None (defaults to linear).
Maybe make None default for all (linear only) or make linear/embedding default for all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep it broad, may be, linear/embedding default enables more usecases?
Overall looks good. Address comments then feel free to merge. |
Adds coreml quant recipes after FP32/16 recipes added in #13121
Recipes added: