MinMax Recurrent Neural Cascades
A parallelisable recurrent sequence model built on the MinMax operator — expressively powerful, efficiently implementable, and provably not affected by vanishing or exploding gradient.
Resources:
- Paper for the formal description and analyses.
- Repository including architecture reference in
docs/model.md.
Key properties
-
Perfect memory. MinMax neurons can store and retain information arbitrarily long (formal expressivity: all group-free functions).
-
Parallel training. All hidden states across a sequence of length T are computed simultaneously in O(log T) depth, with no sequential bottleneck.
-
Efficient inference. Runs as a true RNN: O(1) compute and O(D) memory per token, making it practical for long-context streaming generation.
-
Stable recurrence. The MinMax operator is bounded and its gradients cannot vanish or explode through the state path.
The model
Each layer contains three sub-modules applied sequentially with pre-norm and residual connections:
- Convolution — one-step causal mixing.
- Feed-forward network — feature mixing (gated or standard MLP).
- MinMax Neuron — the recurrent cell, updating a hidden state
x_{t+1} = max(min(r_t, x_t), s_t)element-wise in parallel via a prefix scan.
Installation
pip install minmaxrnc
PyTorch (≥ 2.0) is required. For GPU support, follow the PyTorch installation guide before installing this package.
Quick start
Sequence backbone
import torch
from minmaxrnc import MinMaxRNC, MinMaxRNCConfig
model = MinMaxRNC(MinMaxRNCConfig.medium()) # d_model=512
u = torch.randn(batch_size, seq_len, 512)
# Parallel over the full sequence (training)
y = model(u, unroll_steps=seq_len) # (B, T, 512)
# Carry state across calls (streaming inference)
y, state = model(u, seq_len, return_state=True)
y_next = model(u_next, seq_len, state=state)
Language model
import torch
from minmaxrnc import MinMaxRNC_LM, MinMaxRNCLMConfig, MinMaxRNCConfig
model = MinMaxRNC_LM(
vocab_size = 50257,
cfg = MinMaxRNCLMConfig(backbone=MinMaxRNCConfig.medium()),
)
tokens = torch.randint(0, 50257, (batch_size, seq_len))
logits = model(tokens, unroll_steps=seq_len) # (B, T, vocab_size)
# Autoregressive generation: prefill on prompt, then generate token by token
logits, state = model(tokens, unroll_steps=seq_len, return_state=True)
for _ in range(max_new_tokens):
next_tok = logits[:, -1].argmax(-1, keepdim=True)
logits, state = model(next_tok, unroll_steps=1, state=state, return_state=True)
Custom configuration
from minmaxrnc import MinMaxRNC, MinMaxRNCConfig
cfg = MinMaxRNCConfig(
d_model = 768,
n_layers = 12,
d_state = 192, # hidden-state dimension per neuron
norm = 'rmsnorm',
ffn_type = 'gated',
ffn_act_fn = 'swish', # → SwiGLU
output_gate = True,
use_postlayers_ffn = True,
)
model = MinMaxRNC(cfg)
Preset sizes
| Preset | d_model |
n_layers |
d_state |
Parameters (backbone) | Parameters (LM, GPT-2 vocab) |
|---|---|---|---|---|---|
small |
90 | 2 | 40 | ~0.1 M | ~4.6 M |
medium |
512 | 8 | 512 | ~16.6 M | ~42.4 M |
large |
728 | 12 | 1456 | ~75.9 M | ~112.5 M |
Running the tests
pytest
How to cite
@misc{ronca2026minmaxpaper,
title={{MinMax} Recurrent Neural Cascades},
author={Alessandro Ronca},
year={2026},
eprint={2605.06384},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2605.06384},
}
@software{ronca2026minmaxcode,
author = {Alessandro Ronca},
title = {{MinMax} Recurrent Neural Cascades},
year = {2026},
url = {https://github.com/minmaxrnc/model},
version = {0.3.0},
}
License
This project is source-available under the PolyForm Noncommercial License 1.0.0.
You may use, copy, modify, and distribute this software only for non-commercial purposes under the terms of that license.
Commercial use is not permitted without a separate commercial license from the copyright holder.
For commercial licensing, contact:
Alessandro Ronca alessandro.ronca@iris-ai.org
Third-party dependencies
This project depends on third-party software, including Python and PyTorch. These dependencies are licensed separately by their respective copyright holders.
See THIRD_PARTY_NOTICES.md for details.
Metadata
Release files for minmaxrnc 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| minmaxrnc-0.3.0.tar.gz | 24.9 kB | Without provenance | Details for minmaxrnc-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| minmaxrnc-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for minmaxrnc-0.3.0-py3-none-any.whl |
Total release size: 48.8 kB
Release files / minmaxrnc-0.3.0.tar.gz
| Download URL | minmaxrnc-0.3.0.tar.gz |
|---|---|
| Size | 24.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e545e46856d4357fdef9e3d9a903e2dcc5d16a870f262313ca44d744f2dd895f
|
|
BLAKE2b-256 checksum How to use checksums |
9ab0178499627e0315b626e44fe73879462634c38d4ce59cebf13a8f1ff38a0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / minmaxrnc-0.3.0-py3-none-any.whl
| Download URL | minmaxrnc-0.3.0-py3-none-any.whl |
|---|---|
| Size | 23.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c13d5e2fedcf28c17ed9c2c35ce8f1b5d8360bb33717e1c772e79e65b76cea0b
|
|
BLAKE2b-256 checksum How to use checksums |
abca75948ff1be0d3e7631b445e8804c9d807d054b58391aa276fe29ae2cb543
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for minmaxrnc 0.3.0
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.