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

Uploaded Source

Built Distribution

peer_pytorch-0.0.5-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: peer_pytorch-0.0.5.tar.gz
  • Upload date:
  • Size: 98.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.0.5.tar.gz
Algorithm Hash digest
SHA256 f6b368d8545bbdf771bba0bff6e3afb69578f56070c5e775d610d65119232c14
MD5 b978320a2e60148400c17cb2483fe935
BLAKE2b-256 b82d53763eb46321dccf2f91e134d6b7bc52d329deec54d1af3a8d04c78dab42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for peer_pytorch-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c6f56a22332aac1951fe77824b5fbd5c21935469938bf341fb422dfa9977005a
MD5 220625f14e2115a1316cb6629a48613d
BLAKE2b-256 b36fe0493b9f33db0ab79d8d7a363dd7b9caa675da1cfc8f9addd5f845b3f72f

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