Skip to main content

PEER - Pytorch

Project description

PEER - Pytorch

Pytorch implementation of the PEER block from the Deepmind paper, Mixture of A Million Experts, by Xu Owen He.

Install

$ pip install PEER-pytorch

Usage

import torch
from PEER_pytorch import PEER

peer = PEER(
    dim = 512,
    heads = 8,                   # tested up to 32 - (hk = heads * num_experts_per_head (16))
    num_experts = 1_000_000,     # he chose 1 million
    num_experts_per_head = 16,   # he settled on 16, but was 32 in PKM paper
    dim_key = 128,
    pre_rmsnorm = True
).cuda()

x = torch.randn(2, 1024, 512).cuda()

out = peer(x) + x

assert x.shape == out.shape

Citations

@inproceedings{He2024MixtureOA,
    title   = {Mixture of A Million Experts},
    author  = {Xu Owen He},
    year    = {2024},
    url     = {https://api.semanticscholar.org/CorpusID:271038610}
}
@article{Csordas2023ApproximatingTF,
    title   = {Approximating Two-Layer Feedforward Networks for Efficient Transformers},
    author  = {R'obert Csord'as and Kazuki Irie and J{\"u}rgen Schmidhuber},
    journal = {ArXiv},
    year    = {2023},
    volume  = {abs/2310.10837},
    url     = {https://api.semanticscholar.org/CorpusID:264172384}
}
@inproceedings{anonymous2025continual,
    title   = {Continual Learning via Sparse Memory Finetuning},
    author  = {Anonymous},
    booktitle = {Submitted to The Fourteenth International Conference on Learning Representations},
    year    = {2025},
    url     = {https://openreview.net/forum?id=LGo7U1m24L},
    note    = {under review}
}

Project details


Download files

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

Source Distribution

peer_pytorch-0.2.2.tar.gz (268.3 kB view details)

Uploaded Source

Built Distribution

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

peer_pytorch-0.2.2-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file peer_pytorch-0.2.2.tar.gz.

File metadata

  • Download URL: peer_pytorch-0.2.2.tar.gz
  • Upload date:
  • Size: 268.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for peer_pytorch-0.2.2.tar.gz
Algorithm Hash digest
SHA256 54e9794c3e8df635e8b4d6a1f5dd8c24c65c85e9ca5c8c3ea6a03ce1525c7963
MD5 061c0bacf8bdb0227b79e3119513ee33
BLAKE2b-256 575102cb3eb051abe7ad12ad80ed196943d6969fb8bc6d74430588b9f6e2dc45

See more details on using hashes here.

File details

Details for the file peer_pytorch-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: peer_pytorch-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for peer_pytorch-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e9bc1a251bb428ab6ce4043f28ecaacd9a3de39b2b13b1133eacbc5c767e0d8d
MD5 c2f83317759e4bb3454caa33c1829e12
BLAKE2b-256 1dc7beb72a8f683baf3a3ffa1f0b76974854b4dac4a5fdf4f661190cdae71143

See more details on using hashes here.

Supported by

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