-
Notifications
You must be signed in to change notification settings - Fork 86
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
fix: add cuda backend support for to_raggedtensor
and from_raggedtensor
functions
#3263
Open
maxymnaumchyk
wants to merge
11
commits into
scikit-hep:main
Choose a base branch
from
maxymnaumchyk:maxymnaumchyk/add-cuda-support-for-raggedtensor-conversions
base: main
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.
+88
−10
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
303f78f
add cuda backend support
maxymnaumchyk 7f9bb74
style changes
maxymnaumchyk 832e1ed
Merge branch 'main' into maxymnaumchyk/add-cuda-support-for-raggedten…
ianna 4189a02
keep gpu id the same
maxymnaumchyk 27f9e44
style changes
maxymnaumchyk 9fd6e8e
Merge branch 'scikit-hep:main' into maxymnaumchyk/add-cuda-support-fo…
maxymnaumchyk e58772b
fix device id selection
maxymnaumchyk 2237922
add new functions to the documentation
maxymnaumchyk 23b0b4b
Merge remote-tracking branch 'origin/maxymnaumchyk/add-cuda-support-f…
maxymnaumchyk e23f29a
add cuda backend support for ak.from_raggedtensor
maxymnaumchyk 5cfccda
add suggestions from Jim
maxymnaumchyk 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 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
This file contains 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
This file contains 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 had to check the documentation on str.endswith, but it seems that this is equivalent to
(though I think the latter is easier to understand because slicing is more well-known than the extra arguments of
str.endswith
).However, are you assuming that the GPU number is one digit? That is, will the above code break for a computer with 10 GPUs?
If the format for the 15th GPU is
"GPU-14"
(zero-indexed), then maybe you want(and if lowercase is possible, you can also add a
.upper()
in the chain).But before you accept the suggestion above, is it really a hyphen? If there's only one GPU, would there be no hyphen? (Note that
device.split("-")[0]
is equal todevice
if there is no hyphen, so the same code may be fine.)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.
Thanks for catching that, I haven't thought about that case! If there's only one GPU, then the
device
looks like this:/job:localhost/replica:0/task:0/device:GPU:0
So, I think
if device.split(":")[-2].upper() == "GPU":
will work for all cases.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 will, but it relies on TensorFlow never changing the text to end with
"GPU"
rather than"GPU:0"
. All of this is about trying to write something defensively, so that either our incomplete knowledge of the upstream library (TensorFlow) or possible changes in that upstream library would cause our code to break. By "break," I mean "do the wrong thing without an error message." Failing with an error message if TensorFlow changes would be fine.Given that what we expect from TensorFlow is a string like
or
or
this would be a safe way to catch it:
It also expresses to the future maintainer (or code reviewer) what you know about what TensorFlow gives you. (The import needs to be in the import section.)