Practical overview
When it fits
Use it when a Python/PyTorch project needs the documented minGRU component, especially when the same sequence-processing workflow calls for both parallel input handling and sequential token-by-token inference.
Who it is for
- PyTorch developers adding a recurrent sequence-processing component to a model.
- Researchers and practitioners experimenting with minGRU-based sequence or language-model architectures.
Documented uses
- Apply a minGRU layer to a batched sequence tensor.
- Process a sequence in parallel or incrementally, carrying hidden state between tokens.
- Use a minGRU implementation as a basis for sequence-model experiments.
Requirements & limits
The public repository identifies the project as open source under the MIT license.
- The implementation is specifically the log-space numerically stable version.
- The documented interface supports batched sequence tensors and a sequential mode that carries forward hidden state.
- The repository provides a pip installation command and an enwik8 training entry point.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Install and apply the minGRU layer
Add the documented minGRU component to a Python sequence-model experiment and apply it to a batched input tensor.
Before you start
- Python
- PyTorch
- Installation through pip
Steps
Install the package with the command below.
pip install minGRU-pytorchImport
torchandminGRUfromminGRU_pytorch.Create a layer with
minGRU(512)and a tensor such astorch.randn(2, 1024, 512).Call the layer on the tensor to obtain the sequence output.
Expected outcome
A minGRU layer is applied to a batched sequence tensor; the README example shows output with the same shape as its input.
Guide limitations
- The documented implementation is the log-space numerically stable version.
- The example does not establish performance or compatibility beyond its stated use.
Process a sequence sequentially with carried hidden state
Use the documented token-by-token interface and pass hidden state between sequence steps.
Before you start
- Python
- PyTorch
- The installed minGRU-pytorch package
- A sequence tensor with batch, sequence and feature dimensions
Steps
Create a minGRU layer, as in the README example.
Initialize the previous hidden state as
None.Unbind the input sequence along its sequence dimension and call the layer for each token, passing the previous hidden state and setting
return_next_prev_hidden=True.Retain the returned hidden state for the next token.
Expected outcome
Each token is processed in sequence while the hidden state is carried forward.
Guide limitations
- The README's numerical comparison is a documented example, not an independent execution test.
- The example compares final parallel and sequential outputs for a particular tensor and configuration.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 8 October 2026
- Original website title
- lucidrains/minGRU-pytorch · Official homepage title · retained in its source language

