Skip to main content

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

pope = PoPE(dim = 64, heads = 8).cuda()
pos_emb = pope(1024)

q = torch.randn(1, 8, 1024, 64).cuda()
k = torch.randn(1, 8, 1024, 64).cuda()

# fused triton similarity

sim = compute_attn_similarity(q, k, pos_emb) # (1, 8, 1024, 1024)

attn = sim.softmax(dim = -1) # ...

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


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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pope_pytorch-0.0.8-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file pope_pytorch-0.0.8.tar.gz.

File metadata

  • Download URL: pope_pytorch-0.0.8.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

Hashes for pope_pytorch-0.0.8.tar.gz
Algorithm Hash digest
SHA256 374cbf1dacb102d93540a3306998a88e0fd984b6853e61021f18610472beeb2b
MD5 d991fe035dc67848d9012ad1deb21c4b
BLAKE2b-256 c15e7ab3b7f29511fce2ecd7dcbd4a4a8b746a06757d40106e193cb203c0742d

See more details on using hashes here.

File details

Details for the file pope_pytorch-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: pope_pytorch-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for pope_pytorch-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 2d3f9a9a9d7bb47b9ed8259b4a41473046bb55b9932501ed5498c19c0b1cbf3b
MD5 01cec9a7f045936ac4f224a1d72129a0
BLAKE2b-256 fd00bf844965a1102856c5fa5c72004e5b2f6ba1ad5f4a205a8ea87ab4727ea7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page