Overwriting Activation Buffers for Memory-Efficient Neural Networks

41 concepts31 papers1 proposal

When optimizing deep neural networks, engineers often focus heavily on reducing model weights through quantization or pruning. However, in many real-world applications—such as high-resolution computer vision, long-context language modeling, or deployment on edge microcontrollers—the true bottleneck is not the weights, but the intermediate activations.

Traditional deep learning frameworks manage memory via "double-buffering": to compute a layer's output, they read from an input buffer and write to a completely separate output buffer. When processing high-resolution data or deep architectures, this approach leads to massive memory overhead, as multiple full-sized feature maps must reside in memory simultaneously.

To break this bottleneck, a powerful paradigm has emerged: in-place activation overwriting and buffer reuse. Instead of treating memory as a static sequence of isolated allocations, this approach treats memory as a dynamic, shared pool. By understanding the precise lifecycles and spatial access patterns of tensors, systems can safely overwrite input data with output data the moment it becomes "stale," allowing massive models to run within incredibly tight hardware constraints.


The Core Intuition: Exploiting Data Lifecycles

Why is traditional double-buffering wasteful? The answer lies in data locality and lifecycles. In a standard feed-forward network, once a layer finishes processing an input tensor, that input tensor is often never accessed again. Even within a single layer's computation—such as a sliding-window convolution—individual elements of the input tensor become redundant long before the entire layer finishes executing.

Once a piece of data has contributed to all dependent downstream operations, it is considered stale. If we can precisely map when data becomes stale, we can immediately reuse its physical memory address to store incoming output values.

Traditional Double-Buffering:
[ Input Buffer (Layer N) ] -------> [ Output Buffer (Layer N+1) ] (Double Space Required)

In-Place Overwriting:
[ Shared Buffer: Input N  ] --(Compute)--> [ Shared Buffer: Overwritten with Output N+1 ] (Half Space Required)

In-Place Overwriting via Safe Pointer Offsets

The most direct application of this insight is executing a single layer's computation within a single shared buffer. For element-wise operations or batch normalization, this is straightforward because one input element maps directly to one output element. Lorenzo Porzi et al. leveraged this in In-Place Activated BatchNorm for Memory-Optimized Training of DNNs, demonstrating that fusing batch normalization and activation functions within the same input buffer halves the required storage during training.

For sliding-window operations like convolutions, however, in-place execution is significantly harder. A single output pixel depends on a local neighborhood of input pixels; writing an output value too early could corrupt input data that a neighboring window still needs to read.

To solve this, Petar Jokic et al. demonstrated in Improving Memory Utilization in Convolutional Neural Network Accelerators that it is mathematically possible to calculate a minimum safe offset between read and write pointers. Because a convolutional kernel moves predictably across an image, the top-left pixels of the input neighborhood become stale as the window moves right and down. By delaying the write pointer by a precise number of memory addresses, the output tensor can safely chase the read pointer through the exact same buffer without causing data corruption, cutting activation memory requirements by nearly 50%.

Shared Buffer:
[ Stale Input (Safe to Overwrite) ] [ Active Input Neighborhood ] [ Unread Input ]
                ^                               ^
          Write Pointer                    Read Pointer

This strategy can be pushed to extreme granularities. Albert Gural et al. introduced a "herringbone" pixel-ordering strategy in Memory-Optimal Direct Convolutions for Maximizing Classification Accuracy in Embedded Applications, optimizing the exact sequence of local operations to maximize immediate staleness. This allowed high-accuracy CNNs to run entirely within a 2KB RAM footprint. Similarly, Ji Lin et al. showed in MCUNet: Tiny Deep Learning on IoT Devices that combining global buffer scheduling with in-place depth-wise convolutions reduces peak SRAM requirements on microcontrollers by nearly half.


Memory Pooling Across Non-Concurrent Lifecycles

We can expand this concept beyond adjacent layers to the entire network graph. A neural network is a directed acyclic graph (DAG) of operations. By analyzing the execution timeline of this graph, we can determine the exact birth and death of every tensor. Two layers that execute at different times do not need separate allocations; they can share a single global memory pool.

Miguel de Prado et al. formalized this in Automated Design Space Exploration for Optimized Deployment of DNN on Arm Cortex-A CPUs, showing that allocating memory pools for layers with non-overlapping execution lifecycles can reduce activation memory footprints by up to 88% without sacrificing model accuracy or speed.

This greedy reclamation strategy scales seamlessly from microcontrollers up to massive generative models and distributed systems:


Interleaved and Patch-Based Execution Schedules

Instead of changing where tensors are stored, we can fundamentally alter the order of computation to prevent large tensors from ever existing in the first place.

Standard execution computes an entire layer's feature map before moving to the next layer. If a feature map is $H \times W$, the memory footprint scales with the full image area. However, if we interleave the execution of consecutive layers, we can process the data in smaller, localized chunks.

Tibor Schneider et al. applied this to edge devices in Q-EEGNet: an Energy-Efficient 8-bit Quantized Parallel EEGNet Implementation for Edge Motor-Imagery Brain-Machine Interfaces. By interleaving consecutive convolutional layers, their system processes data in vertical slices or columns. The output of a small column in Layer 1 is immediately consumed by Layer 2, bypassing the need to ever materialize or store the full intermediate feature map in RAM and reducing the memory footprint by up to 85%.

Layer-by-Layer Execution (High Memory):
[ Full Layer 1 Map ] ---> [ Full Layer 2 Map ]

Interleaved Column Execution (Low Memory):
[ Slice ] -> [ Slice ]
[ Slice ] -> [ Slice ]  --> (Only one slice buffered at a time)
[ Slice ] -> [ Slice ]

This concept can be extended to spatial patches and sliding windows:


Co-Designing Hardware, Scheduling, and Architectures

To unlock the full potential of buffer overwriting, memory management must be tightly integrated with hardware dataflows and network architectures.

At the hardware level, Yu Feng et al. showed in ASV: Accelerated Stereo Vision System that when multiple sub-convolutions share an input feature map, a dynamic programming optimizer can schedule operations to ensure shared activations remain in fast on-chip buffers, eliminating energy-intensive DRAM accesses. For hardware accelerators utilizing in-memory computing, Martino Dazzi et al. explored how varying activation storage from pixel-level to kernel-level interleaving balances bit-masking complexity against consistent access times.

At the architectural level, network design can be tailored to minimize concurrent data lifespans:

  • Linear Bottlenecks: Mark Sandler et al. demonstrated in MobileNetV2: Inverted Residuals and Linear Bottlenecks that placing residual shortcut connections exclusively between narrow bottleneck layers—rather than high-dimensional expansion layers—drastically reduces the amount of tensor data that must be held in memory simultaneously.
  • Interleaved Memory Access: In Do Transformers Need Deep Long-Range Memory?, Jack W. Rae et al. proved that full-depth activation caching in Transformers is highly redundant; spacing out layers with long-range memory access evenly throughout the network maintains performance while significantly decreasing the peak memory required for activation caching.
  • Asymmetric Activation Sharing: To optimize hardware-friendly training without standard backpropagation, Sunghyeon Woo et al. proposed organizing layers into blocks where every layer in the group shares a single activation from a lower layer for its weight updates, simplifying communication and reducing storage overhead.

By treating memory as a dynamic canvas where data is continuously written, reclaimed, and overwritten, these techniques prove that the boundaries of deep learning deployment are determined not just by hardware capacity, but by the intelligence of the execution schedule.

Key Foundational Work

Memory-Optimal Direct Convolutions for Maximizing Classification Accuracy in Embedded Applications (2019) — contributed 2 concept elements to this direction.
In-Place Activated BatchNorm for Memory-Optimized Training of DNNs (2018) — contributed 1 concept elements to this direction.
Backprop with Approximate Activations for Memory-efficient Network Training (2019) — contributed 1 concept elements to this direction.
History & citationVersion 1 · 2026-10-04

Current · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_in_place_activation_overwriting_91bb7573,
  title = {in-place activation overwriting},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/in-place-activation-overwriting/rdr_91bb7573bfb546089c6c535f49d61a78},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-25},
}

This exact version (version 1, frozen text):

@misc{lacuna_in_place_activation_overwriting_91bb7573_v1,
  title = {in-place activation overwriting},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/in-place-activation-overwriting/rdr_91bb7573bfb546089c6c535f49d61a78/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-25},
}
About

These directions overlap with this one through shared papers.

See something wrong? Report a mistake