Skip to main content

A Proximal One-step Geometric Orthoptimizer in Pytorch

Project description

A Proximal One-step Geometric Orthoptimizer

This a PyTorch implementation of the POGO algorithm proposed in An Embarrassingly Simple Way to Optimize Orthogonal Matrices at Scale. This is a lightweight and easy-to-use library containing the optimizer as a normal Pytorch Optimizer, and two base optimizers to choose for from now: SGD and Vector Adam.

Beware: You should pass only orthogonal parameters to POGO and initialize them as such. See below!

Installation

You can install pogo from pip by simply running

pip install pogo-torch

Or, if you are using uv, you can add it to your project with

uv add pogo-torch

Alternatively, you can install it directly from the repository:

pip install git+https://github.com/adrianjav/pogo

Getting started

POGO is implemented as a Pytorch optimizer, so it should be quite intuitive to use. Moreover, the default parameters should work for most use cases. If that were not the case, feel free to check the docstrings and ultimately open an issue.

To initialize your parameters as orthogonal, you can either use torch.init.orthogonal_ (but make sure it does what you intend given the shape of your parameters) or use any other initialization method and then project them to be orthogonal. For example:

X = ... # My parameter
U, S, VT = torch.linalg.svd(X, full_matrices=False)
X.data = U @ VT

Then, you can use POGO as any other optimizer:

from pogo import base, POGO

model = ...  # Ensure that your parameters are initialized as orthogonal!
optimizer = POGO(model.parameters(), base.VectorAdam(), learning_rate)

for epoch in range(num_epochs):
    optimizer.zero_grad()
    ...
    loss.backward()
    optimizer.step()

By default, POGO expects matrices of the form [num_matrices, p, n] with $p < n$ and such that torch.bmm(X, X) yields num_matrices identity matries of size $p \times p$. If that does not fit your needs (e.g. you have more than one leading axis, or you need colum-orthogonal matrices), then please do check POGO's flatten_fn and rows parameters.

Citation

@article{javaloy2026pogo,
    title   = {An Embarrassingly Simple Way to Optimize Orthogonal Matrices at Scale},
    author  = {Javaloy, Adri{\'a}n and Vergari, Antonio},
    year    = 2025,
	journal = {ArXiv preprint},
	volume  = {2602.14656},
	url     = {https://arxiv.org/abs/2602.14656}
}

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

pogo_torch-1.0.2.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

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

pogo_torch-1.0.2-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file pogo_torch-1.0.2.tar.gz.

File metadata

  • Download URL: pogo_torch-1.0.2.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pogo_torch-1.0.2.tar.gz
Algorithm Hash digest
SHA256 1692174d7c4c8ec26d65ce259c8d2e73d5b16a261de4d55c6eb635a97d88801a
MD5 13a526ea21c87294e06826ee6f2c5666
BLAKE2b-256 72d58481cd46ed481e02b8586e82ee6b81de73f4f09aa16fe0cf721627e3f966

See more details on using hashes here.

Provenance

The following attestation bundles were made for pogo_torch-1.0.2.tar.gz:

Publisher: publish.yml on adrianjav/pogo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pogo_torch-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pogo_torch-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pogo_torch-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d5d63e956ea02ea54c1572ce4900fe3b665191580adc9e464f339354a39af504
MD5 4dc6255d3056d7319f9e78ee1320e579
BLAKE2b-256 554484d0867325801817deeecfc7c55133193bdd7a452a40939091f2851bfbdb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pogo_torch-1.0.2-py3-none-any.whl:

Publisher: publish.yml on adrianjav/pogo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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