Abstract
Neural Processes (NPs) are efficient methods for estimating predictive uncertainties. NPs comprise of a conditioning phase where a context dataset is encoded, a querying phase where the model makes predictions using the context dataset encoding, and an updating phase where the model updates its encoding with newly received datapoints. However, state-of-the-art methods require additional memory which scales linearly or quadratically with the size of the dataset, limiting their applications, particularly in low-resource settings. In this work, we propose Constant Memory Attentive Neural Processes (CMANPs), an NP variant which only requires constant memory for the conditioning, querying, and updating phases. In building CMANPs, we propose Constant Memory Attention Block (CMAB), a novel general-purpose attention block that can compute its output in constant memory and perform updates in constant computation. Empirically, we show CMANPs achieve state-of-the-art results on meta-regression and image completion tasks while being (1) significantly more memory efficient than prior methods and (2) more scalable to harder settings.
Introduction
Neural Processes (NPs) provide a powerful framework for meta-learning, enabling models to represent function distributions and provide uncertainty estimates. A key advantage of NPs is their ability to incorporate new data without full retraining. However, the integration of attention mechanisms—essential for high-performance NPs—introduces significant memory overhead. Transformer-based NPs (TNPs) exhibit $O(N^2)$ memory scaling, while Latent Bottlenecked NPs (LBANPs) improve this to $O(N)$. Despite this improvement, linear scaling still poses a barrier for deployment on resource-constrained edge devices like IoT sensors or mobile phones, where RAM is limited.
Methods: Constant Memory Attention
The core innovation of this work is the Constant Memory Attention Block (CMAB). Unlike standard attention layers where queries change through the network depth, CMAB utilizes a fixed set of learned latent vectors ($L_B$) as queries. This architectural choice allows the model to process context data as a stream.
To achieve true $O(1)$ memory scaling, the authors derive a numerically stable update operation for cross-attention. By treating the context data as a rolling average and employing a specialized log-sum-exp trick, the model can update its internal state with new data points in constant memory and time. This "fast update" mechanism avoids the need to store or re-process the entire context history.
Furthermore, the CMANP-AND (Autoregressive Not-Diagonal) extension addresses the limitation of independent target predictions. By combining the autoregressive approach with the constant-memory update mechanism, CMANP-AND can model correlations between predictions (non-diagonal covariance) without the quadratic memory explosion typical of previous methods.
Empirical Evaluation
CMANPs were evaluated across diverse benchmarks, including 1D meta-regression, image completion (EMNIST, CelebA), and temporal point processes.
The results demonstrate that CMANPs maintain constant memory usage regardless of the context dataset size. In high-resolution image completion tasks (e.g., CelebA 128x128), CMANPs successfully operated while baseline models like TNP-D and ANP frequently encountered Out-of-Memory (OOM) errors. Crucially, this efficiency does not come at the cost of accuracy; CMANPs achieved state-of-the-art log-likelihoods, such as 7.15 on CelebA 128x128. As shown in the complexity plots, CMANP's query time also remains flat as the context size grows, providing a significant speedup over Transformer-based alternatives.
Conclusion
CMANPs represent a significant step toward deploying sophisticated uncertainty estimation models on edge devices. By breaking the link between dataset size and memory consumption through the CMAB, this work enables scalable meta-learning. While performance is naturally bounded by the size of the latent bottleneck, the ability to process massive context streams in constant memory opens new avenues for real-time applications in robotics and IoT. Future work may explore extending these blocks to higher-dimensional modalities like video.
Summary updated