Skip to content

Commit 53acd7d

Browse files
committed
Merge remote-tracking branch 'ggerganov/master' into fix_decoding
* ggerganov/master: readme : update links and make commands (ggml-org#2489) ruby : fix bindings (ggml-org#2484) readme : add Vulkan notice (ggml-org#2488) make : fix GGML_VULKAN=1 build (ggml-org#2485) whisper : add dtw preset for large-v3-turbo (ggml-org#2481) convert : handle max_target_positions (ggml-org#2477) readme : update the Quick Start section (ggml-org#2475) whisper : add OpenVINO init with state (ggml-org#2464)
2 parents f0d3bb9 + a5abfe6 commit 53acd7d

28 files changed

+301
-17764
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Bindings Tests (Ruby)
2+
on:
3+
push:
4+
paths:
5+
- bindings/ruby/**
6+
- src/whisper.cpp
7+
- include/whisper.h
8+
- ggml/src/ggml.c
9+
- ggml/src/ggml-impl.h
10+
- ggml/src/ggml-aarch64.h
11+
- ggml/src/ggml-aarch64.c
12+
- ggml/src/ggml-alloc.c
13+
- ggml/src/ggml-backend-impl.h
14+
- ggml/src/ggml-backend.cpp
15+
- ggml/src/ggml-common.h
16+
- ggml/src/ggml-quants.h
17+
- ggml/src/ggml-quants.c
18+
- ggml/src/ggml-cpu-impl.h
19+
- ggml/include/ggml.h
20+
- ggml/include/ggml-alloc.h
21+
- ggml/include/ggml-backend.h
22+
- ggml/include/ggml-cuda.h
23+
- ggml/include/ggml-kompute.h
24+
- ggml/include/ggml-metal.h
25+
- ggml/include/ggml-sycl.h
26+
- ggml/include/ggml-vulkan.h
27+
- examples/dr_wav.h
28+
pull_request:
29+
paths:
30+
- bindings/ruby/**
31+
- src/whisper.cpp
32+
- include/whisper.h
33+
- ggml/src/ggml.c
34+
- ggml/src/ggml-impl.h
35+
- ggml/src/ggml-aarch64.h
36+
- ggml/src/ggml-aarch64.c
37+
- ggml/src/ggml-alloc.c
38+
- ggml/src/ggml-backend-impl.h
39+
- ggml/src/ggml-backend.cpp
40+
- ggml/src/ggml-common.h
41+
- ggml/src/ggml-quants.h
42+
- ggml/src/ggml-quants.c
43+
- ggml/src/ggml-cpu-impl.h
44+
- ggml/include/ggml.h
45+
- ggml/include/ggml-alloc.h
46+
- ggml/include/ggml-backend.h
47+
- ggml/include/ggml-cuda.h
48+
- ggml/include/ggml-kompute.h
49+
- ggml/include/ggml-metal.h
50+
- ggml/include/ggml-sycl.h
51+
- ggml/include/ggml-vulkan.h
52+
- examples/dr_wav.h
53+
54+
jobs:
55+
ubuntu-latest:
56+
runs-on: ubuntu-latest
57+
defaults:
58+
run:
59+
working-directory: bindings/ruby
60+
steps:
61+
- uses: ruby/setup-ruby@v1
62+
with:
63+
ruby-version: '3.0'
64+
- uses: actions/checkout@v4
65+
- run: rake test

.github/workflows/bindings-ruby.yml.disabled

Lines changed: 0 additions & 23 deletions
This file was deleted.

Makefile

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ ifdef GGML_RPC
134134
BUILD_TARGETS += rpc-server
135135
endif
136136

137+
ifdef GGML_VULKAN
138+
BUILD_TARGETS += vulkan-shaders-gen
139+
endif
140+
137141
ifeq ($(shell sdl2-config --cflags --libs 2>/dev/null),)
138142
else
139143
BUILD_TARGETS += \
@@ -624,8 +628,8 @@ endif # GGML_CUDA
624628

625629
ifdef GGML_VULKAN
626630
MK_CPPFLAGS += -DGGML_USE_VULKAN
627-
MK_LDFLAGS += -lvulkan
628-
OBJ_GGML += ggml/src/ggml-vulkan.o
631+
MK_LDFLAGS += $(shell pkg-config --libs vulkan)
632+
OBJ_GGML += ggml/src/ggml-vulkan.o ggml/src/ggml-vulkan-shaders.o
629633

630634
ifdef GGML_VULKAN_CHECK_RESULTS
631635
MK_CPPFLAGS += -DGGML_VULKAN_CHECK_RESULTS
@@ -639,6 +643,10 @@ ifdef GGML_VULKAN_MEMORY_DEBUG
639643
MK_CPPFLAGS += -DGGML_VULKAN_MEMORY_DEBUG
640644
endif
641645

646+
ifdef GGML_VULKAN_PERF
647+
MK_CPPFLAGS += -DGGML_VULKAN_PERF
648+
endif
649+
642650
ifdef GGML_VULKAN_VALIDATE
643651
MK_CPPFLAGS += -DGGML_VULKAN_VALIDATE
644652
endif
@@ -647,10 +655,28 @@ ifdef GGML_VULKAN_RUN_TESTS
647655
MK_CPPFLAGS += -DGGML_VULKAN_RUN_TESTS
648656
endif
649657

650-
ggml/src/ggml-vulkan.o: \
651-
ggml/src/ggml-vulkan.cpp \
652-
ggml/include/ggml-vulkan.h
653-
$(CXX) $(CXXFLAGS) -c $< -o $@
658+
GLSLC_CMD = glslc
659+
_ggml_vk_genshaders_cmd = $(shell pwd)/vulkan-shaders-gen
660+
_ggml_vk_header = ggml/src/ggml-vulkan-shaders.hpp
661+
_ggml_vk_source = ggml/src/ggml-vulkan-shaders.cpp
662+
_ggml_vk_input_dir = ggml/src/vulkan-shaders
663+
_ggml_vk_shader_deps = $(echo $(_ggml_vk_input_dir)/*.comp)
664+
665+
ggml/src/ggml-vulkan.o: ggml/src/ggml-vulkan.cpp ggml/include/ggml-vulkan.h $(_ggml_vk_header) $(_ggml_vk_source)
666+
$(CXX) $(CXXFLAGS) $(shell pkg-config --cflags vulkan) -c $< -o $@
667+
668+
$(_ggml_vk_header): $(_ggml_vk_source)
669+
670+
$(_ggml_vk_source): $(_ggml_vk_shader_deps) vulkan-shaders-gen
671+
$(_ggml_vk_genshaders_cmd) \
672+
--glslc $(GLSLC_CMD) \
673+
--input-dir $(_ggml_vk_input_dir) \
674+
--target-hpp $(_ggml_vk_header) \
675+
--target-cpp $(_ggml_vk_source)
676+
677+
vulkan-shaders-gen: ggml/src/vulkan-shaders/vulkan-shaders-gen.cpp
678+
$(CXX) $(CXXFLAGS) -o $@ $(LDFLAGS) ggml/src/vulkan-shaders/vulkan-shaders-gen.cpp
679+
654680
endif # GGML_VULKAN
655681

656682
ifdef GGML_HIPBLAS

README.md

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@ Stable: [v1.7.1](https://github.com/ggerganov/whisper.cpp/releases/tag/v1.7.1) /
1212
High-performance inference of [OpenAI's Whisper](https://github.com/openai/whisper) automatic speech recognition (ASR) model:
1313

1414
- Plain C/C++ implementation without dependencies
15-
- Apple Silicon first-class citizen - optimized via ARM NEON, Accelerate framework, Metal and [Core ML](https://github.com/ggerganov/whisper.cpp#core-ml-support)
15+
- Apple Silicon first-class citizen - optimized via ARM NEON, Accelerate framework, Metal and [Core ML](#core-ml-support)
1616
- AVX intrinsics support for x86 architectures
1717
- VSX intrinsics support for POWER architectures
1818
- Mixed F16 / F32 precision
19-
- [4-bit and 5-bit integer quantization support](https://github.com/ggerganov/whisper.cpp#quantization)
19+
- [4-bit and 5-bit integer quantization support](#quantization)
2020
- Zero memory allocations at runtime
21+
- [Vulkan support](#vulkan-gpu-support)
2122
- Support for CPU-only inference
22-
- [Efficient GPU support for NVIDIA](https://github.com/ggerganov/whisper.cpp#nvidia-gpu-support-via-cublas)
23-
- [OpenVINO Support](https://github.com/ggerganov/whisper.cpp#openvino-support)
24-
- [Ascend NPU Support](https://github.com/ggerganov/whisper.cpp#ascend-npu-support)
23+
- [Efficient GPU support for NVIDIA](#nvidia-gpu-support)
24+
- [OpenVINO Support](#openvino-support)
25+
- [Ascend NPU Support](#ascend-npu-support)
2526
- [C-style API](https://github.com/ggerganov/whisper.cpp/blob/master/include/whisper.h)
2627

2728
Supported platforms:
@@ -72,6 +73,12 @@ First clone the repository:
7273
git clone https://github.com/ggerganov/whisper.cpp.git
7374
```
7475

76+
Navigate into the directory:
77+
78+
```
79+
cd whisper.cpp
80+
```
81+
7582
Then, download one of the Whisper [models](models/README.md) converted in [`ggml` format](#ggml-format). For example:
7683

7784
```bash
@@ -82,7 +89,7 @@ Now build the [main](examples/main) example and transcribe an audio file like th
8289

8390
```bash
8491
# build the main example
85-
make
92+
make -j
8693

8794
# transcribe an audio file
8895
./main -f samples/jfk.wav
@@ -93,7 +100,7 @@ make
93100
For a quick demo, simply run `make base.en`:
94101

95102
```text
96-
$ make base.en
103+
$ make -j base.en
97104
98105
cc -I. -O3 -std=c11 -pthread -DGGML_USE_ACCELERATE -c ggml.c -o ggml.o
99106
c++ -I. -I./examples -O3 -std=c++11 -pthread -c whisper.cpp -o whisper.o
@@ -217,26 +224,26 @@ ffmpeg -i input.mp3 -ar 16000 -ac 1 -c:a pcm_s16le output.wav
217224
If you want some extra audio samples to play with, simply run:
218225

219226
```
220-
make samples
227+
make -j samples
221228
```
222229

223230
This will download a few more audio files from Wikipedia and convert them to 16-bit WAV format via `ffmpeg`.
224231

225232
You can download and run the other models as follows:
226233

227234
```
228-
make tiny.en
229-
make tiny
230-
make base.en
231-
make base
232-
make small.en
233-
make small
234-
make medium.en
235-
make medium
236-
make large-v1
237-
make large-v2
238-
make large-v3
239-
make large-v3-turbo
235+
make -j tiny.en
236+
make -j tiny
237+
make -j base.en
238+
make -j base
239+
make -j small.en
240+
make -j small
241+
make -j medium.en
242+
make -j medium
243+
make -j large-v1
244+
make -j large-v2
245+
make -j large-v3
246+
make -j large-v3-turbo
240247
```
241248

242249
## Memory usage
@@ -258,7 +265,7 @@ Here are the steps for creating and using a quantized model:
258265

259266
```bash
260267
# quantize a model with Q5_0 method
261-
make quantize
268+
make -j quantize
262269
./quantize models/ggml-base.en.bin models/ggml-base.en-q5_0.bin q5_0
263270

264271
# run the examples as usual, specifying the quantized model file
@@ -423,6 +430,16 @@ make clean
423430
GGML_CUDA=1 make -j
424431
```
425432

433+
## Vulkan GPU support
434+
Cross-vendor solution which allows you to accelerate workload on your GPU.
435+
First, make sure your graphics card driver provides support for Vulkan API.
436+
437+
Now build `whisper.cpp` with Vulkan support:
438+
```
439+
make clean
440+
make GGML_VULKAN=1 -j
441+
```
442+
426443
## BLAS CPU support via OpenBLAS
427444

428445
Encoder processing can be accelerated on the CPU via OpenBLAS.
@@ -619,7 +636,7 @@ The [stream](examples/stream) tool samples the audio every half a second and run
619636
More info is available in [issue #10](https://github.com/ggerganov/whisper.cpp/issues/10).
620637

621638
```bash
622-
make stream
639+
make stream -j
623640
./stream -m ./models/ggml-base.en.bin -t 8 --step 500 --length 5000
624641
```
625642

bindings/ruby/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
README.md
2+
LICENSE
3+
pkg/
4+
lib/whisper.*

bindings/ruby/Rakefile

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,55 @@
11
require 'rake/clean'
2-
require 'rubygems/package'
3-
4-
desc 'Build gem'
5-
task :package do
6-
spec_source = File.read File.join(File.dirname(__FILE__),'whispercpp.gemspec')
7-
spec = nil
8-
# see: http://gist.github.com/16215
9-
Thread.new { spec = eval("#{spec_source}") }.join
10-
spec.validate
11-
Gem::Package.build(spec)
2+
require "bundler/gem_tasks"
3+
require "pathname"
4+
require "yaml"
5+
require "rake/testtask"
6+
7+
extsources = YAML.load_file("extsources.yaml")
8+
extsources.each_pair do |src_dir, dests|
9+
dests.each do |dest|
10+
src = Pathname(src_dir)/File.basename(dest)
11+
12+
file src
13+
file dest => src do |t|
14+
cp t.source, t.name
15+
end
16+
end
17+
end
18+
SOURCES = extsources.values.flatten
19+
CLEAN.include SOURCES
20+
CLEAN.include FileList["ext/*.o", "ext/whisper.so", "ext/whisper.bundle", "ext/whisper.dll"]
21+
22+
task build: SOURCES + FileList[
23+
"ext/extconf.rb",
24+
"ext/ruby_whisper.h",
25+
"ext/ruby_whisper.cpp",
26+
"whispercpp.gemspec",
27+
]
28+
29+
directory "pkg"
30+
CLOBBER.include "pkg"
31+
32+
TEST_MODEL = "../../models/ggml-base.en.bin"
33+
LIB_NAME = "whisper".ext(RbConfig::CONFIG["DLEXT"])
34+
LIB_FILE = File.join("lib", LIB_NAME)
35+
36+
directory "lib"
37+
task LIB_FILE => SOURCES + ["lib"] do |t|
38+
Dir.chdir "ext" do
39+
sh "ruby extconf.rb"
40+
sh "make"
41+
end
42+
mv "ext/#{LIB_NAME}", t.name
43+
end
44+
CLEAN.include LIB_FILE
45+
46+
Rake::TestTask.new do |t|
47+
t.test_files = FileList["tests/test_*.rb"]
48+
end
49+
task test: [TEST_MODEL, LIB_FILE]
50+
51+
file TEST_MODEL do
52+
Dir.chdir "../.." do
53+
sh "./models/download-ggml-model.sh base.en"
54+
end
1255
end

bindings/ruby/ext/.gitignore

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,26 @@ ggml.c
33
ggml.h
44
ggml-alloc.c
55
ggml-alloc.h
6-
whisper.bundle
6+
ggml-aarch64.c
7+
ggml-aarch64.h
8+
ggml-backend.cpp
9+
ggml-backend-impl.h
10+
ggml-backend.c
11+
ggml-backend.h
12+
ggml-common.h
13+
ggml-cpu-impl.h
14+
ggml-cuda.h
15+
ggml-impl.h
16+
ggml-kompute.h
17+
ggml-metal.h
18+
ggml-opencl.h
19+
ggml-quants.c
20+
ggml-quants.h
21+
ggml-sycl.h
22+
ggml-vulkan.h
723
whisper.cpp
824
whisper.h
925
dr_wav.h
26+
whisper.bundle
27+
whisper.so
28+
whisper.dll

0 commit comments

Comments
 (0)