]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
bindings-java : disable flash attention by default (#3445)
authorDaniel Bevenius <redacted>
Wed, 1 Oct 2025 07:13:34 +0000 (09:13 +0200)
committerGitHub <redacted>
Wed, 1 Oct 2025 07:13:34 +0000 (09:13 +0200)
This commit disables flash-attention for the Java binding test so that
the testFullTranscribe test passes.

Without this change the test was failing because the expected output
mismatches after the flash-attention change:
```console
<And so my fellow Americans ask not what your country can do for you ask what you can do for your country.>
but was:
<and so my fellow Americans ask not what your country can do for you ask what you can do for your country>
```

An alternative would also be to update the expected output but it felt
better to keep the same expected output and disable flash-attention and
not just change the expected output to match the new behavior.

bindings/java/src/main/java/io/github/ggerganov/whispercpp/params/WhisperContextParams.java
bindings/java/src/test/java/io/github/ggerganov/whispercpp/WhisperCppTest.java

index 4bcdb6b0401864ac0c914d79d0f67542118515f1..66ec5d7046553442b23eb52a57206617b89c0202 100644 (file)
@@ -20,7 +20,7 @@ public class WhisperContextParams extends Structure {
     /** Use GPU for inference (default = true) */
     public CBool use_gpu;
 
-    /** Use flash attention (default = false) */
+    /** Use flash attention (default = true) */
     public CBool flash_attn;
 
     /** CUDA device to use (default = 0) */
index bf37e5199922774b022e6f3164481292e14d3839..e5b22cf8de8eb07109771613127ed20d8a3c99f5 100644 (file)
@@ -4,6 +4,7 @@ import static org.junit.jupiter.api.Assertions.*;
 \r
 import io.github.ggerganov.whispercpp.bean.WhisperSegment;\r
 import io.github.ggerganov.whispercpp.params.CBool;\r
+import io.github.ggerganov.whispercpp.params.WhisperContextParams;\r
 import io.github.ggerganov.whispercpp.params.WhisperFullParams;\r
 import io.github.ggerganov.whispercpp.params.WhisperSamplingStrategy;\r
 import org.junit.jupiter.api.BeforeAll;\r
@@ -25,7 +26,9 @@ class WhisperCppTest {
         //String modelName = "../../models/ggml-tiny.bin";\r
         String modelName = "../../models/ggml-tiny.en.bin";\r
         try {\r
-            whisper.initContext(modelName);\r
+            WhisperContextParams.ByValue contextParams = whisper.getContextDefaultParams();\r
+            contextParams.useFlashAttn(false);  // Disable flash attention\r
+            whisper.initContext(modelName, contextParams);\r
             //whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_GREEDY);\r
             //whisper.getJavaDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_BEAM_SEARCH);\r
             modelInitialised = true;\r