Skip to content

Flat fix #3114

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

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open

Flat fix #3114

wants to merge 44 commits into from

Conversation

peardox
Copy link

@peardox peardox commented May 2, 2025

Fixingcommit conflicts

peardox added 30 commits April 23, 2025 18:48
@peardox
Copy link
Author

peardox commented May 5, 2025

@danbev your #3090 and others are now in master so will this get thru CI now?

I just merged and everything looks good

@peardox
Copy link
Author

peardox commented May 5, 2025

In CI Ruby don't like my -DBINDINGS_FLAT (which also creates a GGML_BINDINGS_FLAT)

The whole point of the switch is that it makes the additions / changes transparent to other systems

@KitaitiMakoto
Copy link
Collaborator

KitaitiMakoto commented May 5, 2025

@peardox Hi, I sent a pull request to fix Ruby problem to your branch: WhisperBooks#1

Fix for Ruby options

Thanks - I'm clueless regartding Ruby...
@peardox
Copy link
Author

peardox commented May 7, 2025

Removed superfluous line in ggml-backend.h
Added documentation via comments at end of whisper.cpp explaining placement
Renamed BINDING_FLAT -> WHISPER_BINDINGS_FLAT (in multiple files)
Reduced included in whisper-flat.h
Added params.use_gpu trigger to server + wchess examples if WHISPER_BINDING_FLAT
Checked both with and without -DWHISPER_BINDING_FLAT library exports to ensure extra exposed functions only if enabled
Tested both with and without -DWHISPER_BINDING_FLAT (7 examples modify execution paths with WHISPER_BINDING_FLAT enabled)

@peardox
Copy link
Author

peardox commented May 7, 2025

@danbev Made changes - can you stick it thru CI just to check pls

@peardox
Copy link
Author

peardox commented May 7, 2025

Arggh - ruby failed again
I altered @KitaitiMakoto fix to suit new naming of WHISPER_BINDINGS_FLAT

@KitaitiMakoto
Copy link
Collaborator

Seems a backup file ( ggml/include/ggml-backend.h.bak ) is commited and causes Ruby bindings' test failure.

@peardox
Copy link
Author

peardox commented May 7, 2025

Seems a backup file ( ggml/include/ggml-backend.h.bak ) is commited and causes Ruby bindings' test failure.

Dunno where that came from :(

Copy link
Member

@ggerganov ggerganov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the goal of this change?

Note that this is not suitable to merge - it's probably better to keep in a separate fork.

@peardox
Copy link
Author

peardox commented May 7, 2025

What is the goal of this change?

First it should be mentioned that WHISPER_BINDINGS_FLAT is specifically designed to only do anything if passed to the build command.
It is entirely conditional, if built without WHISPER_BINDINGS_FLAT the code doesn't exist

The main purpose is to make -DBUILD_SHARED_LIBS=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON work
If built with those switches no examples will work as the backends are not available when the model is loaded (try it).
This results in null pointers being used to obtain device informtion.

If devices are loaded via e.g. whisper_flat_backend_load_all() or ggml_backend_try_load_best("cpu", nullptr) before the model is loaded this situation is resolved and examples all work.
However, currently, whisper_load_backends also tries to load backends.
This causes double loading of backends or in the case of only loading e.g. cpu forcing the load of all others as well (which may be undesirable)

The rest of the stuff is for non C++ language support.
C++ specific structures such as std::vector are used freely throughout which causes issues for other languages.
In the case of whisper_init_from_file_with_params state is assigned but is unavailable to non-C++ languages - this is resolved by whisper_flat_get_state_from_context as whisper_state is required extensively
whisper_flat_get_activity_with_state uses a whisper_state to obtain timing (not available as data otherwise)
The whisper_flat...backend functions all deal with getting information about the backends assigned to the current model (so you can tell which ones are actually being used) - this is also unavailable otherwise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants