Thresholded Attention Filtering for Long-Sequence Transformer Inference

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Transformer-based AI models face challenges due to quadratic computational complexity, memory-intensive data movement, and sparsity in attention matrices, limiting their applicability to long sequences and increasing computational and memory requirements.

Innovation Solution

Implementing topologically ordered attention operators with content-based sparsity by calibrating element thresholds for attention matrices, using offline or online methods to filter out non-essential elements, reducing computation and memory demands while maintaining inference quality.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If self-attention mechanism computes all-pairs attention matrix, then understanding of relationships between tokens is improved, but computational complexity and memory requirements increase quadratically with sequence length

Engineering Contradiction:
Improverelationship understandingVSAvoidcomputational complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The patent extracts only the most important attention elements from the full attention matrix by applying calibration-based thresholds. This selective extraction maintains the essential relationship understanding while discarding computationally expensive but less critical attention computations, directly resolving the contradiction between comprehensive relationship analysis and computational complexity.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent applies different quality standards to different parts of the attention matrix by using calibration-based dynamic thresholds. Instead of uniformly processing all attention elements, the method identifies and processes only those elements that exceed the calibrated threshold, allowing high-quality relationship understanding where needed while reducing complexity elsewhere in the matrix.

Inventive Principle:
Principle #3Local quality

2Measurement precision

If full K and V matrices are loaded from KV cache for each generated token, then accuracy of generative decoding is maintained, but memory bandwidth requirements become the bottleneck

Engineering Contradiction:
Improvedecoding accuracyVSAvoidmemory bandwidth efficiency
Core Design Contradiction:
Measurement precisionVSProductivity

Solution Approach 1:

The patent extracts only the necessary portions of the K and V matrices by identifying and loading only those key-value pairs corresponding to attention elements that exceed the calibration threshold. This selective extraction maintains decoding accuracy by preserving important relationships while dramatically reducing memory bandwidth requirements by avoiding loading of redundant data.

Inventive Principle:
Principle #2Taking out (Extraction)

3Device complexity

If content-based sparsity is exploited by filtering attention matrix elements, then computational and memory requirements are reduced, but model performance may deteriorate

Engineering Contradiction:
Improvecomputation efficiencyVSAvoidmodel performance
Core Design Contradiction:
Device complexityVSReliability

Solution Approach 1:

The patent performs preliminary calibration using a calibration dataset before actual inference to establish accurate thresholds for filtering attention elements. This preliminary action ensures that the subsequent sparsity-based computation retains only the most important attention elements, thereby reducing computational complexity while preserving model performance by avoiding premature or inaccurate filtering decisions.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent incorporates feedback mechanisms where the calibration process uses actual model outputs and attention patterns to refine the thresholds for element filtering. This feedback loop ensures that the filtering criteria are continuously optimized to maintain model performance while maximizing computational efficiency, preventing performance deterioration that would result from static or inaccurate threshold selection.

Inventive Principle:
Principle #23Feedback

Data Source

PatentEP4651032A1Top-threshold attention for scalable and efficient attention-based artificial intelligence (AI) models
Publication Date: 2025.11.19 HUAWEI TECH CO LTD
  • EP4651032A1 patent drawingFigure 1
  • EP4651032A1 patent drawingFigure 2
  • EP4651032A1 patent drawingFigure 3

AI summary

This disclosure relates to attention-based AI models, such as Transformers or Large Language Models (LLM). In particular, the disclosure provides a method of operating a trained model comprising attention operators. The method primarily comprises a simple comparison of the attention matrix elements to specially calibrated thresholds, and further using only the elements that pass the threshold for further computations. The thresholds can be calibrated according to a user-defined parameter k in an offline (1) or in an online (2) fashion, and are intended to ideally keep k selected attention elements per row. This achieves reduced computation and memory requirements of the attention operator, reduced data movement from KV cache, an ability to process longer sequences, and avoids retraining.