In-memory computing system and memory device
Patent Information
- Authority / Receiving Office
- EP · EP
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2026-03-11
AI Technical Summary
Existing methods for optimizing the softmax function, particularly for lengthy inputs, face significant computational overhead and reduced performance due to the need to process all input values, limiting efficiency gains.
An in-memory computing system using a Top-k in-memory analog-to-digital converter (Topkima) within SRAM memory cells, which performs MAC operations with modulated wordline pulses and implements a ramp ADC for efficient Top-k selection and conversion of analog MAC values to digital format, reducing the number of nonlinear operations.
The system achieves a 17x speedup with minimal accuracy loss, significantly reducing computational load and energy consumption, making it suitable for edge devices and IoT applications.
Smart Images

Figure CN2024105247_15012026_PF_FP_ABST
Abstract
Description
IN-MEMORY COMPUTING SYSTEM AND MEMORY DEVICE
[0001] Inventors: Arindam BASU; Shuai DONG; Junyi YANG; and Xiaoqi PENGField of the Invention:
[0002] The present invention generally relates to in-memory computing system. More specifically, the present invention relates to in-memory computing system and memory device using Top-k selection.Background of the Invention:
[0003] Vector nonlinear functions, such as the softmax function, are widely used in machine learning and neural network models to convert a vector of values into a probability distribution. These functions involve computationally expensive operations, specifically the calculation of exponentials and divisions. These operations can be particularly burdensome when processing lengthy inputs, leading to increased computational overhead and reduced performance.
[0004] Existing Solutions for Softmax Optimization
[0005] Several methods have been developed to optimize the softmax function and reduce its computational complexity. They are:
[0006] 1. Softermax Approach
[0007] This method simplifies hardware implementations by switching the base of the exponential function from e to 2. This change facilitates easier hardware computation and achieves a speed improvement of approximately 1.25 times.
[0008] 2. Taylor Expansion Method
[0009] Taylor series are used to approximate the exponential function. While this method can reduce the inference time by about 19%, the improvement is limited. The need to handle all input values for the softmax function constrains its efficiency gains.
[0010] Challenges with Lengthy Inputs
[0011] Handling lengthy inputs remains a significant challenge for softmax optimization methods. The necessity to process all input values results in substantial computational demand, ultimately leading to a decline in performance. This issue becomes more pronounced as the input size increases, making traditional approximation methods less effective.Summary of the Invention:
[0012] It is an objective of the present invention to provide an in-memory computing system to solve the aforementioned technical problems.
[0013] It is another objective of the present invention to provide an analog-to-digital converter (ADC) . Particularly, some embodiments of the present invention provide a novel technique called Top-k in-memory ADC (hereinafter referred to as “Topkima” ) .
[0014] It is an objective of the present invention to provide a system using in-memory ADC (IMA) within replica bit-cells to accelerate certain computational tasks, such as the non-linear function computations in transformers.
[0015] It is an objective of the present invention to provide a system, which aims to achieve high efficiency, low energy consumption, and reduced latency, making suitable for applications in edge devices and Internet of things (IoT) devices.
[0016] In accordance with a first aspect of the present invention, an in-memory computing system is provided. The in-memory computing system comprises a memory device and a processing unit. The memory device comprises a plurality of static random-access memory (SRAM) memory cells, an analog-to-digital convertor (ADC) , and a control logic. The multiply-accumulate (MAC) operation is performed using the SRAM memory cells in which the wordline enable signal’s pulse width is modulated according to an input, while weights are digitally stored in the SRAM memory cells. The ADC, based on the single slope or ramp topology, is implemented using the SRAM memory cells. The analog-to-digital conversion process comprises creating a negative or decreasing ramp signal, where larger MAC voltage crosses the ramp earlier. The control logic is configured to execute Top-k selection among the analog MAC values on the bitlines (MAC output, which is the input to the ADC) during an analog-to-digital conversion process. The processing unit is configured to provide general processing. The control logic compares the analog MAC values computed on the bitlines, selecting the k largest values from among them, and converting the selected k analog values to digital format, generating a converted data. k is a positive integer much smaller than the total number of computed analog values, d.
[0017] In accordance with a second aspect of the present invention, a memory device is provided. The memory device comprises a plurality of SRAM memory cells, an ADC, and a control logic. The MAC operation is performed using the SRAM memory cells in which the wordline enable signal’s pulse width is modulated according to an input, while weights are digitally stored in the SRAM memory cells. The ADC, based on the single slope or ramp topology, is implemented using the SRAM memory cells. The analog-to-digital conversion process comprises creating a negative or decreasing ramp signal, where larger MAC voltage crosses the ramp earlier. The control logic is configured to execute Top-k selection among the analog values on the bitlines (MAC output, which is the input to the ADC) during an analog-to-digital conversion process. The processing unit is configured to provide general processing. The control logic compares the analog MAC values computed on the bitlines, selecting the Top-k largest values from among them, and converting the selected Top-k analog values to digital format, generating a converted data. k is a positive integer much smaller than the total number of computed analog values, d.
[0018] In accordance with one embodiment of the present invention, the replica SRAM memory bit-cells are used by the processing unit to perform a computation of non-linear functions directly during data conversion.
[0019] In accordance with another embodiment of the present invention, the memory cells perform a computation, and the computation is integrated into an attention module of a transformer model.
[0020] In accordance with another embodiment of the present invention, the system is optimized by a quantization method. The quantization method is used to reduce the precision of data representations in the memory device, thereby decreasing the energy consumption and improving the latency of the memory operations.
[0021] In accordance with yet another embodiment of the present invention, the system is an edge device or IoT device.Brief Description of the Drawings:
[0022] Embodiments of the invention are described in more details hereinafter with reference to the drawings, in which:
[0023] FIGs. 1a, 1b, and 1c depict a schematic diagram of a Topkima marco architecture and illustrate its operation of the system in accordance with an embodiment of the present invention;
[0024] FIGs. 2a, 2b, and 2c show the macro level evaluation results of an embodiment of the present invention;
[0025] FIGs. 3a, 3b, 3c, and 3d depict the schematic diagrams of an overall architecture of Topkima in transformer within a hierarchical structure of the system in accordance with embodiment of the present invention;
[0026] FIG. 4 illustrates a data flow of the Topkima in transformer; and
[0027] FIGs. 5a and 5b show the results of the optimization techniques employed in an embodiment of the present invention.Detailed Description:
[0028] In the following description, systems and memory devices of in-memory computing and the likes are set forth as preferred examples. It will be apparent to those skilled in the art that modifications, including additions and / or substitutions may be made without departing from the scope and spirit of the invention. Specific details may be omitted so as not to obscure the invention; however, the disclosure is written to enable one skilled in the art to practice the teachings herein without undue experimentation.
[0029] In accordance with a first aspect of the present invention, a highly efficient system for executing transformer operations with lower energy consumption and reduced latency is provided.
[0030] The Top-k Selection
[0031] In this description, “Top-k” refers to top k selection. In some embodiments of the present invention, “Top-k” refers to selecting the k largest values from a set of data.
[0032] In some embodiments, systems are provided with Topkima, which combines the selection of the Top-k analog values with IMA for efficient computation of nonlinear functions, such as the softmax function used in transformers. In this description, softmax is referred to as the function that converts a vector of values into a probability distribution.
[0033] In some embodiments, the Top-k method is introduced, which selectively retains only the Top-k activations from the softmax inputs, setting all other values to zero. The key advantages of the Top-k method are as follows:
[0034] 1. Reduced Computational Load
[0035] By focusing only on the k largest values (where k is much smaller than the total number of inputs d) , the method significantly reduces the number of values that need to be processed by the non-linear operator.
[0036] 2. Performance Improvement
[0037] This approach can achieve a speedup of approximately 17 times when k = 5, with only a minimal loss in accuracy. The exponential nature of the softmax function ensures that the largest values dominate the output, thus maintaining the overall distribution's integrity.
[0038] Optimizing the softmax function is crucial for enhancing the performance of neural network models. While traditional methods like softermax and Taylor expansion offer some improvements, they are often limited by the need to handle all input values. The Top-k method presents a more effective solution by significantly reducing the computational load and achieving substantial performance gains, especially for lengthy inputs.
[0039] In accordance with one embodiment of the present invention, an in-memory computing system is provided. The in-memory computing system comprises a memory device and a processing unit. The processing unit is configured to provide general processing, and the system is providing the in-memory computing through the memory device.
[0040] In this description, in-memory computing refers to performing computations directly within the memory cells, which can significantly reduce data movement, power consumption, and latency. This concept is critical in designing energy-efficient and high-speed computing systems.
[0041] The memory device of this embodiment comprises a plurality of memory cells, an analog-to-digital convertor (ADC) , and a control logic. The MAC operation is performed using the memory cells in which the wordline enable signal’s pulse width is modulated according to an input, while weights are digitally stored in the memory cells. The MAC operation can be viewed as a digital-analog conversion process since the MAC output is an analog MAC voltage value on the bitline. The ADC is implemented using the memory cells. In this embodiment, the ADC is the means that converts continuous analog signals into discrete digital numbers. The analog-to-digital conversion process comprises creating a negative or decreasing ramp signal, where larger MAC voltage crosses the ramp earlier. The system uses IMA to accelerate certain computation tasks, such as the non-linear function computations in transformers.
[0042] The control logic of this embodiment is configured to execute Top-k selection among the stored analog values during an analog-to-digital conversion process. The control logic compares the analog MAC values computed on the bitlines (MAC output, which is the input to the ADC) , selecting k largest values from among them, and controlling the ADC to convert the selected k analog values to digital format, generating a converted data. k is a positive integer much smaller than the total number of the computed analog MAC values, d.
[0043] In this embodiment, the system selects the k largest analog values directly within the memory using a modified ramp ADC technique. By doing this in-memory, the overhead of transferring data to separate processing units can be avoided, thus lowering energy consumption and reducing operational latency.
[0044] In one embodiment, the memory cells form a computing array, which is an in-memory computing array. The computing array enables computation directly within the memory. The computing array where the SRAM bit-cells are organized to perform parallel computations, significantly reducing data movement.
[0045] The ADC is a ramp ADC, which converts analog signals to digital values. In this description, the ramp ADC refers to the type of ADC that compares the input signal to a ramp signal (asteadily increasing or decreasing voltage) and measures the time it takes for the ramp signal to match the input signal.
[0046] In accordance with one embodiment, while the MAC operation is performed using the memory cells, the analog-to-digital conversion process by the ADC is performed using the bit-cells. These bit-cells for the ADC operation are exactly similar as the ones used for the MAC operation, hence they are referred to as replica bit-cells. Advantage of using the replica bit-cells lies in that any non-ideality in the digital-analog conversion process is sort of inverted in the analog-digital conversion process making the final result robust and stable.
[0047] As such, the ramp ADC is integral to an in-memory computing process, allowing for the efficient selection of the k values directly within the computing array. The ramp ADC is implemented using replica bit-cells to perform efficient in-memory analog-to-digital conversion. Through this approach, the system saves energy and reduces latency during data conversion and subsequent nonlinear operations on the reduced number of values.
[0048] In the embodiment, the control logic manages and controls the in-memory operations. More specifically, the control logic coordinates the selection, conversion, and processing tasks within the memory array.
[0049] In accordance with one embodiment of the present invention, the system is an edge computing device. The system leverages the low-energy and low-latency benefits of the computing array of edge computing devices. The memory device can be integrated into the edge computing device or an IoT device, which includes other components such as sensors, processors, and communication interfaces. The control logic of the memory device manages the data flow between the memory cells and other components of the edge device or IoT device, ensuring efficient processing of data close to the source of data generation. This integration enables real-time data processing with low latency and energy consumption, making the system suitable for resource-constrained environments.
[0050] In the various embodiments, the system comprises at least one processing unit, which handles tasks not performed in-memory, such as high-level processing and coordination. The processing unit can be a CPU, a GPU, or a neural network accelerator. The system further comprises interconnections and data buses, which facilitate communication between memory, control logic, processing unit, and external processors. The high-speed interconnects ensure efficient data transfer within the system and to external components when necessary. The system further comprises a power supply, which provides and regulates power to the system. The power supply or power supply and management ensure stable and efficient power delivery to all components, optimizing for low-energy consumption. The system may further comprise a cooling system, which manages the thermal output of the system. The cooling system ensures the system operates within safe temperature ranges, preventing overheating and maintaining performance.
[0051] In accordance with various embodiments, the processing unit performs a computation of non-linear functions directly with the data in the memory cells while converting the data from analog to digital formats, and the non-linear functions include the softmax function. The memory cells perform a computation of non-linear functions directly within the computing device. By performing these operations directly within the memory, the system can achieve faster and more efficient computation. In other words, the system uses this technique to enhance efficiency by performing computations directly within memory arrays, reducing data movement and power consumption.
[0052] In an embodiment of the present invention, the k largest activations out of the total d inputs (where k is much smaller than d) for the softmax function are kept unchanged, while all other values are set to zero. This approach reduces the number of nonlinear operations (such as computing exponentials in the softmax function) to just k, significantly reducing the latency of nonlinear function evaluation.
[0053] By integrating Top-k selection with data conversion, the system eliminates the need for a digital processor to sort inputs, preserving the advantage of reduced nonlinear computations.
[0054] In some embodiments, the system illustrates the benefit of using Topkima for the softmax function within the attention module of a transformer. Additional system optimizations (such as quantization) and hardware designs (such as pipelining) can be introduced to fully leverage the Topkima in transformers (hereinafter referred to as “Topkima-Former” ) .
[0055] In this description, the transformer refers to the type of neural network architecture in the field of deep learning, particularly for natural language processing (NLP) tasks. The transformer is designed to handle sequential data, such as text, without relying on recurrent networks (RNNs) or convolutional networks (CNNs) .
[0056] In some embodiments, the transformer uses self-attention mechanisms, which allow the model to weigh the importance of different words in a sentence when making predictions or generating output.
[0057] In some embodiments, the transformers are software-based neural network architecture used for sequential data.
[0058] In this description, the attention module refers to the component in the transformer models that allow the models to focus on different parts of the input sequence.
[0059] In some embodiments, the memory cells perform at least one computation, and the computation is integrated into attention modules of a transformer model. This integration allows the model to process data more efficiently by reducing the computational load.
[0060] In this description, the quantization refers to the process that reduces the precision of the numbers used in computation, often to speed up processing and reduce memory usage.
[0061] Referring to FIG. 1 in the following description. In accordance to one embodiment of the present invention, the system for executing transformer operations employs a Topkima macro designed to efficiently perform the softmax computation.
[0062] FIG. 1a shows an input mapping of weights and activations, which shows how weights KT and activations Q from an attention module are mapped into the Topkima array.
[0063] In this description, the term “weights” means parameters within a neural network that transform input data within the network’s layer. They are the factors that the network learns during the training process to make predictions or classifications. In the Topkima macro, weights are KT in the attention mechanism of a transformer model. They transform the input activations to calculate the attention scores.
[0064] In this description, the term “activations” means the outputs of the neurons in a neural network after applying an activation function to weighted sum of inputs. They represent the transformed input data as it flows through the network.
[0065] In the Topkima macro, activations are outputs from previous layers or modules, representing the data that needs to be processed. In the attention module, activations are used to compute weighted sums with the weights KT to generate new representations of the data. The weights KT from the result of a X·WK operation are written into the dual 8T SRAM cells.
[0066] FIG. 1b illustrates the structure of the Topkima array used for in-memory computing and ADC ramp generation. SRAM cells are used for efficient frequent writes. Dual 8T SRAM cells are shown as an example, but other types of read-decoupled SRAM cells can also be used. However, SRAM is preferred because it uses less energy when writing data compared to other types such as Resistive RAM (RRAM) . The SRAM array used here has 8T cells, which are designed to separate reading and writing operations, making them more efficient. Dual cells are used to store signed weights (which can be positive or negative values) . The SRAM cells are used for in-memory computing and generating ADC ramp signals.
[0067] The register array captures the outputs of the sense amplifier (SA) array, which switches state at each crossing of the ramp signal. The arbiter, decoder, and counter circuits work together to count the total number of analog inputs converted and stop the data conversion process once the total reaches k.
[0068] A register array captures the outputs of the SA array, which changes state at each crossing of the ramp signal. The system includes arbiter, decoder, and counter circuits to count the total number of analog inputs converted and stop the data conversion process once the total reaches k. The arbiter resolves cases with multiple ramp crossings in the same cycle.
[0069] FIG. 1c shows a linearly decreasing ramp ADC, highlighting how larger voltages are detected first and conversion stops after the first k values. Unlike conventional ramp ADCs that use an increasing voltage ramp, this design uses a linearly decreasing ramp voltage. This means larger voltages are detected first, allowing the conversion process to stop early after the first k values are processed.
[0070] The input activations Q are sent into the system to perform a MAC operation. This is done by modulating the wordline pulses, which completes the calculation of Q·KT as voltages on the bitline. These voltages are then converted to digital values using a ramp-based IMA. The ADC works by using replica bit-cells to create a ramp voltage. A SA acts as a comparator in this process, converting the analog voltages into digital values.
[0071] To integrate the Top-k selection in the IMA, the ramp voltage is first modified to decrease over time (as shown in FIG 1 (c) ) . This means that larger voltages will cross the ramp threshold earlier than smaller voltages (e.g., t1 < tk if V1 > Vk) in FIG. 1 (c) ) .
[0072] To determine which columns’ SAs are triggered in each cycle, an arbiter-encoder combination is used. This setup is similar to address event representation (AER) , where the latched outputs of the SAs are treated as requests, and acknowledgment signals are used to disable the SAs after they trigger. Along with the encoded address of the column, the specific conversion cycle at which the ramp crossing occurred is stored as the ADC output in a first-in-first-out (FIFO) buffer.
[0073] In this embodiment, a counter keeps track of the number of requests and stops the data conversion once the count reaches or exceeds k. In the rare case where the count exceeds k due to ties (when there are many similar large values) , the system reduces the number of outputs to k by prioritizing the smaller column addresses.
[0074] The benefit of this invention can be understood by comparing the latency of a conventional softmax macro, Tsm, conv, which is given by: Tsm, conv = Twr + d · (Tpwm, inp + Tima + d ·TNL, dig) ;
[0075] where:
[0076] Twr is the time to write the K and Q values into SRAM;
[0077] Tpwm, inp is the time to create wordline (WL) pulses, generally proportional to 2nb (where nb is the bit-width of the input, and can be reduced by encoding a few bits in wordline voltages) ;
[0078] Tima is the time for data conversion by the IMA; and
[0079] TNL, dig is the time taken for the digital implementation of exponentiation and division.
[0080] Here, Twr occurs once, while d rows of Q are processed one by one. For a Top-k approach, the latencies for digital sorting (Tsm, Dtopk) and the proposed approach Tsm, Topkima are given by: Tsm, Dtopk = Twr + d y (Tpwm, inp + Tima + Tsort + k y TNL, dig) ; Tsm, Topkima = Twr + d y (Tpwm, inp + αTima + k y TNL, dig) .
[0081] For both approaches, the nonlinear (NL) compute time reduces by d / k, but an additional time for sorting (Tsort = min (d y log (d) , d y k) y Tclk) is required in the digital sorting case. Additionally, the IMA latency in Topkima reduces by a factor α (α ≈ 0.31, when k=5, d=384) due to the early stopping of the ramp.
[0082] FIG. 2 shows the macro level evaluation results of an embodiment of the present invention. FIG. 2a shows a theoretical and simulated MAC value, and the corresponding error in FIG. 2b. FIG. 2c shows the advantage of proposed Topkima macro over other baseline softmax implementations macros.
[0083] Simulations
[0084] First, simulations are conducted using SPICE software with 65 nm CMOS models for the Topkima macro, setting k = 5 and IMA resolution nb = 5. The BERT-base model on the SQUAD dataset is evaluated. In this setup, the input Q and transposed weight K have dimensions of 384 × 64 (meaning the sequence length, SL, is 384) . The 64×384 array for Q y KT) is split into three smaller sub-arrays of size 64 × 128, based on optimization from NeuroSim simulations, and one of these sub-arrays is simulated. Each column in the sub-array includes 64 replica bit-cells (used for ramp generation and offset correction) , making the total simulated sub-array size 128 × 128 cells.
[0085] The arbiter, encoder, and counter across different conditions are simulated, and the results of worst-case delays at the SS corner are 1.51 ns, 0.57 ns, and 0.51 ns, respectively, at Vdd = 0.8V. Accordingly, the clock period for the IMA, Tclk, ima, is set at 4 ns, resulting in Tim a= 128 ns, with α ≈ 0.31 (Equation 2) averaged across the dataset. The supply voltage for the SRAM, Vdd, SRAM, is set at 0.5V to reduce the discharge current of the unit cells, requiring slow (5 ns) writes for robust operation across different conditions. Writing in parallel across columns allows Twrite = 320 ns and TNL, dig = 6.5 ns) (estimated from references) .
[0086] Weights are stored in sign magnitude format, requiring four dual 8T SRAM cells. The PWM input is scaled by a factor of 2 from the least significant bit (LSB) to the most significant bit (MSB) of the weight. Using a 2 GHz clock for the input 5-bit PWM results in a maximum Tpwm, inp = 124 ns for the MSB, making the latency for the Topkima approach Tsm, Topkima approximately 14 times and 11 times less than the conventional softmax Tsm, conv and digital Top-k Tsm, Dtopk approaches, respectively (see FIG. 2c) . Note that digital Top-k does not significantly improve over conventional softmax due to the overhead of sorting time.
[0087] Similarly, the energy consumption of the design Esm, Topkima is 26 times and 3 times less than the conventional softmax (Esm, conv) and digital Top-k (Esm, Dtopk) , respectively. These improvements increase with the sequence length (SL) , which is promising for the scalability of this method (e.g., GPT-3.5 has SL = 4096) .
[0088] FIG. 2a shows the distribution of the IMA circuit output compared to software calculations, averaged across 128 conversions. The corresponding error distribution in FIG. 2b was used to inject errors in software simulations (for Q y KT and A y V) mapped to SRAM) , resulting in a small drop in accuracy from 86.7%to 85.1%.
[0089] Benefits of Topkima-Former
[0090] To achieve high accuracy and performance when integrating Topkima into an attention module, several aspects are applied in the embodiments of the present invention. These aspects are described below:
[0091] 1. Top-k Forward-Complete Backward Propagation Training Method
[0092] When using the Top-k method in some embodiments, only the top k out of d values are retained, which can affect accuracy. To address this, a modified training method called Top-k forward-complete backward propagation (TFCBP) is proposed. This method is inspired by quantization-aware training. In TFCBP, only the Top-k values are used to calculate softmax probabilities during the forward pass, while all activations are used in the gradient computation during the backward pass. This helps to maintain accuracy.
[0093] 2. Activation Quantization Scheme
[0094] The operational latency and energy consumption of the ramp IMA increase significantly with higher resolution. To tackle this, the system of the embodiments introduces activation quantization, which reduces the precision of activations. During the forward pass, quantized activations are used to save energy and reduce latency. During the backward pass, high-precision FP-32 activations are used to update the weights, ensuring minimal accuracy loss.
[0095] 3. Overall Architecture
[0096] FIG. 3 depicts a schematic diagram of the overall structure of Topkima-Former within a hierarchical structure of the system in accordance an embodiment of the present invention. FIG. 3a depicts a Chip-level architecture; FIG. 3b depicts a Tile-level architecture; FIG. 3c depicts a Processing Element (PE) level architecture; and FIG. 3d depicts a detailed circuit of the synaptic array and Topkima.
[0097] The overall system architecture is based on the NeuroSim framework. The architecture is hierarchical, starting from the chip level (FIG. 3a) , then the tile level (FIG. 3b) , and finally the processing element (PE) level (FIG. 3c) .
[0098] There are two types of synaptic arrays: Projection (Proj) and Attention (Atten) . The Projection arrays use RRAM for weight stationary vector-matrix multiplication (StaticVMM) , such as WQ y x, WK y x, and WV y x. RRAM is chosen because it offers high storage density, fast read speed, and low energy consumption for parallel VMM operations. However, RRAM has high write energy, high write latency, and low endurance, making it unsuitable for dynamic vector-matrix multiplication (DynamicVMM) like Q y KT and A y V, where frequent reprogramming of the crossbars is required.
[0099] For DynamicVMM operations, SRAM is used and combined with Topkima for the softmax calculations. The detailed circuits of the synaptic arrays and the Topkima are illustrated in FIG. 3d.
[0100] 4. Scale-free Design
[0101] In accordance with various embodiments of the present invention, the system provides a scale-free design. In the attention module of a transformer, the process begins with obtaining Queries (Q) , Keys (K) , and Values (V) by multiplying the input data (X) with their respective weight matrices. This can be represented as:
[0102] Q = X y WQ, K = X y WK, V = X y WV
[0103] where: WQ, WK, and WV are weight matrices;
[0104] dmodel is the dimension of the model;
[0105] dk and dv are the dimensions of Q, K, and V; and
[0106] l is the sequence length of X.
[0107] The resulting attention values are calculated by:
[0108] The scale operation involves dividing each dot product result of Q y KT by the square root of dk. This operation is necessary but consumes a lot of time and energy in hardware. To simplify this, various techniques have been developed, such as replacing division with bit shifting. However, these techniques still introduce overhead.
[0109] To eliminate this overhead, the scale-free design works:
[0110] By substituting the scaled weights into the equation, the attention calculation can be simplified as:
[0111] where:
[0112] Thus, the weights are adjusted from WQ to WQ / (dk) 0.5 (denoted as WQs) to achieve the scaling function without any additional hardware overhead. This eliminates the need for explicit scaling operations in the hardware, simplifying the design and improving efficiency.
[0113] 5. Pipeline Design
[0114] The system of some embodiments uses a pipeline design in the Topkima-Former to achieve higher processing speed, reduce the need to access memory for intermediate data, and make the most out of data reuse. This design is shown in FIG. 4. Unlike other systems like ELSA and SpAtten, which only focus on speeding up the attention engine part, the design includes a more comprehensive data flow by also incorporating the projection engine part. This creates three main data flows in the attention module, which are labeled Flow 1, Flow 2, and Flow 3 in FIG. 4. These flows consist of five steps:
[0115] Step 1: Loading Weights and Performing StaticVMM
[0116] 5 IMC macros for the projection engine and 4 IMC macros for the attention engine are used. The number of macros (N) can be adjusted based on the network's dimensions.
[0117] Five macros (IMC 0-5) are preloaded with the weights WQs, WK, and WV to perform static vector-matrix multiplication (StaticVMM) .
[0118] The input odd vector x [x1, x3, …, xSL-1] is fed into IMC0, IMC1, and IMC3, generating the query vector qs [q1s, q3s, ..., qSL-1s] , key vector k [k1, k3, …, kSL-1] , and value vector v [v1, v3, …, vSL-1] .
[0119] The even vector x [x2, x4, …, xSL] is sent to IMC2 and IMC4, producing the other key vector k [k2, k4, …, kSL] and the remaining value vector v [v2, v4, …, vSL] .
[0120] Step 2: Storing Intermediate Results
[0121] The odd query vector qs [q1s, q3s, ..., qSL-3s] is stored in the output buffer to be used in the attention engine stage.
[0122] The key vectors k [k1, k2, …, kSL] and value vectors v [v1, v2, …, vSL] are directly programmed into the synaptic arrays of IMC5-6 and IMC7-8 without being written back to the buffer.
[0123] Step 3: Generating Even Query Vectors
[0124] The even query vector qs [q2s, q4s, …, qSLs] is generated.
[0125] The directly obtained even query vector qs [qSL-1s, q2s, q4s, …, qSLs] and the odd query vector qs [q1s, q3s, …, qSL-3s] fetched from the buffer are alternately sent into IMC5 and IMC6.
[0126] Step 4: Performing Softmax Operation
[0127] The outputs from IMC5 and IMC6 undergo the softmax operation to generate the score vectors a [a1, …, aSL] .
[0128] Step 5: Generating Final Results:
[0129] The final result is generated by multiplying the score vectors a with the value vectors V.
[0130] By using this pipeline design, the two smaller latencies in Flows 2 and 3 can be concealed and the larger latency in Flow 1 as the overall latency is considered, making the system more efficient.
[0131] Simulation Results of Topkima-Former
[0132] To demostrate how well the Topkima-Former works, a full attention module is simulated using NeuroSim, a tool for such simulations. Two types of memory technology: RRAM and SRAM, are used.
[0133] 1. SRAM Array Programming
[0134] The SRAM memory array is programmed row by row, with each row taking one clock cycle. This method ensures precise timing and power control. The dynamic power consumed by each memory cell is very low, at 1.8 × 10-7 milliwatts per megahertz (mW / MHz) .
[0135] 2. Peripheral Configuration
[0136] The configuration settings for the peripherals (additional circuits that support the main memory operations) are the same as those in previous studies. The read pulse, which is the voltage used to read data from the memory, is set at 0.5 volts.
[0137] 3. ADC Replacement
[0138] The ADC used for processing the product of Q y KT in the original NeuroSim setup is replaced with the Topkima ADC for more efficient softmax operations.
[0139] 4. Simulation Specifics
[0140] One attention module from the BERT-base model using the SQuAD dataset, with a sequence length SL of 384 and k = 5, is simulated. This setup is used to estimate the hardware performance of the Topkima-Former because transformers are constructed by stacking multiple attention modules.
[0141] Comparison and Performance of Topkima-Former
[0142] The scale-free design of some embodiments of the present invention is evaluated by comparing it with two other methods: the left shift scale and Tron's free scale. The results, shown in FIG. 5a, demonstrate that the design achieves a speedup of 2.0 times compared to the left shift scale and 1.6 times compared to Tron's free scale.
[0143] Left Shift Scale
[0144] This method is less efficient because it requires scaling for all elements from Q y KT, which is time-consuming.
[0145] Tron's Free Scale
[0146] This method lacks parallel processing capabilities and requires additional transpose operations, making it less efficient.
[0147] Additionally, in some embodiments, a pipeline design into the Topkima-Former is introduced. As shown in FIG. 5b, the pipeline design improves performance significantly. It outperforms the non-pipelined version by 4 times. Moreover, it achieves a speedup of 17 times over conventional softmax transformers and 15 times over digital Top-k softmax transformers. The improvement is even greater than the benefits observed at the macro level as shown in FIG. 2c due to the enhanced parallel processing capabilities of the pipeline design.
[0148] This comparison highlights the superior performance and efficiency of the Topkima-Former of the embodiments with the pipeline design, demonstrating its advantages over other scaling methods and softmax transformer designs.
[0149] Table 1: Comparison with state-of-art works
[0150] Table 1 presents a comparison with SOTA accelerators, including traditional systems and analog / digital CIM-based accelerators. The Topkima-Former of the embodiments can achieve 24.2 / 37.85 TOPS / sthroughput and 18.26 / 18.28 TOPS / W energy efficiency at 200 / 500 MHz. Compared to RTX 3090 Ti, ELSA, ReTransformer and X-Former, Topkima-Former (at 200 MHz) could achieve 76×, 22×, 303× higher speed, and 17200×, 16×, 39× and 1.4× energy reduction, respectively. Topkima-Former also achieves 16× speedup and near-equivalent energy efficiency than TranCIM.
[0151] The functional units and modules of the in-memory computing system and memory device in accordance with the embodiments disclosed herein may be implemented using computing devices, computer processors, or electronic circuitries including but not limited to application specific integrated circuits (ASIC) , field programmable gate arrays (FPGA) , microcontrollers, and other programmable logic devices configured or programmed according to the teachings of the present disclosure. Computer instructions or software codes running in the computing devices, computer processors, or programmable logic devices can readily be prepared by practitioners skilled in the software or electronic art based on the teachings of the present disclosure.
[0152] All or portions of the methods in accordance to the embodiments may be executed in one or more computing devices including server computers, personal computers, laptop computers, mobile computing devices such as smartphones and tablet computers.
[0153] The embodiments may include computer storage media, transient and non-transient memory devices having computer instructions or software codes stored therein, which can be used to program or configure the computing devices, computer processors, or electronic circuitries to perform any of the processes of the present invention. The storage media, transient and non-transient memory devices can include, but are not limited to, floppy disks, optical discs, Blu-ray Disc, DVD, CD-ROMs, and magneto-optical disks, ROMs, RAMs, flash memory devices, or any type of media or devices suitable for storing instructions, codes, and / or data.
[0154] Each of the functional units and modules in accordance with various embodiments also may be implemented in distributed computing environments and / or Cloud computing environments, wherein the whole or portions of machine instructions are executed in distributed fashion by one or more processing devices interconnected by a communication network, such as an intranet, Wide Area Network (WAN) , Local Area Network (LAN) , the Internet, and other forms of data transmission medium.
[0155] The foregoing description of the present invention has been provided for the purposes of illustration and description. It is not intended to be exhaustive or to limit the invention to the precise forms disclosed. Many modifications and variations will be apparent to the practitioner skilled in the art.
[0156] The embodiments were chosen and described in order to best explain the principles of the invention and its practical application, thereby enabling others skilled in the art to understand the invention for various embodiments and with various modifications that are suited to the particular use contemplated.
Claims
1.An in-memory computing system, comprising:a memory device comprising:a plurality of memory cells configured to allow a multiply and accumulate operation be performed on a plurality of stored digital values and time encoded analog values on wordlines, wherein computed analog values are made available on bitlines;an analog-to-digital converter (ADC) implemented using the memory cells; anda control logic configured to execute a Top-k selection among the computed analog values during an analog-to-digital conversion process, comprising:the control logic comparing the computed analog values on the bitlines;selecting k largest values from among the computed analog values; andcontrolling the ADC to convert the selected k computed analog values to digital format to generate k converted data;wherein k is a positive integer much smaller than a total number of the computed analog values.2.The system of claim 1, further comprising a processor configured to perform computations of non-linear functions directly with the k converted data.3.The system of claim 1, wherein the memory cells includes a plurality of replica bit-cells.4.The system of claim 1, wherein the ADC is implemented using replica bit-cells.5.The system of claim 1, wherein the memory cells perform a computation, and the computation is integrated into an attention modules of a transformer model.6.The system of claim 1; wherein the system is optimized by a quantization method, comprising: reducing precision of data representations in the memory device, thereby decreasing energy consumption and reducing latency of the memory operations.7.The system of claim 1, wherein the system is an edge device or an Internet of things (IoT) device.8.A memory device, comprising:a plurality of memory cells configured to perform a multiply and accumulate operation on a plurality of stored digital values and time encoded analog values on wordlines, wherein computed analog values are made available on bitlines;an analog-to-digital converter (ADC) implemented using the memory cells; anda control logic configured to execute a Top-k selection among the computed analog values during an analog-to-digital conversion process, comprising:the control logic comparing the computed analog values on the bitlines;selecting k largest values from among the computed analog values; andcontrolling the ADC to convert the selected k computed analog values to digital format to generate k converted data;wherein k is a positive integer much smaller than a total number of the computed analog values.9.The memory device of claim 8, wherein computations of non-linear functions directly with the k converted data are performed by an external processor.10.The memory device of claim 8, wherein the memory cells includes a plurality of replica bit-cells.11.The memory device of claim 8, wherein the ADC is implemented using replica bit-cells.12.The memory device of claim 8, wherein the memory cells perform a computation, and the computation is integrated into an attention modules of a transformer model.