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 40 commits into
base: master
Choose a base branch
from
Open

Flat fix #3114

wants to merge 40 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...
@@ -0,0 +1,60 @@
#include "whisper.h"
Copy link
Collaborator

@danbev danbev May 6, 2025

Choose a reason for hiding this comment

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

Could the number of includes be reduced here to only whisper-flat.h and ggml-backend.h perhaps?

Copy link
Author

Choose a reason for hiding this comment

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

Ahh, yeah - probably overkill there :)

I just copied what was in whisper.cpp and added to it (lazy me, sorry)

return whisper_get_system_info_json();
}

struct whisper_state * whisper_flat_get_state_from_context(struct whisper_context * ctx) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this really be exposed? My reason for asking is that whisper_state contains C++ constructs like std::vector and my understanding is that the purpose of this is avoid them as not all languages can deal with them in an easy way.

Copy link
Author

Choose a reason for hiding this comment

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

Addressed in next reply - also whisper state is used in other functions - not just the ones I create (I'd have to look em up)

#ifdef BINDINGS_FLAT
WHISPER_FLAT_API void whisper_flat_backend_load_all(void);
WHISPER_FLAT_API struct whisper_activity * whisper_flat_get_activity_with_state(struct whisper_state * state);
WHISPER_FLAT_API struct whisper_state * whisper_flat_get_state_from_context(struct whisper_context * ctx);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same question as above, this should really be exposed?

Copy link
Author

Choose a reason for hiding this comment

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

They exist precisely owing to the fact that c++ std:vector aren't available in other languages
Externally whisper_state can be treated as an opaque object as long as you have its address so whisper_flat_get_state_from_context can pluck it out of a whisper_context then plug it into whisper_flat_get_activity_with_state to get timing data directly rather than via JSON

@@ -1309,14 +1309,19 @@ static size_t aheads_masks_nbytes(struct whisper_aheads_masks & aheads_masks) {
static ggml_backend_t whisper_backend_init_gpu(const whisper_context_params & params) {
ggml_log_set(g_state.log_callback, g_state.log_callback_user_data);

#ifndef BINDINGS_FLAT
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Macros are mostly placed at the beginning of the line in the code base, even if the code they guard is indented. This is done in a few other places in this PR as well.

Copy link
Author

@peardox peardox May 6, 2025

Choose a reason for hiding this comment

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

I specifically decided to stick them at the end to clearly delineate them from everything else

Also when reading code I tend to think of things up top as more important. Well, BINDINGS_FLAT is only important to a very small subset of Whisper devs - hence make it as unimportant as possible

@@ -70,6 +70,10 @@ option(WHISPER_ALL_WARNINGS_3RD_PARTY "whisper: enable all compiler warnings in
option(WHISPER_FATAL_WARNINGS "whisper: enable -Werror flag" OFF)
option(WHISPER_USE_SYSTEM_GGML "whisper: use system-installed GGML library" OFF)

# flat bindings
option(BINDINGS_FLAT "Add extra flat definitions to Whisper + GGML" OFF)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps this should be WHISPER_BINDINGS_FLAT to be consistent with the others?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah - I had that idea after deciding GGML_BINDINGS_FLAT was a good idea

Copy link
Author

@peardox peardox May 6, 2025

Choose a reason for hiding this comment

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

Be updating everything in a bit - in the middle of a huge all CUDA architecture build _ SYCL test (PCs going slow)

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.

3 participants