Skip to content
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

[Torch] Support FP16 Conversion #2429

Open
YifanShenSZ opened this issue Jan 9, 2025 · 0 comments
Open

[Torch] Support FP16 Conversion #2429

YifanShenSZ opened this issue Jan 9, 2025 · 0 comments
Labels
feature request Functionality does not currently exist, would need to be created as a new feature (type)

Comments

@YifanShenSZ
Copy link
Collaborator

As of now, our torch converter

  1. Assumes the given torch model is in fp32 compute precision (i.e. weights and activations are all in fp32)
  2. Converts torch model as is (i.e. no treatments such as promoting types)
  3. Sandwichs ops with cast(fp16) -> op -> cast(fp32) then eliminate cancelling casts to obtain fp16 compute precision

This works in most cases: people usually can call torch_model.to(torch.float32) then invoke coremltools.convert. However, there are cases where developers request conversion support for fp16 or mixed fp16-fp32 torch models

  1. Remove state cast to fp32 #2423 fp32 torch model would be too big to fit in memory
  2. Skip casting model inputs to fp32 if weights and inputs are all fp16 #2274
  3. Avoid fp32 cast for Torch div operator #2241
@YifanShenSZ YifanShenSZ added the feature request Functionality does not currently exist, would need to be created as a new feature (type) label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Functionality does not currently exist, would need to be created as a new feature (type)
Projects
None yet
Development

No branches or pull requests

1 participant