Documentation Index
Fetch the complete documentation index at: https://mintlify.com/SforAiDl/lrnnx/llms.txt
Use this file to discover all available pages before exploring further.
Why discretization?
Linear RNNs are based on continuous-time state-space models:A_bar and B_bar are the discretized matrices obtained from continuous-time A and B.
The discretization method you choose affects the model’s stability, accuracy, and how it handles different temporal patterns.
Available methods
lrnnx implements several discretization methods from the literature. Each has different properties and use cases:Zero-Order Hold
Most common - assumes input is constant between timesteps
Bilinear
Original S4 method - trapezoidal approximation
Dirac
For event-based data - treats inputs as impulses
Zero-Order Hold (ZOH)
Mathematical formulation
ZOH is the most widely used discretization method in modern linear RNNs. It assumes the input signal is piecewise constant (held) between timesteps: WhereΔ is the discretization step size (learned or fixed), and γ_bar is used to compute B_bar = γ_bar * B.
Implementation
Fromlrnnx/core/discretization.py:
Usage
- LTI Model
- LTV Model
When to use ZOH
Default choice
Default choice
ZOH is the recommended default for most applications. It’s used in:
- S4D, S5 (both LTI and LTV variants)
- LRU
- Mamba (default)
- Most modern linear RNN papers
Sampled continuous signals
Sampled continuous signals
Ideal when your discrete sequence comes from sampling a continuous signal:
- Audio (sampling continuous sound waves)
- Time series (sampling continuous measurements)
- Video (sampling continuous visual scenes)
Bilinear method
Mathematical formulation
The bilinear method (also called Tustin’s method or trapezoidal rule) was the original discretization used in S4:Implementation
Fromlrnnx/core/discretization.py:
Usage
When to use bilinear
Original S4 compatibility
Original S4 compatibility
Use bilinear if you need to exactly reproduce results from the original S4 paper or checkpoints.
Numerical stability
Numerical stability
Bilinear can provide better stability properties for certain system matrices, though ZOH is generally preferred in modern implementations.
Most modern implementations (including S4D, S5, Mamba) use ZOH by default as it tends to perform better empirically.
Dirac method
Mathematical formulation
The Dirac method treats inputs as instantaneous impulses (Dirac delta functions) rather than sustained signals: Note thatγ_bar = 1.0 (constant), unlike ZOH where it depends on A.
Implementation
Fromlrnnx/core/discretization.py:
Usage
When to use Dirac
Event-based processing
Event-based processing
Dirac discretization is designed for event-based data where inputs represent discrete events rather than continuous signals:
- Neuromorphic spike trains
- Event cameras (DVS sensors)
- Point process data
Impulse responses
Impulse responses
Use when modeling systems that respond to instantaneous inputs rather than sustained signals.
Asynchronous discretization
Mathematical formulation
Asynchronous discretization allows different timesteps at each sequence position, useful for irregular event streams:Implementation
Fromlrnnx/core/discretization.py:
Usage
When to use async
Irregular time series
Irregular time series
When your data has non-uniform sampling intervals:
- Medical records with irregular timestamps
- Financial tick data
- Sensor networks with asynchronous reporting
Event-based sensors
Event-based sensors
Neuromorphic event cameras and other asynchronous sensors where events occur at irregular intervals.
Model compatibility
Different models support different discretization methods:- LTI Models
- LTV Models
| Model | zoh | bilinear | dirac | async |
|---|---|---|---|---|
| S4 | ✓ | ✓ | ✓ | ✗ |
| S4D | ✓ | ✓ | ✓ | ✗ |
| S5 | ✓ | ✓ | ✓ | ✗ |
| LRU | ✓ | ✓ | ✓ | ✗ |
| Centaurus | ✓ | ✓ | ✓ | ✗ |
LTI models cannot use async discretization because it creates time-varying dynamics.
Advanced: Custom discretization
You can implement custom discretization methods by following the function signature:Quick reference
ZOH
Default choiceUse for: Most applications, sampled continuous signalsModels: All LTI and LTV models
Bilinear
Original S4 methodUse for: S4 compatibility, specific stability requirementsModels: All LTI and LTV models
Dirac
Event-basedUse for: Neuromorphic data, event cameras, impulse responsesModels: All LTI and LTV models
Async
Irregular timestepsUse for: Asynchronous events, irregular time seriesModels: LTV models only
Next steps
Linear RNNs
Learn the fundamentals of linear RNNs
LTI vs LTV
Understand when to use each model type
Model Reference
Detailed API documentation for all models
Examples
See complete usage examples
