{"id":15600947,"url":"https://github.com/lucidrains/peer-pytorch","last_synced_at":"2025-06-10T10:35:37.368Z","repository":{"id":247603273,"uuid":"826381809","full_name":"lucidrains/PEER-pytorch","owner":"lucidrains","description":"Pytorch implementation of the PEER block from the paper, Mixture of A Million Experts, by Xu Owen He at Deepmind","archived":false,"fork":false,"pushed_at":"2024-08-23T13:19:56.000Z","size":277,"stargazers_count":123,"open_issues_count":4,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-10T01:15:14.439Z","etag":null,"topics":["artificial-intelligence","deep-learning","mixture-of-experts","product-key"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucidrains.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-09T15:46:42.000Z","updated_at":"2025-04-01T18:44:17.000Z","dependencies_parsed_at":"2024-07-09T17:31:31.759Z","dependency_job_id":"b6470529-482e-4813-98a0-2c0fa3f7fe62","html_url":"https://github.com/lucidrains/PEER-pytorch","commit_stats":{"total_commits":26,"total_committers":1,"mean_commits":26.0,"dds":0.0,"last_synced_commit":"6cb671f997c38ad19b27838f3f1a6aacb0a373f4"},"previous_names":["lucidrains/peer-pytorch"],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2FPEER-pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2FPEER-pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2FPEER-pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2FPEER-pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucidrains","download_url":"https://codeload.github.com/lucidrains/PEER-pytorch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137891,"owners_count":21053775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence","deep-learning","mixture-of-experts","product-key"],"created_at":"2024-10-03T02:10:00.806Z","updated_at":"2025-04-10T01:15:20.668Z","avatar_url":"https://github.com/lucidrains.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"./peer.png\" width=\"400px\"\u003e\u003c/img\u003e\n\n\u003cimg src=\"./peer2.png\" width=\"400px\"\u003e\u003c/img\u003e\n\n## PEER - Pytorch\n\nPytorch implementation of the PEER block from the Deepmind paper, \u003ca href=\"https://arxiv.org/abs/2407.04153\"\u003eMixture of A Million Experts\u003c/a\u003e, by Xu Owen He.\n\n## Install\n\n```bash\n$ pip install PEER-pytorch\n```\n\n## Usage\n\n```python\nimport torch\nfrom PEER_pytorch import PEER\n\npeer = PEER(\n    dim = 512,\n    heads = 8,                   # tested up to 32 - (hk = heads * num_experts_per_head (16))\n    num_experts = 1_000_000,     # he chose 1 million\n    num_experts_per_head = 16,   # he settled on 16, but was 32 in PKM paper\n    dim_key = 128,\n    pre_rmsnorm = True\n).cuda()\n\nx = torch.randn(2, 1024, 512).cuda()\n\nout = peer(x) + x\n\nassert x.shape == out.shape\n```\n\n## Citations\n\n```bibtex\n@inproceedings{He2024MixtureOA,\n    title   = {Mixture of A Million Experts},\n    author  = {Xu Owen He},\n    year    = {2024},\n    url     = {https://api.semanticscholar.org/CorpusID:271038610}\n}\n```\n\n```bibtex\n@article{Csordas2023ApproximatingTF,\n    title   = {Approximating Two-Layer Feedforward Networks for Efficient Transformers},\n    author  = {R'obert Csord'as and Kazuki Irie and J{\\\"u}rgen Schmidhuber},\n    journal = {ArXiv},\n    year    = {2023},\n    volume  = {abs/2310.10837},\n    url     = {https://api.semanticscholar.org/CorpusID:264172384}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidrains%2Fpeer-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucidrains%2Fpeer-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidrains%2Fpeer-pytorch/lists"}