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}
}

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.0.tar.gz (268.0 kB view details)

Uploaded Source

Built Distribution

peer_pytorch-0.2.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: peer_pytorch-0.2.0.tar.gz
  • Upload date:
  • Size: 268.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for peer_pytorch-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f01aba5284b3e5f4f66a4a85db2275c826b9f96b561c92fb2af63f2f5891a888
MD5 ad9135a5fdded40aa8c31700e6d3b41c
BLAKE2b-256 5ee02f3ff2572d7cbf0295278e70b8be87601265285392c63e000a2c9a8b6544

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for peer_pytorch-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e473446ff9d43ca4f1ca8856abfbc49942ee9bb5d2fe2de3803c1c607112124b
MD5 ad39e6c6162ecfda1aa70337e25d8382
BLAKE2b-256 a8465777826bdb4ead5f49359bbc496f81694778d2344ad244d4480cee3f118a

See more details on using hashes here.

Supported by

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