On-Chip Learning via Transformer In-Context Learning

Jan Finkbeiner, Emre Neftci

TL;DR

This paper maps the self-attention mechanism of transformers directly onto local synaptic plasticity rules, enabling efficient in-context learning on neuromorphic hardware. By deploying an autoregressive transformer on Intel’s Loihi 2 chip, the authors demonstrate backpropagation-free, on-chip few-shot learning that bypasses traditional memory bottlenecks.

What Problem Does This Paper Address?

While transformers are incredibly powerful, their self-attention mechanism introduces a massive memory bottleneck during inference. At each step, the model must load prior token projections—known as the Key-Value (KV) cache—from the main memory. This results in low arithmetic intensity, meaning conventional processors spend more time moving data than actually computing.

Neuromorphic architectures (brain-inspired chips) offer a solution via near-memory processing, but mapping the global, dynamic operations of a transformer to the strictly local communication style of neuromorphic hardware is a significant challenge. This paper addresses this gap by framing transformer inference not as a static computation, but as a local learning process.

Methods

The authors reformulate the dynamic construction and retrieval of the KV-cache as a local synaptic plasticity rule, establishing an algorithmic bridge between transformers and neuromorphic physics.

Illustration of an Autoregressive Decoder-Only Transformer layer.

Specifically, they split the self-attention mechanism into two distinct local learning rules:

  • Key-Learning Rule: Formulated as a two-factor learning rule combining a pre-synaptic trace and a post-synaptic spike trigger.
  • Value-Learning Rule: Formulated as a three-factor learning rule utilizing a pre-synaptic spike trigger, a post-synaptic spike, and a third external trace factor.
Illustration demonstrating the interpretation of the self-attention mechanism as local plasticity rule.

Using this formulation, the KV-cache effectively acts as a standard weight matrix that updates locally. The architecture was implemented on the Intel Loihi 2 neuromorphic processor using the Lava programming framework. Non-linear operations like softmax, RMSNorm, and ReLU were handled via custom neurons written in Loihi microcode.

Datasets

The model's in-context learning capabilities were evaluated using the standard Omniglot dataset, which consists of 1,623 handwritten characters from 50 different alphabets. The authors structured the evaluation as an N-way K-shot classification task, where the network is presented with a sequence of images and labels concatenated into tokens, followed by a query image with an unknown label.

Illustration of the problem setup for the N-way K-shot few-shot learning experiment.

Key Insights and Ideas

  • Inference as Learning: The core "aha moment" is that a transformer's in-context learning behavior during inference can be mathematically mapped to forward-only weight updates. It requires no backpropagation or loss-projection layers to adapt to new data.
  • Attention is Plasticity: Self-attention can be viewed as a dynamic feed-forward layer where the weight matrix is entirely dependent on the input sequence—conceptually identical to how local synaptic plasticity functions in biological brains.
  • Eliminating the Quadratic Mask: By processing tokens autoregressively on-chip, the network avoids instantiating a full attention mask (which scales quadratically with sequence length), drastically reducing peak memory requirements.

Key Results

The Loihi 2 neuromorphic implementation achieved highly competitive performance compared to traditional non-convolutional meta-learning baselines:

  • 5-Way Classification: The Transformer-tiny (Loihi) model achieved 86.1% accuracy on 1-shot tasks and 96.3% on 5-shot tasks, performing nearly on par with the unquantized floating-point baseline (93.1% / 97.3%).
  • 20-Way Classification: On the more challenging 20-way task, the Loihi implementation reached 60.9% (1-shot) and 83.4% (5-shot) accuracy.
  • Comparison to Baselines: The local plasticity-based transformer outperformed Memory-Augmented Neural Networks (MANNs) and remained highly competitive with Model-Agnostic Meta-Learning (MAML), all while operating entirely on-chip without backpropagation.

Limitations and Future Work

  • Quantization Loss: The authors noted a slight accuracy degradation when moving from floating-point simulations to the fixed-point constraints of the Loihi 2 hardware, particularly on the complex 20-way classification task.
  • Sampling Noise: Due to hardware constraints, the Loihi and Lava results were evaluated on a limited set of 32–256 task samples, introducing minor sampling noise into the reported metrics.
  • Future Directions: To mitigate quantization errors, the authors suggest exploring quantization-aware pretraining and scaling up the model size, leveraging the predictable scaling laws inherent to transformer architectures.

Summary updated

BibTeX
@inproceedings{finkbeiner2025chip,
  author = {Jan Finkbeiner and Emre Neftci},
  title = {{On-Chip Learning via Transformer In-Context Learning}},
  booktitle = {AICAS},
  year = {2025},
  doi = {10.1109/aicas64808.2025.11173092},
}
Figure