PRISM: Breaking the O(n) Memory Wall in Long-Context LLM Inference via O(1) Photonic Block Selection
Organizations: Department of Physics, Chungnam National University, Daejeon 34134, Republic of Korea
Abstract
Long-context LLM inference is bottlenecked not by compute but by the O(n) memory bandwidth cost of scanning the KV cache at every decode step -- a wall that no amount of arithmetic scaling can break. Recent photonic accelerators have demonstrated impressive throughput for dense attention computation; however, these approaches inherit the same O(n) memory scaling as electronic attention when applied to long contexts. We observe that the real leverage point is the coarse block-selection step: a memory-bound similarity search that determines which KV blocks to fetch. We identify, for the first time, that this task is structurally matched to the photonic broadcast-and-weight paradigm -- the query fans out to all candidates via passive splitting, signatures are quasi-static (matching electro-optic MRR programming), and only rank order matters (relaxing precision to 4-6 bits). Crucially, the photonic advantage grows with context length: as N increases, the electronic scan cost rises linearly while the photonic evaluation remains O(1). We instantiate this insight in PRISM (Photonic Ranking via Inner-product Similarity with Microring weights), a thin-film lithium niobate (TFLN) similarity engine. Hardware-impaired needle-in-a-haystack evaluation on Qwen2.5-7B confirms 100% accuracy from 4K through 64K tokens at k=32, with 16x traffic reduction at 64K context. PRISM achieves a four-order-of-magnitude energy advantage over GPU baselines at practical context lengths (n >= 4K).
Figures & tables
| Parameter | Value | Notes |
| Platform | X-cut TFLN | 600 nm LN/SiO 2 |
| Waveguide | Rib, m | 500 nm etch |
| MRR radius | m | FSR 8.3 nm |
| FDTD: 12,500 | ||
| Extinction | 15 dB | Add-drop |
| Wt. precision | 5 bit | EO resolution |
| Element | Loss (dB) | Cumulative (dBm) |
|---|---|---|
| Laser output | — | 20.0 |
| Fiber–chip coupling | 2.0 | 18.0 |
| MZM modulator (avg.) | 3.0 | 15.0 |
| splitter | 25.7 a | 10.7 |
| Waveguide (2 cm) | 1.0 | 11.7 |
| MRR (balanced, worst-case drop) | 3.2 b | 14.9 |
| Impairment | Parameter | Range |
|---|---|---|
| Weight quantization | (bits) | 4–8 |
| Thermal drift | ( ) | 10–100 |
| MRR insertion loss | IL ( ) | 0.02–0.05 c |
| Splitter excess loss | ( ) | 0.1–0.3 |
| Detector NEP | ( ) | 1–20 |
| MRR crosstalk | Isolation ( ) | 15 to 30 |
| Component | Power ( ) | Energy/query ( ) |
|---|---|---|
| Laser source | 20.0 | 180 |
| TEC (thermal stab.) | 1000 | 9000 † |
| Voltage driver array | 5.0 | 45 |
| DACs ( channels) | 32.0 | 288 |
| MZM modulators | 6.4 | 58 |
| EO bias (static) | ∗ |
| Stage | Latency | Notes |
|---|---|---|
| DAC | 1 ns | 4-bit |
| MZM | 0.1 ns | Si depl. |
| Opt. prop. | 0.5 ns | 5 cm |
| MRR decay | 0.1 ns | |
| PD | 0.2 ns | Ge |
| TIA+ADC | 2 ns | 6-bit flash |
| Model | Context | (%) | Heads | Mean |
|---|---|---|---|---|
| Qwen2.5-7B | 2K | 83.9 | 94/112 | 0.574 |
| 4K | 83.0 | 93/112 | 0.560 | |
| 8K | 91.1 | 102/112 | 0.627 | |
| 16K | 92.9 | 104/112 | 0.639 | |
| 32K | 95.5 | 107/112 | 0.656 | |
| 65K | 92.0 | 103/112 | 0.633 |
| Blocks | R@8 (%) | R@16 (%) | R@32 (%) | NIAH (%) | |
|---|---|---|---|---|---|
| 4K | 16 | 46.7 | 100 | — ∗ | 100 |
| 8K | 32 | 29.2 | 55.8 | 100 | 100 |
| 16K | 64 | 26.7 | 41.7 | 57.5 | 100 |
| 32K | 128 | (OOM † ) | 100 | ||
| 64K | 256 | — | 100 | ||
| Configuration | 2K | 4K | 8K |
|---|---|---|---|
| Full attention | 90.9 | 100.0 | 100.0 |
| Ideal select | 90.9 | 100.0 | 100.0 |
| 5-bit, 20 pm | 90.9 | 100.0 | 100.0 |
| 4-bit, 30 pm | 90.9 | 100.0 | 100.0 |
| 5-bit, 10 pm | 90.9 | 100.0 | 100.0 |
| Configuration | 4K | 8K | 16K | 32K | 64K | 128K † |
|---|---|---|---|---|---|---|
| Full attention | 100 | 100 | 100 | 100 | 100 | 45.5 |
| Ideal ( ) | 100 | 100 | 100 | 100 | 100 | 18.2 ‡ |
| 5-bit, 20 pm | 100 | 100 | 100 | 100 | 100 | 27.3 ‡ |
| 4-bit, 30 pm | 100 | 100 | 100 | 100 | 100 | 27.3 ‡ |
| 5-bit, 10 pm | 100 | 100 | 100 | 100 | 100 | 27.3 ‡ |
| Context | Feasibility | |||
|---|---|---|---|---|
| 32 | 256 | 32K | Current TFLN | |
| 64 | 1024 | 128K | Near-term | |
| 128 | 4096 | 512K | Multi-chip |
Appendix figures & tables6 assets
Supplementary material from the paper’s appendix.
Appendix
LLM Inference Acceleration
LLM inference acceleration develops algorithms and systems that reduce language-model latency, memory use, and serving cost while preserving output quality.
See all 1,084 papers