Skip to main content

minGRU

Implementation of the proposed minGRU in Pytorch, only the log-space numerically stable version.

Yannic's paper review

Appreciation

Install

$ pip install minGRU-pytorch

Usage

import torch
from minGRU_pytorch import minGRU

min_gru = minGRU(512)

x = torch.randn(2, 1024, 512)

out = min_gru(x)

assert x.shape == out.shape

Sanity check

import torch
from minGRU_pytorch import minGRU

min_gru = minGRU(dim = 512, expansion_factor = 1.5)

x = torch.randn(1, 2048, 512)

# parallel

parallel_out = min_gru(x)[:, -1:]

# sequential

prev_hidden = None
for token in x.unbind(dim = 1):
    sequential_out, prev_hidden = min_gru(token[:, None, :], prev_hidden, return_next_prev_hidden = True)

assert torch.allclose(parallel_out, sequential_out, atol = 1e-4)

Test

enwik8

$ python train.py

Citations

@inproceedings{Feng2024WereRA,
    title   = {Were RNNs All We Needed?},
    author  = {Leo Feng and Frederick Tung and Mohamed Osama Ahmed and Yoshua Bengio and Hossein Hajimirsadegh},
    year    = {2024},
    url     = {https://api.semanticscholar.org/CorpusID:273025630}
}
@inproceedings{anonymous2024hymba,
    title   = {Hymba: A Hybrid-head Architecture for Small Language Models},
    author  = {Anonymous},
    booktitle = {Submitted to The Thirteenth International Conference on Learning Representations},
    year    = {2024},
    url     = {https://openreview.net/forum?id=A1ztozypga},
    note    = {under review}
}

Metadata

Release files for minGRU-pytorch 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for minGRU-pytorch 0.2.1
File Size Uploaded Provenance Actions
mingru_pytorch-0.2.1.tar.gz 36.6 MB Without provenance Details for mingru_pytorch-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for minGRU-pytorch 0.2.1
File Interpreter ABI Platform Actions
mingru_pytorch-0.2.1-py3-none-any.whl Python 3 none any Details for mingru_pytorch-0.2.1-py3-none-any.whl

Total release size: 36.6 MB

Release files / mingru_pytorch-0.2.1.tar.gz

Download URL mingru_pytorch-0.2.1.tar.gz
Size 36.6 MB
Tags Source
SHA-256 checksum
How to use checksums
fc9b278b4e04db930a5cd4cdab36e2713b1d6e14084269b161d4f133819e758d
BLAKE2b-256 checksum
How to use checksums
71b5ef07d75b1e7a33175c372332d3885bc4411908e0a9785325f92599005ac0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release files / mingru_pytorch-0.2.1-py3-none-any.whl

Download URL mingru_pytorch-0.2.1-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22e83b7e9437f4b1a04c21b7e47686fd6ef2fa60bc961cd19e295a592e5e58d7
BLAKE2b-256 checksum
How to use checksums
60e5d2992e2813314add3a0d368d8b57904007a31917a5455005d1d7b8714c6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Security for minGRU-pytorch 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page