Hyena
A subquadratic drop-in replacement for attention built from implicit long convolutions and gating.
Language · 52 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
At a glance
- Task
- Language
- Parameters
- 1.1M
- Operations
- 52
- Framework
- PyTorch
- Recurrent
- No
- Published
- 2023
- Cited by
- 622 (as of 17 November 2026)
- Authors
- Michael Poli, Stefano Massaroli, Eric Nguyen and others
- Source
- GitHub: HazyResearch/safari
- License
- Apache-2.0
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m1386
- Graph hash
- 25405f5731096170ba0be6b710a11886f48e522cf37f135d85d75dedde4f6e15
- Skeleton hash
- dbc4422e46433870c51dc83b7ba54e23d290e7a24e985b18ee812172f2a97db8
- Architecture hash
- eba76ffe02c3d22819a3145de629df7f237b40c08003187ef260f7b5924ec881
- Diagram SHA-256
- 966678fe7d662d14c23eaaccf3e2c269d0675a660c0767a6c0b28dd9b98f5582
- TorchLens version
- 2.36.0
- Renderer
- graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
- Check
- Forward pass replayed in PyTorch
What it is
Hyena is a subquadratic drop-in replacement for attention, built by interleaving implicitly parametrized long convolutions with data-controlled gating. The motivation is the cost of the attention operator, which grows quadratically in sequence length and limits the amount of context a model can reach. Earlier subquadratic methods based on low-rank and sparse approximations still had to be combined with dense attention layers to match Transformers, which the authors read as a gap in capability.
The operator is defined as a recurrence of two efficient subquadratic primitives, a long convolution and element-wise multiplicative gating. The convolution filters are not stored as explicit weights; each Hyena filter is parameterized by a feed-forward network, with sine as the activation function for that network. The paper situates the design as generalizing a line of gated state-space work such as H3 by introducing a recurrence of gates and implicit long convolutions, evaluated efficiently. The time complexity of a Hyena recurrence is O(N L log2 L). The captured member is the order-2 HyenaOperator from the safari repository, which was forked from Albert Gu's state spaces repo and borrows its structure.
On recall and reasoning tasks over thousands to hundreds of thousands of tokens, Hyena improves accuracy by more than 50 points over operators relying on state-spaces and other implicit and explicit methods, matching attention-based models. On WikiText103 and The Pile it reaches Transformer quality with a 20% reduction in training compute at sequence length 2K. Hyena operators are twice as fast as highly optimized attention at sequence length 8K, and 100x faster at sequence length 64K. The authors also swap Hyena into a Vision Transformer in place of attention on ImageNet and match performance with ViT.
Key idea. An attention-free operator that interleaves implicitly parametrized long convolutions with data-controlled gating, matching Transformer quality on language modeling at subquadratic cost.
- hyena
- hyena hierarchy
- hyena operator
- long convolution
- implicit convolution
- gating
- subquadratic attention replacement
- convolutional language model
- fftconv
- safari
- state spaces
- the pile
- wikitext103
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{poli2023hyenahierarchylargerconvolutional,
title={Hyena Hierarchy: Towards Larger Convolutional Language Models},
author={Michael Poli and Stefano Massaroli and Eric Nguyen and Daniel Y. Fu and Tri Dao and Stephen Baccus and Yoshua Bengio and Stefano Ermon and Christopher Ré},
year={2023},
eprint={2302.10866},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2302.10866},
}