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

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

Uploaded Source

Built Distribution

peer_pytorch-0.0.10-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: peer_pytorch-0.0.10.tar.gz
  • Upload date:
  • Size: 265.6 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.0.10.tar.gz
Algorithm Hash digest
SHA256 5303b9ece7c75e693348f07c66b00ad438b1ce805da08f02123242f61d7c06af
MD5 bad25fad759aeb48aa5551d291e20498
BLAKE2b-256 f77e7e91d5d8244bba8e05730c9adea792959c6009632022daccf1da7baea46a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for peer_pytorch-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 f78b413e9485d9d0fe6ed5f45f8c9bd5e0208ad47899d6d085dc9c3ff31c7192
MD5 118b16fc58d0f7ef53b447d2e8ee98ec
BLAKE2b-256 116d1e8888eb7624feafefc92850a4cf4e9b5d929e70a117a2853da5243b983d

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