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

Uploaded Source

Built Distribution

peer_pytorch-0.1.4-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: peer_pytorch-0.1.4.tar.gz
  • Upload date:
  • Size: 266.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.1.4.tar.gz
Algorithm Hash digest
SHA256 c04f55e86aeabefea3d18f22aad8aae9880bd6f7dab3b634793ad912edc30ba7
MD5 7cc0d06443d13829c8f7dc9a3546154c
BLAKE2b-256 a73478ee48479a3450d9d74545345842c30c9e435c2db86e58964597d3e9ddda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for peer_pytorch-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4dc9ed4a27d71a29ceebd6f7ebdd3545be75b753072919a1e2ab93a0c6c302a2
MD5 951cf17ffc3a160b7c5eae10822313c0
BLAKE2b-256 0f8f773d001bd34ce09684a81f6f16862212dec9a460666542a1538d70583eb2

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