Skip to main content

TorchRec

TorchRec is a PyTorch domain library built to provide common sparsity and parallelism primitives needed for large-scale recommender systems (RecSys). TorchRec allows training and inference of models with large embedding tables sharded across many GPUs and powers many production RecSys models at Meta.

External Presence

TorchRec has been used to accelerate advancements in recommendation systems, some examples:

Introduction

To begin learning about TorchRec, check out:

TorchRec Features

  • Parallelism primitives that enable easy authoring of large, performant multi-device/multi-node models using hybrid data-parallelism/model-parallelism.
  • Sharders to shard embedding tables with different strategies including data-parallel, table-wise, row-wise, table-wise-row-wise, column-wise, and table-wise-column-wise sharding.
  • Planner that can automatically generate optimized sharding plans for models.
  • Pipelined training overlapping dataloading device transfer (copy to GPU), inter-device communications (input_dist), and computation (forward, backward) for increased performance.
  • Optimized kernels for RecSys powered by FBGEMM.
  • Quantization support for reduced precision training and inference, along with optimizing a TorchRec model for C++ inference.
  • Common modules for RecSys.
  • RecSys datasets (criteo click logs and movielens)
  • Examples of end-to-end training such as the DLRM event prediction model trained on criteo click logs dataset.

Installation

Check out the Getting Started section in the documentation for recommended ways to set up Torchrec.

From Source

Generally, there isn't a need to build from source. For most use cases, follow the section above to set up TorchRec. However, to build from source and to get the latest changes, do the following:

  1. Install pytorch. See pytorch documentation.

    CUDA 12.6
    
    pip install torch --index-url https://download.pytorch.org/whl/nightly/cu126
    
    CUDA 12.8
    
    pip install torch --index-url https://download.pytorch.org/whl/nightly/cu128
    
    CUDA 12.9
    
    pip install torch --index-url https://download.pytorch.org/whl/nightly/cu129
    
    CPU
    
    pip install torch --index-url https://download.pytorch.org/whl/nightly/cpu
    
  2. Clone TorchRec.

    git clone --recursive https://github.com/meta-pytorch/torchrec
    cd torchrec
    
  3. Install FBGEMM.

    CUDA 12.6
    
    pip install fbgemm-gpu --index-url https://download.pytorch.org/whl/nightly/cu126
    
    CUDA 12.8
    
    pip install fbgemm-gpu --index-url https://download.pytorch.org/whl/nightly/cu128
    
    CUDA 12.9
    
    pip install fbgemm-gpu --index-url https://download.pytorch.org/whl/nightly/cu129
    
    CPU
    
    pip install fbgemm-gpu --index-url https://download.pytorch.org/whl/nightly/cpu
    
  4. Install other requirements.

    pip install -r requirements.txt
    
  5. Install TorchRec.

    python setup.py install develop
    
  6. Test the installation.

    GPU mode
    
    torchx run -s local_cwd dist.ddp -j 1x2 --gpu 2 --script test_installation.py
    
    CPU Mode
    
    torchx run -s local_cwd dist.ddp -j 1x2 --script test_installation.py -- --cpu_only
    

    See TorchX for more information on launching distributed and remote jobs.

  7. If you want to run a more complex example, please take a look at the torchrec DLRM example.

Contributing

See CONTRIBUTING.md for details about contributing to TorchRec!

Citation

If you're using TorchRec, please refer to BibTeX entry to cite this work:

@inproceedings{10.1145/3523227.3547387,
author = {Ivchenko, Dmytro and Van Der Staay, Dennis and Taylor, Colin and Liu, Xing and Feng, Will and Kindi, Rahul and Sudarshan, Anirudh and Sefati, Shahin},
title = {TorchRec: a PyTorch Domain Library for Recommendation Systems},
year = {2022},
isbn = {9781450392785},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3523227.3547387},
doi = {10.1145/3523227.3547387},
abstract = {Recommendation Systems (RecSys) comprise a large footprint of production-deployed AI today. The neural network-based recommender systems differ from deep learning models in other domains in using high-cardinality categorical sparse features that require large embedding tables to be trained. In this talk we introduce TorchRec, a PyTorch domain library for Recommendation Systems. This new library provides common sparsity and parallelism primitives, enabling researchers to build state-of-the-art personalization models and deploy them in production. In this talk we cover the building blocks of the TorchRec library including modeling primitives such as embedding bags and jagged tensors, optimized recommender system kernels powered by FBGEMM, a flexible sharder that supports a veriety of strategies for partitioning embedding tables, a planner that automatically generates optimized and performant sharding plans, support for GPU inference and common modeling modules for building recommender system models. TorchRec library is currently used to train large-scale recommender models at Meta. We will present how TorchRec helped Meta’s recommender system platform to transition from CPU asynchronous training to accelerator-based full-sync training.},
booktitle = {Proceedings of the 16th ACM Conference on Recommender Systems},
pages = {482–483},
numpages = {2},
keywords = {information retrieval, recommender systems},
location = {Seattle, WA, USA},
series = {RecSys '22}
}

License

TorchRec is BSD licensed, as found in the LICENSE file.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

torchrec-1.8.0-py314-none-any.whl (1.1 MB view details)

Uploaded Python 3.14

torchrec-1.8.0-py313-none-any.whl (1.1 MB view details)

Uploaded Python 3.13

torchrec-1.8.0-py312-none-any.whl (1.1 MB view details)

Uploaded Python 3.12

torchrec-1.8.0-py311-none-any.whl (1.1 MB view details)

Uploaded Python 3.11

torchrec-1.8.0-py310-none-any.whl (1.1 MB view details)

Uploaded Python 3.10

File details

Details for the file torchrec-1.8.0-py314-none-any.whl.

File metadata

  • Download URL: torchrec-1.8.0-py314-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3.14
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for torchrec-1.8.0-py314-none-any.whl
Algorithm Hash digest
SHA256 a3253423694f25e6c2697a4f7af4167558cd104b4d1bb660a2bd68330b16e12f
MD5 748b27ac39762a0e6964d44e9f49bb26
BLAKE2b-256 cf18282fca466cc1c9f5f3c59f0dab94e0e9f740df9f20721bf3248f647abaed

See more details on using hashes here.

File details

Details for the file torchrec-1.8.0-py313-none-any.whl.

File metadata

  • Download URL: torchrec-1.8.0-py313-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3.13
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for torchrec-1.8.0-py313-none-any.whl
Algorithm Hash digest
SHA256 bd2f689f2a93e47ed94d629bae9d25c8eed93da8e2b907acbb7e48de548dfe5a
MD5 33daff76ff2d01cd32a6648e25c98bc8
BLAKE2b-256 6ea98d513f779f309eb9d902c93e8a148399742ee29dd81112c59aebe17bb3d3

See more details on using hashes here.

File details

Details for the file torchrec-1.8.0-py312-none-any.whl.

File metadata

  • Download URL: torchrec-1.8.0-py312-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3.12
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for torchrec-1.8.0-py312-none-any.whl
Algorithm Hash digest
SHA256 a26f89fa4b01b7aaf862a8ad8c4922e79c873d9d947a825ec57a64ecf383eac7
MD5 9cfb36c263a4beb897d801bce5f55adc
BLAKE2b-256 6161892ec4562e1bbbeb0cd3e1b7daecebb24faf6d0a03c312a456c36e922d2f

See more details on using hashes here.

File details

Details for the file torchrec-1.8.0-py311-none-any.whl.

File metadata

  • Download URL: torchrec-1.8.0-py311-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3.11
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for torchrec-1.8.0-py311-none-any.whl
Algorithm Hash digest
SHA256 c6f9785faf6663310d955102b3077fb9ed7a9d8f866061a64247cc51915034f2
MD5 ff14a6b159e9b5670d06b8d7238fd2a4
BLAKE2b-256 4e842742759c54d7dec92134e06dc357c2849db299d949debd798947c8f515e8

See more details on using hashes here.

File details

Details for the file torchrec-1.8.0-py310-none-any.whl.

File metadata

  • Download URL: torchrec-1.8.0-py310-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3.10
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for torchrec-1.8.0-py310-none-any.whl
Algorithm Hash digest
SHA256 d45a856d00868302dc30d45ba87e4e5010b47eccd6cad019e7350bf69c43335a
MD5 77a5cee766ef8f6eb792cc82fd70be69
BLAKE2b-256 f039ec85df95fc82458c1edf03e92df6480412bc864d6ad7ead9323b7b07c0b3

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.8.0 This release

5 files

1.7.0

5 files

1.6.1

5 files

1.6.0

1 file

1.5.1

5 files

1.5.0

3 files

1.4.0

4 files

1.3.0

4 files

1.2.0

5 files

1.1.0

4 files

1.0.0

4 files

0.8.0

5 files

0.7.0

5 files

0.6.0

5 files

0.5.0

4 files

0.4.0

3 files

0.3.2

3 files

0.3.1

4 files

0.2.0

3 files

0.1.0

3 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page