Integrated electro-optic attention nonlinearities for transformers

Luis Mickeler, Kai Lion, Alfonso Nardi, Jost Kellner, Pierre Didier, Bhavin J. Shastri, Niao He, Rachel GrangearXiv 2026

TL;DR

This paper introduces an analog electro-optic approach to eliminate the "Softmax bottleneck" in Transformer architectures by replacing digital activation functions with thin-film lithium niobate (TFLN) Mach-Zehnder modulators (MZMs). By executing nonlinear attention mappings as inherent physical transformations, the proposed Optmax and Optmoid frameworks achieve up to two orders of magnitude latency reduction compared to conventional accelerators while maintaining near-parity accuracy, even under aggressive 4-bit quantization.

What Problem Does This Paper Address?

Transformers dominate modern AI, but their core mechanism—self-attention—suffers from a hidden computational bottleneck. While linear operations like matrix multiplications (Matmuls) are heavily accelerated by high-throughput Tensor Cores on modern GPUs, nonlinear operations like Softmax are relegated to Special Function Units (SFUs).

SFUs approximate transcendental functions (like exponentials) using piecewise polynomials, resulting in significantly lower throughput. Consequently, while Softmax accounts for less than 1% of a model's total FLOPs, it can consume over 20% of the total GPU runtime during inference for long sequence lengths. As lower-precision numerical formats speed up linear operations even further, this non-linear bottleneck will only worsen.

GPU runtime bottleneck of GPT-2 and the concept of using co-packaged optics as a nonlinear unit.

Methods

Instead of trying to approximate exponentials digitally, the authors propose leveraging the intrinsic, nonlinear physical transfer function of a Mach-Zehnder modulator (MZM) fabricated on a thin-film lithium niobate (TFLN) platform. They introduce two drop-in hardware-software alternatives for attention modules:

  1. Optmax (Electro-Optic Softmax): Standard Softmax requires exponentiation, summation, and division. Optmax maps digital inputs to analog voltages via a digital-to-analog converter (DAC). It uses the rising slope of a first MZM's sinusoidal response to mimic the exponential numerator. A low-bandwidth photodiode integrates the total power to compute the denominator, which then drives a second MZM operating on its falling slope to perform the reciprocal multiplication (division).
  2. Optmoid (Electro-Optic Sigmoid): As an alternative to the row-wise normalization of Softmax, the authors leverage element-wise Sigmoid attention. Because the Sigmoid function is naturally bounded between 0 and 1, it maps cleanly to the full minimum-to-maximum swing of a single MZM.

To train these models, the authors developed differentiable, hardware-aware forward simulation models that individually account for the finite bit-depth of the DAC and ADC stages.

The Optmax architecture and simulation flow mapping digital inputs to optical responses.

Datasets

The electro-optic nonlinearities were evaluated across two distinct domains:

  • Image Classification: Vision Transformers (ViTs) were trained and evaluated on the MNIST, CIFAR-10, and SVHN datasets.
  • Causal Language Modeling: A 124M-parameter GPT-2 model was trained from scratch and evaluated on the FineWeb-Edu text dataset.

Key Insights and Ideas

  • Preserving Essential Properties: Even though the physical transmission of an MZM is bounded by unity and periodic (unlike a true mathematical exponential), it successfully preserves the two key properties required for attention to work: non-negativity and a non-linear re-weighting scheme that concentrates the distribution.
  • Resilience to Quantization: In digital regimes, Softmax is highly susceptible to accuracy loss during quantization due to the sensitivity of the summation process. The electro-optic architecture sidesteps this by isolating quantization strictly to the input (DAC) and output (ADC) stages. The internal non-linear transformations and accumulations occur entirely in the analog domain with theoretically arbitrary physical precision, making the system remarkably resilient to aggressive 4-bit quantization.

Key Results

  • Accuracy Parity: On CIFAR-10, full-precision Optmax achieved validation performance virtually identical to standard digital Softmax. Under harsh 4-bit quantization, Optmax maintained a mean test accuracy of 74.6% (compared to 76.3% for digital Softmax).
  • Language Modeling Parity: For GPT-2 trained on FineWeb-Edu, Optmax tracked digital Softmax closely, even achieving a slightly lower test loss at 4 bits (5.85 vs 5.97).
  • Massive Speedups: Operating at encoding speeds up to 10 GBaud, Optmax demonstrated a latency of 13.7 ns per sequence (for length $n=64$), outperforming custom digital and electronic accelerators by over an order of magnitude. Optmoid pushed this further, achieving nearly two orders of magnitude improvement with a latency of just 6.5 ns.
FIG. 4. Vision Transformer (ViT) performance using electro-optic nonlinearities. (a) A vision transformer clas- sifies images using stacked transformer blocks. We drop-in replace different attention nonlinearities. (b) Final test accuracy comparison for ViT models on MNIST, CIFAR-10, and SVHN datasets. The proposed Optmax and Optmoid demonstrate competitive performance relative to standard Softmax and Sigmoid benchmarks. (c) Training and validation loss curves for the CIFAR-10 dataset, illustrating stable convergence across all tested activation functions. (d) Quantization sensitivity analysis showing test accuracy as a function of bit-depth (full precision down to 4-bit). (e) Noise robustness showing final test accuracy under additive Gaussian noise N(0, σ2) (no noise during training).

Limitations and Future Work

  • Sensitivity to Additive Noise: While the system is highly robust to multiplicative noise (like gain fluctuations typical in photonics), it degrades significantly under high levels of additive noise during inference if trained without noise. When the noise floor interacts with a strict 4-bit quantization threshold, it can inadvertently activate suppressed weights.
  • Dynamic Range Compression: Because MZM transmission is capped at unity and limited by the system's noise floor, the achievable dynamic range is physically compressed compared to floating-point digital logic.

Future Directions: The authors highlight that incorporating noise-aware training protocols will be essential to fully bridge the gap between simulation and physical deployment. Additionally, the framework paves the way for exploring other natural analog nonlinearities, such as the steep Lorentzian response of micro-ring resonators or the subthreshold characteristics of CMOS transistors.

Summary updated

BibTeX
@misc{mickeler2026integrated,
  author = {Luis Mickeler and Kai Lion and Alfonso Nardi and Jost Kellner and Pierre Didier and Bhavin J. Shastri and Niao He and Rachel Grange},
  title = {{Integrated electro-optic attention nonlinearities for transformers}},
  year = {2026},
  eprint = {2604.09512},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.09512},
}
Figure