-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Add pinned_memory and non_blocking transfer for default collate_fn #52948
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Srinath Krishnamachari <[email protected]>
Signed-off-by: Srinath Krishnamachari <[email protected]>
Signed-off-by: Srinath Krishnamachari <[email protected]>
Signed-off-by: Srinath Krishnamachari <[email protected]>
Signed-off-by: Srinath Krishnamachari <[email protected]>
Co-authored-by: lanbochen-anyscale <[email protected]> Signed-off-by: srinathk10 <[email protected]>
…athk10-train-fix-collate-fn
Signed-off-by: Srinath Krishnamachari <[email protected]>
Signed-off-by: Srinath Krishnamachari <[email protected]>
Signed-off-by: srinathk10 <[email protected]>
…-memory Signed-off-by: srinathk10 <[email protected]>
Signed-off-by: srinathk10 <[email protected]>
@@ -213,6 +213,13 @@ def __call__(self, batch: "pyarrow.Table") -> Dict[str, List["torch.Tensor"]]: | |||
# However, for CPU transfer, we need to combine the chunked arrays first | |||
# before converting to numpy format and then to Tensors. | |||
combine_chunks = self.device.type == "cpu" | |||
|
|||
# If the device is CPU, we don't need to pin the memory. | |||
pin_memory = self.device.type != "cpu" |
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.
We should probably expose this arg to users.
pinning memory isn't always better (e.g., when there are many small batches)
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.
yea, seeing overhead with pinning for batch size = 32
Why are these changes needed?
Add pinned_memory and non_blocking transfer for default collate_fn
Related issue number
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.