Skip to content

GPUDirect Storage prototype tutorial #3317

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Conversation

mikaylagawarecki
Copy link
Contributor

No description provided.

Copy link

pytorch-bot bot commented Apr 8, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/3317

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 7d9de66 with merge base 7cb6915 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@mikaylagawarecki mikaylagawarecki requested a review from albanD April 8, 2025 14:24
@mikaylagawarecki mikaylagawarecki marked this pull request as draft April 8, 2025 14:24
@@ -31,6 +31,7 @@
"prototype_source/vmap_recipe",
"prototype_source/torchscript_freezing",
"prototype_source/nestedtensor",
"prototype_source/gpu_direct_storage", # requires specific filesystem + GPUDirect Storage to be set up
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it run in compat mode with a random machine?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need a specific filesystem

# The loading flow is the inverse, we can ``torch.load`` under the ``torch.serialization.skip_data`` context
# manager to load everything except the storage bytes. This means that any tensors in the checkpoint will be
# created but their storages will be empty (i.e. the tensors will be created via ``torch.empty``). If the
# tensors to be loaded to are persistent, one can use the ``torch.cuda.gds.gds_register_buffer`` API to register
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The register API is not used here?

f.load_storage(v.untyped_storage(), offset)
assert torch.equal(v, sd[k])

del f
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar synchronization question as above

Copy link
Contributor Author

@mikaylagawarecki mikaylagawarecki Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think synchronization is needed after the call as cuFileRead/Write are blocking operations that block until IO is complete https://docs.nvidia.com/gpudirect-storage/api-reference-guide/index.html#cufileread. You might need to synchronize before these ops (rather than after) though

Screenshot 2025-04-08 at 11 21 32 AM

Comment on lines 68 to 71
# If you are continuously saving the same state dictionary during training, you
# would only need to obtain the offsets once and the same offsets can be re-used. Similarly if tensor is going to
# be loaded to repeatedly one can use the ``torch.cuda.gds.gds_register_buffer`` which wraps
# ``cuFileBufRegister`` to register the storages as gds buffers.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@albanD is this better?

Copy link
Contributor

@svekars svekars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor nits


del f

# Conclusion
Copy link
Contributor

@svekars svekars Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants