Skip to content
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

Revamp TorchRec intro tutorial #3064

Merged
merged 31 commits into from
Oct 2, 2024
Merged

Revamp TorchRec intro tutorial #3064

merged 31 commits into from
Oct 2, 2024

Conversation

PaulZhang12
Copy link
Contributor

@PaulZhang12 PaulZhang12 commented Sep 27, 2024

Description

Revamps TorchRec tutorial for stable release

cc @iamzainhuda

Copy link

pytorch-bot bot commented Sep 27, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit f799561 with merge base 97b20b3 (image):
💚 Looks good so far! There are no failures yet. 💚

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

kernels and GPU enabled operations to run

"""

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
###############################################


"""

# Install stable versions for best reliability
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Install stable versions for best reliability
# If you do not have the following components in your environment, please install them by running:
#
# .. code-block:: sh

Comment on lines 17 to 21

!pip3 install --pre torch --index-url https://download.pytorch.org/whl/cu121 -U
!pip3 install fbgemm_gpu --index-url https://download.pytorch.org/whl/cu121
!pip3 install torchmetrics==1.0.3
!pip3 install torchrec --index-url https://download.pytorch.org/whl/cu121
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
!pip3 install --pre torch --index-url https://download.pytorch.org/whl/cu121 -U
!pip3 install fbgemm_gpu --index-url https://download.pytorch.org/whl/cu121
!pip3 install torchmetrics==1.0.3
!pip3 install torchrec --index-url https://download.pytorch.org/whl/cu121
#
# !pip3 install --pre torch --index-url https://download.pytorch.org/whl/cu121 -U
# !pip3 install fbgemm_gpu --index-url https://download.pytorch.org/whl/cu121
# !pip3 install torchmetrics==1.0.3
# !pip3 install torchrec --index-url https://download.pytorch.org/whl/cu121

@@ -0,0 +1,1081 @@
"""
**Open Source Installation** (For Reference)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
**Open Source Installation** (For Reference)
Introduction to TorchRec

@@ -0,0 +1,1081 @@
"""
**Open Source Installation** (For Reference)
--------------------------------------------
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
--------------------------------------------
==================================


# Install stable versions for best reliability

!pip3 install --pre torch --index-url https://download.pytorch.org/whl/cu121 -U
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
!pip3 install --pre torch --index-url https://download.pytorch.org/whl/cu121 -U
# !pip3 install --pre torch --index-url https://download.pytorch.org/whl/cu121 -U

# Install stable versions for best reliability

!pip3 install --pre torch --index-url https://download.pytorch.org/whl/cu121 -U
!pip3 install fbgemm_gpu --index-url https://download.pytorch.org/whl/cu121
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
!pip3 install fbgemm_gpu --index-url https://download.pytorch.org/whl/cu121
# !pip3 install fbgemm_gpu --index-url https://download.pytorch.org/whl/cu121


!pip3 install --pre torch --index-url https://download.pytorch.org/whl/cu121 -U
!pip3 install fbgemm_gpu --index-url https://download.pytorch.org/whl/cu121
!pip3 install torchmetrics==1.0.3
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
!pip3 install torchmetrics==1.0.3
# !pip3 install torchmetrics==1.0.3

!pip3 install --pre torch --index-url https://download.pytorch.org/whl/cu121 -U
!pip3 install fbgemm_gpu --index-url https://download.pytorch.org/whl/cu121
!pip3 install torchmetrics==1.0.3
!pip3 install torchrec --index-url https://download.pytorch.org/whl/cu121
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
!pip3 install torchrec --index-url https://download.pytorch.org/whl/cu121
# !pip3 install torchrec --index-url https://download.pytorch.org/whl/cu121

Comment on lines 25 to 27
# Intro to TorchRec
# =================
#
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Intro to TorchRec
# =================
#

.jenkins/metadata.json Outdated Show resolved Hide resolved
.jenkins/metadata.json Outdated Show resolved Hide resolved
@@ -70,3 +70,5 @@ pycocotools
semilearn==0.3.2
torchao==0.0.3
segment_anything==1.0
torchrec
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we pin dependencies to specific versions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can do torchrec==0.8 for now, and change to 1.0 once it's out?

# Set up environment variables for distributed training
# RANK is which GPU we are on, default 0
os.environ["RANK"] = "0"
# How many devices in our "world", since Bento can only handle 1 process, 1 GPU
Copy link
Contributor

Choose a reason for hiding this comment

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

We should remove Bento, you can say Colab.

intermediate_source/torchrec_interactive_tutorial.py Outdated Show resolved Hide resolved
intermediate_source/torchrec_interactive_tutorial.py Outdated Show resolved Hide resolved
Comment on lines 15 to 17
* Explore advanced techniques for distributing large embedding tables across multiple GPUs
.. grid-item-card:: :octicon:`list-unordered;1em;` Prerequisites
:class-card: card-prerequisites
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Explore advanced techniques for distributing large embedding tables across multiple GPUs
.. grid-item-card:: :octicon:`list-unordered;1em;` Prerequisites
:class-card: card-prerequisites
* Explore advanced techniques for distributing large embedding tables across multiple GPUs
.. grid-item-card:: :octicon:`list-unordered;1em;` Prerequisites
:class-card: card-prerequisites

# following dependencies:
#
# .. code-block:: sh

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change



######################################################################
# Congrats!
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Congrats!
# Conclusion

# Congrats!
# ---------
#
# You have now gone from training a distributed RecSys model all the way
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# You have now gone from training a distributed RecSys model all the way
# In this tutorial, you have gone from training a distributed RecSys model all the way

#
# You have now gone from training a distributed RecSys model all the way
# to making it inference ready.
# https://github.com/pytorch/torchrec/tree/main/torchrec/inference has a
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# https://github.com/pytorch/torchrec/tree/main/torchrec/inference has a
# The `TorchRec repo <https://github.com/pytorch/torchrec/tree/main/torchrec/inference>`__ has a

#
# For more information, please see our
# `dlrm <https://github.com/facebookresearch/dlrm/tree/main/torchrec_dlrm/>`__
# example, which includes multinode training on the criteo terabyte
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# example, which includes multinode training on the criteo terabyte
# example, which includes multinode training on the Criteo 1TB

# For more information, please see our
# `dlrm <https://github.com/facebookresearch/dlrm/tree/main/torchrec_dlrm/>`__
# example, which includes multinode training on the criteo terabyte
# dataset, using Meta’s `DLRM <https://arxiv.org/abs/1906.00091>`__.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# dataset, using Meta’s `DLRM <https://arxiv.org/abs/1906.00091>`__.
# dataset using the methods described in `Deep Learning Recommendation Model for Personalization and Recommendation Systems (DLRM) <https://arxiv.org/abs/1906.00091>`__.

@@ -619,3 +619,32 @@ warmup
webp
wsi
wsis
Meta's
Copy link
Contributor

Choose a reason for hiding this comment

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

can you run the sort command in vim (:sort), so it's sorted alphabetically.

# Embeddings in PyTorch
# ---------------------
#
# `torch.nn.Embedding <https://pytorch.org/docs/stable/generated/torch.nn.Embedding.html>`__:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# `torch.nn.Embedding <https://pytorch.org/docs/stable/generated/torch.nn.Embedding.html>`__:
# :class:`torch.nn.Embedding`:

# Embedding table where forward pass returns the embeddings themselves as
# is.
#
# `torch.nn.EmbeddingBag <https://pytorch.org/docs/stable/generated/torch.nn.EmbeddingBag.html>`__:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# `torch.nn.EmbeddingBag <https://pytorch.org/docs/stable/generated/torch.nn.EmbeddingBag.html>`__:
# :class:`torch.nn.EmbeddingBag`:

@svekars svekars added the 2.5 PR related to version 2.5 label Oct 1, 2024
@svekars svekars added torchrec PR related to the TorchRec library and removed 2.5 PR related to version 2.5 labels Oct 2, 2024
@iamzainhuda
Copy link
Contributor

need to fix the headings on the side, optimizer heading obfuscates rest of tutorial
image

# predictions and reduced model size. For example FP32 (4 bytes) in
# trained model to INT8 (1 byte) for each embedding weight. This is also
# necessary given the vast scale of embedding tables, as we want to use as
# few devices as possible for inference to minimize latency. \* **C++
Copy link
Contributor

Choose a reason for hiding this comment

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

the bulleted lists don't render as such
image

@svekars
Copy link
Contributor

svekars commented Oct 2, 2024

need to fix the headings on the side, optimizer heading obfuscates rest of tutorial

that's unfortunately the bug of the theme that we can't currently address.

index.rst Outdated Show resolved Hide resolved
index.rst Outdated Show resolved Hide resolved
.jenkins/metadata.json Outdated Show resolved Hide resolved
Copy link
Contributor

@iamzainhuda iamzainhuda left a comment

Choose a reason for hiding this comment

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

lgtm

@svekars svekars merged commit 4895c27 into pytorch:main Oct 2, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed torchrec PR related to the TorchRec library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants