File size: 21,793 Bytes
e2bfccc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
# Gamma Space Model

Gamma Space Model is a PyTorch codebase for experimenting with a Gamma-structured state space model (SSM) and an S4-inspired enhanced Gamma SSM while preserving a fixed lower-bidiagonal ternary-friendly transition matrix.

This repository is now organized as an installable Python package:

1. `gamma_space_model/` contains the models we are actively developing.
2. `csrc/` contains optional pure-Python acceleration helpers used when the runtime supports them.
3. `output/jupyter-notebook/` contains the benchmark notebooks and saved Colab runs.

Earlier versions of this repository included a copied `s4-main/` reference tree. That vendored copy has been removed so the project can behave like a normal package. S4 remains an external theory/reference dependency, cited below, rather than source code we ship inside this repo.

The current project direction is:

- keep the Gamma / ternary transition structure for deployment compatibility
- borrow the most useful ideas from S4 for stability and full-sequence efficiency
- benchmark both training-time full-sequence behavior and deployment-time recurrent behavior

## Repository Layout

```text

gamma_ssm_s4_v2/

|-- gamma_space_model/

|   |-- modules/

|   |   |-- ssm_gamma.py        # original Gamma SSM core

|   |   |-- block.py            # original residual Gamma block

|   |   |-- ssm_gamma_s4.py     # S4-inspired enhanced Gamma SSM core

|   |   |-- block_s4.py         # enhanced Gamma blocks

|   |   `-- normalization.py    # LayerNorm, RMSNorm

|   |-- ops/

|   |   `-- selective_scan_interface.py

|   `-- __init__.py

|-- csrc/

|   `-- tilelang/                 # optional acceleration helpers

|-- output/jupyter-notebook/

|   |-- gamma-s4-sinewave-benchmark.ipynb

|   |-- gamma-s4-research-benchmark.ipynb

|   |-- gamma-s4-challenge-benchmark.ipynb

|   `-- *_rN.ipynb              # saved Colab benchmark runs

|-- scripts/

|   |-- generate_gamma_benchmark_notebook.py

|   `-- generate_gamma_challenge_benchmark_notebook.py

|-- tests/

|-- EXPERIMENT_RECORD.md        # run-by-run experiment history

|-- pyproject.toml              # package metadata for pip install

|-- setup.py                    # compatibility shim for editable installs

`-- Gamma Distributed Ternary HiPPO.pdf

```

## What We Are Modeling

At the highest level, all variants in this repo are state space models. The standard continuous-time form is

```math

\dot{h}(t) = A h(t) + B u(t), \qquad y(t) = C h(t) + D u(t)

```

where:

- `u(t)` is the input sequence
- `h(t)` is the latent state
- `y(t)` is the output sequence
- `A` controls the state dynamics
- `B` injects the input into the state
- `C` reads the state back out
- `D` is a direct skip term

The main design choice in this project is to keep `A` structured and deployment-friendly.

## The Gamma Transition Matrix

The original Gamma SSM in this repo uses a fixed lower-bidiagonal matrix:

```math

A_{n,n} = -1, \qquad A_{n,n-1} = 1

```

and zero everywhere else.

In matrix form:

```text

[-1  0  0  ...]

[ 1 -1  0  ...]

[ 0  1 -1  ...]

[ .  .  .   . ]

```

This is important for the project because:

- it is sparse
- it only uses the values `-1`, `0`, and `1`
- it maps naturally to the ternary computing direction we care about

That structural constraint is the main reason we do not simply replace Gamma with a standard S4 parameterization.

## The Original Gamma SSM

The original implementation is in [`gamma_space_model/modules/ssm_gamma.py`](./gamma_space_model/modules/ssm_gamma.py).

It uses Euler discretization:

```math

h_{t+1} = h_t + \Delta t \, (A h_t + B u_t)

```

and output readout:

```math

y_t = C h_{t+1}

```

Key properties of the baseline:

- fixed Gamma `A`
- learned `B` and `C`
- scalar fixed `delta_t`
- recurrent forward pass
- optional TileLang/Triton accelerated scan path when available

This version is the simplest and most deployment-aligned baseline in the repo.

## The S4-Inspired Enhanced Gamma SSM

The enhanced implementation is in [`gamma_space_model/modules/ssm_gamma_s4.py`](./gamma_space_model/modules/ssm_gamma_s4.py).

The goal is not to become full S4. The goal is to keep the Gamma transition structure while borrowing ideas that made S4 powerful and stable:

- learned positive timestep `dt`
- stable discretization
- optional direct skip term `D`
- full-sequence kernel view for parallel training/inference
- recurrent stepping for deployment
- Mamba-inspired input selection before the Gamma SSM

### Discretization

The enhanced model supports three discretizations:

#### Euler

```math

\bar{A} = I + \Delta t A, \qquad \bar{B} = \Delta t B

```

#### Bilinear (Tustin)

```math

\bar{A} = (I - \tfrac{1}{2}\Delta t A)^{-1}(I + \tfrac{1}{2}\Delta t A)

```

```math

\bar{B} = (I - \tfrac{1}{2}\Delta t A)^{-1}\Delta t B

```

#### ZOH

```math

\bar{A} = e^{\Delta t A}

```

```math

\bar{B} = A^{-1}(\bar{A} - I)B

```

The default practical choice is bilinear discretization, because it has been the most stable and effective in our current experiments.

### Kernel View

For a linear time-invariant discrete SSM, the output can also be written as a causal convolution:

```math

y_t = \sum_{\ell=0}^{t} K_{\ell} u_{t-\ell} + D u_t

```

with kernel

```math

K_{\ell} = C \bar{A}^{\ell} \bar{B}

```

This gives us two useful execution styles for the same model:

- recurrent stepping: useful for deployment and streaming
- full-sequence kernel/convolution view: useful for parallel whole-sequence computation

In this repo, the enhanced model exposes:

- `kernel_mode="recurrent"`
- `kernel_mode="conv"`
- `kernel_mode="auto"`

The `auto` mode switches to the kernel path only when the sequence is long enough to justify it.

## Why This Is Not "Full S4"

This is the central design tradeoff of the project.

S4 gets its strongest speedups from a structured parameterization of `A` that can be diagonalized or reduced to efficient kernel computations such as Cauchy/Vandermonde operations.

Our Gamma model intentionally keeps:

- a fixed lower-bidiagonal `A`
- ternary-friendly values
- deployment-oriented structure

So we borrow selected S4 ideas, but we do not inherit the entire original S4 kernel machinery.

That means:

- we can improve stability and full-sequence performance substantially
- but the exact original S4 fast-kernel theory does not transfer directly

## Block Design

### Original Block

[`gamma_space_model/modules/block.py`](./gamma_space_model/modules/block.py) defines `GammaSingleBlock`.

Its structure is:

```text

x

-> LayerNorm (if prenorm)

-> Gamma SSM

-> Dropout

-> Residual add

-> optional postnorm

```

### Enhanced Block

[`gamma_space_model/modules/block_s4.py`](./gamma_space_model/modules/block_s4.py) defines `GammaS4Block`.

Its structure is:

```text

x

-> LayerNorm

-> optional input-selection gate

-> SSMGammaS4

-> activation

-> optional gate

-> optional output linear

-> layer scale

-> dropout

-> residual add

```

In equations, the enhanced block is roughly:

```math

\tilde{x} = \mathrm{Norm}(x)

```

```math

u = \tilde{x} \odot \sigma(W_{in\_gate}\tilde{x} + b_{in\_gate})

```

```math

s = \mathrm{SSMGammaS4}(u)

```

```math

z = \mathrm{OutputLinear}(\sigma(s) \odot \mathrm{Gate}(\tilde{x}))

```

```math

\mathrm{Block}(x) = x + \alpha z

```

where:

- `sigma` is the chosen activation
- the input-selection gate is a per-token channel gate inspired by Mamba's selective input flow
- `Gate` may be absent
- `alpha` is a learnable layer-scale parameter

The input-selection gate does not change the fixed Gamma transition matrix `A`. It modulates the input before it enters the state, so the model can learn to emphasize information-bearing tokens and suppress blanks/noise while keeping the ternary-friendly state transition intact.

There is also a lighter variant:

- `GammaS4MinimalBlock`

which removes the richer input-gating/output-gating/output-linear pathway and keeps only the core S4-inspired stability changes.

## Stacked Model Pattern

The benchmark notebooks use a simple stacked forecaster pattern:

```math

x_0 = W_{in} u

```

```math

x_{\ell+1} = \mathrm{Block}_{\ell}(x_{\ell})

```

```math

\hat{y} = W_{out} x_L

```

This pattern is implemented inside the notebooks rather than as a dedicated package module because we are still iterating rapidly on benchmark design.

## Full-Sequence vs Recurrent vs Deployment-Lite

The benchmarks report several distinct execution modes.

### 1. Full-sequence

The whole sequence is passed to `forward(...)` in one call.

This is the relevant mode for:

- standard training
- offline batch inference
- full-sequence throughput comparisons

Important detail:

- full-sequence does not always mean convolution is being used
- it only means the whole sequence is evaluated in one forward pass

### 2. Recurrent

The model is stepped token by token using `step(...)` while carrying state.

This is the relevant mode for:

- streaming inference
- autoregressive deployment
- hardware-style stateful execution

### 3. Deployment-lite

This is an experimental recurrent inference mode for `GammaS4Block`.

It uses the same trained weights but simplifies part of the block-time recurrent computation to reduce runtime. The current lite path is intentionally aggressive: it skips the input-selection gate and post-SSM gate/output branch during recurrent stepping. The benchmark reports both:

- speed improvement
- output mismatch versus the standard full-sequence prediction

For the baseline model, deployment and recurrent are effectively the same path, so those numbers match exactly.

### 4. Balanced deployment

This is a middle-ground recurrent inference mode for `GammaS4Block`.

It keeps the trained output projection, but replaces the input-selection and post-SSM gates with static gates derived from the learned gate biases. This is meant to test whether we can recover more fidelity than deployment-lite while still avoiding the full gate cost at every token.

In the notebooks, these metrics appear as `balanced_deploy_*`.

## Current Empirical Status

The benchmark notebooks live in:

- [`output/jupyter-notebook/gamma-s4-sinewave-benchmark.ipynb`](./output/jupyter-notebook/gamma-s4-sinewave-benchmark.ipynb)
- [`output/jupyter-notebook/gamma-s4-research-benchmark.ipynb`](./output/jupyter-notebook/gamma-s4-research-benchmark.ipynb)
- [`output/jupyter-notebook/gamma-s4-challenge-benchmark.ipynb`](./output/jupyter-notebook/gamma-s4-challenge-benchmark.ipynb)

The challenge notebook is separate from the quick and research notebooks. It tracks harder capability-style tests:

- permuted MNIST for long-range image-as-sequence memory
- selective copying for sparse content recall
- induction-style recall for key-value association across a sequence
- token-memory curriculum tiers for easy, moderate, and hard selective/induction diagnostics

The research and challenge notebooks also include inference-oriented sections. These separate full-sequence prefill-style inference from recurrent decode-style inference, report deployment-lite and balanced deployment variants where available, and include quality/fidelity columns so speed is not interpreted independently from accuracy or output mismatch.

Saved Colab runs are also committed in the same folder using `_rN` suffixes.

### Experiment record guide

The run-by-run history is summarized in [`EXPERIMENT_RECORD.md`](./EXPERIMENT_RECORD.md).

Use that file when you want to answer:

- what changed between `_r1`, `_r2`, ..., `_r10`
- which model variants were tested in each run
- which notebook and task configuration produced each result
- which results are complete, partial, or not recorded
- what we learned from each run

The saved notebooks under `output/jupyter-notebook/` are the raw experiment artifacts. They include the actual Colab outputs, plots, printed metrics, and configuration cells. The experiment record is the human-readable index over those artifacts.

The naming convention is:

- `gamma_s4_sinewave_benchmark_r1.ipynb` and `gamma_s4_sinewave_benchmark_r2.ipynb`
  - early single-notebook experiments before the quick/research split
- `gamma-s4-sinewave-benchmark_rN.ipynb`
  - saved quick benchmark runs
  - use these for fast regression history
- `gamma-s4-research-benchmark_rN.ipynb`
  - saved practical/research benchmark runs
  - use these for presentation and deeper analysis
- `gamma-s4-challenge-benchmark_rN.ipynb`
  - saved challenge benchmark runs
  - use these for permuted MNIST, selective copying, and induction-style recall history

For the current project state, the most useful records are:

- `_r9` research benchmark: best presentation artifact
- `_r10` quick/research benchmarks: latest deployment fidelity comparison with balanced deployment metrics
- `_r8` research benchmark: first mature run with token-lite enabled and strong long-context conv results
- `_r2`: early evidence that `gamma_s4_enhanced` could outperform baseline on harder sequence tasks

When presenting to others, start with the README for theory and architecture, then use `EXPERIMENT_RECORD.md` for the experiment timeline, then open the latest `_rN` research notebook for plots and raw outputs.

### What the quick benchmark is for

The sinewave/quick notebook is the fast regression loop. It is used to answer:

- does the model still train correctly?
- does full-sequence performance remain strong?
- does recurrent/deployment behavior regress?

### What the research benchmark is for

The research notebook is the more presentable and more practical benchmark. It currently includes:

- `current_reference`: medium practical forecasting task
- `long_context`: harder long-range forecasting task
- `token-lite`: lightweight character-level next-token benchmark

### Latest recorded highlights

From the latest committed `_r10` GPU runs:

- Quick benchmark:
  - enhanced val loss is much lower than baseline on both `simple` and `moderate`
  - enhanced full-sequence throughput is higher than baseline
  - enhanced recurrent inference is still slower than baseline

- Research benchmark:
  - `current_reference`
    - enhanced validation loss: `0.019951`
    - baseline validation loss: `0.709749`
  - `long_context`
    - enhanced validation loss: `0.011708`
    - baseline validation loss: `27.229956`
    - enhanced mean epoch time: `15.86s`
    - baseline mean epoch time: `40.35s`
    - enhanced full-sequence throughput: `16957 tokens/s`
    - baseline full-sequence throughput: `2395 tokens/s`
    - enhanced balanced deployment match MSE: `0.001692`
    - enhanced deployment-lite match MSE: `0.200325`
  - `token-lite`
    - enhanced validation CE: `2.4868`
    - baseline validation CE: `3.1322`
    - enhanced perplexity: `12.02`
    - baseline perplexity: `22.92`

The challenge notebook has been added after `_r10`, so its first saved run should be treated as the first challenge-task record.

### Practical interpretation

The current picture is:

- the enhanced Gamma SSM is now clearly the stronger model for full-sequence training and harder tasks
- the long-context conv/full-sequence path is finally showing meaningful advantages
- recurrent deployment remains the main remaining weakness
- challenge recall tasks remain near random, so the next question is whether the model can solve easier curriculum tiers before investing in harder selective-memory variants

## Installation

The distribution package is named `gamma-ssm-s4-enhanced`; the Python import package remains `gamma_space_model`.

### Install From This Checkout

```bash

pip install -e .

```

### Install From GitHub

```bash

pip install "git+https://github.com/StarMists/gamma_SSM_S4_enhanced.git"

```

### Install From A Private GitHub Repo

Use a GitHub personal access token with read access to the private repository. In Colab or a shell, prefer keeping the token in an environment variable instead of hard-coding it into notebooks:

```bash

export GITHUB_TOKEN="ghp_your_token_here"

pip install "git+https://${GITHUB_TOKEN}@github.com/StarMists/gamma_SSM_S4_enhanced.git"

```

In Google Colab:

```python

import os



os.environ["GITHUB_TOKEN"] = "ghp_your_token_here"

!pip install "git+https://${GITHUB_TOKEN}@github.com/StarMists/gamma_SSM_S4_enhanced.git"

```

### Install Optional Extras

For development:

```bash

pip install -e ".[dev]"

```

For benchmark notebooks:

```bash

pip install -e ".[notebook]"

```

For optional performance dependencies:

```bash

pip install -e ".[performance]"

```

For a private GitHub install with extras, use the PEP 508 form:

```bash

pip install "gamma-ssm-s4-enhanced[notebook,performance] @ git+https://${GITHUB_TOKEN}@github.com/StarMists/gamma_SSM_S4_enhanced.git"

```

Notes:

- CUDA / Triton / TileLang acceleration is optional
- the code automatically falls back to pure PyTorch paths when those kernels are unavailable
- installing from GitHub gives downstream LLM code access to the latest committed package without cloning the repo manually

## Quick Start

### Original Gamma block

```python

import torch

from gamma_space_model import GammaSingleBlock



block = GammaSingleBlock(

    d_model=64,

    hidden_dim=128,

    delta_t=0.1,

    prenorm=True,

)



x = torch.randn(2, 128, 64)

y, h_T = block(x)

print(y.shape, h_T.shape)

```

### Enhanced Gamma block

```python

import torch

from gamma_space_model import GammaS4Block



block = GammaS4Block(

    d_model=64,

    hidden_dim=128,

    discretization="bilinear",

    kernel_mode="auto",

    kernel_threshold=384,

    input_gate=True,

    gate=True,

    use_D=True,

)



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

y, h_T = block(x)

print(y.shape, h_T.shape)

```

### Export discretized matrices for deployment

```python

from gamma_space_model import SSMGammaS4



ssm = SSMGammaS4(state_dim=64, hidden_dim=128)

deployment_mats = ssm.export_inference_matrices()

print(deployment_mats.keys())

```

## Tests

The main test files are:

- [`tests/test_ssm_gamma.py`](./tests/test_ssm_gamma.py)
- [`tests/test_block.py`](./tests/test_block.py)
- [`tests/test_ssm_gamma_s4.py`](./tests/test_ssm_gamma_s4.py)

These cover:

- forward and step behavior
- state initialization
- recurrent/full-sequence agreement
- enhanced conv vs recurrent consistency
- deployment cache paths

## Roadmap / Next Improvement Points

These are the main next-step items identified from the latest benchmark runs. They are intentionally listed as a to-do record, not yet implemented in this README update.

1. Improve enhanced recurrent inference further.
   - Full-sequence behavior is now strong.
   - Recurrent deployment remains the largest performance gap.

2. Improve deployment-lite fidelity.
   - It speeds up recurrent inference, but its output mismatch on `long_context` is still too large.

3. Improve structured kernel generation further.
   - The current conv path is much better than before, but it still uses a direct kernel-building loop rather than the strongest possible structured kernel derivation.

4. Strengthen the token benchmark.
   - The current token-lite task is useful for relative comparison, but still too small to serve as a final language-model benchmark.

5. Add more presentation-oriented result summaries.
   - The research notebook now includes task previews and prediction/error plots.
   - A future pass could add automated summary tables or figure exports for slide decks.

## References

### Internal project note

- `Gamma Distributed Ternary HiPPO.pdf` in the repository root

### External references

- Albert Gu, Karan Goel, Christopher Re. *Efficiently Modeling Long Sequences with Structured State Spaces*. ICLR 2022.
  - [arXiv](https://arxiv.org/abs/2111.00396)
  - [official S4 repository](https://github.com/state-spaces/s4)

- Albert Gu, Tri Dao, Stefano Ermon, Atri Rudra, Christopher Re. *HiPPO: Recurrent Memory with Optimal Polynomial Projections*. NeurIPS 2020.
  - [arXiv](https://arxiv.org/abs/2008.07669)

- Albert Gu, Tri Dao. *Mamba: Linear-Time Sequence Modeling with Selective State Spaces*. 2023.
  - [arXiv](https://arxiv.org/abs/2312.00752)

## Citation

Yes, adding citations is good practice here. This repo builds directly on ideas from HiPPO and S4, and the README should make that explicit.

If you use this repository in academic or technical writing, please cite the upstream S4, HiPPO, and Mamba papers above, and mention that this codebase studies a Gamma-structured SSM with S4-inspired enhancements.

Example BibTeX entries:

```bibtex

@inproceedings{gu2022s4,

  title={Efficiently Modeling Long Sequences with Structured State Spaces},

  author={Gu, Albert and Goel, Karan and Re, Christopher},

  booktitle={International Conference on Learning Representations},

  year={2022}

}



@inproceedings{gu2020hippo,

  title={HiPPO: Recurrent Memory with Optimal Polynomial Projections},

  author={Gu, Albert and Dao, Tri and Ermon, Stefano and Rudra, Atri and Re, Christopher},

  booktitle={Advances in Neural Information Processing Systems},

  year={2020}

}



@article{gu2023mamba,

  title={Mamba: Linear-Time Sequence Modeling with Selective State Spaces},

  author={Gu, Albert and Dao, Tri},

  journal={arXiv preprint arXiv:2312.00752},

  year={2023}

}

```