PoPE
Project description
PoPE-pytorch (wip)
Efficient implementation (and explorations) into polar coordinate positional embedding (PoPE) - from Gopalakrishnan et al. under Schmidhuber
Install
$ pip install PoPE-pytorch
Usage
import torch
from PoPE_pytorch import PoPE
# define pope
pope = PoPE(64, heads = 8)
# pass in sequence length
pos_embed = pope(1024)
# queries and keys in attention
q = torch.randn(1, 8, 1024, 64)
k = torch.randn(1, 8, 1024, 64)
# training
rotated_q, rotated_k = pope.apply_pope_to_qk(pos_embed, q, k)
# inference
rotated_q, rotated_k = pope.apply_pope_to_qk(pos_embed, q[..., -1:, :], k)
Fused Attention Similarity
import torch
from PoPE_pytorch import PoPE, compute_attn_similarity
# define pope
pope = PoPE(dim = 64, heads = 8).cuda()
# get rotations
pos_emb = pope(1024)
# queries and keys
q = torch.randn(1, 8, 1024, 64).cuda()
k = torch.randn(1, 8, 1024, 64).cuda()
# fused attention similarity, avoiding expanding 64 to 128
sim = compute_attn_similarity(q, k, pos_emb) # (1, 8, 1024, 1024)
attn = sim.softmax(dim = -1) # the usual in attention..
Citations
@misc{gopalakrishnan2025decouplingwhatwherepolar,
title = {Decoupling the "What" and "Where" With Polar Coordinate Positional Embeddings},
author = {Anand Gopalakrishnan and Robert Csordás and Jürgen Schmidhuber and Michael C. Mozer},
year = {2025},
eprint = {2509.10534},
archivePrefix = {arXiv},
primaryClass = {cs.LG},
url = {https://arxiv.org/abs/2509.10534},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pope_pytorch-0.0.9.tar.gz
(208.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pope_pytorch-0.0.9.tar.gz.
File metadata
- Download URL: pope_pytorch-0.0.9.tar.gz
- Upload date:
- Size: 208.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27bd2bb02c4996c8caf8cb54e38ccc0467820daf4eb21802724c0fed07ce0c7d
|
|
| MD5 |
9fd43ecaa3bab6d846082d79fc323f32
|
|
| BLAKE2b-256 |
04e025ac1027ee264055f6b24d4d5e7f6975b1ef08142bca38118758a0cf9734
|
File details
Details for the file pope_pytorch-0.0.9-py3-none-any.whl.
File metadata
- Download URL: pope_pytorch-0.0.9-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3ea679afacfdf78e5dcea2b7c8467107e43b4fdc2ace3525ccc7095208b5ba0
|
|
| MD5 |
5184da01f37f29ada9bb7809d40757df
|
|
| BLAKE2b-256 |
522e0282d0c8b8ccb78f51de703000a20fc6b4d5a3120941f54621a6275fcff8
|