-
Notifications
You must be signed in to change notification settings - Fork 14.2k
build: for GGML_BACKEND_DL, ggml need not depend on backend #17709
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
jeffbolznv
wants to merge
1
commit into
ggml-org:master
Choose a base branch
from
jeffbolznv:ggml_remove_dep
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+0
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is a build order dependency and I think it should be kept.
add_dependencies(A B)tells CMake that target A depends on target B meaning that whenever we build target A, CMake must first make sure that target B is built.This makes sure that if we make a change to a backend and then try to build the ggml target, CMake will first rebuild the backend before rebuilding ggml and this keeps things consistent.
If we don't have this it would be possible that after everything is built and we have libggml-base.so, libggml.so, and libggml-vulkan.so in the build directory, and if we then make a change to the ggml-vulkan backend and try building the ggml target, cmake would check ggml and determine that it is up to date and the ggml-vulkan backend would not get rebuilt. So our changes would not be compiled. But with this build order dependency CMake will first rebuild the ggml-vulkan backend before rebuilding ggml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what you're saying is that this dependency is not functionally required, but that people may be using
--target ggmlas a shorthand to build all ggml libraries, and for some reason not just using--target all. I'm not sure why people would do that, but if you want to preserve that kind of behavior we could add a new target for it:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think that this is required to allow the following:
Suppose I use ggml by including it as part of my cmake project. And I've configured
GGML_BACKEND_DL=ONto generate dynamic libraries for the backends I want to use that can be loaded at runtime (as opposed to linked at build time).With the dependency to the backend there, when I build ggml the backends will also be built. Without this dependency only libggml.so and libggml-base.so will be built which might cause issues for project using ggml in this way. Without this those project would have to explicitly build each backend or use --target all.
I think that users/projects that embed ggml might do this in a similar way as described above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The backends are built because their cmake files get included and those files call ggml_add_backend_library->add_library. It's the add_library call that tells cmake to build it, not the dependency. add_dependencies additionally enforces a build order, and that's what I want to remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I think this is something we might want to keep. My concern is the following scenario.
As an example, we first build with
GGML_BACKEND_DL=ONwithadd_dependencies:Now if we remove
add_dependenciesand update the CUDA backend:$ echo "something" >> ggml/src/ggml-cuda/ggml-cuda.cuAnd then build with the same command as above the following will be built:
So the CUDA backend is not built and would not compile if it was. This is the issue I think might have consequences for some users/projects if we remove this.
But if others don't see this as an issue I'm alright with this change. I just mainly wanted to make sure we have considered this scenario.