LSH Attention Mechanism Reducing Neural Network Memory

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing attention-based neural networks face substantial computational costs and memory requirements when processing sequential data, particularly during training, due to the dot-product attention mechanism and the need to save layer activations for backpropagation.

Innovation Solution

The implementation of a locality-sensitive hashing (LSH) attention mechanism and reversible residual connection layers, which restrict the input positions that a query can attend to and allow recovery of intermediate layer activations from final layer activations, respectively, thereby reducing computational resources and memory needs.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If dot-product attention mechanism is used to process sequential data, then attention can be applied to all input positions, but computational cost becomes substantial for significant sequence lengths

Engineering Contradiction:
Improveattention coverageVSAvoidcomputational cost
Core Design Contradiction:
Adaptability or versatilityVSPower

Solution Approach 1:

The patent segments the sequence of keys into multiple groups using locality-sensitive hashing (LSH). Instead of computing dot products between a query and all keys, the query only computes dot products with keys in the same LSH group, significantly reducing computational cost while maintaining attention capability within localized regions of the sequence.

Inventive Principle:
Principle #1Segmentation

2Reliability

If layer activations are saved for backpropagation, then gradient computation is enabled, but memory requirements reach tens or hundreds of gigabytes

Engineering Contradiction:
Improvetraining capabilityVSAvoidmemory requirements
Core Design Contradiction:
ReliabilityVSQuantity of substance

Solution Approach 1:

The patent applies gradient checkpointing, which saves only critical intermediate activations at specific checkpoints during the forward pass, rather than saving all layer activations. During backpropagation, intermediate activations are recomputed from the checkpoints, enabling gradient computation while dramatically reducing memory requirements from tens/hundreds of gigabytes to manageable levels.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS12299580B2Attention neural networks with locality-sensitive hashing
Publication Date: 2025.05.13 GOOGLE LLC
  • US12299580B2 patent drawing
  • US12299580B2 patent drawing
  • US12299580B2 patent drawing

AI summary

Methods, systems, and apparatus, including computer programs encoded on a computer storage medium, for performing a machine learning task on a network input to generate a network output. In one aspect, one of the systems includes an attention neural network configured to perform the machine learning task, the attention neural network including one or more LSH attention layers, each LSH attention layer comprising one or more LSH attention sub-layers, each LSH sub-layer configured to: receive a sequence of queries derived from an input sequence to the LSH attention layer, the sequence of queries having a respective query at each of a plurality of input positions; determine one or more respective hash values for each of the respective queries at each of the plurality of input positions; generate a plurality of LSH groupings; and generate an attended input sequence.