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.
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
sycl: always set the main device after initialization #7909
sycl: always set the main device after initialization #7909
Changes from 1 commit
3704f33
d38f1ae
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
In single mode, the main device ID is set by the parameter of cmd line.
So, set it as 0, will disable the parameter: --main-gpu in fact.
So rm 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.
What about
ggml_sycl_set_main_device(main_gpu_id)
?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 was confused by this initially also, but I think zero is the only safe and correct initial value. Here's why:
There are two sets of devices we can get and iterate through: The first is the set of devices returned by
dpct::dev_mgr::instance().get_device()
. This is the set of all devices in the system, andmain_gpu_id
is an index into this set. The second is the set of devices stored insycl_gpu_mgr
. This is essentially a "filtered" set of devices we've chosen to use, and it can be indexed from zero tosycl_gpu_mgr->get_gpu_count()
.In the case where we choose a main GPU on the command line, the filtering will be performed when we create the
sycl_gpu_mgr
above.llama.cpp/ggml-sycl.cpp
Line 17392 in 172c825
After the filtering occurs, the only valid index to pass to
ggml_sycl_set_main_device()
is index zero, because there is only one device in thesycl_gpu_mgr
.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 this breaks multi-GPU semantics, @NeoZhangJianyu can you try this on a multi-GPU env?
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 convinced myself that this would be OK even in a multi-GPU environment, though admittedly I haven't tested this myself so it'd be great to confirm this works.
My thinking is: we're eventually going to set the main device via some other codepath, such as via
ggml_backend_sycl_init
(probably throughllama_new_context_with_model
). We may even set the main device multiple times. This is all fine; we just need some valid initial value, so if we happen to lookup the SYCL queue and hence the SYCL context, say to allocate host USM when loading a model, we have a valid value to perform the lookup.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.
In mulitple mode, set main gpu is not needed. #0 gpu is always default main gpu.
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.
Unfortunately this isn't the case:
llama.cpp/ggml-sycl.cpp
Line 3374 in 172c825
We could change the initial value of
g_main_device
from -1 to 0, but we'd probably also want to change some other initial values to stay in sync, say forg_main_device_id
. It seems safer to me to just callggml_sycl_set_main_device(0)
instead, but let me know what you prefer.