]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commit
coreml: fix Whisper to CoreML conversion by disabling SDPA [no ci] (#2979)
authorDaniel Bevenius <redacted>
Tue, 1 Apr 2025 16:01:23 +0000 (18:01 +0200)
committerGitHub <redacted>
Tue, 1 Apr 2025 16:01:23 +0000 (18:01 +0200)
commit11688b262f0e4836107cfaad34be9d28b27a0c24
treeafabea31ea0f4fb2734c10eea3700cd4f4175bf7
parent04b9508fb3bb4556763f6addf3e53a6edabdef4b
coreml: fix Whisper to CoreML conversion by disabling SDPA [no ci] (#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: https://github.com/ggerganov/whisper.cpp/issues/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.
models/convert-whisper-to-coreml.py
models/generate-coreml-interface.sh
src/coreml/whisper-decoder-impl.h
src/coreml/whisper-decoder-impl.m
src/coreml/whisper-encoder-impl.h
src/coreml/whisper-encoder-impl.m