-
Notifications
You must be signed in to change notification settings - Fork 19.1k
sycl: fix performance regression by caching getenv #23381
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
Closed
iOptimizeThings
wants to merge
1
commit into
ggml-org:master
from
iOptimizeThings:fix-sycl-getenv-perf
Closed
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
It might be better to check for env var in
ggml_sycl_init()once #23097 goes through (I'm hesitant to tweak it more as it is approved and merge ready)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.
This function
ggml_sycl_use_level_zero_device_alloc(sycl::queue &q)can be replaced byg_ggml_sycl_enable_level_zerowhich has been set.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 original code should be updated as this PR or suggestion.
But even if use my suggestion, it impacts the performance less.
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.
Makes sense using g_ggml_sycl_enable_level_zero has even less overhead. I'll update ggml_sycl_use_level_zero_device_alloc to use the global. Should I rebase on #23097 first since it's merge-ready, or is it fine to land this independently as the small fix?
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.
actually scratch that,
g_ggml_sycl_enable_level_zerois less overhead but it starts at 0 and only gets set insideggml_check_sycl(), and the comment under this function notes large buffers can be allocated before that runs, so gating on it directly would make those early allocs skip the level zero path and fall back to theDMA-buf/TTM stagingthis was added to avoid. i checked #23097 too and it keeps the assignment inggml_check_sycl(), so that early window doesn't change. the static const cache keeps it init-order independent while still dropping the per-alloc getenv, so i think it covers both — good to keep that approach, or is the global guaranteed set before those early allocs somewhere i'm not seeing?Uh oh!
There was an error while loading. Please reload this page.
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 went with #23399 (rebase-pending, so the diff is a mess) but there could be a better way.
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.
Makes sense, checking it during
ggml_sycl_init()avoids the early allocation window entirely, cleaner than the static cache. Happy to close this in favor of #23399 if that's the direction.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.
@iOptimizeThings
OK, it's great if you close this PR.
We could focus on the review of #23399. The comments will be moved to it.
Thank you for your sharing of this issue and solution!