TRANSFORMER ACCELERATION DEVICE

A transformer acceleration device may include a memory device including first and second memory blocks respectively storing first and second plurality of cache vectors for first and second plurality of tokens, and a memory striding circuit accessing first and second memory blocks. The memory striding circuit may include a memory block address management circuit storing first and second memory block base addresses for the first and second memory blocks, a target address generation circuit calculating a first target address of the first memory block based on the first memory block base address and a first subblock offset and calculating a second target address of the second memory block based on the second memory block base address and the first subblock offset; and a command issue circuit issuing first and second plurality of memory access commands for first and second target subblock of the first and second target address respectively.

CROSS-REFERENCE TO RELATED APPLICATION

This application claims priority to and the benefit of Korean Patent Application No. 10-2024-0060016 filed in the Korean Intellectual Property Office on May 7, 2024, the entire contents of which are incorporated herein by reference.

BACKGROUND

(a) Field of the Invention

The present disclosure relates to transformer acceleration devices that execute a transformer generating an output token based on a plurality of input tokens. More particularly, the present disclosure relates to transformer acceleration devices including a memory striding circuit configured to continuously read key-value vectors cached for executing the transformer.

(b) Description of the Related Art

A transformer acceleration device may generate an output token based on a plurality of input tokens. For example, the transformer acceleration device executes a transformer based on the plurality of input tokens to generate a first output token which is appropriate to following the plurality of input tokens.

The transformer may operate in an auto-regression scheme. For example, the transformer further uses the first output token with the plurality of input tokens to generate a second output token appropriate to following the plurality of input tokens and the first output token. That is, the transformer may sequentially operate throughout a plurality of iterations, and a token generated by each iteration may be used as an input of a subsequent iteration.

The transformer may reuse key-value vectors generated throughout the plurality of iterations. For example, the transformer may reuse a key-value vector computed in a previous iteration in a subsequent iteration. However, when a scheme in which the transformer stores and reads the key-value vectors is not optimized, operation efficiency of the transformer acceleration device may be reduced due to the storing and reading of the key-value vectors.

SUMMARY

The present disclosure provides transformer acceleration devices including a memory striding circuit implemented to read a key-value vector by an optimization scheme

According to some example embodiments, a transformer acceleration device of the present disclosure may include a memory device including a first memory block configured to store a first plurality of cache vectors for a first plurality of tokens, and a second memory block configured to store a second plurality of cache vectors for a second plurality of tokens; and a memory striding circuit configured to access the first and second memory blocks in response to a first striding request provided from an external device. The memory striding circuit may include a memory block address management circuit configured to store a first memory block base address for the first memory block and store a second memory block base address for the second memory block; a target address generation circuit configured to calculate, in response to the first striding request, a first target address included in the first memory block based on the first memory block base address and a first subblock offset and calculate, in response to the first striding request, a second target address included in the second memory block based on the second memory block base address and the first subblock offset; and a command issue circuit configured to issue a first plurality of memory access commands for a first target subblock located in the first target address, and issue a second plurality of memory access commands for a second target subblock located in the second target address.

Some example embodiments may provide a transformer acceleration device configured to execute a plurality of decoder layers including multi head attention calculations respectively performed based on a plurality of heads. The transformer acceleration device may include a first memory block including a first subblock configured to store a first plurality of cache vectors generated for a first plurality of tokens based on a first head and a first decoder layer, the first head being one of the plurality of heads and the first decoder layer being one of the plurality of decoder layers; a second memory block including a second subblock configured to store a second plurality of cache vectors generated for a second plurality of tokens based on the first head and the first decoder layer; a memory striding circuit configured to read the first plurality of cache vectors and the second plurality of cache vectors based on sequentially accessing the first subblock and the second subblock in response to a first striding request provided from an outside; and a calculation circuit configured to perform a first attention calculation for the first head and the first decoder layer based on the first plurality of cache vectors and the second plurality of cache vectors.

Some example embodiments may provide a transformer acceleration device including a memory device including a plurality of memory blocks including a plurality of subblocks; a memory striding circuit configured to sequentially access the plurality of subblocks in response to a first striding request provided from an external device; and a calculation circuit configured to perform a first attention calculation based on a first plurality of subblocks accessed by the memory striding circuit during a first time period, and perform a second attention calculation based on a second plurality of subblocks accessed by the memory striding circuit during a second time period after the first time period, the plurality of subblocks include the first plurality of subblocks and the second plurality of subblocks.

DETAILED DESCRIPTION

Hereinafter, embodiments of the present disclosure will be clearly and specifically described so that those skilled in the art of the present disclosure may easily implement the present disclosure. Details, such as detailed configurations and structures, are simply provided to help the overall understanding of the example embodiments of the present disclosure. Therefore, the transformations of the example embodiments described in the text may be performed by those skilled in the art without departing from the technical spirit and the scope of the present disclosure. Moreover, descriptions of well-known functions and structures are omitted for clarity and simplicity. The compositions in the following drawings or detailed description may be shown in the drawings or are connected to those other than the components described in the detailed description. The terms used in the text are the terms defined in consideration of the functions of the present disclosure and are not limited to specific functions. The definition of the terms may be determined based on the details described in the detailed description.

Components described with reference to the terms such as a driver or a block used in the detailed description may be implemented in the form of software, hardware, or combinations thereof. For example, software may be machine code, firmware, embedded code, and application software. For example, hardware may include an electrical circuit, an electronic circuit, a processor, a computer, integrated circuit cores, a pressure sensor, an inertia sensor, a micro electro mechanical system (MEMS), a passive element, or a combination thereof.

FIG. 1 is a block diagram illustrating a transformer acceleration device according to some example embodiments of the present disclosure. Referring to FIG. 1, the transformer acceleration device 100 may receive one or more input tokens TKin, and output an output token TKout. For example, the transformer acceleration device 100 may execute a transformer TF. The transformer TF may generate the output token TKout appropriate to following the one or more input tokens TKin based on the one or more input tokens TKin.

The transformer TF may operate in an auto-regression scheme. For example, the transformer TF may generate a token appropriate to follow the output token TKout further based on the generated output token TKout. By such a scheme, the transformer TF may generate one output token TKout whenever the transformer TF performs one iteration (e.g., one operation cycle). By such a scheme, the transformer TF sequentially performs a plurality of iterations to sequentially generate the plurality of output tokens TKout. A specific operation scheme of the transformer TF will be described in more detail with reference to FIG. 3 below.

In some example embodiments, the transformer acceleration device 100 may be used for implementing a large language model (LLM). For example, the transformer acceleration device 100 may predict an output token TKout that is to follow a plurality of input tokens TKin based on the plurality of input tokens TKin. However, the scope of the present disclosure is not limited to the type of specific model in which the transformer acceleration device 100 is used. For example, the transformer acceleration device 100 may be able to be used for implementing any type of artificial intelligence model such as an image generation model, a translation model, etc. However, hereinafter, for simpler description, some example embodiments in which the transformer acceleration device 100 is used for implementing the LLM will be representatively described.

FIG. 2 is a block diagram more specifically illustrating the transformer acceleration device of FIG. 1. Referring to FIGS. 1 and 2, the transformer acceleration device 100 may include a processing circuit 110, a calculation circuit 120, a memory striding circuit 130, a host interface circuit 140, a memory controller 150, and a memory device 160. The processing circuit 110, the calculation circuit 120, the memory striding circuit 130, the host interface circuit 140, and the memory controller 150 may communicate with each other through a bus.

The processing circuit 110 may control all operations of the transformer acceleration device 100. The processing circuit 110 may schedule a task or a calculation required for driving the transformer TF. That is, the processing circuit 110 may allocate the task or the calculation required for driving the transformer TF to the calculation circuit 120, the memory striding circuit 130, and the memory controller 150. For example, in order to allocate the task to the memory striding circuit 130, the processing circuit 110 may transmit a striding request REQ_STRD to the memory striding circuit 130.

The calculation circuit 120 may perform various types of calculations such as a linear calculation, an attention calculation, etc. For example, the calculation circuit 120 may include dedicated hardware optimized for the linear calculation and/or the attention calculation.

In some example embodiments, the calculation circuit 120 may include one or more processing cores included in various types of processing units including a graphic processing unit (GPU), a central processing unit (CPU), etc. That is, the scope of the present disclosure is not limited to a specific implementation scheme of the calculation circuit 120.

For simpler description, in FIG. 2, it is illustrated that the processing circuit 110 is a separate component from the calculation circuit 120, but the scope of the present disclosure is not limited thereto. For example, the processing circuit 110 and the calculation circuit 120 may be configured by separate hardware, or also implemented by one hardware.

The memory striding circuit 130 may iteratively access the memory device 160 in response to the control of the processing circuit 110. For example, in response to the striding request REQ_STRD, the memory striding circuit 130 may sequentially access data stored in mutually separated addresses of the memory device 160. That is, in response to the striding request REQ_STRD, the memory striding circuit 130 may sequentially issue a plurality of memory access commands CMD_MA to the memory device 160 through the memory controller 150. A configuration and an operation of the memory striding circuit 130 will be described in more detail with reference to the following drawings.

In some example embodiments, each of the plurality of memory access commands CMD_MA may be a read command, an activate command, and/or combination thereof.

In some example embodiments, in response to the striding request REQ_STRD, the memory striding circuit 130 may be implemented as an intellectual property (IP) circuit configured to sequentially access the mutually separated addresses of the memory device 160. However, the scope of the present disclosure is not limited to a specific implementation scheme of the memory striding circuit 130.

The host interface circuit 140 may support interfacing with an external host device (e.g., a central processing unit) of the transformer acceleration device 100. For example, the host interface circuit 140 may receive the input token TKin from the host device, and output the output token TKout to the host device.

In some example embodiments, the host interface circuit 140 may communicate with the host device based on various types of communication interfaces including a peripheral component interconnect express (PCIe), a double data rate (DDR), etc. However, the scope of the present disclosure is not limited to a specific operation scheme of the host interface circuit 140.

The memory controller 150 may control the memory device 160 in response to request of the processing circuit 110, the calculation circuit 120, and the memory striding circuit 130. For example, the memory controller 150 may store data in the memory device 160 or read the data stored in the memory device 160.

The memory device 160 may be used as an operation memory of the transformer acceleration device 100. For example, the memory device 160 may store data which are reused by the transformer TF throughout the plurality of iterations. More specifically, in some example embodiments, the memory device 160 may cache (e.g., store) a plurality of key vectors KEY and a plurality of value vectors VAL to be reused by the calculation circuit 120 throughout the plurality of iterations of the transformer TF. In this case, while followed iterations are performed, the calculation circuit 120 may not calculate the plurality of key vectors KEY and the plurality of value vectors VAL stored in the memory device 160, and as a result, an operation speed of the transformer acceleration device 100 may be enhanced.

Hereinafter, for simpler description, the key vector KEY, the value vector VAL, and any combination thereof which are stored in the memory device 160 may be referred to as “key-value vector”, “key-value cache”, “cache vector”, or “key-value cache vector”. That is, “key-value vector”, “key-value cache”, “cache vector, and “key-value cache vector” may refer to one or more key vectors KEY, or refer to one or more value vector VAL, or refer to a pair of one or more key vectors KEY and value vectors VAL. However, the scope of the present disclosure is not limited to the term.

In some example embodiments, the memory device 160 may pre-store (or, alternatively, generate or receive) the plurality of key vectors KEY and the plurality of value vectors VAL to be reused throughout the plurality of iterations in a training stage of the transformer TF.

In some example embodiments, the memory device 160 may pre-store (or, alternatively, generate or receive) the plurality of key vectors KEY and the plurality of value vectors VAL to be reused in following iterations while the transformer TF performs each iteration.

In some example embodiments, the memory device 160 may further store a weight matrix to be iteratively reused in decoder layers included in the transformer TF.

In some example embodiments, the memory device 160 may be a dynamic random access memory (DRAM) device. However, the scope of the present disclosure is not limited to a specific type of the memory device 160.

In some example embodiments, the memory device 160 may include a plurality of memory blocks corresponding to different addresses from each other. The plurality of key vectors KEY and the plurality value vectors VAL may be stored in different ones of the plurality of memory blocks.

In some example embodiments, the memory striding circuit 130 may sequentially access the plurality of memory blocks in response to one striding request REQ_STRD. That is, in response to one striding request REQ_STRD, the memory striding circuit 130 may sequentially issue the plurality of memory access commands CMD_MA for the plurality of memory blocks having different addresses. In this case, even though the processing circuit 110 does not directly issue the plurality of memory access commands CMD_MA for different addresses, the data stored in the plurality of memory blocks may be able to be sequentially read. Accordingly, a processing load of the processing circuit 110 may be minimized or reduced.

For simpler description, in FIG. 2, some example embodiments that the striding request REQ_STRD is issued from the processing circuit 110 are representatively illustrated, but the scope of the present disclosure is not limited thereto. For example, the striding request REQ_STRD may be issued from the external host device of the transformer acceleration device 100. In this case, the striding request REQ_STRD may be delivered to the memory striding circuit 130 through the processing circuit 110, or directly delivered to the memory striding circuit 130 from the host interface circuit 140 unlike the case illustrated FIG. 2.

FIG. 3 is a block diagram illustrating an operation of the transformer of FIG. 1. Referring to FIGS. 1 to 3, the transformer TF may sequentially operate throughout the plurality of iterations. Hereinafter, operations of transformers performing first to third iterations TF_IT1 to TF_IT3 will be representatively described. The first to third iterations may be mutually consecutive.

Hereinafter, for simpler description, it is assumed that an n-th token TKn is generated by a summarization stage of the transformer TF, and it is assumed that the first to third iterations are included in a generation stage. For example, hereinafter, it is assumed that a token stream including first to (n−1)-th tokens TK1 to TKn−1 is provided from the outside (e.g., from an external device) of the transformer acceleration device 100 (e.g., as a prompt tokens), and a 0-th iteration preceding the first iteration generates the n-th token TKn based the token stream. However, the scope of the present disclosure is not limited thereto.

The transformer TF may perform the plurality of iterations in an auto-regression scheme. The transformer TF may generate one output token TKout whenever performing each of the plurality of iterations. For example, when performing one iteration, the transformer TF may use the output token Tkout generated by the previous iteration as input token Tkin.

More specifically, in some example embodiments, the transformer performing the first iteration TF_IT1 may generate an (n+1)-th token TKn+1 by using the n-th token TKn generated by the iteration preceding the first iteration (e.g., the 0-th iteration) as the input token Tkin. Similarly to this, the transformer performing the second iteration TF_IT2 may generate an (n+2)-th token TKn+2 by using the (n+1)-th token TKn+1 as the input token Tkin, and the transformer performing the third iteration TF_IT3 may generate an (n+3)-th token TKn+3 by using the (n+2)-th token TKn+2 as the input token Tkin.

By such a scheme, the transformer acceleration device 100 may sequentially generate a plurality of tokens by executing the transformer TF throughout the plurality of iterations. In this case, the plurality of tokens generated by the transformer TF may form one token sequence with the token stream (e.g., the first to (n−1)-th token TK1 to TKn−1) provided from the external device. For example, the first to (n+2)-th token TK1 to TKn+2 may form one token sequence.

In some example embodiments, when the transformer acceleration device 100 is used for implementing the LLM, the token sequence may correspond to one or more sentences. However, the scope of the present disclosure is not limited thereto.

In some example embodiments, a maximum length of the token sequence may be predetermined, or, alternatively, may be generated or based on another feature of the transformer acceleration device 100. For example, the maximum length of the token sequence may be determined according to the number of tokens which the transformer TF may process at once. In some example embodiments, the maximum length of the token sequence may be set during manufacturing, or by a user.

In some example embodiments, tokens preceding a token in one token sequence may be referred to as preceding tokens therefor. For example, the first to (n−1)-th tokens TK1 to TKn−1 may be referred to as preceding tokens for the n-th token TKn, and the first to (n+1)-th tokens TK1 to TKn+1 may be referred to as preceding tokens for the (n+2)-th token TKn+2.

When performing one iteration, the transformer TF may generate the output token TKout based on the input token TKin and preceding tokens for the input token TKin. For example, the transformer performing the first iteration TF_IT1 may generate the (n+1)-th token TKn+1 based on the n-th token TKn, and the first to (n−1)-th tokens TK1 to TKn−1. Similarly to this, the transformer performing the second iteration TF_IT2 may generate the (n+2)-th token TKn+2 based on the (n+1)-th token TKn+1, and the first to n-th tokens TK1 to TKn.

As a result, when the transformer TF performs any iteration, calculation results for the plurality of tokens used for performing preceding iterations may be required again. For example, when the transformer TF performs any iteration, a plurality of key vectors KEY and a plurality of value vectors VAL corresponding to the plurality of tokens used for performing the preceding iterations may be required iteratively.

Accordingly, when the transformer TF performs any iteration, the plurality of key vectors KEY and the plurality of value vectors VAL calculated while performing the preceding iterations may be reused. For example, the transformer performing the first iteration TF_IT1 may reuse a plurality of key vectors KEY and a plurality of value vectors VAL corresponding to the first to (n−1)-th tokens TK1 to TKn−1, and the transformer performing the second iteration TF_IT2 may reuse a plurality of key vectors KEY and a plurality of value vectors VAL corresponding to the first to n-th tokens TK1 to TKn.

More specifically, in some example embodiments, whenever performing each iteration, the transformer TF may cache (e.g., store) a plurality of key vectors KEY and a plurality of value vectors VAL corresponding to the input token TKin into the memory device 160. In this case, calculation amount of the transformer TF performing following iterations may be minimized or reduced. Hereinafter, the operation of the transformer TF of each iteration will be described in more detail.

First, the transformer TF may store, in the memory device 160, key-value vectors for the preceding tokens for the n-th token TKn (e.g., the first to (n−1)-th tokens TK1 to TKn−1) before performing the first iteration (for example, while performing the 0-th iteration corresponding to the summarization stage).

Thereafter, the transformer performing the first iteration TF_IT1 may read the key-value vectors for the first to (n−1)-th tokens TK1 to TKn−1 stored in the memory device 160, and generate the key-value vectors for the n-th token TKn. In this case, the transformer performing the first iteration TF_IT1 may be able to generate the (n+1)-th token TKn+1 without calculating the key-value vectors for the first to (n−1)-th tokens TK1 to TKn−1. Meanwhile, the transformer performing the first iteration TF_IT1 may further store the key-value vectors for the n-th token TKn in the memory device 160.

Thereafter, the transformer performing the second iteration TF_IT2 may read the key-value vectors for the first to n-th tokens TK1 to TKn stored in the memory device 160, and generate the key-value vectors for the (n+1)-th token TKn+1. In this case, the transformer performing the second iteration TF_IT2 may be able to generate the (n+2)-th token TKn+2 without calculating the key-value vectors for the first to n-th tokens TK1 to TKn. Meanwhile, the transformer performing the second iteration TF_IT2 may further store the key-value vectors for the (n+1)-th token TKn+1 in the memory device 160.

By such a scheme, the transformer performing the third iteration TF_IT3 may read the key-value vectors for the first to (n+1)-th tokens TK1 to TKn+1 from the memory device 160, and store the key-value vectors for the (n+2)-th token TKn+2 to the memory device 160.

That is, according to some example embodiments of the present disclosure, while performing each iteration, the transformer TF may read, from the memory device 160, the key-value vectors corresponding to the preceding tokens for the output token TKout of the preceding iterations. In addition, the transformer TF may generate the key-value vectors corresponding to the output token TKout of the previous iteration, and cache (e.g., store) the generated key-value vectors in the memory device 160.

FIG. 4 is a block diagram illustrating a configuration of the transformer of FIG. 3 according to some example embodiments. Hereinafter, referring to FIGS. 1 to 4, a configuration and an operation of the transformer performing the first iteration will be representatively described. However, the scope of the present disclosure is not limited thereto, and the transformer TF that performs another iteration may be able to be implemented in a similar scheme thereto.

Further, for simpler description, hereinafter, a configuration and an operation of the transformer TF processing one token stream will be described. However, the scope of the present disclosure is not limited thereto, and the transformer TF may also be implemented to simultaneously process a plurality of token streams based on a batching scheme.

The transformer TF may include a pre-hidden layer HL_pre, first to m-th decoder layers DL1 to DLm, and a post-hidden layer HL_post.

The pre-hidden layer HL_pre may generate a full-activation vector FACT corresponding to the input token TKin based on the input token TKin. For example, the pre-hidden layer HL_pre may generate a full-activation vector FACT_L1_TKn based on the n-th token TKn.

In some example embodiments, the pre-hidden layer HL_pre may perform various types of token processing operations such as a token embedding operation, a positional encoding operation, etc.

The first to m-th decoder layers DL1 to DLm may generate the full-activation vector FACT_Lm+1_TKn by sequentially transforms the full-activation vector FACT_L1_TKn. More specifically, in some example embodiments, the k-th decoder layer DLk may generate the full-activation vector FACT_Lk+1_TKn based on the full-activation vector FACT_Lk_TKn (wherein, ‘k’ is an integer of 1 to m). For example, the first decoder layer DL1 may generate a full-activation vector FACT_L2_TKn based on the full-activation vector FACT_L1_TKn, and the second decoder layer DL2 may generate a full-activation vector FACT_L3_TKn based on the full-activation vector FACT_L2_TKn. By such a scheme, the m-th decoder layers DLm may generate the full-activation vector FACT_Lm+1_TKn based on the full-activation vector FACT_Lm_TKn.

In some example embodiments, dimensions of the full-activation vector FACT_L1_TKn to the full-activation vector FACT_Lm+1_TKn may be the same as each other. For example, the full-activation vector FACT_L1_TKn to the full-activation vector FACT_Lm+1_TKn may include the same number of elements.

In some example embodiments, each of the first to m-th decoder layers DL1 to DLm may generate the plurality of key vectors KEY and the plurality of value vectors VAL for the input token TKin (e.g., the n-th token TKn) based on the provided full-activation vector FACT. Each of the first to m-th decoder layers DL1 to DLm may store the plurality of key vectors KEY and the plurality of value vectors VAL which are generated in the memory device 160. In this case, when the transformer TF performs following iterations (e.g., the second iteration and the third iteration of FIG. 3), the transformer TF may not calculate the plurality of key vectors KEY and the plurality of value vectors VAL corresponding to the n-th token TKn. Some example embodiments of each of the first to m-th decoder layers DL1 to DLm will be described in more detail with reference to FIGS. 5 to 11 below.

The post-hidden layer HL_post may calculate the output token TKout (e.g., the (n+1)-th token TKn+1) based on the full-activation vector FACT_Lm+1_TKn.

In some example embodiments, the post-hidden layer HL_post may perform various types of vector processing operations such as a layer normalization operation, a fully connected network calculation operation, etc.

FIG. 5 is a diagram more specifically illustrating the configuration of the decoder layer of FIG. 4. Hereinafter, referring to FIGS. 1 to 5, a configuration and an operation of a first decoder layer DL1 will be representatively described. However, the scope of the present disclosure is not limited thereto, and second to m-th decoder layers DL2 to DLm will also be able to be implemented by a similar scheme thereto.

The first decoder layer DL1 may include a linear calculation LNC, and a multi head attention calculation MHATC. The linear calculation LNC and the multi head attention calculation MHATC may be performed by the calculation circuit 120.

The linear calculation LNC may refer to a calculation of multiplying the full-activation vector FACT with various types of weight matrixes. The linear calculation LNC will be described in more detail with reference to FIG. 6 below.

The multi head attention calculation MHATC may refer to a calculation of reflecting a correlation between the input token TKin (e.g., the n-th token TKn) and preceding tokens therefor based on a plurality of heads. Hereinafter, for simpler description, it is assumed that the transformer TF performs the multi head attention calculation MHATC based on N-heads. That is, hereinafter, it is assumed that the number of heads is ‘N’. The multi head attention calculation MHATC will be described in more detail with reference to FIGS. 7 to 10 below.

Hereinafter, for simpler description, the linear calculation LNC performed by a k-th decoder layer DLk may be referenced as a linear calculation LNC_Lk, and the multi head attention calculation MHATC performed by the k-th decoder layer DLk may be referenced as a multi head attention calculation MHATC_Lk.

FIG. 6 is a diagram more specifically illustrating the linear calculation of FIG. 5. Referring to FIGS. 1 to 6, the calculation circuit 120 may perform a linear calculation LNC_L1. For example, the calculation circuit 120 may generate a full-query vector FQRY_L1_TKn by multiplying the full-activation vector FACT_L1_TKn and a query weight matrix WM_QRY, generate a full-key vector FKEY_L1_TKn by multiplying the full-activation vector FACT_L1_TKn and a key weight matrix WM_KEY, and generate a full-value vector FVAL_L1_TKn by multiplying the full-activation vector FACT_L1_TKn and a value weight matrix WM_VAL.

In some example embodiments, the calculation circuit 120 may read, from the memory device 160, the query weight matrix WM_QRY, the key weight matrix WM_KEY, and the value weight matrix WM_VAL.

In some example embodiments, weight matrixes used by the transformer TF to perform linear calculations LNC included in different decoder layers DL may be different from each other. For example, the key weight matrix WM_KEY used for the linear calculation LNC_L1 may be different from the key weight matrix WM_KEY used for the linear calculation LNC_L2.

In some example embodiments, weight matrixes used by the transformer TF to perform linear calculations LNC included in the same decoder layers DL included in the plurality of iterations, respectively may be the same as each other. For example, the transformer TF may perform the linear calculations LNC of the first decoder layers DL1 included in the plurality of iterations, respectively based on the same weight matrix.

Each of the full-query vector FORY_L1_TKn, the full-key vector FKEY_L1_TKn, and the full-value vector FVAL_L1_TKn may be split into a plurality of vectors corresponding to a plurality of heads, respectively. For simpler description, hereinafter, some example embodiments in which each of the full-query vector FQRY_L1_TKn, the full-key vector FKEY_L1_TKn, and the full-value vector FVAL_L1_TKn is split into a plurality of vectors each having four elements will be representatively described. That is, hereinafter, it is assumed that the dimension of head is ‘4’. However, the scope of the present disclosure is not limited thereto.

The full-query vector FQRY_L1_TKn may be split into a query vector QRY_L1_TKn_H1 to a query vector QRY_L1_TKn_HN, the full-key vector FKEY_L1_TKn may be split into a key vector KEY_L1_TKn_H1 to a key vector KEY_L1_TKn_HN, and the full-value vector FVAL_L1_TKn may be split into a value vector VAL_L1_TKn_H1 to a value vector VAL_L1_TKn_HN. In this case, each of the query vector QRY_L1_TKn_H1 to the query vector QRY_L1_TKn_HN, the key vector KEY_L1_TKn_H1 to the key vector KEY_L1_TKn_HN, and the value vector VAL_L1_TKn_H1 to the value vector VAL_L1_TKn_HN may include four elements.

In some example embodiments, the full-query vector FQRY_L1_TKn may have a dimension of N times of that of each of the query vectors QRY_L1_TKn_H1 to QRY_L1_TKn_HN.

In some example embodiments, the full-key vector FKEY_L1_TKn may have a dimension of N times of that of each of the key vectors KEY_L1_TKn_H1 to KEY_L1_TKn_HN.

In some example embodiments, the full-value vector FVAL_L1_TKn may have a dimension of N times of that of each of the value vectors VAL_L1_TKn_H1 to VAL_L1_TKn_HN.

FIGS. 7 and 8 are diagrams more specifically illustrating the multi head attention calculation of FIG. 5.

First, referring to FIGS. 1 to 7, the first decoder layer DL1 may include N heads. The calculation circuit 120 may perform a multi head attention calculation MHATC_L1 for the first decoder layer DL1 based on N heads. For example, the multi head attention calculation MHATC_L1 may include a plurality of attention calculations ATC_L1_H1 to ATC_L1_HN corresponding to the first to N-th heads (hereinafter, referenced as H1 to HN, respectively), respectively. The calculation circuit 120 may independently perform the plurality of attention calculations ATC_L1_H1 to ATC_L1_HN.

The attention calculation ATC_L1_H1 may include an attention score calculation CAL_ATS_L1_H1 and an attention vector calculation CAL_AV_L1_H1. For example, the calculation circuit 120 may calculate a plurality of attention scores by performing the attention score calculation CAL_ATS_L1_H1, and generate an attention vector by performing the attention vector calculation CAL_AV_L1_H1 based on the calculated plurality of attention scores. The attention score calculation CAL_ATS_L1_H1 will be described in more detail with reference to FIG. 9 below, and the attention vector calculation CAL_AV_L1_H1 will be described in more detail with reference to FIG. 10 below.

For simpler description, a configuration of the attention calculation ATC_L1_H1 corresponding to the first head is representatively described, but the scope of the present disclosure is not limited thereto, and the attention calculations ATC_L1_H2 to ATC_L1_HN will also be able to be configured by the similar scheme thereto. That is, the calculation circuit 120 may perform the attention score calculation CAL_ATS and the attention vector calculation CAL_AV for each of the plurality of heads.

Referring to FIGS. 1 to 8, the calculation circuit 120 may perform the plurality of attention calculations ATC_L1_H1 to ATC_L1_HN based on the first to N-th heads H1 to HN.

The calculation circuit 120 may perform the plurality of attention calculations ATC_L1_H1˜ATC_L1_HN based on the query vectors QRY_L1_TKn_H1 to the query vector QRY_L1_TKn_HN, the key vector KEY_L1_TKn_H1 to the key vector KEY_L1_TKn_HN, and the value vector VAL_L1_TKn_H1 to the value vector VAL_L1_TKn_HN described with reference to FIG. 6 above. For example, the calculation circuit 120 may generate the attention vector AV_L1_TKn_H1 by performing the attention calculation ATC_L1_H1 corresponding to the first head H1 of the first decoder layer DL1 based on the query vector QRY_L1_TKn_H1, the key vector KEY_L1_TKn_H1, and the value vector VAL_L1_TKn_H1. A scheme in which the calculation circuit 120 performs the attention calculation ATC_L1_H1 will be described in more detail with reference to FIGS. 9 and 10 below.

Similar to this, the calculation circuit 120 may generate an attention vector AV_L1_TKn_H2 by performing an attention calculation ATC_L1_H2 corresponding to the second head H2 of the first decoder layer DL1 based on the query vector QRY_L1_TKn_H2, the key vector KEY_L1_TKn_H2, and the value vector VAL_L1_TKn_H2.

By such a scheme, the calculation circuit 120 may independently perform the attention calculation ATC_L1_H1 to the attention calculation ATC_L1_HN. For example, the calculation circuit 120 may calculate the attention vector AV_L1_TKn_H1 to the attention vector AV_L1_TKn_HN based on different processing cores, or at different times.

Thereafter, the transformer TF may concatenate the attention vector AV_L1_TKn_H1 to the attention vector AV_L1_TKn_HN. For example, the transformer TF concatenates the attention vector AV_L1_TKn_H1 to the attention vector AV_L1_TKn_HN to generate the full-attention vector FAV_L1_TKn. Thereafter, the transformer TF may generate the full-activation vector FACT_L2_TKn by executing one or more of various types of vector processing algorithms such as a residual layer, a fully-connected layer, etc., based on the full-attention vector FAV_L1_TKn.

In some example embodiments, the attention calculation ATC performed based on a single, specific head may be referred to as single head attention. For example, the attention calculation ATC_L1_H1 performed based on the first head H1 may be referred to as the single head attention for the first head H1. However, the scope of the present disclosure is not limited to the term.

FIG. 9 is a diagram more specifically illustrating the attention score calculation of FIG. 7. That is, hereinafter, referring to FIGS. 1 to 9, the attention score calculation CAL_ATS_L1_H1 performed by the first head H1 of the first decoder layer DL1 based on the n-th token TKn will be representatively described.

The calculation circuit 120 may generate attention scores ATS1_L1_TKn_H1 to ATSn_L1_TKn_H1 corresponding to the n-th token TKn and the preceding tokens therefor (e.g., the first to (n−1)-th tokens TK1 to TKn−1) based on the query vector QRY_L1_TKn_H1. For example, the calculation circuit 120 may calculate the attention score ATS1_L1_TKn_H1 based on a dot product result of the query vector QRY_L1_TKn_H1 and the key vector KEY_L1_TK1_H1, and calculate the attention score ATS2_L1_TKn_H1 based on a dot product result of the query vector QRY_L1_TKn_H1 and the key vector KEY_L1_TK2_H1. By such a scheme, the calculation circuit 120 may calculate an attention score ATSn_L1_TKn_H1 based on a dot product result of the query vector QRY_L1_TKn_H1 and the key vector KEY_L1_TKn_H1. In this case, key vectors KEY_L1_TK1_H1 to KEY_L1_TKn−1_H1 corresponding to the preceding tokens (hereinafter, may be referred to as preceding key vectors) may have been already calculated in advance by preceding iteration (e.g., the 0-th iteration).

That is, in order to perform the attention score calculation CAL_ATS_L1_H1, the calculation circuit 120 may require not only the key vector KEY for the input token but also the preceding key vectors therefor iteratively. As a result, the calculation circuit 120 may store the calculated key vector KEY in the memory device 160, and then reuse the key vector KEY. For example, while the transformer TF performs the first iteration, the first head H1 of the first decoder layer DL1 may store the key vector KEY_L1_TKn_H1 in the memory device 160. In this case, while the transformer TF performs the second iteration, the calculation circuit 120 may be able to perform the attention score calculation CAL_ATS_L1_H1 by reusing the key vector KEY_L1_TKn_H1 stored in the memory device 160.

FIG. 10 is a diagram more specifically illustrating the attention vector calculation of FIG. 7. That is, hereinafter, referring to FIGS. 1 to 10, the attention vector calculation CAL_AV_L1_H1 performed with respect to the first head H1 of the first decoder layer DL1 based on the n-th token TKn will be representatively described.

The calculation circuit 120 may perform the attention vector calculation CAL_AV for the n-th token TKn, based on the attention scores ATS and the value vectors VAL respectively corresponding to the n-th token TKn and the preceding tokens therefor (e.g., the first to (n−1)-th tokens TK1 to TKn−1). For example, the calculation circuit 120 may generate the attention vector AV_L1_TKn_H1 based on a result of accumulating multiplications of the value vectors VAL_L1_TK1_H1 to VAL_L1_TKn_H1 and the attention scores ATS1_L1_TKn_H1 to ATSn_L1_TKn_H1, respectively. In this case, value vectors VAL_L1_TK1_H1 to VAL_L1_TKn−1_H1 corresponding to the preceding tokens (hereinafter, may be referred to as preceding value vectors) may have been already calculated in advance by the preceding iteration (e.g., the 0-th iteration).

That is, in order to perform the attention vector calculation CAL_AV_L1_H1, the calculation circuit 120 may require not only the value vector VAL for the input token TKin but also the preceding value vectors therefor. As a result, the calculation circuit 120 may store the calculated value vector VAL in the memory device 160, and then reuse the value vector VAL.

For example, while the transformer TF performs the first iteration, the first head H1 of the first decoder layer DL1 may be able to store the value vector VAL_L1_TKn_H1 in the memory device 160. In this case, while the transformer TF performs the second iteration, the calculation circuit 120 may be able to perform the attention vector calculation CAL_AV_L1_H1 by reusing the value vector VAL_L1_TKn_H1 stored in the memory device 160.

FIG. 11 is a diagram more specifically illustrating the operation of the transformer of FIG. 3. Hereinafter, for simpler description, referring to FIGS. 1 to 11, the key vectors KEY and the value vectors VAL which the transformer TF caches (e.g., stores) into the memory device 160 while the first iteration is performed will be representatively described.

While the transformer TF performs the first iteration, each of the first to m-th decoder layers DL1 to DLm may store a plurality of key vectors KEY for first to N-th heads H1 to HN in the memory device 160. For example, the first decoder layer DL1 may store key vectors KEY_L1_TKn_H1 to KEY_L1_TKn_HN in the memory device 160, and the second decoder layer DL2 may store key vectors KEY_L2_TKn_H1 to KEY_L2_TKn_HN in the memory device 160.

Similar to this, while the transformer TF performs the first iteration, each of the first to m-th decoder layers DL1 to DLm may store a plurality of value vectors VAL for the first to N-th heads H1 to HN in the memory device 160. For example, the first decoder layer DL1 may store value vectors VAL_L1_TKn_H1 to VAL_L1_TKn_HN in the memory device 160, and the second decoder layer DL2 may store value vectors VAL_L2_TKn_H1 to VAL_L2_TKn_HN in the memory device 160.

In other words, when one decoder layer DL is executed, the calculation circuit 120 may store a plurality of key vectors KEY and a plurality of value vectors VAL corresponding to the input token TKin in the memory device 160.

By such a scheme, whenever the transformer TF performs one decoder layer DL, N-pairs of ‘key vector KEY-value vector VAL’ may be further stored in the memory device 160. Accordingly, whenever the transformer TF performs one iteration, (m×N)-pairs of ‘key vector KEY-value vector VAL’ may be further stored in the memory device 160.

In some example embodiments, each of the plurality of key vectors KEY and the plurality of value vectors VAL cached to the memory device 160 may also be referred to as cache vector.

FIG. 12 is a block diagram more specifically illustrating the operation of the memory striding circuit according to some example embodiments of the present disclosure. Referring to FIGS. 1 to 12, the memory striding circuit 130 may receive the striding request REQ_STRD. The memory striding circuit 130 may sequentially access a plurality of memory regions included in the memory device 160 in response to the striding request REQ_STRD.

The memory device 160 may include a plurality of memory blocks BLK. For example, the memory device 160 may include first to q-th memory blocks BLK1 to BLKq.

Each of the plurality of memory blocks BLK may store key vectors KEY and value vectors VAL for a plurality of tokens. For example, the first memory block BLK1 may include a memory region for storing key vectors KEY and value vectors VAL for first to p-th tokens TK1 to TKp, and the second memory block BLK2 may include a memory region for storing key vectors KEY and value vectors VAL for (p+1)-th to (2p)-th tokens TKp+1 to TK2p. Similarly to this, the q-th memory block BLKq may include a memory region for storing key vectors KEY and value vectors VAL for (qp+1)-th to ((q+1)p)-th tokens TKqp+1 to TK(q+1)p.

More specifically, in some example embodiments, each memory block BLK may store key vectors KEY and value vectors VAL for a plurality of decoder layers DL included in the transformer TF. For example, the first memory block BLK1 may store key vectors KEY and value vectors VAL which are corresponding to the first to p-th tokens TK1 to TKp and generated by the first to m-th decoder layers DL1 to DLm.

For simpler description, hereinafter, some example embodiments in which each memory block BLK is implemented to store both of the key vectors KEY and the value vector VAL will be representatively described. However, the scope of the present disclosure is not limited thereto, and each memory block BLK may be able to be implemented to store only the key vectors KEY, or implemented to store only the value vectors VAL.

Capacities of the plurality of memory blocks BLK may be the same as each other. For example, the plurality of memory blocks BLK may occupy memory regions having the same size as each other. In this case, the numbers of cache vectors (e.g., key vectors KEY or value vectors VAL) which may be stored in the plurality of memory blocks BLK may be the same as each other.

In some example embodiments, the numbers of cache vectors which may be stored in the plurality of memory blocks BLK may be determined based on the type of artificial intelligence model executed by the transformer acceleration device 100. That is, the scope of the present disclosure is not limited to a size of ‘p’.

In some example embodiments, each of the plurality of memory blocks BLK may occupy continuous memory regions. For example, each memory block BLK may occupy memory regions corresponding to a plurality of memory cells in which a row address and/or a bank address are adjacent to each other. That is, each memory block BLK may occupy a discreet, physical section of the memory device 160. However, the scope of the present disclosure is not limited thereto.

In some example embodiments, forms of the memory regions occupied by each of the plurality of memory blocks BLK may be the same as each other. For example, sizes of row address ranges occupied by each of the plurality of memory blocks BLK may be the same as each other, and sizes of bank address ranges occupied by each of the plurality of memory blocks BLK may be the same as each other. However, the scope of the present disclosure is not limited thereto.

Meanwhile, the processing circuit 110 may be implemented to sequentially allocate the plurality of memory blocks BLK to the memory device 160 according to a length of a token sequence generated by an auto-regressive operation of transformer TF described with reference to FIGS. 3 to 11. For example, the processing circuit 110 may determine whether to allocate a new memory block BLK based on whether space to store key vectors KEY and value vectors VAL for a new generated token remains in the memory block BLK allocated to the memory device 160.

More specifically, in some example embodiments, when the transformer TF generates the p-th token TKp, a total length of the token sequence may become ‘p’. In this case, there may be an empty space which may store the key vectors KEY and the value vectors VAL for the p-th token TKp in the first memory block BLK1. Accordingly, the processing circuit 110 may not allocate a memory region for the new memory block BLK to the memory device 160.

On the contrary, when the transformer TF generates the (p+1)-th token TKp+1, a total length of the token sequence may become ‘p+1’. In this case, the first memory block BLK1 may already store the key vectors KEY and the value vectors VAL for the first to p-th tokens TK1 to TKp. That is, there will be no empty space which may store the key vectors KEY and the value vectors VAL for the (p+1)-th token TKp+1 in the first memory block BLK1. Accordingly, the processing circuit 110 may newly allocate a memory region for a second memory block BLK2 to the memory device 160.

By such a scheme, as the length of the token sequence increases, the processing circuit 110 may newly allocate the memory region for the new memory block BLK to the memory device 160. In this case, the plurality of memory blocks BLK may be allocated in different time points each other. Accordingly, when another data is further stored in the memory device 160 between the time points at which the plurality of memory blocks BLK are allocated, the plurality of memory blocks BLK may be allocated with mutually separated addresses. For example, when the transformer acceleration device 100 caches key-value vectors for another token sequence (not illustrated) generated by a batch operation to the memory device 160, the plurality of memory blocks BLK may be allocated to mutually separated addresses.

However, similarly to the description by referring to FIGS. 1 to 11 above, when the calculation circuit 120 performs the attention calculation ATC, the calculation circuit 120 may require both of the plurality of key vectors KEY and the plurality of value vectors VAL for the preceding tokens. For example, when the calculation circuit 120 performs the attention calculation ATC for generating the (qp+2)-th token TKqp+2, the calculation circuit 120 may require both of the plurality of key vectors KEY and the plurality of value vectors VAL for the first to (qp+1)-th tokens TK1 to TKqp+1. That is, the calculation circuit 120 may require the plurality of key vectors KEY and the plurality of value vectors VAL distributed in the plurality of memory blocks BLK in order to perform the attention calculation ATC.

The memory striding circuit 130 may sequentially access the plurality of memory blocks BLK in response to the striding request REQ_STRD. For example, the memory striding circuit 130 may sequentially read the plurality of key vectors KEY and the plurality of value vectors VAL distributed in the first to q-th memory blocks BLK1 to BLKq.

In some example embodiments, the processing circuit 110 may be implemented to directly issue a memory access command CMD_MA for the plurality of key vectors KEY and the plurality of value vectors VAL distributed in the plurality of memory blocks BLK. In this case, since the processing circuit 110 should directly manage addresses storing the plurality of key vectors KEY and the plurality of value vectors VAL, a processing load of the processing circuit 110 may increase.

In some example embodiments, the memory striding circuit 130 may be implemented to issue the memory access command CMD_MA for the plurality of key vectors KEY and the plurality of value vectors VAL instead of the processing circuit 110 in response to the striding request REQ_STRD. In this case, since the processing circuit 110 may not directly manage the addresses storing the plurality of key vectors KEY and the plurality of value vectors VAL, and a frequency of which the processing circuit 110 issues the memory access command CMD_MA may be minimized or reduced, the processing load processed by the processing circuit 110 may be minimized or reduced.

FIG. 13 is a block diagram more specifically illustrating the memory striding circuit of FIG. 2. Referring to FIGS. 1 to 13, the memory striding circuit 130 may include a memory block address management circuit 131, a target address generation circuit 132, and a command issue circuit 133.

The memory block address management circuit 131 may include a memory block base address table MBBAT. The memory block base address table MBBAT may include a memory block base address (hereinafter, referenced as “BASE”) of each of the plurality of memory blocks BLK.

In some example embodiments, the memory block base address may be one address included in a memory block BLK. That is, the memory block base address may be one address representing the memory block BLK. More specifically, in some example embodiments, the memory block base address may refer to a smallest address among the addresses of the memory region occupied by the memory block BLK. However, the scope of the present disclosure is not limited thereto.

In some example embodiments, the memory block address management circuit 131 may receive the memory block base address table MBBAT from the processing circuit 110. For example, the memory block address management circuit 131 may receive the striding request REQ_STRD including the memory block base address table MBBAT. However, the scope of the present disclosure is not limited thereto, and the memory block address management circuit 131 may also receive the memory block base address table MBBAT from an external host device (e.g., a central processing unit) of the transformer acceleration device 100 through the host interface circuit 140.

The target address generation circuit 132 may generate a target address (hereinafter, referenced as “TG”) storing the key vector KEY or the value vector VAL to be read from the memory device 160. For example, the target address generation circuit 132 may generate a target address based on the memory block base address stored in the memory block base address table MBBAT.

In some example embodiments, the target address generation circuit 132 may generate a target address TG based on a relative address (hereinafter, referenced as subblock offset OFST) of the memory region to be accessed, for the memory block base address. For example, the target address generation circuit 132 may generate the target address TG by adding the subblock offset OFST to the memory block base address BASE.

The command issue circuit 133 may issue a memory access command CMD_MA for the target address TG. For example, the command issue circuit 133 may issue an active command and a read command for the target address TG.

FIG. 14 is a diagram illustrating a memory block base address table of FIG. 13. Referring to FIGS. 1 to 14, the memory block base address table MBBAT may store a plurality of memory block base addresses BASE corresponding to the plurality of memory blocks BLK, respectively. For example, the memory block base address table MBBAT may store first to q-th memory block base addresses BASE1 to BASEq corresponding to first to q-th memory blocks BLK1 to BLKq, respectively.

The first to q-th memory block base addresses BASE1 to BASEq may be different from each other. For example, the first memory block base address BASE1 may be “0x11101”, the second memory block base address BASE2 may be “0x21101”, the third memory block base address BASE3 may be “0x31101”, and the q-th memory block base address BASEq may be “0xq1101”.

For simpler description, in the present disclosure, some example embodiments that each of the plurality of memory block base addresses BASE is 20 bits is representatively illustrated, but the scope of the present disclosure is not limited thereto. For example, each of the plurality of memory block base addresses BASE may be any number of bits corresponding to a bank group address, a bank address, a row address, a column address, and/or any combination thereof.

FIG. 15 is a diagram more specifically illustrating a memory block of FIG. 12. Hereinafter, referring to FIGS. 1 to 15, the configuration of the first memory block BLK1 will be representatively described. However, the scope of the present disclosure is not limited thereto, and each of the plurality of memory blocks BLK included in the memory device 160 may be configured by the similar scheme thereto.

The first memory block BLK1 may include a plurality of subblocks SB. For example, the first memory block BLK1 may include a plurality of subblocks SB referenced as “SB_LkHj” (k is an integer of 1 or more and m or less, and j is an integer of 1 or more and N or less). For example, the first memory block BLK1 may include a subblock SB_L1H1 to a subblock SB_LmHN.

The plurality of subblocks SB may correspond to different combinations of the plurality of decoder layers DL and the plurality of heads H. Each of the plurality of subblocks SB may correspond to one decoder layer DL and one head H. For example, the subblock SB_LkHj may correspond to a k-th decoder layer DLk and a j-th head Hj. More specifically, in some example embodiments, the subblock SB_L1H1 may correspond to the first decoder layer DL1 and the first head H1, the subblock SB_L1H2 may correspond to the first decoder layer DL1 and the second head H2, and the subblock SB_L2H1 may correspond to the second decoder layer DL2 and the first head H1.

In some example embodiments, the number of subblocks included in one memory block BLK may be determined based on the product of the number (e.g., m) of decoder layers and the number (e.g., N) of heads.

Each of the plurality of subblocks SB may store the plurality of key vectors KEY and/or the plurality of value vectors VAL for the corresponding decoder layer DL and head H, cached to the memory device 160 for the attention calculation ATC. For example, the subblock SB_LkHj may store the plurality of key vectors KEY and/or the plurality of value vectors VAL cached for the attention calculation ATC_Lk_Hj. That is, the subblock SB_LkHj included in the first memory block BLK1 may store key vectors KEY_Lk_TK1_Hj to KEY_Lk_TKp_Hj and/or value vectors VAL_Lk_TK1_Hj to VAL_Lk_TKp_Hj for the first to p-th tokens TK1 to TKp, which are cached for the attention calculation ATC_Lk_Hj. More specifically, in some example embodiments, the subblock SB_L1H1 included in the first memory block BLK1 may store key vectors KEY_L1_TK1_H1 to KEY_L1_TKp_H1 and/or value vectors VAL_L1_TK1_H1 to VAL_L1_TKp_H1 for the first to p-th token TK1 to TKp; the subblock SB_L1H2 included in the first memory block BLK1 may store key vectors KEY_L1_TK1_H2 to KEY_L1_TKp_H2 and/or value vectors VAL_L1_TK1_H2 to VAL_L1_TKp_H2 for the first to p-th token TK1 to TKp; and the subblock SB_L2H1 included in the first memory block BLK1 may store key vectors KEY_L2_TK1_H1 to KEY_L2_TKp_H1 and/or value vectors VAL_L2_TK1_H1 to VAL_L2_TKp_H1 for the first to p-th token TK1 to TKp.

That is, according to some example embodiments of the present disclosure, each of the plurality of subblocks SB may store the plurality of key vectors KEY and/or the plurality of value vectors VAL. However, hereinafter, for simpler description, addresses storing the plurality of key vectors KEY in the plurality of subblocks SB will be representatively described. As a result, hereinafter, some example embodiments in which the memory striding circuit 130 accesses the plurality of key vectors KEY stored in the memory device 160 will be representatively described. However, the scope of the present disclosure is not limited thereto, and one subblock SB may be implemented to store the plurality of value vectors VAL, or also implemented to store both the plurality of key vectors KEY and the plurality value vectors VAL. In this case, the memory striding circuit 130 may be able to access the plurality of value vectors VAL stored in the memory device 160, or access both of the plurality of key vectors KEY and the plurality of value vectors VAL stored in the memory device 160.

Subblocks corresponding to the k-th decoder layer DLk among the plurality of subblocks SB may form a subblock group SBG_Lk. For example, a subblocks SB_L1H1 to SB_L1HN may form a subblock group SBG_L1.

Subblocks corresponding to the j-th head Hj among the plurality of subblocks SB may form a subblock group SBG_Hj. For example, the subblocks SB_L1H1 to SB_LmH1 may form a subblock group SBG_H1.

Address intervals of the plurality of subblocks included in one subblock group SBG may be same each other. For example, address intervals between the subblocks SB_L1H1 to SB_L1HN may be the same as each other, and address intervals between the subblocks SB_L1H1 SB_LmH1 may be the same as each other. Accordingly, the target address generation circuit 132 may be able to identify ‘subblock base addresses’ respectively corresponding to all subblocks SB included in the first memory block BLK1, by sequentially adding the address intervals to the first memory block base address BASE1. The address intervals between the plurality of subblocks SB will be described with reference to FIGS. 17 and 18 below, and the operation of the target address generation circuit 132 will be described in more detail with reference to FIGS. 19 to 30 below.

FIG. 16 is a diagram more specifically illustrating a configuration of a subblock illustrated in FIG. 15. Hereinafter, referring to FIGS. 1 to 16, the configuration of the subblock SB_L1H1 will be representatively described. However, the scope of the present disclosure is not limited thereto, and other subblocks SB included in the first memory block BLK1 may be configured by the similar scheme thereto.

The subblock SB_L1H1 may store the key vectors KEY_L1_TK1_H1 to KEY_L1_TKp_H1. The key vectors KEY_L1_TK1_H1 to KEY_L1_TKp_H1 may be stored in mutually continuous addresses in the memory device 160. For example, the addresses may be adjacent to one another, and may be in a continuous (or uninterrupted) string, and occupy a discreet, physical section of the memory device 160. For example, the key vector KEY_L1_TK1_H1 may be stored in an address “0x01101”, the key vector KEY_L1_TK2_H1 may be stored in an address “0x01102”, and the key vector KEY_L1_TK3_H1 may be stored in an address “0x01103”. Similarly to this, the key vector KEY_L1_TKp_H1 may be stored in an address “0x0110p”. That is, the subblock SB_L1H1 may occupy memory regions corresponding to the addresses “0x01101” to “0x0110p” of the memory device 160.

In some example embodiments, the size of the subblock SB may be the same as a reading size which is a unit continuously read (e.g., a unit which is read together) from the memory striding circuit 130. For example, when the subblock SB_L1H1 occupies memory regions corresponding to p-addresses which increase from the address “0x01101” by “0x00001”, the memory striding circuit 130 may continuously read data stored in p-addresses which increase from the target address by “0x00001”. A relationship between the reading size and the size of the subblock SB will be described in more detail with reference to the following drawings.

For simpler description, in FIG. 16, some example embodiments in which the subblock SB_L1H1 occupies the memory regions corresponding to p addresses which increase from the address “0x01101” by “0x00001” is representatively illustrated, but the scope of the present disclosure is not limited thereto. For example, the subblock SB_L1H1 may also occupy the memory regions corresponding to p-addresses which increase from the first memory block base address BASE1 by any size.

In some example embodiments, the subblock SB_L1H1 may correspond to one page of the memory device 160. For example, the memory region occupied by the subblock SB_L1H1 may correspond to one memory bank and one row address included in the memory device 160. However, the scope of the present disclosure is not limited thereto.

In some example embodiments, the subblock SB_L1H1 may correspond to two or more pages of the memory device 160. In this case, the subblock SB_L1H1 may occupy a memory region corresponding to two or more row addresses in one memory bank included in the memory device 160, or occupy a memory region corresponding to a single row address in two or more memory banks included in the memory device 160. However, the scope of the present disclosure is not limited thereto.

FIGS. 17 and 18 are diagrams more specifically illustrating a subblock group of FIG. 15. Hereinafter, the configuration of the subblock group SBG_H1 will be described with reference to FIG. 17, and the configuration of the subblock group SBG_L1 will be described with reference to FIG. 18.

First, referring to FIGS. 1 to 17, the subblock group SBG_H1 may include a plurality of subblocks SB. For example, the subblock group SBG_H1 may include the subblock SB_L1H1 to the subblock SB_L3H1.

Similarly to the description by referring to FIG. 16 above, the subblock SB_L1H1 may store the key vectors KEY_L1_TK1_H1 to KEY_L1_TKp_H1. Similarly to this, the subblock SB_L2H1 may store the key vectors KEY_L2_TK1_H1 to KEY_L2_TKp_H1 and the subblocks SB_L3H1 may store the key vectors KEY_L3_TK1_H1 to KEY_L3_TKp_H1.

Address intervals between the plurality of subblocks SB included in the subblock group SBG_H1 may be the same as each other. For example, address intervals between the subblock SB_L1H1 and the subblock SB_L2H1, and address intervals between the subblock SB_L2H1 and the subblock SB_L3H1 may be a layer address interval INTV_layer. Hereinafter, for simpler description, it is assumed that the layer address interval INTV_layer is “0x01000”.

More specifically, in some example embodiments, a difference between addresses storing the key vectors KEY_L1_TK1_H1˜KEY_L1_TKp_H1 and addresses storing the key vectors KEY_L2_TK1_H1˜KEY_L2_TKp_H1, respectively may be the layer address interval INTV_layer, and a difference between addresses storing the key vectors KEY_L2_TK1_H1˜KEY_L2_TKp_H1 and addresses storing the key vectors KEY_L3_TK1_H1˜KEY_L3_TKp_H1, respectively may be the layer address interval INTV_layer.

That is, the addresses occupied by each of the subblocks SB included in the subblock group SBG_H1 may correspond to addresses obtained by adding an integer multiple of the layer address interval INTV_layer to the addresses occupied by the subblock SB_L1H1, respectively. For example, the addresses occupied by the subblock SB_L2H1 may correspond to addresses obtained by adding the layer address interval INTV_layer to the addresses occupied by the subblock SB_L1H1, respectively; and the addresses occupied by the subblock SB_L3H1 may correspond to addresses obtained by adding twice of the layer address interval INTV_layer to the addresses occupied by the subblock SB_L1H1, respectively.

Accordingly, according to some example embodiments of the present disclosure, the target address generation circuit 132 may calculate the subblock base address for each of the subblocks SB included in the subblock group SBG_H1 by sequentially adding the layer address interval INTV_layer to the first memory block base address BASE1. More specifically, in some example embodiments, the target address generation circuit 132 may calculate a subblock base address “0x02101” for the subblock SB_L2H1 by adding the layer address interval INTV_layer “0x01000” to the subblock base address “0x01101” for the subblock SB_L1H1 (that is, the first memory block base address BASE1); and calculate a subblock base address “0x03101” for the subblock SB_L3H1 by adding the layer address interval INTV_layer “0x01000” to the subblock base address “0x02101” for the subblock SB_L2H1. In this case, even though the memory striding circuit 130 does not directly manage the subblock base address for each of the plurality of subblocks SB, the memory striding circuit 130 may calculate the subblock base address for each of the plurality of subblocks SB.

For simpler description, in FIG. 17, the configuration of the subblock group SBG_H1 is representatively described, but the scope of the present disclosure is not limited thereto. For example, the subblock groups SBG_H2 to SBG_Hm may also be implemented similarly to the subblock group SBG_H1. More specifically, in some example embodiments, an address interval between subblocks included in the subblock groups SBG_H2 to SBG_Hm may be the layer address interval INTV_layer.

Subsequently, referring to FIGS. 1 to 16, and 18, the subblock group SBG_H1 may include a plurality of subblocks SB. For example, the subblock group SBG_H1 may include the subblock SB_L1H1 to the subblock SB_L1H3.

Similarly to the description by referring to FIG. 16 above, the subblock SB_L1H1 may store the key vectors KEY_L1_TK1_H1 to KEY_L1_TKp_H1. Similarly to this, the subblock SB_L1H2 may store the key vectors KEY_L1_TK1_H2 to KEY_L1_TKp_H2 and the subblocks SB_L1H3 may store the key vectors KEY_L1_TK1_H3 to KEY_L1_TKp_H3.

Address intervals between the plurality of subblocks SB included in the subblock group SBG_L1 may be the same as each other. For example, address interval between the subblock SB_L1H1 and the subblock SB_L1H2, and address interval between the subblock SB_L1H2 and the subblock SB_L1H3 may be a head address interval INTV_head. Hereinafter, for simpler description, it is assumed that the head address interval INTV_head is “0x00100”.

More specifically, in some example embodiments, a difference between addresses storing the key vectors KEY_L1_TK1_H1 to KEY_L1_TKp_H1 and addresses storing the key vectors KEY_L1_TK1_H2 to KEY_L1_TKp_H2, respectively may be the head address interval INTV_head, and a difference between addresses storing the key vectors KEY_L1_TK1_H2 to KEY_L1_TKp_H2 and addresses storing the key vectors KEY_L1_TK1_H3 to KEY_L1_TKp_H3, respectively may be the head address interval INTV_head.

That is, the addresses occupied by the respective subblocks SB included in the subblock group SBG_L1 may correspond to addresses obtained by adding an integer multiple of the head address interval INTV_head to the addresses occupied by the subblock SB_L1H1, respectively. For example, the addresses occupied by the subblock SB_L1H2 may correspond to addresses obtained by add the head address interval INTV_head to the addresses occupied by the subblock SB_L1H1, respectively; and the addresses occupied by the subblock SB_L1H3 may correspond to addresses obtained by twice add of the head address interval INTV_head to the addresses occupied by the subblock SB_L1H1, respectively.

Accordingly, according to some example embodiments of the present disclosure, the target address generation circuit 132 may identify the subblock base address for each of the plurality of subblocks SB included in the subblock group SBG_L1 by sequentially adding the head address interval INTV_head to the first memory block base address BASE1. More specifically, in some example embodiments, the target address generation circuit 132 may calculate a subblock base address “0x01201” for the subblock SB_L1H2 by adding the head address interval INTV_head “0x00100” to the subblock base address “0x01101” for the subblock SB_L1H1 (that is, the first memory block base address BASE1); and calculate a subblock base address “0x01301” for the subblock SB_L1H3 by adding the head address interval INTV_head “0x00100” to the subblock base address “0x01201” for the subblock SB_L1H2. In this case, even though the memory striding circuit 130 does not directly manage the subblock base address for each of the plurality of subblocks SB, the memory striding circuit 130 may calculate the subblock base address for the plurality of subblocks SB.

For simpler description, in FIG. 18, the configuration of the subblock group SBG_L1 is representatively described, but the scope of the present disclosure is not limited thereto. For example, the subblock groups SBG_L2 to SBG_Lm may also be implemented similarly to the subblock group SBG_L1. More specifically, in some example embodiments, an address interval between subblocks included in the subblock groups SBG_L2 to SBG_Lm may be the head address interval INTV_head.

FIG. 19 is a diagram illustrating an operation of a memory striding circuit according to some example embodiments. Referring to FIGS. 1 to 19, the processing circuit 110 may issue a head striding request REQ_STRD_head. The memory striding circuit 130 may sequentially access the plurality of subblocks SB included in the plurality of memory blocks BLK in response to the head striding request REQ_STRD_head.

Hereinafter, for simpler description, some example embodiments will be representatively described in which the transformer acceleration device 100 generates a (q(p+1)+1)-th token TKq(p+1)+1 based on the cache vectors (e.g., the key vectors KEY) stored in the first to q-th memory blocks BLK1 to BLKq. In this case, as described with reference to FIGS. 1 to 11 above, the calculation circuit 120 may require the cache vectors for the first to q(p+1)-th tokens TK1 to TKq(p+1). Accordingly, hereinafter, some example embodiments will be representatively described in which the memory striding circuit 130 reads the key vectors KEY for the first to q(p+1)-th tokens TK1 to TKq(p+1) from the first to q-th memory blocks BLK1 to BLKq.

The head striding request REQ_STRD_head may include a total number of blocks NUM_block, a memory block base address table MBBAT, a subblock offset OFST, and a reading size RS.

The total number of blocks NUM_block may indicate the total number of memory blocks BLK to be accessed by the memory striding circuit 130. For example, the total number of blocks NUM_block may indicate the number (e.g., ‘q’) of memory blocks BLK allocated to the memory device 160.

The memory block base address table MBBAT may include a memory block base addresses BASE of each of the plurality of memory blocks BLK. Since the configuration of the memory block base address table MBBAT is described with reference to FIG. 14 above, a detailed description is omitted.

The subblock offset OFST may indicate a relative location, in the plurality of memory blocks BLK, of the subblocks SB to be accessed by the memory striding circuit 130. For example, the subblock offset OFST may indicate a difference between the subblock base addresses for the subblocks SB to be accessed by the memory striding circuit 130, and the plurality of memory block base addresses BASE.

The reading size RS may indicate the size of each of the subblocks SB to be accessed by the memory striding circuit 130. For example, the reading size RS may indicate a size of a memory region continuously read from the memory striding circuit 130 for one memory block BLK.

The memory striding circuit 130 may iteratively issue commands for reading subblocks SB corresponding to one decoder layer DL and one head H in response to the head striding request REQ_STRD_head. For example, the memory striding circuit 130 may iteratively issue commands for accessing subblocks SB corresponding to a specific decoder layer DL and a specific head H among the subblocks SB included in the plurality of memory blocks BLK in response to the head striding request REQ_STRD_head.

That is, the memory striding circuit 130 may issue a plurality of memory access commands CMD_MA for reading one subblock SB from the first memory block BLK1, and issue the plurality of memory access commands CMD_MA for reading one subblock SB from the second memory block BLK2. By such a scheme, the memory striding circuit 130 may also issue the plurality of memory access commands CMD_MA for reading one subblock SB from the q-th memory block BLKq.

More specifically, in some example embodiments, the target address generation circuit 132 may generate a plurality of target addresses (hereinafter, referenced as “TG”) by adding the subblock offset OFST to each of the plurality of memory block base addresses BASE. The command issue circuit 133 may read a memory region corresponding to the reading size RS from each of the plurality of target addresses TG. An operation of the memory striding circuit 130 based on the subblock offset OFST and the reading size RS will be described in more detail with reference to FIG. 20 below.

In some example embodiments, the memory region corresponding to the reading size RS at which the target address TG is located may correspond to one subblock SB. That is, the memory striding circuit 130 may read cache vectors stored in one subblock corresponding to the target address TG. In this case, one subblock corresponding to the target address TG may also be referred to as ‘target subblock’. However, the scope of the present disclosure is not limited to the term.

FIG. 20 is a diagram more specifically illustrating the operation of the memory striding circuit of FIG. 19. Hereinafter, referring to FIGS. 1 to 20, some example embodiments will be representatively described in which the memory striding circuit 130 issues the memory access command CMD_MA for reading the subblock SB_L2H2 corresponding to the second decoder layer DL2 and the second head H2 from each of the first to q-th memory blocks BLK1 to BLKq in response to the head striding request REQ_STRD_head. However, the scope of the present disclosure is not limited thereto.

The target address generation circuit 132 may generate first to q-th target addresses TG1 to TGq by adding the subblock offset OFST to the first to q-th memory block base addresses BASE1 to BASEq, respectively. In this case, the first to q-th target addresses TG1 to TGq may be subblock base addresses for the subblock SB_L2H2 included in the first to q-th memory blocks BLK1 to BLKq, respectively.

In some example embodiments, the subblock offset OFST may correspond to an integer multiple of the layer address interval INTV_layer and an integer multiple of the head address interval INTV_head. For example, the subblock offset OFST corresponding to the subblock SB_L2H2 may be “0x01100”.

In some example embodiments, the subblock offset OFST included in the striding request REQ_STRD may have a format of address size. For example, the subblock offset OFST included in the striding request REQ_STRD may be “0x01100”. However, the scope of the present disclosure is not limited thereto, and the subblock offset OFST included in the striding request REQ_STRD may also have an ordered pair format of integers which to be multiplied to the layer address interval INTV_layer and the head address interval INTV_head, respectively.

The command issue circuit 133 may issue a plurality of memory access commands CMD_MA for reading memory region as large as the reading size RS from the first to q-th target addresses TG1 to TGq, respectively. For example, the command issue circuit 133 may issue the plurality of memory access commands CMD_MA for reading the memory region as large as the reading size RS from the first target address TG1, and issue the plurality of memory access commands CMD_MA for reading the memory region as large as the reading size RS from the second target address TG2. By such a scheme, the command issue circuit 133 may issue a plurality of memory access commands CMD_MA for reading the memory region as large as the reading size RS from the q-th target address TGq.

In response to the plurality of memory access commands CMD_MA provided from the command issue circuit 133, the memory device 160 may output key vectors KEY stored in subblocks SB_L2H2 of the first to q-th memory blocks BLK1 to BLKq (illustrated as a gray), respectively. For example, the memory device 160 may provide, to the calculation circuit 120, the plurality of key vectors KEY_L2_TK1_H2 to KEY_L2_TKp_H2 stored in the subblock SB_L2H2 included in the first memory block BLK1; the memory device 160 may provide, to the calculation circuit 120, the plurality of key vectors KEY_L2_TKp+1_H2 to KEY_L2_TK2p_H2 stored in the subblock SB_L2H2 included in the second memory block BLK2; and by such a scheme, the memory device 160 may provide, to the calculation circuit 120, the plurality of key vectors KEY_L2_TKqp+1_H2 to KEY_L2_TKq(p+1)_H2 stored in the subblock SB_L2H2 included in the q-th memory block BLKq. In this case, the calculation circuit 120 may perform an attention calculation ATC_L2_H2 for the second decoder layer DL2 and the second head H2 based on the provided key vectors KEY_L2_TK1_H2 to KEY_L2_TKq(p+1)_H2.

FIG. 21 is a flowchart illustrating the operation of the memory striding circuit of FIG. 19. Referring to FIGS. 1 to 21, in operation S110, a variable (i) may be set to 1. The variable i is just used for describing an iterative operation of the memory striding circuit 130, and does not limit the scope of the present disclosure.

In operation S120, the memory striding circuit 130 may issue commands for reading a subblock included in an (i)-th memory block BLKi. For example, the memory striding circuit 130 may sequentially read a plurality of key vectors KEY stored in one subblock included in the (i)-th memory block BLKi by sequentially issuing the plurality of memory access commands CMD_MA. Operation S120 will be described in more detail with reference to FIG. 22 below.

In operation S130, the memory striding circuit 130 may determine whether the variable (i) is the same as the total number of memory blocks NUM_block. For example, the memory striding circuit 130 may determine whether one subblock SB is read from each of all memory blocks BLK.

In operation S130, when the variable (i) is different from the total number of memory blocks NUM_block, the memory striding circuit 130 may perform operation S140 below.

In operation S140, the memory striding circuit 130 may increase the variable (i) by ‘1’. Thereafter, the memory striding circuit 130 may iteratively perform operation S120 described above. By such a scheme, the memory striding circuit 130 may read one subblock SB from each of the plurality of memory blocks BLK. More specifically, in some example embodiments, the memory striding circuit 130 may read ‘p’ key vectors from each of the plurality of memory blocks BLK.

In operation S130, when the variable (i) is the same as the total number of memory blocks NUM_block, the operation of the memory striding circuit 130 may be terminated. In this case, the calculation circuit 120 may be able to perform the attention calculation ATC based on the read key vector KEY.

FIG. 22 is a flowchart more specifically illustrating operation S120 of FIG. 21. Referring to FIGS. 1 to 22, operation S120 may include operations S121 to S123 below.

In operation S121, the memory striding circuit 130 may identify the memory block base address BASE of the (i)-th memory block BLKi. For example, the target address generation circuit 132 may identify an (i)-th memory block base address BASEi from the memory block base address table MBBAT.

In operation S122, the memory striding circuit 130 may generate the target address TG by adding the memory block base address BASE and the subblock offset OFST. For example, the target address generation circuit 132 may generate an (i)-th target address TGi by adding the (i)-th memory block base address BASEi and the subblock offset OFST.

In operation S123, the memory striding circuit 130 may issue commands for reading the reading size RS from the target address TG. For example, the command issue circuit 133 may provide a plurality of memory access commands CMD_MA for reading the memory region as large as the reading size RS from the (i)-th target address TGi to the memory device 160 through the memory controller 150.

FIG. 23 is a diagram illustrating an operation of a memory striding circuit according to some example embodiments. Referring to FIGS. 1 to 18 and 23, the processing circuit 110 may issue a layer striding request REQ_STRD_layer. In response to the layer striding request REQ_STRD_layer, the memory striding circuit 130 may sequentially access the plurality of subblocks SB respectively included in the plurality of memory blocks BLK.

The layer striding request REQ_STRD_layer may include a total number of blocks NUM_block, a memory block base address table MBBAT, a reading size RS, a head address interval INTV_head, and a total number of heads NUM_head.

The total number of blocks NUM_block, the memory block base address table MBBAT, and the reading size RS are similar to those described by referring to FIG. 19 above, so a detailed description is omitted.

The head address interval INTV_head may indicate an address interval between the plurality of subblocks SB corresponding to one decoder layer DL and one memory block BLK.

The total number of heads NUM_head may indicate the number of subblocks SB which is needed to be accessed by the memory striding circuit 130 from each memory block BLK. For example, the total number of heads NUM_head may indicate the number of heads H (e.g., ‘N’) used for the multi-head attention calculation MHATC of the transformer TF executed by the transformer acceleration device 100.

The memory striding circuit 130 may iteratively issue commands for reading the plurality of subblocks SB corresponding to one decoder layer DL in response to the layer striding request REQ_STRD_layer. For example, the memory striding circuit 130 may sequentially issue commands for accessing the plurality of subblocks SB corresponding to a specific decoder layer DL among the subblocks SB included in the plurality of memory blocks BLK in response to the layer striding request REQ_STRD_layer.

That is, the memory striding circuit 130 may issue a plurality of memory access commands CMD_MA for reading one of the plurality of subblocks SB included in one subblock group SBG_L from the first to q-th memory blocks BLK1 to BLKq, respectively; and issue a plurality of memory access commands CMD_MA for reading the other one of the plurality of subblocks SB included in one subblock group SBG_L from the first to q-th memory blocks BLK1 to BLKq, respectively. By such a scheme, the memory striding circuit 130 may sequentially read the plurality of subblocks SB included in one subblock group SBG_L from the first to q-th memory blocks BLK1 to BLKq, respectively.

More specifically, in some example embodiments, the target address generation circuit 132 may calculate the subblock offset OFST by calculating an integer multiple of the head address interval INTV_head. The target address generation circuit 132 may generate the plurality of target addresses TG by adding the subblock offset OFST to the plurality of memory block base addresses BASE for the plurality of memory blocks BLK, respectively. In this case, the command issue circuit 133 may issue a plurality of memory access commands CMD_MA for reading the memory region corresponding to the reading size RS from the plurality of target addresses, respectively.

Thereafter, the target address generation circuit 132 may change the subblock offset OFST by adjusting the multiple of the head address interval INTV_head. In this case, the plurality of target addresses TG may be changed. The command issue circuit 133 may issue a plurality of memory access commands CMD_MA for reading the memory region corresponding to the reading size RS from the plurality of target addresses, respectively.

By such a scheme, the memory striding circuit 130 may read subblocks SB corresponding to the total number of heads NUM_head from each of the plurality of memory blocks BLK by sequentially changing the subblock offset OFST. An operation of the memory striding circuit 130 based on the head address interval INTV_head and the total number of heads NUM_head will be described in more detail with reference to FIG. 24 below.

FIG. 24 is a diagram more specifically illustrating the operation of the memory striding circuit of FIG. 20. Hereinafter, referring to FIGS. 1 to 18, and 23 to 24, some example embodiments will be representatively described in which the memory striding circuit 130 issues the memory access command CMD_MA for reading the plurality of subblocks SB included in the subblock group SBG_L1 from each of the first to q-th memory blocks BLK1 to BLKq in response to the layer striding request REQ_STRD_layer. However, the scope of the present disclosure is not limited thereto.

First, the memory striding circuit 130 may access the subblocks SB_L1H1 included in the first to q-th memory blocks BLK1 to BLKq based on the first to q-th memory block base addresses BASE1 to BASEq, respectively. For example, the command issue circuit 133 may issue the plurality of memory access commands CMD_MA for reading the memory region as large as the reading size RS from the first to q-th memory block base addresses BASE1 to BASEq, respectively. In this case, the calculation circuit 120 may perform the attention calculation ATC_L1_H1 for the first decoder layer DL1 and the first head H1 based on the key vectors KEY_L1_TK1_H1 to KEY_L1_TKq(p+1)_H1 read from the memory device 160.

Thereafter, the memory striding circuit 130 may access, based on the first to q-th memory block base addresses BASE1 to BASEq and the head address interval INTV_head, the subblocks SB_L1H2 included in the first to q-th memory blocks BLK1 to BLKq, respectively. For example, the target address generation circuit 132 may generate the first to q-th target addresses TG1 to TGq by adding ‘1’ multiple of the head address interval INTV_head (e.g., the subblock offset OFST) to the first to q-th memory block base addresses BASE1 to BASEq, respectively; and the command issue circuit 133 may issue the plurality of memory access commands CMD_MA for reading the memory region as large as the reading size RS from the first to q-th target addresses TG1 to TGq. In this case, the calculation circuit 120 may perform the attention calculation ATC_L1_H2 for the first decoder layer DL1 and the second head H2 based on the key vectors KEY_L1_TK1_H2 to KEY_L1_TKq(p+1)_H2 read from the memory device 160.

By such a scheme, the memory striding circuit 130 may sequentially access the subblocks SB_L1H3 to SB_L1HN included in the first to q-th memory blocks BLK1 to BLKq, respectively. For example, the target address generation circuit 132 may change the subblock offset OFST by sequentially increasing the size of the integer to be multiplied by the head address interval INTV_head; and the command issue circuit 133 may issue the plurality of memory access commands CMD_MA for reading the plurality of subblocks SB from the target address TG corresponding to the changed subblock offset OFST. In this case, the calculation circuit 120 may perform attention calculations ATC_L1_H1 to TC_L1_HN (e.g., multi head attention calculation MHATC) for all heads included in the first decoder layer DL1 based on the key vectors KEY read from the memory device 160

That is, the memory striding circuit 130 may traverse a plurality of subblocks SB corresponding to one decoder layer DL for each memory block BLK. A scheme in which the memory striding circuit 130 accesses one subblock (e.g., the subblock SB_L1H1) included in each of the first to q-th memory blocks BLK1 to BLKq is similar to the scheme described by referring to FIG. 20, so a detailed description is omitted.

FIG. 25 is a flowchart illustrating the operation of the memory striding circuit of FIG. 24. Hereinafter, referring to FIGS. 1 to 18, and 23 to 25, an operation of the memory striding circuit 130 reading the key vectors KEY for performing the multi head attention calculation MHATC_L1 will be representatively described. However, the scope of the present disclosure is not limited thereto.

In operation S210, variables (i) and (j) may be set to 1. The variables (i) and (j) are just used for describing an iterative operation of the memory striding circuit 130, and do not limit the scope of the present disclosure.

In operation S220, the memory striding circuit 130 may issue commands for reading one subblock for a (j)-th head Hj included in the (i)-th memory block BLKi. For example, the memory striding circuit 130 may sequentially read a plurality of key vectors KEY stored in the subblock SB_L1Hj included in the (i)-th memory block BLKi by sequentially issuing the plurality of memory access commands CMD_MA. Operation S220 will be described in more detail with reference to FIG. 26 below.

In operation S230, the memory striding circuit 130 may determine whether the variable (i) is the same as the total number of memory blocks NUM_block. For example, the memory striding circuit 130 may determine whether the subblock SB_L1Hj has been read from each of all memory blocks BLK.

In operation S230, when the variable (i) is different from the total number of memory blocks NUM_block, the memory striding circuit 130 may perform operation S240 below.

In operation S240, the memory striding circuit 130 may increase the variable (i) by ‘1’. Thereafter, the memory striding circuit 130 may iteratively perform operation S220 described above. By such a scheme, the memory striding circuit 130 may read the subblock SB_L1Hj from each of the plurality of memory blocks BLK. In this case, the calculation circuit 120 may be able to perform the attention calculation ATC_L1_Hj for the (j)-th head Hj based on the read key vectors KEY.

In operation S230, when the variable (i) is the same as the total number of memory blocks NUM_block, the memory striding circuit 130 may perform operation S250 below.

In operation S250, the memory striding circuit 130 may determine whether the variable (j) is the same as the total number of heads NUM_head. For example, the memory striding circuit 130 may determine whether all subblocks SB are read from the subblock group SBG_L1 from each of all memory blocks BLK. In other words, the memory striding circuit 130 may determine whether subblocks SB of the same number as the total number of heads NUM_head has been read from all memory blocks BLK, respectively.

In operation S250, when the variable (j) is different from the total number of heads NUM_head, the memory striding circuit 130 may perform operation S260 below.

In operation S260, the memory striding circuit 130 may decrease the variable (i) by ‘1’, and increase the variable (j) by ‘1’. Thereafter, the memory striding circuit 130 may iteratively perform operation S220 described above. By such a scheme, the memory striding circuit 130 may read all subblocks SB included in the subblock group SBG_L1 from each of the plurality of memory blocks BLK.

In operation S250, when the variable (j) is same from the total number of heads NUM_head, the operation of the memory striding circuit 130 may be terminated. In this case, the calculation circuit 120 may be able to perform the multi head attention calculation MHATC_L1 based on the read key vectors KEY.

FIG. 26 is a flowchart more specifically illustrating operation S220 of FIG. 25. Referring to FIGS. 1 to 18, and 23 to 26, operation S220 may include operations S221 to S224 below.

In operation S221, the memory striding circuit 130 may identify the memory block base address BASE of the (i)-th memory block BLKi. For example, the target address generation circuit 132 may identify an (i)-th memory block base address BASEi from the memory block base address table MBBAT.

In operation S222, the memory striding circuit 130 may calculate the subblock offset OFST by multiplying the head address interval INTV_head and (j−1). For example, the target address generation circuit 132 may calculate the subblock offset OFST by multiplying the head address interval INTV_head and (j−1).

In operation S223, the memory striding circuit 130 may generate the target address TG by adding the memory block base address BASE and the subblock offset OFST. In operation S224, the memory striding circuit 130 may issue the commands for reading the reading size RS from the target address TG. Operations S223 to S224 are similar to operations S122 to S123 described by referring to FIG. 22 above, so a detailed description is omitted.

FIG. 27 is a diagram illustrating an operation of a memory striding circuit according to some example embodiments. Referring to FIGS. 1 to 18 and 27, the processing circuit 110 may issue an iteration striding request REQ_STRD_iteration. The memory striding circuit 130 may sequentially access the plurality of subblocks SB included in the plurality of memory blocks BLK, respectively in response to the iteration striding request REQ_STRD_iteration.

The iteration striding request REQ_STRD_iteration may include a total number of blocks NUM_block, a memory block base address table MBBAT, a reading size RS, a head address interval INTV_head, a total number of heads NUM_head, a layer address interval INTV_layer, and a total number of layers NUM_layer.

The total number of blocks NUM_block, the memory block base address table MBBAT, the reading size RS, and the head address interval INTV_head are similar to those described by referring to FIG. 23 above, so a detailed description is omitted.

The layer address interval INTV_layer may indicate an address interval between the plurality of subblocks SB corresponding to one head H and one memory block BLK.

The total number of heads NUM_head and the total number of layers NUM_layer may indicate the number of subblocks SB of which the memory striding circuit 130 need to access from each memory block BLK. For example, the total number of heads NUM_head may indicate the number of heads H (e.g., ‘N’) used for the multi-head attention calculation MHATC of the transformer TF executed by the transformer acceleration device 100, and the total number of layers NUM_layer may indicate the number of decoder layers DL (e.g., ‘m’) included in the transformer TF executed by the transformer acceleration device 100.

The memory striding circuit 130 may iteratively issue commands for reading the plurality of subblocks SB corresponding to one iteration of the transformer TF, in response to the iteration striding request REQ_STRD_iteration. For example, the memory striding circuit 130 may sequentially issue commands for sequentially accessing all subblocks SB included in the plurality of memory blocks BLK, in response to the iteration striding request REQ_STRD_iteration.

More specifically, in some example embodiments, the target address generation circuit 132 may calculate the subblock offset OFST by adding an integer multiple of the head address interval INTV_head and an integer multiple of the layer address interval INTV_layer. The target address generation circuit 132 may generate the plurality of target addresses TG by adding the subblock offset OFST to the plurality of memory block base addresses BASE for the plurality of memory blocks BLK, respectively. In this case, the command issue circuit 133 may issue a plurality of memory access commands CMD_MA for reading the memory region corresponding to the reading size RS from the plurality of target addresses, respectively.

Thereafter, the target address generation circuit 132 may change the subblock offset OFST by adjusting multiples of the head address interval INTV_head and the layer address interval INTV_layer. In this case, the plurality of target addresses TG may be changed. The command issue circuit 133 may issue a plurality of memory access commands CMD_MA for reading the memory region corresponding to the reading size RS from the plurality of target addresses TG, respectively.

By such a scheme, the memory striding circuit 130 may read subblocks SB corresponding to a product of the total number of heads NUM_head and the total number of layers NUM_layer from each of the plurality of memory blocks BLK by sequentially changing the subblock offset OFST. An operation of the memory striding circuit 130 based on the head address interval INTV_head, the layer address interval INTV_layer, the total number of heads NUM_head, and the total number of layers NUM_layer will be described in more detail with reference to FIGS. 28 to 30 below.

FIG. 28 is a diagram more specifically illustrating the operation of the memory striding circuit of FIG. 27. Referring to FIGS. 1 to 18, and 27 to 28, in response to the iteration striding request REQ_STRD_iteration, the memory striding circuit 130 may issue the memory access command CMD_MA for reading all subblocks SB included in the first to q-th memory blocks BLK1 to BLKq, respectively.

First, the memory striding circuit 130 may access the subblock group SBG_L1 included in the first to q-th memory blocks BLK1 to BLKq, respectively. For example, the memory striding circuit 130 may sequentially read the subblocks SB_L1H1 to SB_L1HN from the first to q-th memory blocks BLK1 to BLKq, respectively. A scheme in which the memory striding circuit 130 reads the subblocks SB_L1H1 to SB_L1HN is similar to the scheme described by referring to FIG. 24 above, so a detailed description is omitted. In this case, the calculation circuit 120 may be able to perform the multi head attention calculation MHATC_L1 based on the key vectors KEY read from the memory device 160.

Thereafter, the memory striding circuit 130 may access the subblock group SBG_L2 included in the first to q-th memory blocks BLK1 to BLKq, respectively. For example, the memory striding circuit 130 may sequentially read the subblocks SB_L2H1 to SB_L2HN from the first to q-th memory blocks BLK1 to BLKq, respectively. In this case, the calculation circuit 120 may be able to perform the multi head attention calculation MHATC_L2 based on the key vectors KEY read from the memory device 160.

By such a scheme, the memory striding circuit 130 may sequentially read all subblocks SB included in the first to q-th memory blocks BLK1 to BLKq, respectively. That is, the memory striding circuit 130 may sequentially read all subblocks SB included in the first to q-th memory blocks BLK1 to BLKq, respectively by a scheme of sequentially accessing the plurality of subblocks corresponding to one decoder layer DL, and then sequentially accessing a plurality of subblocks corresponding to another decoder layer DL.

More specifically, in some example embodiments, the target address generation circuit 132 may change the subblock offset OFST by sequentially increasing the multiples of the head address interval INTV_head and the layer address interval INTV_layer. The command issue circuit 133 may issue a plurality of memory access commands CMD_MA for reading the plurality of subblocks SB from a target address TG corresponding to the changed subblock offset OFST. In this case, the transformer acceleration device 100 may be able to generate the output token TKout (e.g., (q(p+1)+1)-th token TKq(p+1)+1) by sequentially executing the first to m-th decoder layers DL1 to DLm included in the transformer TF based on the key vectors KEY read from the memory device 160.

FIG. 29 is a flowchart illustrating the operation of the memory striding circuit of FIG. 27. Referring to FIGS. 1 to 18, and 27 to 29, in operation S310, variables (i), (j), and (k) may be set to ‘1’. The variables (i), (j), and (k) are just used for describing an iterative operation of the memory striding circuit 130, and do not limit the scope of the present disclosure.

In operation S320, the memory striding circuit 130 may issue commands for reading one subblock SB_LkHj corresponding to a (k)-th decoder layer DLk and the (j)-th head Hj included in the (i)-th memory block BLKi. For example, the memory striding circuit 130 sequentially issues the plurality of memory access commands CMD_MA to sequentially read a plurality of key vectors KEY stored in the subblock SB_LkHj included in the (i)-th memory block BLKi. Operation S320 will be described in more detail with reference to FIG. 30 below.

In operation S330, the memory striding circuit 130 may determine whether the variable (i) is the same as the total number of memory blocks NUM_block.

In operation S330, when the variable (i) is different from the total number of memory blocks NUM_block, the memory striding circuit 130 may perform operation S340 below. In operation S340, the memory striding circuit 130 may increase the variable (i) by ‘1’. Thereafter, the memory striding circuit 130 may iteratively perform operation S320 described above.

In operation S330, when the variable (i) is the same as the total number of memory blocks NUM_block, the memory striding circuit 130 may perform operation S350 below.

In operation S350, the memory striding circuit 130 may determine whether the variable (j) is the same as the total number of heads NUM_head.

In operation S350, when the variable (j) is different from the total number of heads NUM_head, the memory striding circuit 130 may perform operation S360 below.

In operation S360, the memory striding circuit 130 may decrease the variable (i) by ‘1’, and increase the variable (j) by ‘1’. Thereafter, the memory striding circuit 130 may iteratively perform operation S320 described above.

The operations of the memory striding circuit 130 in operations S330 to S360 are similar to those in operations S230 to S260 described with reference to FIG. 25 above, so a detailed description is omitted.

In operation S350, when the variable (j) is the same as the total number of heads NUM_head, the memory striding circuit 130 may perform operation S370 below.

In operation S370, the memory striding circuit 130 may determine whether the variable (k) is the same as the total number of layers NUM_layer.

In operation S370, when the variable (k) is different from the total number of layers NUM_layer, the memory striding circuit 130 may perform operation S380 below.

In operation S380, the memory striding circuit 130 may decrease the variables (i) and (j) to ‘1’, and increase the variable (k) by ‘1’. Thereafter, the memory striding circuit 130 may iteratively perform operation S320 described above. By such a scheme, the memory striding circuit 130 may read all subblocks SB included in the plurality of memory blocks BLK.

In operation S370, when the variable (k) is the same as the total number of layers NUM_layer, the operation of the memory striding circuit 130 may be terminated. In this case, since the calculation circuit 120 may execute the multi head attention calculation MHATC included in all decoder layers DL of the transformer TF based on the key vector KEY read from the memory device 160, the transformer acceleration device 100 may be able to generate the output token TKout.

FIG. 30 is a flowchart more specifically illustrating operation S320 of FIG. 29. Referring to FIGS. 1 to 18, and 27 to 30, operation S320 may include operations S321 to S324 below.

In operation S321, the memory striding circuit 130 may identify the memory block base address BASE of the (i)-th memory block BLKi. For example, the target address generation circuit 132 may identify an (i)-th memory block base address BASEi from the memory block base address table MBBAT.

In operation S322, the memory striding circuit 130 may calculate the subblock offset OFST by adding a product the head address interval INTV_head and (j−1), and a product of the layer address interval INTV_layer and (k−1). For example, the target address generation circuit 132 may calculate the subblock offset OFST by adding the product the head address interval INTV_head and (j−1), and the product of the layer address interval INTV_layer and (k−1).

In operation S323, the memory striding circuit 130 may generate the target address TG by adding the memory block base address BASE and the subblock offset OFST. In operation S324, the memory striding circuit 130 may issue commands for reading the reading size RS from the target address TG. Operations S323 to S324 are similar to operations S122 to S123 described by referring to FIG. 22 above, so a detailed description is omitted.

Therefore, the improved devices and methods overcome the deficiencies of the conventional devices and methods of token based processing, in particular, related to attention calculation, while reducing resource consumption (e.g., processing capability, power, bandwidth), improving performance (e.g., speed or operations, reliability of operations), and resource allocation (e.g., latency).

As described herein, any electronic devices and/or portions thereof according to any of the example embodiments may include, may be included in, and/or may be implemented by one or more instances of processing circuitry such as hardware including logic circuits; a hardware/software combination such as a processor executing software; or any combination thereof. For example, the processing circuitry more specifically may include, but is not limited to, a central processing unit (CPU), an arithmetic logic unit (ALU), a graphics processing unit (GPU), an application processor (AP), a digital signal processor (DSP), a microcomputer, a field programmable gate array (FPGA), and programmable logic unit, a microprocessor, application-specific integrated circuit (ASIC), a neural network processing unit (NPU), an Electronic Control Unit (ECU), an Image Signal Processor (ISP), and the like. In some example embodiments, the processing circuitry may include a non-transitory computer readable storage device (e.g., a memory), for example a DRAM device, storing a program of instructions, and a processor (e.g., CPU) configured to execute the program of instructions to implement the functionality and/or methods performed by some or all of any devices, systems, modules, units, controllers, circuits, architectures, and/or portions thereof according to any of the example embodiments, and/or any portions thereof.

The above-described contents are specific embodiments for carrying the present disclosure. The present disclosure will include not only the above-described embodiments, but also embodiments that can be simply designed or easy to change. In addition, the present disclosure will also include technologies that can be easily modified and implemented using the example embodiments. Therefore, the scope of the present disclosure should not be limited to the example embodiments and should be defined by the appended claims of the present disclosure and equivalents to the appended claims.