Registry / ai-ml / torchrec

torchrec

JSON →
library1.6.0pypypiunverified

TorchRec is a PyTorch library for building and scaling recommendation systems, providing modular building blocks for distributed training, large embeddings, and advanced sharding strategies. Current version is 1.6.0, with a release cadence of roughly quarterly.

pip install torchrec
INSTALL
IMPORT
SIG · TORCHREC
T
torchrec
ai-mlpythonv1.6.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EmbeddingBagCollection
✓ from torchrec import EmbeddingBagCollection
✗ from torchrec.models import EmbeddingBagCollection
EmbeddingBagCollection is in top-level torchrec, not in a submodule.
KeyedJaggedTensor
✓ from torchrec import KeyedJaggedTensor
✗ from torchrec.sparse import KeyedJaggedTensor
KeyedJaggedTensor is exported from torchrec; no need to import from submodules.
DenseArch
✓ from torchrec.models.deepfm import DenseArch
✗ from torchrec import DenseArch
DenseArch is in the deepfm model submodule, not directly in torchrec.

Minimal example using EmbeddingBagCollection and KeyedJaggedTensor on CPU.

import torch from torchrec import EmbeddingBagCollection, KeyedJaggedTensor # Create an embedding bag collection with 2 tables ebc = EmbeddingBagCollection( tables=[ {"name": "users", "num_embeddings": 1000, "embedding_dim": 64}, {"name": "items", "num_embeddings": 5000, "embedding_dim": 128}, ], device=torch.device("cpu"), ) # Dummy sparse features features = KeyedJaggedTensor( keys=["users", "items"], values=torch.tensor([1, 2, 3, 4, 5]), lengths=torch.tensor([2, 0, 1, 0, 2]), offsets=torch.tensor([0, 2, 2, 3, 3, 5]), ) # Forward pass output = ebc(features) print(output)
Debug
Known issues
breakingIn v1.4.0, the GitHub repository moved from pytorch/torchrec to meta-pytorch/torchrec. Update your git remotes and any references to the old organization.
fix
git remote set-url origin https://github.com/meta-pytorch/torchrec.git
affects: >=1.4.0
deprecatedStarting with v1.5.0, type checking migrated from Pyre to Pyrefly. All deprecated Pyre1 configurations have been removed in v1.6.0.
fix
Migrate any custom type checking configuration to Pyrefly; refer to https://github.com/facebook/pyrefly
affects: >=1.5.0
gotchaTorchRec requires PyTorch version >=2.0.0 and CUDA (if using GPU) 11.7+. Using older PyTorch or CUDA versions can cause silent runtime errors.
fix
Ensure torch.__version__ >= '2.0.0' and CUDA >= 11.7. Check compatibility with the torchrec version you install.
affects: all
gotchaThe module 'torchrec.distributed' has frequent API changes. If you use distributed training, pin your torchrec version to avoid breakage.
fix
Pin torchrec==1.5.0 or similar exact version in your requirements.txt.
affects: all
Upgrade
Version history
1.6.0latest on PyPI · released Mar 30, 2026
Audit
Dependencies
torchrequiredCore PyTorch dependency
fbgemm-gpuoptionalRequired for GPU embedding operations
Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources
torchrec — pip install torchrec · libregistry