-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
coreml : revisit instructions and model generation scripts #2783
Comments
how to integrate .mlmodelc into my swiftui app? I am stuck here? I want to use coreml support. is there any example that I can follow? |
The swiftui example currently does not have support for coreml, but the objective-c example does, and it contains a link to how to convert models. Perhaps these could be helpful to implement in swift. |
I am very beginner in obj C... Would it be possible for you guys to make swift ui example? I think a lot of people would appreciate that because as saw in many other repos people were requesting the same thing. |
Perhaps we can update the existing whisper.swiftui example similar to whisper.objc. I've created #2907 to track this. |
If I am not mistaken, it might be as simple as adding |
Nice, I'll give this a try. Thanks |
Hmm, this was not as simple because of the introduction of the xcframework. We are no longer compiling in XCode but instead using the compiled library from the xcframework. And Core ML support requires the above mentioned macro to be set when compiling. My initial throught was that we could provide builds for Core ML for macos and ios and include them in the xcframework, but that does not work as the selection is based on platform and architecture, so trying to create the xcframework results in: A library with the identifier 'macos-arm64_x86_64' already exists. I'll need to investigate this a little more to understand what our options are. |
I think we can enable both |
That would be much things much easier. Great, I'll try this out. |
@furqan4545 We've added an example of using Core ML to the whisper.swiftui example now. |
@danbev and @ggerganov YOU GUYS ARE HERO. I am extremely grateful. |
You should be able to use the master branch now. You are correct, there have been no changes to the swift-ui code, the changes have been to the xcframework that now builds with Core ML support. This will enable a Core ML model to be used by the example. Just make sure that you build/rebuild the xcframework using |
@danbev Thank you so much Dan again for the explanation. I will give it a try tomorrow. |
One thing I noticed while going through the Core ML support is that currently it is required that the original ggml model is also available on the file system. The ggml model will be loaded first, before the Core ML encoder model. I initially thought that this might be an an oversight, that using a Core ML model would only require the converted model, but I believe the original model is still required for the decoder. Perhaps this could be clarified in the docs. |
Yes, this is correct. We should update the docs to highlight this. |
This commit disables the use of PyTorch's `scaled_dot_product_attention` in the Whisper model to avoid compatibility issues during CoreML conversion. The issue occurs because coremltools requires PyTorch 2.5.0, but the Whisper implementation may expect behavior from newer PyTorch versions. By setting `MultiHeadAttention.use_sdpa = False`, we force Whisper to use its fallback manual attention implementation, which works correctly with PyTorch 2.5.0 during the tracing process. Refs: ggml-org#2783
This commit adds a new job to the CI pipeline that downloads the base.en model and converts it to CoreML format. The CoreML model is then packed into a zip file and uploaded as an artifact. Refs: ggml-org#2783
This commit adds a new job to the CI pipeline that downloads the base.en model and converts it to CoreML format. The CoreML model is then packed into a zip file and uploaded as an artifact. Refs: ggml-org#2783
This commit adds a new job to the CI pipeline that downloads the base.en model and converts it to CoreML format. The CoreML model is then packed into a zip file and uploaded as an artifact. This will only be done for pushes to master, releases, or pre-releases. Refs: ggml-org#2783
* ci : add coreml job that converts base.en to coreml [no ci] This commit adds a new job to the CI pipeline that downloads the base.en model and converts it to CoreML format. The CoreML model is then packed into a zip file and uploaded as an artifact. This will only be done for pushes to master, releases, or pre-releases. Refs: #2783 * coreml : remove publishing of coreml model * ci : add GGML_OPENMP=OFF to ubuntu-22-gcc-sanitized
This commit disables the use of PyTorch's `scaled_dot_product_attention` in the Whisper model to avoid compatibility issues during CoreML conversion. The issue occurs because coremltools requires PyTorch 2.5.0, but the Whisper implementation may expect behavior from newer PyTorch versions. By setting `MultiHeadAttention.use_sdpa = False`, we force Whisper to use its fallback manual attention implementation, which works correctly with PyTorch 2.5.0 during the tracing process. Refs: ggml-org#2783
…2979) * coreml: fix Whisper to CoreML conversion by disabling SDPA This commit disables the use of PyTorch's `scaled_dot_product_attention` in the Whisper model to avoid compatibility issues during CoreML conversion. The issue occurs because coremltools requires PyTorch 2.5.0, but the Whisper implementation may expect behavior from newer PyTorch versions. By setting `MultiHeadAttention.use_sdpa = False`, we force Whisper to use its fallback manual attention implementation, which works correctly with PyTorch 2.5.0 during the tracing process. Refs: #2783 * coreml: fix audio shape in whisper decoder conversion This commit fixes the audio shape in the whisper decoder conversion script. The motivation for this is that the audio shape was incorrect and was causing the conversion to fail. * coreml : set -e in generate-coreml-interface.sh The commit sets the -e flag in the generate-coreml-interface.sh script to make sure the script fails if any command fails. * coreml : update generated encoder/decoder interfaces This commit updates the generated encoder/decoder interfaces for the whisper model which is the result of running the generate-coreml-interface.sh script.
This commit clarifies the usage of the Core ML encoder model in the whisper.obj and whisper.swiftui examples. Refs: ggml-org#2783
This commit clarifies the usage of the Core ML encoder model in the whisper.obj and whisper.swiftui examples. Refs: #2783
The CoreML creation process has been flaky from the very beginning (#566), mainly because the python packages were not compatible with each other. Things likely have changed since the initial support was added and hopefully are more stable now.
The text was updated successfully, but these errors were encountered: