Data prefetching method and electronic device
By dynamically allocating prefetching processing to pre-filling and decoding nodes in the large language model inference system, the problems of large cross-node key-value cache transmission volume and high first-word latency in the existing technology are solved, achieving more efficient resource utilization and improved inference system performance.
Patent Information
- Application Number
- CN202611695128.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-29
- Publication Date
- 2026-11-27
AI Technical Summary
In existing technologies, because the space management of hierarchical key-value cache is uniformly performed by the pre-filling node for prefetching and transmission, and the decoding node passively waits, the cross-node key-value cache transmission volume is large and the first word latency is high.
When an inference request is received from the scheduler, an input lexical sequence is generated and prefix matching is performed. The execution body of the prefetching process is dynamically allocated between the pre-filling node and the decoding node. The decoding node performs prefetching processing according to the target key-value matching length and the initial prefetching information, and asynchronously reads the key-value cache data into the host memory and sends it to the pre-filling node for attention calculation.
It reduces the amount of cross-node key-value cache transmission and first-word latency, improves the overall efficiency and resource utilization efficiency of the inference system, and achieves synergy between prefetching and prefilling computation.
Smart Images

Figure CN123178303A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to data prefetching methods and electronic devices. Background Technology
[0002] With the rapid development of large language model inference technology, the demand for reading, writing, and transmitting key-value cache data in pre-filling and decoding separate deployments continues to increase. The space allocation and scheduling capabilities of hierarchical caches directly determine the operating efficiency and first-word latency of the inference system. Currently, for the space management of hierarchical key-value caches, pre-fetching and transmission are usually performed uniformly by the pre-filling node, while the decoding node passively waits. This results in a large amount of cross-node key-value cache transmission, and consequently, a high first-word latency. Summary of the Invention
[0003] This application provides a data prefetching method and electronic device to at least solve the problem in the related art of space management of hierarchical key-value cache, where prefetching and transmission are usually performed uniformly by prefilling nodes, while decoding nodes passively wait, resulting in a large amount of cross-node key-value cache transmission and thus a high first-word latency.
[0004] Firstly, this application provides a data prefetching method, the method comprising:
[0005] In response to receiving an inference request from the scheduler, an input word sequence is generated based on the inference request; the inference request includes the request data to be inferred and the target prefetch node;
[0006] Prefix matching is performed on the input word sequence to determine the target key value matching length;
[0007] In response to determining that the target prefetch node is a prefill node, the key-value cache data corresponding to the input lexical sequence sent by the prefill node is received;
[0008] In response to determining that the target prefetch node is a decoding node, the initial prefetch information generated by the prefilled node is obtained from the preset metadata space; the initial prefetch information includes key-value cache block information;
[0009] Prefetching is performed based on the target key-value matching length and initial prefetch information. The key-value cache data corresponding to the key-value cache block information asynchronously read from the remote storage system to the host memory is sent to the pre-fill node. This allows the pre-fill node to perform attention calculation on the words in the input word sequence that do not hit the prefix based on the key-value cache data corresponding to the key-value cache block information, and generate key-value cache data corresponding to the words in the input word sequence that do not hit the prefix.
[0010] Secondly, this application provides a data prefetching method, the method comprising:
[0011] In response to receiving an inference request from the scheduler, an input word sequence is generated based on the inference request; the inference request includes the request data to be inferred and the target prefetch node;
[0012] Prefix matching is performed on the input word sequence to determine the candidate prefetch length;
[0013] In response to determining that the target prefetch node is a prefill node, prefetching processing is performed based on the candidate prefetch length;
[0014] In response to determining that the target prefetch node is a decoding node, initial prefetch information is generated and written to a preset metadata space; the initial prefetch information includes candidate prefetch length and key-value cache block information; the candidate prefetch length is used to indicate a continuous lexical range.
[0015] Thirdly, this application provides a data prefetching method, the method comprising:
[0016] In response to receiving an inference request from the target user, the corresponding pre-filled node and decoding node are determined based on the inference request; the inference request includes the request data to be inferred;
[0017] Identify the target prefetch node and add the target decoding node to the inference request; the target prefetch node is used to indicate the node to perform prefetch processing.
[0018] The inference request is sent to the corresponding pre-filled node and decoding node.
[0019] Fourthly, this application also provides a data prefetching apparatus, comprising:
[0020] The first generation module is used to generate an input word sequence based on the inference request received from the scheduler in response to the inference request; the inference request includes the request data to be inferred and the target prefetch node;
[0021] The first determining module is used to perform prefix matching on the input word sequence to determine the target key value matching length;
[0022] The receiving module is used to receive the key-value cache data corresponding to the input lexical sequence sent by the pre-fill node in response to determining that the target prefetch node is a pre-fill node;
[0023] The first acquisition module is used to acquire the initial prefetch information generated by the prefilled node from the preset metadata space in response to determining that the target prefetch node is a decoding node; the initial prefetch information includes key-value cache block information.
[0024] The first execution module is used to perform prefetching processing based on the target key-value matching length and the initial prefetch information;
[0025] The first sending module is used to send the key-value cache data corresponding to the key-value cache block information read asynchronously from the remote storage system to the host memory to the pre-filling node, so that the pre-filling node performs attention calculation on the words in the input word sequence that do not hit the prefix based on the key-value cache data corresponding to the key-value cache block information, and generates key-value cache data corresponding to the words in the input word sequence that do not hit the prefix.
[0026] Fifthly, this application also provides a data prefetching apparatus, comprising:
[0027] The second generation module is used to generate an input word sequence based on the inference request received from the scheduler in response to the inference request; the inference request includes the request data to be inferred and the target prefetch node;
[0028] The second determination module is used to perform prefix matching on the input word sequence to determine the candidate prefetch length;
[0029] The second execution module is used to perform prefetching processing based on the candidate prefetch length in response to determining that the target prefetch node is a prefill node;
[0030] The second generation module is used to generate initial prefetch information in response to determining that the target prefetch node is a decoding node;
[0031] The writing module is used to write the initial prefetch information into the preset metadata space; the initial prefetch information includes candidate prefetch length and key-value cache block information; the candidate prefetch length is used to indicate the range of consecutive terms.
[0032] Sixthly, this application also provides a data prefetching apparatus, comprising:
[0033] The third determination module is used to respond to the inference request sent by the target user and determine the corresponding pre-filled node and decoding node based on the inference request; the inference request includes the request data to be inferred;
[0034] The third determination module is also used to determine the target prefetch node;
[0035] The Add module is used to add the target decoding node to the inference request; the Target Prefetch node is used to indicate the node to perform prefetch processing;
[0036] The second sending module is used to send inference requests to the corresponding pre-filled nodes and decoding nodes.
[0037] In a seventh aspect, this application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for executing the computer program to implement the data prefetching method provided in the first, second, or third aspect described above.
[0038] Eighthly, this application also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of the data prefetching method provided in the first, second, or third aspect described above.
[0039] Ninthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the data prefetching method provided in the first, second, or third aspect described above.
[0040] The data prefetching method and electronic device provided in this application, in response to receiving an inference request sent by the scheduler, generates an input lexical sequence based on the inference request. Prefix matching is performed on the input lexical sequence to determine the target key-value matching length. In response to determining that the target prefetching node is a pre-filling node, key-value cache data corresponding to the input lexical sequence sent by the pre-filling node is received. In response to determining that the target prefetching node is a decoding node, initial prefetching information generated by the pre-filling node is obtained from a preset metadata space. Prefetching processing is performed based on the target key-value matching length and the initial prefetching information, and key-value cache data corresponding to the key-value cache block information asynchronously read from the remote storage system to the host memory is sent to the pre-filling node. This allows the pre-filling node to perform attention calculation on the lexical units in the input lexical sequence that do not hit the prefix based on the key-value cache data corresponding to the key-value cache block information, generating key-value cache data corresponding to the lexical units in the input lexical sequence that do not hit the prefix. Therefore, the execution subject of the prefetching process can be extended from a fixed pre-filling node to one that can be dynamically allocated between the pre-filling node and the decoding node according to the real-time load, providing a basis for balancing prefetching tasks and avoiding overload of a single node. Furthermore, the decoding node performs prefetching processing based on the target key-value matching length and initial prefetching information, and sends the prefetched key-value cache data to the pre-filling node. This enables the pre-filling node to perform attention calculations on missed prefix tokens, thus achieving collaboration between prefetching and pre-filling computations. Compared to the method where prefetching processing is fixedly performed by the pre-filling node, dynamically allocating prefetching tasks to the decoding node fully utilizes the local cache and idle resources of the decoding node, overlaps the read time of the remote storage system with the pre-filling computation, reduces the amount of cross-node key-value cache transmission and first-word latency, and ensures the flexibility of prefetching task allocation and the efficiency of system resource utilization, thereby improving the overall efficiency of the inference system. Attached Figure Description
[0041] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 This is an application scenario diagram of the data prefetching method provided in the embodiments of this application;
[0043] Figure 2 A schematic flowchart of a data prefetching method provided in an embodiment of this application;
[0044] Figure 3 A schematic flowchart of a data prefetching method provided in another embodiment of this application;
[0045] Figure 4 A schematic flowchart of a data prefetching method provided in another embodiment of this application;
[0046] Figure 5 A schematic flowchart of a data prefetching method provided in another embodiment of this application;
[0047] Figure 6 This is a schematic diagram of the structure of a data prefetching device provided in an embodiment of this application;
[0048] Figure 7 A schematic diagram of the structure of a data prefetching device provided in another embodiment of this application;
[0049] Figure 8 A schematic diagram of the structure of a data prefetching device provided in another embodiment of this application;
[0050] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0051] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0052] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0053] With the rapid development of large language model inference technology, the demand for reading, writing, and transmitting key-value cache data in pre-filling and decoding separate deployments continues to increase. The space allocation and scheduling capabilities of hierarchical caches directly determine the operating efficiency and first-word latency of the inference system. Currently, for the space management of hierarchical key-value caches, pre-fetching and transmission are usually performed uniformly by the pre-filling node, while the decoding node passively waits. This results in a large amount of cross-node key-value cache transmission, and consequently, a high first-word latency.
[0054] Therefore, when facing the aforementioned technical problems, the method of prefetching processing being fixedly performed by the pre-filling node and the decoding node passively waiting to determine the prefetching and transmission of the key-value cache is no longer adopted. Instead, in response to receiving an inference request sent by the scheduler, an input lexical sequence is generated based on the inference request. Prefix matching is performed on the input lexical sequence to determine the target key-value matching length. In response to determining that the target prefetching node is the pre-filling node, the key-value cache data corresponding to the input lexical sequence sent by the pre-filling node is received. In response to determining that the target prefetching node is the decoding node, the initial prefetch information generated by the pre-filling node is obtained from the preset metadata space. Prefetching processing is performed based on the target key-value matching length and the initial prefetch information, and the key-value cache data corresponding to the key-value cache block information asynchronously read from the remote storage system to the host memory is sent to the pre-filling node. This allows the pre-filling node to perform attention calculation on the lexical units in the input lexical sequence that do not hit the prefix based on the key-value cache data corresponding to the key-value cache block information, and generate key-value cache data corresponding to the lexical units in the input lexical sequence that do not hit the prefix. Therefore, the execution entity of prefetching can be expanded from a fixed pre-filling node to one that can be dynamically allocated between pre-filling and decoding nodes based on real-time load, providing a basis for balancing prefetching tasks and avoiding overload of a single node. Furthermore, the decoding node performs prefetching based on the target key-value matching length and initial prefetching information, and sends the prefetched key-value cache data to the pre-filling node, enabling the pre-filling node to perform attention calculations on missed prefix tokens, thus achieving collaboration between prefetching and pre-filling computation. Compared to the fixed execution of prefetching by the pre-filling node, dynamically allocating prefetching tasks to the decoding node fully utilizes the local cache and idle resources of the decoding node, overlaps the read time of the remote storage system with pre-filling computation, reduces cross-node key-value cache transmission volume and first-word latency, and ensures the flexibility of prefetching task allocation and the efficiency of system resource utilization, thereby improving the overall efficiency of the inference system.
[0055] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0056] Figure 1 This diagram illustrates an application scenario of the data prefetching method provided in the embodiments of this application. For example... Figure 1As shown, the application scenario provided in this embodiment includes: a scheduler 10, a pre-filled node 20, a decoding node 30, and a preset metadata space 40. The device information display method is applied to the decoding node 30. In response to receiving an inference request sent by the scheduler 10, the decoding node 30 generates an input lexical sequence based on the inference request. The inference request includes the request data to be inferred and the target prefetch node. Prefix matching is performed on the input lexical sequence to determine the target key-value matching length. In response to determining that the target prefetch node is the pre-filled node 20, the node receives the key-value cache data corresponding to the input lexical sequence sent by the pre-filled node 20. In response to determining that the target prefetch node is the decoding node 30, the node obtains the initial prefetch information generated by the pre-filled node 20 from the preset metadata space 40. The initial prefetch information includes key-value cache block information. Decoding node 30 performs prefetching processing based on the target key-value matching length and initial prefetch information, and sends the key-value cache data corresponding to the key-value cache block information asynchronously read from the remote storage system to the pre-fill node 20, so that the pre-fill node performs attention calculation on the words in the input word sequence that do not hit the prefix based on the key-value cache data corresponding to the key-value cache block information, and generates key-value cache data corresponding to the words in the input word sequence that do not hit the prefix.
[0057] Figure 2 A schematic flowchart of a data prefetching method provided in an embodiment of this application is shown below. Figure 2 As shown. The data prefetching method provided in this embodiment is applied to the decoding node. The data prefetching method provided in this embodiment specifically includes the following steps:
[0058] S201: In response to receiving an inference request sent by the scheduler, generate an input word sequence based on the inference request.
[0059] The inference request includes the request data to be inferred and the target prefetch node.
[0060] Among them, the decoding node is a dedicated computing node in the decoding stage of the inference process. It is used to obtain the key-value cache generated in the pre-filling stage, and then generate the output by autoregression based on the cache word by word until the inference is completed.
[0061] The decoding node can be an inference service instance deployed on a graphics processor, server, container, or virtual machine, used to perform word-by-word meta-generation tasks during the decoding phase.
[0062] The scheduler is the control component in the inference system responsible for receiving external requests, routing the requests to appropriate computing nodes, and coordinating the data flow between nodes.
[0063] Inference requests are generation tasks submitted by the client to the inference system, which typically include information such as input text, sampling parameters, and output length constraints.
[0064] For example, the request data to be inferred is the raw text entered by the user.
[0065] The target prefetch node is the node determined by the scheduler from the pre-filled nodes and decoding nodes based on the load status of each pre-filled node and decoding node, and is used to perform the prefetching process.
[0066] Optionally, the target prefetch node can be a pre-filled node or a decoded node.
[0067] The input word sequence is the word identifier sequence obtained after the text to be reasoned in the reasoning request has been processed by the word segmenter.
[0068] Optionally, in this embodiment, after receiving the inference request sent by the scheduler, the request data to be inferred in the inference request is segmented by a word segmenter to obtain the input word sequence.
[0069] Among them, a token is the basic discrete unit used by a large language model when processing text. It can be a character, a subword, a word fragment, or other identifier generated by a tokenizer.
[0070] S202: Perform prefix matching on the input word sequence to determine the target key value matching length.
[0071] Prefix matching refers to checking whether reusable key-value cache data already exists at the beginning of the input lexical sequence.
[0072] The decoding node can maintain a prefix cache structure, such as a radix tree, to quickly find the longest reusable prefix of the input lexical sequence.
[0073] The target key-value matching length represents the number of tokens corresponding to the key-value cache data that is ready locally at the decoding node and can be directly reused or quickly restored.
[0074] It is understandable that the target key-value matching length is the number of tokens corresponding to the key-value cache hits in the device memory and host memory by the decoding node, excluding the key-value cache hits in the remote storage system.
[0075] For example, the decoding node starts from the first word of the input word sequence and matches word by word down the radix tree until no further matching is possible. The number of successfully matched words is the target key-value matching length.
[0076] Understandably, prefix matching is a prerequisite for key-value cache reuse. In large language model inference scenarios, multiple inference requests often share the same input prefix, such as the same system prompts, the same document context, or the same historical dialogue content. Since the key-value cache data corresponding to the same input prefix is completely identical in the same model, the calculated prefix key-value cache data can be saved for reuse by subsequent inference requests with the same prefix, thereby avoiding redundant calculations and improving inference efficiency.
[0077] Specifically, prefix matching involves comparing the input lexical sequence of the current inference request with the lexical sequences of historical inference requests stored in the cache system. Starting from the first lexical, the comparison is performed digit by digit to find the longest consecutive identical starting part. This identical starting part is called the hit prefix, and the number of lexical sequences contained in the hit prefix is the key-value matching length.
[0078] It should be noted that prefix matching only matches consecutive identical parts starting from the beginning of the input word sequence. Segments in the middle of the input word sequence that are the same as those in previous requests are not considered a hit, because the context before and after the middle segment is different, and the corresponding key-value cache data is also different, so it cannot be directly reused.
[0079] Optionally, in this embodiment, the lookup order for prefix matching by the decoding node can be device memory, host memory, or remote storage system.
[0080] Of these, the portion of memory hits in the device's memory can be directly used for decoding calculations. The portion of memory hits in the host's memory can be committed to the device's memory for use. The portion of memory hits in the remote storage system needs to be prefetched.
[0081] Optionally, in this embodiment, after generating the input lexical sequence, the decoding node uses a prefix cache structure to perform a longest reusable prefix lookup on the input lexical sequence. The prefix cache structure stores the mapping relationship between the lexical prefixes of historical inference requests and the corresponding key-value cache data. The decoding node compares the input lexical sequence bit by bit with the entries in the prefix cache structure from beginning to end to find the longest matching prefix, thereby determining the target key-value matching length.
[0082] S203: In response to determining that the target prefetch node is a prefill node, receive the key-value cache data corresponding to the input lexical sequence sent by the prefill node.
[0083] When the scheduler determines that the target prefetch node is a prefill node, it means that the prefetch process will be performed by the prefill node.
[0084] The pre-filling node reads reusable key-value cache data from a remote storage system or restores key-value cache data from a local cache, and performs pre-filling calculations on the tokens in the input token sequence that do not have a prefix match, generating complete key-value cache data. Subsequently, the pre-filling node sends the key-value cache data corresponding to the input token sequence to the decoding node.
[0085] For example, the decoding node receives key-value cache data sent by the pre-filling node. This key-value cache data includes key-value cache data corresponding to the prefix portion and key-value cache data corresponding to the newly added token. The decoding node can directly use this key-value cache data for subsequent decoding calculations.
[0086] Optionally, in this embodiment, the decoding node can write the target key-value matching length and the corresponding request identifier into a preset metadata space. When the pre-filling node is about to send key-value cache data to the decoding node, it reads the target key-value matching length in the preset metadata space and deletes the key-value cache data corresponding to the target key-value matching length from the key-value cache range to be transmitted, so as to obtain the adjusted key-value cache range to be transmitted, thereby avoiding repeated transmission of the key-value cache data that the decoding node has already prepared locally.
[0087] S204: In response to determining that the target prefetch node is a decoding node, obtain the initial prefetch information generated by the prefilled node from the preset metadata space.
[0088] The initial prefetch information includes key-value cache block information.
[0089] When the scheduler determines that the target prefetch node is the decoding node, it means that the current prefetching process will be performed by the decoding node.
[0090] The preset metadata space is a request-level control information channel accessible to both pre-filled nodes and decoding nodes, used to transmit prefetch plans, prefetch confirmation information, cache hit length, prefetch failure reasons, etc.
[0091] Optionally, the preset metadata space can be deployed in pre-populated nodes.
[0092] Understandably, the key-value cache data is a data structure in the Transformer attention mechanism that stores the key and value tensors corresponding to historical tokens. In attention calculation, the key tensor is used to calculate the similarity with the query tensor at the current position to obtain the attention weight, and the value tensor is used to perform a weighted sum according to the attention weight to obtain the attention output. Since the keys and values of historical tokens need to be repeatedly referenced in each subsequent decoding step, they are cached to avoid redundant calculations.
[0093] The initial prefetch information is structured information generated by the pre-filled node after prefix matching, which is used to guide the decoding node to perform prefetch processing.
[0094] The initial prefetch information may include candidate prefetch length and key-value cache block information.
[0095] The candidate prefetch length is used to indicate the range of consecutive lexical terms, i.e., the number of consecutive lexical terms that the pre-filled node suggests the decoding node to prefetch.
[0096] Among them, the key-value cache block information is used to indicate the storage location and verification information of the key-value cache data of the continuous term range corresponding to the candidate prefetch length in the remote storage system. For example, it may include the identification information, hash check value and page information of the key-value cache block.
[0097] For example, after performing prefix matching on the input lexical sequence, if the pre-filling node determines that reusable key-value cache data exists in the remote storage system, it generates initial prefetch information and writes it to a preset metadata space. The decoding node reads this initial prefetch information from the preset metadata space in subsequent scheduling cycles.
[0098] Optionally, the purpose of the preset metadata space is to enable pre-filled nodes and decoding nodes to cooperate loosely through a shared control information area without establishing a direct connection. The pre-filled nodes are responsible for providing prefetchable candidate information, and the decoding nodes are responsible for determining the actual prefetching strategy based on their own state.
[0099] The key-value cache block information describes the location and identifier of prefetchable key-value cache data in the remote storage system. Specifically, it can include the identifier information and page information of the key-value cache block. Based on the key-value cache block information, the decoding node can directly locate the corresponding key-value cache data in the remote storage system without traversing and searching.
[0100] S205: Perform prefetching processing based on the target key-value matching length and initial prefetch information, and send the key-value cache data corresponding to the key-value cache block information asynchronously read from the remote storage system to the pre-fill node, so that the pre-fill node performs attention calculation on the words in the input word sequence that do not hit the prefix based on the key-value cache data corresponding to the key-value cache block information, and generates key-value cache data corresponding to the words in the input word sequence that do not hit the prefix.
[0101] The decoding node performs prefetching based on the target key value matching length and the initial prefetch information.
[0102] Specifically, the decoding node can perform prefetching based on the target key-value matching length and the initial prefetch information.
[0103] The host memory is the memory addressable by the central processing unit in the decoding node, used to temporarily store key-value cache data prefetched from the remote storage system. The remote storage system is a shared storage system accessible to both the pre-filling node and the decoding node; its capacity is larger than the device memory and the host memory, but its access speed is slower.
[0104] For example, after the decoding node asynchronously reads key-value cache data from the remote storage system into the host memory, it sends the key-value cache data read into the host memory to the pre-filling node. Upon receiving the key-value cache data, the pre-filling node uses it as a historical key-value cache and performs attention calculations on the tokens in the input token sequence that did not match the prefix. During the attention calculation process, the pre-filling node reads the key-value cache data layer by layer, generating new key-value cache data for each layer after completion. The pre-filling node then transmits the new key-value cache data to the decoding node so that the decoding node obtains the complete key-value cache data and begins decoding.
[0105] Furthermore, the decoding node asynchronously reads the key-value cache data from the remote storage system into the host memory and sends it to the host memory of the pre-filling node. Since the pre-filling node also needs the key-value cache data corresponding to the hit prefix when performing pre-filling calculations, and since the decoding node has already read it from the remote storage system, it directly sends a copy to the pre-filling node. This avoids the pre-filling node having to read it from the remote storage system again, thus avoiding redundant storage read operations and saving storage bandwidth and read time.
[0106] Specifically, in response to receiving an inference request from the scheduler, an input lexical sequence is generated based on the inference request. Prefix matching is performed on the input lexical sequence to determine the target key-value matching length. In response to determining that the target prefetch node is a pre-fill node, the key-value cache data corresponding to the input lexical sequence sent by the pre-fill node is received. In response to determining that the target prefetch node is a decoding node, the initial prefetch information generated by the pre-fill node is obtained from the preset metadata space. Prefetch processing is performed based on the target key-value matching length and the initial prefetch information, and the key-value cache data corresponding to the key-value cache block information asynchronously read from the remote storage system to the host memory is sent to the pre-fill node. This allows the pre-fill node to perform attention calculation on the lexical units in the input lexical sequence that do not hit the prefix based on the key-value cache data corresponding to the key-value cache block information, generating key-value cache data corresponding to the lexical units in the input lexical sequence that do not hit the prefix. Therefore, the execution subject of the prefetch processing can be extended from a fixed pre-fill node to one that can be dynamically allocated between the pre-fill node and the decoding node according to the real-time load, providing a basis for balancing the prefetch task and avoiding overload of a single node. Furthermore, the decoding node performs prefetching processing based on the target key-value matching length and initial prefetching information, and sends the prefetched key-value cache data to the pre-filling node. This enables the pre-filling node to perform attention calculations on missed prefix tokens, thus achieving collaboration between prefetching and pre-filling computations. Compared to the method where prefetching processing is fixedly performed by the pre-filling node, dynamically allocating prefetching tasks to the decoding node fully utilizes the local cache and idle resources of the decoding node, overlaps the read time of the remote storage system with the pre-filling computation, reduces the amount of cross-node key-value cache transmission and first-word latency, and ensures the flexibility of prefetching task allocation and the efficiency of system resource utilization, thereby improving the overall efficiency of the inference system.
[0107] As an optional implementation, based on any of the above embodiments, prefetching processing is performed based on the target key-value matching length and initial prefetching information, including:
[0108] The prefetch execution status is determined based on the target key-value matching length and target payload information;
[0109] In response to the first indication message to perform prefetching, the key-value cache data corresponding to the key-value cache block information is asynchronously read from the remote storage system into the host memory according to the target prefetch length;
[0110] Submit key-value cache data from host memory to device memory and generate confirmation information for the submitted key-value cache;
[0111] The confirmation information is written to the preset metadata space so that the pre-filled nodes can adjust the key-value cache range to be transmitted based on the confirmation information;
[0112] In response to the first indication that prefetching should not be performed, a second indication is written to the preset metadata space to cause the prefilled node to perform prefetching.
[0113] The prefetch execution status includes a first indication of whether to perform prefetching and the target prefetch length when performing prefetching.
[0114] The second instruction includes information on not performing prefetching.
[0115] The target load information is the current load status information of the decoding node, which is used to assess whether the decoding node is currently suitable for performing prefetching processing.
[0116] Optionally, the target load information may include the prefetch queue length, the number of prefetch tasks in progress, the number of prefetch tasks initiated in the current period, the bandwidth information of the remote storage system, and / or the number of tokens to be decoded.
[0117] It is understandable that the prefetch queue length, which is the number of prefetch tasks currently waiting to be executed in the decoding node, indicates that the longer the queue is, the more congested the prefetch tasks are.
[0118] The number of prefetch tasks in execution refers to the number of prefetch tasks running in the background at the same time. A higher number indicates greater background read pressure. The number of prefetch tasks started in the current period refers to the number of new prefetch tasks started in the current scheduling period. This is used to control the prefetch start rate within a single period and avoid starting too many prefetch tasks in a short period of time.
[0119] Among them, the bandwidth information of the remote storage system, that is, the current bandwidth usage of the remote storage system, indicates that the more strained the bandwidth, the slower the data is read from the storage and the longer the prefetching wait time.
[0120] The number of tokens to be decoded is the total number of tokens currently queued for decoding by the decoding node. The larger the number, the busier the main decoding process is, and the fewer resources are available for prefetching.
[0121] Device memory refers to the memory accessible to the graphics processor in the decoding node. Submitting key-value cache data from host memory to device memory means copying the key-value cache data from the CPU-addressable memory to the GPU-addressable memory so that it can be directly used for decoding calculations.
[0122] The confirmation message is used to inform the pre-filled node that the decoding node has successfully prefetched and committed the key-value cache length.
[0123] For example, the confirmation information may include information such as the valid prefetch length, whether a full hit occurred, whether a timeout occurred, or the reason for the failure. The valid prefetch length can be the minimum value among the prefetch completion lengths of multiple parallel execution units. The decoding node obtains the prefetch completion length corresponding to each parallel execution unit, determines the minimum value among the prefetch completion lengths as the valid prefetch length, and submits the key-value cache data corresponding to each parallel execution unit from the host memory to the corresponding device memory according to the valid prefetch length, generating confirmation information.
[0124] Furthermore, the prefetch execution status is the decision result of the decoding node regarding this prefetch processing after comprehensively judging the target key value matching length and target load information.
[0125] The first indication information is used to indicate whether to perform prefetching, and its value is to perform prefetching or not to perform prefetching.
[0126] The target prefetch length, when the first indication is to perform prefetching, represents the actual number of tokens to be prefetched, i.e., how many key-value cache data corresponding to tokens to read from the remote storage system. The target prefetch length does not exceed the candidate prefetch length in the initial prefetch information, nor does it exceed the maximum prefetch length that the current resources of the decoding node can support.
[0127] Optionally, when the decoding node determines that the first indication information is to perform prefetching, it needs to start a key-value cache data read task to read the corresponding key-value cache data from the remote storage system into the host memory. To avoid the read operation blocking the main scheduling loop of the decoding node and affecting the decoding generation of other inference requests, the read task is executed asynchronously, that is, an independent read task is started in the background, and the main scheduling loop of the decoding node continues to run normally without stopping to wait for the read to complete.
[0128] Specifically, asynchronous reading refers to starting an independent reading task in the background, the execution of which does not block the main scheduling loop of the decoding node. After starting the asynchronous reading task, the decoding node can continue to process decoding calculations and scheduling decisions for other inference requests without stopping to wait for the reading to complete. After the reading task is completed, the decoding node can check its status and process the results in subsequent scheduling cycles. The core purpose of asynchronous reading is to overlap the waiting time for storage reading with the decoding calculations, scheduling queuing, and other processes, thereby shortening the overall first-word latency.
[0129] Optionally, in this embodiment, if the decoding node determines that the first indication information is to perform prefetching, it initiates an asynchronous read task according to the target prefetch length. This asynchronous read task reads key-value cache data within the corresponding range from the remote storage system based on the storage location identifier in the key-value cache block information, and writes the read data into the host memory of the decoding node.
[0130] Understandably, after successfully submitting the key-value cache data to the device memory, the decoding node needs to inform the pre-filling node of the prefetch success. This allows the pre-filling node to skip the portion of the key-value cache data that has already been successfully prefetched by the decoding node and only transmit the portion that the decoding node has not yet prefetched, thereby reducing the amount of data transmitted across nodes and saving network bandwidth. Since the pre-filling node and the decoding node exchange control information through a preset metadata space, the decoding node writes confirmation information into the preset metadata space. The pre-filling node reads this confirmation information before executing the transmission and adjusts the range to be transmitted accordingly.
[0131] Specifically, the range of key-value caches to be transmitted is the range of key-value cache data that the pre-filling node originally planned to send to the decoding node over the network. Without decoding-side prefetching, the range to be transmitted typically covers the key-value cache data corresponding to the entire input word sequence; that is, the pre-filling node needs to transmit the key-value cache data for all input words to the decoding node. However, with decoding-side prefetching, the decoding node has already prefetched a portion of the prefix key-value cache data from the remote storage system and committed it to the device memory. This portion of data does not need to be retransmitted by the pre-filling node and can therefore be deleted from the range to be transmitted.
[0132] Furthermore, adjusting the key-value cache range to be transmitted means that after the pre-fill node reads the acknowledgment information written by the decoding node, it removes the portion of key-value cache data that has been successfully prefetched by the decoding node and committed to the device memory from the range to be transmitted, based on the valid prefetch length in the acknowledgment information. After adjustment, the pre-fill node only needs to transmit the portion of key-value cache data in the input lexical sequence that was not successfully prefetched by the decoding node.
[0133] Optionally, in this embodiment, the decoding node writes the generated confirmation information into the preset metadata space at the location corresponding to the current inference request.
[0134] Specifically, when the decoding node determines not to perform prefetching, it writes a second indication to the preset metadata space to notify the prefilling node that this prefetching will be performed by the prefilling node. After reading the second indication, the prefilling node reads the key-value cache data from the remote storage system, performs prefilling calculations, and transmits the generated key-value cache data to the decoding node.
[0135] Optionally, the second indication information may include reasons for not performing prefetching, such as excessive load, insufficient capacity, or insufficient benefits.
[0136] Understandably, when the decoding node determines that the first indication is not to perform prefetching, it means that the current decoding node is unsuitable for performing key-value cache prefetching for some reason (such as invalid initial prefetch information, insufficient prefetch length, insufficient memory capacity, excessive load, etc.). In this case, to ensure the inference process can proceed normally, the prefilling node needs to take over the key-value cache prefetching process. The decoding node needs to inform the prefilling node that it is not performing prefetching, so that the prefilling node knows that it needs to perform the prefetching and transmit the complete key-value cache data. Since the prefilling node and the decoding node exchange control information through a preset metadata space, the decoding node writes the second indication into the preset metadata space.
[0137] Understandably, the second instruction information is control information written into the preset metadata space by the decoding node when it decides not to perform prefetching. It is used to inform the prefilling node that the decoding side will not perform prefetching, and that the prefilling side should perform prefetching and transmit key-value data.
[0138] Optionally, in this embodiment, if the decoding node determines that the first indication information is not to perform prefetching, the decoding node does not start the asynchronous reading task, but instead writes the second indication information to the preset metadata space.
[0139] Specifically, the prefetch execution status is determined by the target load information, enabling the decoding node to adaptively decide whether to perform prefetching and how much to prefetch based on its real-time load. When prefetching is performed, the decoding node writes confirmation information to a preset metadata space, allowing the prefilling node to trim the transmission range and reduce redundant transmissions. When prefetching is not performed, the decoding node notifies the prefilling node to perform prefetching, ensuring the continuity of the inference process. This achieves dynamic adjustment and collaborative processing of prefetching tasks, improving the resource utilization and first-word latency performance of the inference system.
[0140] As an optional implementation, based on the above embodiment, after obtaining the initial prefetch information generated by the pre-filled nodes from the preset metadata space, the method further includes:
[0141] Determine whether the candidate prefetch length is the first preset value;
[0142] Determine whether the cache index meets the first preset condition;
[0143] Determine if the identification information of the key-value cache block is missing;
[0144] In response to a candidate prefetch length being a first preset value, a cache index not meeting a first preset condition, or a missing identifier information for a key-value cache block, the first indication information is determined to not perform prefetching.
[0145] The initial prefetch information also includes the candidate prefetch length.
[0146] The key-value cache block information includes the identifier of the key-value cache block and the cache index of the inference request corresponding to the input lexical sequence.
[0147] Specifically, the candidate prefetch length is a field in the initial prefetch information that indicates the length of the continuous word range that the pre-filled node recommends the decoder node to prefetch based on the prefix matching results, i.e., how many key-value cache data words can be prefetched in total.
[0148] The candidate prefetch length is determined by the pre-filled node based on the hit length of prefix matching. It represents how many consecutive key-value cache data of the input lexical sequence have reusable copies in the remote storage system. The larger the candidate prefetch length, the longer the reusable prefix, and the greater the potential benefit of the prefetch operation.
[0149] The first preset value is a preset value that indicates that the candidate prefetch length is invalid, for example, it can be 0.
[0150] If the candidate prefetch length is the first preset value, it means that the prefix matching did not hit any reusable prefix, or the length of the hit prefix is 0, and there is no prefetchable key-value cache data in the remote storage system.
[0151] The identifier of a key-value cache block is a field within the key-value cache block information, used to uniquely identify a key-value cache block. This identifier can be a hash value, calculated from the content of the key-value cache block. This hash value serves two purposes: it uniquely identifies the key-value cache block and it can be used for data integrity verification after the key-value cache data is read, ensuring that the data read from the remote storage system matches the expected data and has not been corrupted or tampered with. If the identifier of a key-value cache block is missing, the decoding node cannot uniquely determine which key-value cache block to read, nor can it perform integrity verification on the read data; in this case, prefetching is not suitable.
[0152] The cache index is another field in the key-value cache block information, used to indicate the index position or cache entry identifier of the current inference request in the cache system. The cache index is used to locate the key-value cache data corresponding to the current inference request in the remote storage system and is a crucial basis for the decoding node to find and read the key-value cache block. If the cache index does not meet the first preset condition, such as an invalid cache index, out-of-bounds index, or the corresponding cache entry not existing, the decoding node will be unable to find the corresponding key-value cache data based on the cache index, and prefetching will fail.
[0153] The first preset condition is a pre-defined set of conditions used to determine whether a cached index is valid.
[0154] Optionally, the first preset condition may include at least one of the following conditions: the value range of the cache index is valid, that is, the cache index is within the valid index range defined by the system, and there are no illegal situations such as negative numbers or exceeding the maximum index value.
[0155] The cache index must meet several criteria: First, its format must be correct, meaning it conforms to the system-defined format and can be correctly parsed by the caching system. Second, the cache entry corresponding to the cache index must actually exist in the remote storage system, meaning the corresponding key-value cache block can be found in the remote storage system based on the cache index. Third, the cache index must match the input lexical sequence of the current inference request, meaning the prefix of the cache entry corresponding to the cache index matches the prefix of the current input lexical sequence, and there is no mismatch between the index and the request. Only when the cache index meets all of the above first preset conditions is it considered valid and can be used for subsequent prefetching operations.
[0156] If the identification information of the key-value cache block is missing, the decoding node will not be able to uniquely determine which key-value cache block to read, nor will it be able to perform data integrity verification after reading. This may result in reading incorrect or corrupted data, which will affect subsequent decoding calculations and even lead to incorrect inference results.
[0157] Specifically, missing identification information of key-value cache blocks refers to situations where the key-value cache block information in the initial prefetch information does not contain an identification information field for the key-value cache block, or the value of the identification information field is empty, or is a default invalid value, etc.
[0158] For example, the decoding node reads the candidate prefetch length from the initial prefetch information and compares it with a first preset value. If the candidate prefetch length equals the first preset value, the candidate prefetch length is determined to be invalid. The node reads the cache index from the key-value cache block information and determines whether the cache index exists, is valid, and matches the current inference request. If the cache index does not exist, is invalid, or does not match the current inference request, the cache index does not meet the first preset condition. The node reads the identifier information of the key-value cache block from the key-value cache block information. If the identifier information is empty, missing, or does not conform to a preset format, the identifier information of the key-value cache block is determined to be missing.
[0159] Optionally, in this embodiment, the decoding node sequentially performs candidate prefetch length verification, cache index verification, and key-value cache block identification information verification. If the candidate prefetch length is a first preset value (i.e., 0), or the cache index does not meet the first preset condition, or the key-value cache block identification information is missing, as long as any of the above conditions are met, the decoding node determines the first indication information as not performing prefetching and writes the second indication information to the preset metadata space, notifying the prefilling node to perform the prefetching operation on the prefilling side. If all three verifications pass, the decoding node continues to determine the prefetching execution status based on the target key-value matching length and target load information, and enters the subsequent prefetching execution process.
[0160] Specifically, by validating the initial prefetch information, the decoding node can promptly identify invalid prefetch plans before prefetching execution, avoiding useless reads, resource waste, or inference errors caused by invalid plans. Simultaneously, cases of verification failure are uniformly defined as not executing prefetching and the prefilling node is notified to execute prefetching, ensuring the continuity and correctness of the inference process.
[0161] As an optional implementation, based on any of the above embodiments, determining the prefetch execution state based on the target key-value matching length and target payload information includes:
[0162] Calculate the difference between the candidate prefetch length and the target key-value matching length to obtain the length of the cache to be prefetched;
[0163] Determine whether the length of the cache to be prefetched is less than the preset revenue threshold;
[0164] In response to the prefetch cache length being less than a preset revenue threshold, the first indication information is determined to be that prefetching will not be performed;
[0165] In response to a prefetch cache length greater than or equal to a preset revenue threshold, the executable prefetch cache length is determined based on the prefetch cache length, host memory capacity information, and device memory capacity information.
[0166] In response to the executable prefetch cache length being less than a preset revenue threshold, the first indication information is determined to be that prefetching will not be performed;
[0167] In response to the executable prefetch cache length being greater than or equal to a preset revenue threshold, the prefetch queue length, the number of prefetch tasks in execution, the number of prefetch tasks started in the current period, the bandwidth information of the remote storage system, and the number of tokens to be decoded are compared with the corresponding preset thresholds to obtain the comparison results.
[0168] The prefetch execution status is determined based on the executable prefetch cache length and the comparison results.
[0169] The target load information includes the prefetch queue length, the number of prefetch tasks in progress, the number of prefetch tasks started in the current period, the bandwidth information of the remote storage system, and the number of tokens to be decoded.
[0170] Understandably, after obtaining the initial prefetch information and passing the validity check, the decoding node needs to determine how many key-value cache data units actually need to be prefetched from the remote storage system. The candidate prefetch length in the initial prefetch information represents the total prefetchable length suggested by the prefilling node. However, the decoding node may already have some key-value cache data locally, which does not need to be read repeatedly from the remote storage system. Therefore, the candidate prefetch length needs to be subtracted from the length of the key-value cache already ready locally at the decoding node to obtain the actual length that needs to be read from the remote storage system, i.e., the length of the cache to be prefetched.
[0171] Furthermore, the prefetch cache length is the difference between the candidate prefetch length and the target key-value match length, indicating how many additional key-value cache data units the decoding node needs to read from the remote storage system. It's important to note that the target key-value match length here reflects the length of the key-value cache already ready on the decoding node's local machine; that is, the number of units corresponding to the key-value cache data that the decoding node already has in its device cache and host memory that can be directly used. If the prefetch cache length is less than or equal to 0, it means that all the key-value cache data within the candidate range is already ready on the decoding node's local machine, and no further data needs to be read from the remote storage system.
[0172] The prefetch queue length represents the number of prefetch tasks currently waiting to be executed in the decoding node; that is, the number of prefetch tasks that have been submitted but not yet started are queued in the queue. The longer the prefetch queue length, the more congested the prefetch tasks are, and the longer newly submitted prefetch tasks will have to wait.
[0173] The number of prefetch tasks in execution refers to the number of prefetch tasks running in the background at any given time, i.e., the number of asynchronous read tasks that have been started but not yet completed. A higher number of prefetch tasks in execution indicates greater read pressure on the remote storage system from the background, and thus consumes more host memory and storage bandwidth.
[0174] The number of prefetch tasks initiated in the current period refers to the number of new prefetch tasks initiated in the current scheduling period. This metric is used to control the prefetch initiation rate within a single scheduling period, avoiding the concentrated initiation of too many prefetch tasks in a short period of time, which could lead to a sudden surge in access to the remote storage system and cause storage read amplification.
[0175] The bandwidth information for the remote storage system includes its current bandwidth usage, such as currently used bandwidth, total available bandwidth, and bandwidth utilization rate. The more strained the bandwidth of the remote storage system, the slower the data retrieval speed, the longer the waiting time for prefetching tasks, and the lower the prefetching benefits.
[0176] The number of terms to be decoded refers to the total number of terms currently queued and waiting to be decoded by the decoding node, which is the total number of output terms that have not yet been generated in all inference requests that are being processed or waiting to be processed. The more terms to be decoded, the busier the main decoding process is, the more strained the computing resources of the decoding node are, and the fewer resources are available for prefetching operations.
[0177] It is understandable that initiating a read operation on a remote storage system requires certain fixed overhead, including task scheduling overhead, storage lookup overhead, data transfer overhead, and memory management overhead. If the prefetch cache length is too small, that is, if the amount of key-value cache data to be read from the remote storage system is too small, then the benefits of prefetching (i.e., the reduction in prefill computation time and transfer time) may not be enough to offset the fixed overhead of initiating a storage read operation. In this case, performing prefetching is inappropriate.
[0178] Optionally, the preset revenue threshold is pre-set.
[0179] It is understandable that when the length of the cache to be prefetched is less than the preset benefit threshold, it means that the amount of key-value cache data that needs to be read from the remote storage system is too small. The benefit brought by prefetching is not enough to offset the fixed overhead of starting a storage read operation. At this time, it is not cost-effective to perform prefetching. On the contrary, it may affect the overall performance of the system due to the occupation of storage bandwidth and computing resources.
[0180] Understandably, even if the prefetch cache length is large enough and prefetching offers sufficient benefits, the decoding node may not be able to prefetch all the key-value cache data corresponding to the prefetch cache length. This is because the prefetched key-value cache data needs to be stored in the host memory first and then committed to the device memory, and the remaining capacity of the host memory and device memory is limited. If the amount of prefetched key-value cache data exceeds the remaining capacity of the host memory or device memory, it will lead to memory overflow and affect the normal operation of the system.
[0181] Among them, the host memory capacity information refers to the remaining capacity information in the host memory of the decoding node that can be used to store key-value cache data, including the remaining memory space size.
[0182] Among them, the device memory capacity information refers to the remaining capacity information in the device memory of the decoding node that can be used to store key-value cache data, including the remaining video memory space.
[0183] Optionally, in this embodiment, a candidate prefetch length is parsed from the initial prefetch information, and the target key-value matching length is subtracted from the candidate prefetch length. The difference is determined as the prefetch cache length to be prefetched. The calculated prefetch cache length to be prefetched is compared with a preset benefit threshold. If the prefetch cache length to be prefetched is less than the preset benefit threshold, the first indication is determined to not perform prefetching, and subsequent capacity and load judgments are discontinued. Simultaneously, a second indication is written to the preset metadata space to notify the prefilling node to perform prefetching processing. If the prefetch cache length to be prefetched is greater than or equal to the preset benefit threshold, the remaining capacity information of the current host memory and the remaining capacity information of the device memory are obtained to determine the executable prefetch cache length. The executable prefetch cache length is compared with the preset benefit threshold. If the executable prefetch cache length is less than the preset benefit threshold, the first indication is determined to not perform prefetching, and subsequent load judgments are discontinued. Simultaneously, a second indication is written to the preset metadata space to notify the prefilling node to perform prefetching processing on the prefilling side. If the executable prefetch cache length is greater than or equal to a preset revenue threshold, the decoding node obtains the current target load information and compares each load information with its corresponding preset threshold to obtain the comparison result. Based on the comparison result of each load information with its corresponding preset threshold, the executable prefetch cache length is adjusted or it is determined whether to prefetch.
[0184] Specifically, by calculating the length of the prefetch cache and comparing it with a preset benefit threshold, prefetching is avoided for those with insufficient benefits. Furthermore, capacity constraints determine the executable prefetch cache length, preventing prefetching failures due to insufficient space. Moreover, by comparing multiple load metrics with preset thresholds, the prefetching scale is adaptively adjusted, enabling reasonable determination of whether to perform prefetching and how much to prefetch under different load conditions, thereby improving prefetching benefits and system resource utilization.
[0185] As an optional implementation, based on any of the above embodiments, the executable prefetch cache length is determined based on the length of the prefetch cache to be prefetched, the capacity information of the host memory, and the capacity information of the device memory, including:
[0186] The length of the first cache in the host memory is determined based on the host memory capacity information;
[0187] The length of the second cache of the device memory is determined based on the device memory capacity information;
[0188] The minimum value among the prefetch cache length, the first cache length, and the second cache length is determined as the executable prefetch cache length.
[0189] The executable prefetch cache length is the maximum number of tokens that can actually be prefetched, provided that the prefetching requirements, host memory capacity constraints, and device memory capacity constraints are all met.
[0190] The first cache length is the key-value cache length that the host memory can support. The second cache length is the key-value cache length that the device memory can support.
[0191] Understandably, the first cache length is the maximum number of key-value cached data terms that can be accommodated within the constraints of the host's remaining memory capacity. The second cache length is the maximum number of key-value cached data terms that can be accommodated within the constraints of the device's remaining memory capacity.
[0192] Optionally, in this embodiment, the remaining capacity of the host memory is obtained, and a first cache length supported by the host memory is calculated based on the number of bytes occupied by the key-value cache data corresponding to each term. The remaining capacity of the device memory is obtained, and a second cache length supported by the device memory is calculated based on the number of bytes occupied by the key-value cache data corresponding to each term. The prefetch cache length, the first cache length, and the second cache length are compared, and the minimum value is taken as the executable prefetch cache length.
[0193] Optionally, the number of bytes occupied by the key-value cache data corresponding to each lexical can be determined according to the model structure, such as the number of model layers, the number of attention heads, the head dimension, the number of key-value pairs, and the data precision.
[0194] Specifically, the executable prefetch cache length is determined by calculating the first cache length supported by the host memory and the second cache length supported by the device memory, and then taking the minimum value between these two values and the length of the cache to be prefetched. Therefore, the actual amount of data that can be prefetched under the current capacity constraints can be accurately determined before prefetching, avoiding prefetch task failure or blocking due to insufficient host or device memory.
[0195] As an optional implementation, based on any of the above embodiments, determining the prefetch execution state based on the executable prefetch cache length and the comparison result includes:
[0196] Read the comparison results;
[0197] If at least one of the indicators in the target load information is greater than or equal to the corresponding first preset threshold, the first indication information will be determined as not performing prefetching;
[0198] If all indicators in the target load information are less than the first preset threshold and at least one is greater than or equal to the corresponding second preset threshold, the minimum value between the executable prefetch cache length and the first prefetch length will be compared with the preset revenue threshold.
[0199] If the minimum value between the executable prefetch cache length and the first prefetch length is less than the preset revenue threshold, the first indication information will be determined as not performing prefetching;
[0200] If the minimum value between the executable prefetch cache length and the first prefetch length is greater than or equal to the preset revenue threshold, the target prefetch length is determined as the first prefetch length;
[0201] If all indicators in the target load information are less than the second preset threshold and at least one is greater than or equal to the corresponding third preset threshold, the target prefetch length is determined to be the minimum value between the executable prefetch cache length and the second prefetch length.
[0202] If all indicators in the target load information are less than the third preset threshold, the target prefetch length is determined to be the minimum value between the executable prefetch cache length and the third prefetch length.
[0203] The preset thresholds include a first preset threshold, a second preset threshold, and a third preset threshold.
[0204] The comparison result is obtained by comparing each indicator in the target load information with its corresponding preset threshold.
[0205] The three threshold levels, from highest to lowest, are the first preset threshold, the second preset threshold, and the third preset threshold.
[0206] The first preset threshold is the highest level of load threshold, indicating that the decoding node or remote storage system is already overloaded.
[0207] The second preset threshold is the second highest load threshold, indicating that the system is under high pressure.
[0208] The third preset threshold is the medium pressure threshold, which indicates that the system is in a medium pressure state.
[0209] When any indicator reaches or exceeds the corresponding first preset threshold, it indicates that continuing to perform the prefetch operation will put too much pressure on the system. Therefore, the first indication information is determined to not perform prefetching, that is, the bypass strategy is selected, and the prefill node performs the prefetch operation.
[0210] Specifically, if all indicators fail to reach the first preset threshold, but at least one reaches or exceeds the corresponding second preset threshold, it indicates high system pressure, necessitating a limitation on the prefetching scale. In this case, the decoding node takes the minimum of the executable prefetch cache length and the first prefetch length and compares it with a preset benefit threshold. If the minimum of the executable prefetch cache length and the first prefetch length is less than the preset benefit threshold, it means that even if prefetching is performed according to the first prefetch length, the benefit is too small to justify initiating the prefetching operation; therefore, the first indication is set to not perform prefetching. When the minimum of the executable prefetch cache length and the first prefetch length is greater than or equal to the preset benefit threshold, it indicates that prefetching according to the first prefetch length has sufficient benefit. Since the first prefetch length is the upper limit under this pressure level and is less than or equal to the executable prefetch cache length, the target prefetch length is determined to be the first prefetch length.
[0211] The first pre-take length is the maximum allowable pre-take length under high pressure conditions, which is smaller than the second and third pre-take lengths.
[0212] Specifically, when all indicators are less than the second preset threshold, but at least one indicator reaches or exceeds the corresponding third preset threshold, it indicates that the system pressure is moderate, and partial prefetching can be performed. In this case, the decoding node takes the minimum value between the executable prefetch buffer length and the second prefetch length as the target prefetch length. The second prefetch length is the maximum prefetch length allowed under moderate pressure, which is greater than the first prefetch length and less than the third prefetch length.
[0213] When all indicators are less than the third preset threshold, it indicates that the system is in a low-pressure state and can perform a full prefetch. The minimum value between the executable prefetch cache length and the third prefetch length is taken as the target prefetch length. The third prefetch length is the maximum prefetch length allowed under low-pressure conditions, which is greater than the second prefetch length and can be equal to or close to the executable prefetch cache length.
[0214] Specifically, by setting a first, second, and third preset threshold, various indicators in the target load information are compared with thresholds of different levels, thereby dividing the system pressure into multiple levels. Under different pressure levels, different prefetch length determination strategies are adopted, which can adaptively adjust the prefetch scale according to the real-time load, making full use of caching benefits while avoiding excessive pressure on the system. This ensures inference correctness while improving resource utilization and first-word latency performance.
[0215] As an optional implementation, based on any of the above embodiments, key-value cache data is submitted from host memory to device memory, and confirmation information for the submitted key-value cache is generated, including:
[0216] Obtain the prefetch completion length for each parallel execution unit;
[0217] The minimum value among the prefetch completion lengths corresponding to each parallel execution unit is determined as the effective prefetch length;
[0218] Based on the effective prefetch length, the key-value cache data corresponding to each parallel execution unit is submitted from the host memory to the corresponding device memory, and confirmation information of the submitted key-value cache is generated.
[0219] The confirmation information for the submitted key-value cache includes the valid prefetch length.
[0220] Understandably, in large language model inference systems, due to the typically large number of model parameters, the video memory of a single Graphics Processing Unit (GPU) or other acceleration device is often insufficient to hold the complete model weights and key-value cache data. Therefore, parallel computing techniques such as Tensor Parallelism (TP) are commonly used to distribute the computational task of an inference request across multiple parallel execution units. Each parallel execution unit stores only a portion of the model weights and a portion of the key-value cache data for that request, and independently performs its prefetch task. Therefore, before submitting the key-value cache data from host memory to device memory, it is necessary to obtain the prefetch completion length for each parallel execution unit, i.e., how many lexical key-value cache data each parallel execution unit has successfully read from the remote storage system.
[0221] In this context, a parallel execution unit refers to an execution entity that participates in the computation of the same inference request.
[0222] Optionally, when the decoding node uses tensor parallelism, the decoding node includes multiple parallel execution units, each responsible for a portion of the key-value cache data. The parallel execution unit is rank.
[0223] For example, each parallel execution unit can segment the key-value cache data according to the attention head dimension, and each parallel execution unit is responsible for a portion of the key-value cache data corresponding to the attention head.
[0224] The prefetch completion length is the length of the key-value cache that each parallel execution unit asynchronously reads from the remote storage system into the host memory, starting from the prefetch start point. Since the read speeds of each parallel execution unit may differ, the prefetch completion length for each parallel execution unit may also differ.
[0225] The effective prefetch length is the key-value cache length that has been read by all parallel execution units and can be safely used for submission and subsequent decoding computation. Since decoding computation requires all parallel execution units to have key-value cache data of the corresponding length, the minimum value among the prefetch completion lengths must be taken as the effective prefetch length.
[0226] Each parallel execution unit corresponds to its own device memory. Based on the valid prefetch length, the decoding node submits the key-value cache data corresponding to the first valid prefetch length in each parallel execution unit from the host memory to its respective device memory. After submission, the decoding node generates confirmation information for the submitted key-value cache, which includes the valid prefetch length.
[0227] Optionally, the decoding node queries the read progress of each parallel execution unit to obtain the prefetch completion length corresponding to each parallel execution unit. The minimum value among the prefetch completion lengths corresponding to each parallel execution unit is determined as the effective prefetch length. Based on the effective prefetch length, the key-value cache data corresponding to each parallel execution unit is submitted from the host memory to the corresponding device memory, and confirmation information of the submitted key-value cache is generated.
[0228] For example, the decoding node submits the key-value cache data of the first 780 tokens in parallel execution unit 0 from the host memory to the device memory of parallel execution unit 0. It then submits the key-value cache data of the first 780 tokens in parallel execution unit 1 from the host memory to the device memory of parallel execution unit 1. Finally, it submits the key-value cache data of the first 780 tokens in parallel execution unit 2 from the host memory to the device memory of parallel execution unit 2. After submission, an acknowledgment message including a valid prefetch length of 780 tokens is generated.
[0229] Specifically, by obtaining the prefetch completion length corresponding to each parallel execution unit and taking the minimum value as the effective prefetch length, it is ensured that all parallel execution units have key-value cache data of the same length, avoiding decoding calculation errors caused by a certain parallel execution unit lagging behind in reading progress. At the same time, based on the effective prefetch length, the key-value cache data corresponding to each parallel execution unit is submitted to its respective device memory, and confirmation information including the effective prefetch length is generated. This allows the pre-filling node to accurately trim the range of key-value cache to be transmitted based on the confirmation information, further reducing duplicate transmissions and improving the overall efficiency of the inference system.
[0230] As an optional implementation, based on any of the above embodiments, it further includes:
[0231] Create and start an asynchronous read task, and record the start time, progress update time and length read. The asynchronous read task reads the key-value cache data corresponding to the key-value cache block information from the remote storage system to the host memory according to the target prefetch length.
[0232] Periodically determine the current read length of the asynchronous read task;
[0233] If the current read length is greater than the already read length, update the already read length to the current read length, and update the progress update time to the current time;
[0234] The first target stop time is determined periodically based on the start time and progress update time;
[0235] If the current time is less than the first target stopping time and the asynchronous reading task has not yet entered the completion state, continue to execute the asynchronous reading task;
[0236] If the current time is greater than or equal to the first target stop time and the asynchronous read task has not entered the completion state or the asynchronous read task has entered the read failure state, stop executing the asynchronous read task and write the second indication information to the preset metadata space so that the prefilled node can perform prefetching processing.
[0237] In response to an asynchronous read task entering a completed state, record the completion time.
[0238] The asynchronous read task is a task executed in the background by the decoding node to read key-value cache data from the remote storage system into the host memory. This task does not block the main scheduling loop of the decoding node, allowing the decoding node to continue processing other requests or performing other scheduling operations while waiting for the read to complete.
[0239] The start time is the current time when the asynchronous read task starts. The progress update time is the time when the most recent read progress changed; its initial value can be equal to the start time. The read length is the number of tokens corresponding to the key-value cache data read continuously from the prefetch start point; its initial value can be zero. It should be noted that the read length must be a continuous length starting from the prefetch start point and cannot contain gaps; otherwise, it cannot be used for subsequent submissions.
[0240] Optionally, the decoding node can maintain a progress variable, which is updated each time the asynchronous read task successfully reads a continuous block of key-value cached data. The decoding node reads this progress variable during the scheduling cycle to obtain the current read length.
[0241] If the current read length is greater than the already read length, it means that the asynchronous read task is still progressing normally and the read progress has increased.
[0242] The first target stopping time is the point in time used to determine whether the asynchronous read task should stop. The decoding node determines the first target stopping time based on the start time, progress update time, and parameters such as the basic waiting time, progress stagnation time, and maximum waiting time.
[0243] For example, the first target stopping time can be determined by taking the maximum value among the sum of the start time and the basic waiting time, and the sum of the progress update time and the progress stagnation time, and then comparing the maximum value with the sum of the start time and the maximum waiting time, and taking the minimum value as the first target stopping time.
[0244] Wherein, the first target stopping time = min(start time + maximum waiting time, max(start time + basic waiting time, progress update time + progress stagnation time)).
[0245] Optionally, the maximum waiting time, the basic waiting time, and the progress stagnation time are preset.
[0246] Among them, the basic waiting time represents the minimum allowed running time after the asynchronous read task starts, to avoid the task being mistakenly judged as timeout as soon as it starts; the progress stagnation time represents the allowed waiting time after the most recent progress update. If there is no progress update after this time, the task is considered to be stuck; the maximum waiting time represents the upper limit of the total running time of the asynchronous read task regardless of the progress, to prevent the request from being suspended indefinitely.
[0247] Understandably, since the progress update time will be continuously updated as the reading progress increases, the first target stop time will also be extended, thereby achieving progress-based adaptive timeout control.
[0248] Optionally, if the asynchronous read task enters a read failure state, such as when the remote storage system returns an error, the network is interrupted, or the data verification fails, the decoding node also stops executing the asynchronous read task and writes the second indication information.
[0249] Specifically, when the asynchronous read task successfully reads the key-value cache data corresponding to the target prefetch length, or when the task returns a completion status, the decoding node determines that the asynchronous read task has entered the completion status and records the completion time. The completion time is used to subsequently determine the stop time of the second target, in order to control the waiting time for submission and synchronization operations.
[0250] Optionally, in this embodiment, after determining that the first indication information is to perform prefetching and the target prefetch length is greater than zero, the decoding node creates an asynchronous read task and initializes the start time and progress update time to the current time, and initializes the read length to zero. The asynchronous read task is then started to read key-value cache data from the remote storage system into the host memory. In each scheduling cycle, the execution status of the asynchronous read task is queried to obtain the number of tokens corresponding to the key-value cache data that has been continuously read from the remote storage system into the host memory, which is taken as the current read length. If the current read length is greater than the read length, the read length is updated to the current read length, and the progress update time is updated to the current time to indicate that the most recent progress increase occurred at the current moment. If the current time has not yet reached the first target stop time, and the asynchronous read task has not yet completed, it indicates that the task still has a chance to complete, and the decoding node continues to wait and periodically performs progress monitoring. If the current time has reached or exceeded the first target stop time, but the asynchronous read task has still not completed, it indicates that the read progress may have stalled or the task is abnormally slow, and continuing to wait will result in excessive request latency. At this point, the decoding node stops executing the asynchronous read task and writes a second indication message to the preset metadata space, notifying the pre-filling node that the prefetch could not be completed by the decoding node and that the prefetch operation should be performed by the pre-filling node. After the asynchronous read task is completed, the completion time is recorded, and the step of committing the key-value cache data from the host memory to the device memory continues. If an exception or timeout occurs during the commit process, the decoding node can determine a second target stop time based on the completion time and a preset waiting time, and stop the commit and write the second indication message when the second target stop time is exceeded.
[0251] Specifically, by creating asynchronous read tasks and recording their start time, progress update time, and read length, real-time monitoring of the read progress is achieved. Furthermore, by dynamically determining the first target stop time based on the start time and progress update time, the timeout judgment can be adaptively extended according to the read progress, avoiding both the false kill of slow tasks and indefinite waiting. Upon timeout or read failure, the task is stopped and the pre-fill node is notified to perform prefetching, ensuring the continuity and correctness of the inference process. This achieves efficient and reliable management of asynchronous prefetching tasks, improving the stability and resource utilization of the inference system.
[0252] As an optional implementation, based on any of the above embodiments, after responding to the first indication information to perform prefetching and asynchronously reading the key-value cache data corresponding to the key-value cache block information from the remote storage system to the host memory according to the target prefetch length, the method further includes:
[0253] The stop time of the second target is determined based on the start time, completion time, and preset waiting time.
[0254] If it is determined that the key-value cache data has not been successfully committed from the host memory to the device memory, obtain the current time;
[0255] Compare the current time with the stopping time of the second target;
[0256] If the current time is greater than or equal to the second target stop time, stop submitting key-value cache data from host memory to device memory, and write the second indication information to the preset metadata space so that the pre-filled node can perform prefetching processing.
[0257] The second target stopping time is the point in time used to determine whether the operation of submitting key-value cache data from host memory to device memory should be stopped.
[0258] After the asynchronous read task is completed, the key-value cache data is already in the host memory, but it still needs to undergo synchronization by multiple parallel execution units and submission to device memory. These operations may take too long due to insufficient resources, synchronization waits, or device malfunctions. Therefore, a second target stop time needs to be set for the submission phase to prevent requests from being suspended indefinitely.
[0259] For example, the second target stopping time can be determined by taking the sum of the completion time and the preset waiting time, comparing it with the sum of the start time and the maximum waiting time, and taking the minimum value as the second target stopping time.
[0260] Wherein, the second target stopping time = min(start time + maximum waiting time, completion time + preset waiting time).
[0261] The preset waiting time is the waiting period reserved for commit and synchronization operations. The preset waiting time can be a fixed value preset by the system, or it can be dynamically determined based on the current load, the number of parallel execution units, or the historical commit time.
[0262] The sum of the start time and the maximum waiting time is the hard upper limit for the entire prefetch process, ensuring that the total waiting time does not exceed this limit. The sum of the completion time and the preset waiting time is the additional waiting time allowed in the submission phase. The minimum of the two is taken to ensure that there is sufficient processing time in the submission phase without exceeding the total time limit.
[0263] In this process, after the asynchronous read task is completed, the decoding node attempts to commit the key-value cached data from the host memory to the device memory. If the commit process fails, it periodically retrieves the current time and compares it with the second target stop time. If the current time is less than the second target stop time, it means there is still time leeway in the commit phase, and the decoding node can continue to attempt to commit or wait for synchronization to complete. If the current time is greater than or equal to the second target stop time, it means the commit phase has timed out, and continuing to wait will result in excessive request latency.
[0264] Therefore, when the current time reaches or exceeds the second target stop time, the decoding node stops the commit operation and no longer waits. At the same time, the decoding node writes the second indication information to the preset metadata space, notifying the pre-filling node that the prefetch could not be completed by the decoding node and that the prefetch processing will be performed by the pre-filling node.
[0265] Optionally, if the current time is less than the second target stop time, but the submission operation has been successfully completed, the decoding node will generate confirmation information normally and write it into the preset metadata space, and the process will end.
[0266] Specifically, after the asynchronous read task is completed, a second target stop time is determined based on the start time, completion time, and preset waiting time. Timeout control is implemented for the commit phase to prevent requests from being suspended indefinitely due to synchronization failures of multiple parallel execution units, insufficient device memory, or commit blocking. Simultaneously, in the event of a commit timeout, committing is stopped and the pre-filling node is notified to perform prefetching, ensuring the continuity and correctness of the inference process. Through complete timeout management of the prefetching process from reading to commit, the stability and resource utilization of the inference system are further improved.
[0267] As an optional implementation, based on any of the above embodiments, it further includes:
[0268] In response to the effective prefetch length not meeting the second preset condition, the submission of key-value cache data from host memory to device memory is stopped, and the second indication information is written to the preset metadata space to enable the prefilled node to perform prefetch processing.
[0269] The effective prefetch length is the minimum value among the prefetch completion lengths corresponding to each parallel execution unit.
[0270] The second preset condition is the minimum length requirement used to determine whether the effective prefetch length has submission value.
[0271] Optionally, the second preset condition can be that the effective prefetch length is greater than or equal to a preset revenue threshold, or that the effective prefetch length is greater than zero, or that the effective prefetch length can cover a preset proportion of the prefix length, etc.
[0272] Optionally, in this embodiment, if the effective prefetch length does not meet the preset condition, it means that even if this part of the key-value cache data is submitted to the device memory, the reduction in cross-node transmission volume is very limited. The device memory occupation, multi-parallel execution unit synchronization overhead, and subsequent waiting time before decoding caused by the submission operation may outweigh its benefits. Therefore, the decoding node stops submitting key-value cache data from the host memory to the device memory to avoid invalid submissions occupying device memory resources.
[0273] The second indication information is used to notify the pre-fill node that the prefetch could not be effectively submitted by the decoding node and that the prefetch operation needs to be performed by the pre-fill node.
[0274] Optionally, the second instruction information may include the reason for not performing prefetching.
[0275] Specifically, by stopping submissions and notifying the prefetching node to perform prefetching when the effective prefetch length does not meet preset conditions, the problem of invalid device memory usage, increased synchronization overhead, and prolonged subsequent decoding waiting time due to insufficient prefetch benefits is avoided. Simultaneously, timely rollback to the prefetching node ensures the continuity and correctness of the inference process, thus achieving fine-grained control over prefetch benefits and further improving the resource utilization and overall efficiency of the inference system.
[0276] Figure 3 A flowchart illustrating a data prefetching method provided in another embodiment of this application is shown below. Figure 3 As shown. The data prefetching method provided in this embodiment is applied to pre-filled nodes. The data prefetching method provided in this embodiment specifically includes the following steps:
[0277] S301: In response to receiving an inference request sent by the scheduler, generate an input word sequence based on the inference request.
[0278] The inference request includes the request data to be inferred and the target prefetch node.
[0279] In this embodiment, the execution entity can be a pre-filled node, which can be an inference service instance deployed on a graphics processor, server, container, or virtual machine, used to perform input lexical processing and forward computation tasks in the pre-filling stage.
[0280] Optionally, in this embodiment, after the pre-filled node receives the inference request sent by the scheduler, it can perform word segmentation on the request data to be inferred in the inference request through a word segmenter to obtain the input word sequence.
[0281] S302: Perform prefix matching on the input word sequence to determine the candidate prefetch length.
[0282] Optionally, in this embodiment, the pre-filled node starts from the first word of the input word sequence and matches word by word downwards in the radix tree until no further matching is possible. The number of successfully matched words is the candidate prefetch length.
[0283] S303: In response to determining that the target prefetch node is a prefill node, perform prefetch processing based on the candidate prefetch length.
[0284] When the scheduler determines that the target prefetch node is a pre-fill node, it means that the prefetch operation will be performed by the pre-fill node. The pre-fill node reads the corresponding key-value cache data from the remote storage system into the host memory based on the candidate prefetch length, then submits the key-value cache data from the host memory to the device memory, and performs pre-fill calculations based on the submitted key-value cache data to generate key-value cache data corresponding to the words in the input word sequence that did not hit their prefixes.
[0285] S304: In response to determining that the target prefetch node is a decoding node, generate initial prefetch information and write the initial prefetch information into the preset metadata space.
[0286] The initial prefetch information includes candidate prefetch length and key-value cache block information. The candidate prefetch length is used to indicate a continuous range of terms.
[0287] When the scheduler determines that the target prefetch node is a decoding node, it means that the current prefetch operation will be performed by the decoding node. The pre-fill node generates initial prefetch information to guide the decoding node in performing the prefetch operation.
[0288] For example, after determining the candidate prefetch length based on the prefix matching result, the pre-fill node queries the remote storage system metadata to obtain the key-value cache block information corresponding to the candidate prefetch length. Subsequently, the pre-fill node writes the initial prefetch information, including the candidate prefetch length and the key-value cache block information, into the preset metadata space.
[0289] Specifically, upon receiving an inference request, the pre-filling node first generates the input lexical sequence and performs prefix matching to determine the candidate prefetch length. When the scheduler designates the target prefetch node as the pre-filling node, the pre-filling node directly performs the prefetch operation based on the candidate prefetch length, ensuring the successful completion of the prefetch task. When the scheduler designates the target prefetch node as the decoding node, the pre-filling node generates initial prefetch information including the candidate prefetch length and key-value cache block information and writes it to a preset metadata space. The decoding node then performs the prefetch operation based on the initial prefetch information. By flexibly allocating prefetch operations to either the pre-filling node or the decoding node, the system can balance the prefetch tasks according to real-time load, avoiding excessive pressure on a single node. Simultaneously, the initial prefetch information generated by the pre-filling node provides the decoding node with a clear prefetch plan, ensuring the accuracy and effectiveness of the prefetch operation. This achieves dynamic allocation and collaborative processing of prefetch tasks, improving the resource utilization and first-word latency performance of the inference system.
[0290] As an optional implementation, based on any of the above embodiments, prefetching processing is performed based on the candidate prefetch length, including:
[0291] Retrieve key-value cache block information;
[0292] Determine the length to be prefetched from the candidate prefetch lengths;
[0293] Determine that the length to be pre-fetched is greater than the second preset value;
[0294] In response to a prefetch length exceeding a second preset value, the key-value cache data corresponding to the key-value cache block information is read from the remote storage system and stored in the host memory.
[0295] Submit key-value cache data from host memory to device memory.
[0296] Among them, the key-value cache block information is used to indicate the storage location of the key-value cache data of the continuous word range corresponding to the candidate prefetch length in the remote storage system.
[0297] The length to be prefetched is the number of lexical units corresponding to the key-value cache data that actually needs to be prefetched from the remote storage system.
[0298] If some reusable key-value cache data already exists in the local device memory or host memory, the length to be prefetched can be the candidate prefetch length minus the locally ready length. If there is no reusable data locally, the length to be prefetched is equal to the candidate prefetch length.
[0299] In this process, after determining that the target prefetch node is a prefetch node, the pre-fill node queries the metadata of the remote storage system based on the candidate prefetch length to obtain the storage location of the key-value cache data of the continuous word range corresponding to the candidate prefetch length in the remote storage system.
[0300] The second preset value is the minimum length threshold used to determine whether prefetching is worthwhile. If the prefetch length is too short, the time required to read data from the remote storage system may outweigh the benefits, therefore prefetching is not performed.
[0301] The second preset value is 0.
[0302] Optionally, in this embodiment, the pre-fill node compares the length to be prefetched with a second preset value. If the length to be prefetched is greater than the second preset value, prefetching is performed. Otherwise, prefetching is not performed, and pre-filling calculation is directly performed on the words in the input word sequence that do not have a prefix, and the generated key-value cache data is transmitted to the decoding node. In response to the length to be prefetched being greater than the second preset value, the pre-fill node reads the key-value cache data corresponding to the length to be prefetched from the remote storage system to the host memory according to the storage location and page information in the key-value cache block information. Further, after submitting the key-value cache data corresponding to the length to be prefetched from the host memory to the device memory, attention calculation can be performed on the words in the input word sequence that do not have a prefix based on the key-value cache data to generate a new key-value cache.
[0303] Specifically, by obtaining key-value cache block information, the length to be prefetched is determined, and prefetching is performed when the length to be prefetched is greater than a second preset value. This avoids initiating remote reading for excessively short lengths, saving storage bandwidth and reading time. At the same time, the read key-value cache data is submitted to the device memory, providing a data foundation for subsequent pre-filling calculations.
[0304] As an optional implementation, based on any of the above embodiments, after generating the initial prefetch information, the method further includes:
[0305] Read the preset metadata space;
[0306] In response to receiving the confirmation message, the valid prefetch length is obtained from the confirmation message, and the key-value cache data corresponding to the valid prefetch length is deleted from the key-value cache range to be transmitted, so as to obtain the adjusted key-value cache range to be transmitted.
[0307] In response to reading the second instruction information, prefetching is performed.
[0308] The preset metadata space is a request-level control information channel accessible to both pre-filled nodes and decoding nodes. After writing the initial prefetch information into the preset metadata space, the pre-filled node will periodically or event-triggeredly read the preset metadata space in subsequent scheduling cycles to obtain feedback information written by the decoding node.
[0309] The key-value cache range to be transmitted is the range of key-value cache data that the pre-filled node originally planned to transmit to the decoding node. It typically includes the prefix key-value cache data corresponding to the candidate prefetch length and the newly calculated key-value cache data by the pre-filled node.
[0310] Optionally, in this embodiment, the pre-filled node queries the preset metadata space in each scheduling cycle to determine whether there is confirmation information or second indication information for the current request. If it exists, the information is read and subsequent steps are executed. If it does not exist, the node continues to wait or executes other tasks.
[0311] If the confirmation message also includes information such as whether a full hit was achieved, whether a timeout occurred, or the reason for the failure, the pre-fill node can further adjust its transmission strategy accordingly. For example, if the confirmation message indicates that the decoding node has achieved a full hit, the pre-fill node does not need to transmit the prefix key-value cache data anymore, but only the newly added key-value cache data.
[0312] The second indication information is the information written to the preset metadata space when the decoding node determines that prefetching should not be performed or prefetching has failed. The second indication information includes information about not performing prefetching, such as the reason for not performing prefetching.
[0313] For example, after the prefill node reads the second indication information from the preset metadata space, it determines that the prefetch could not be completed by the decoding node and then performs the prefetch operation.
[0314] Specifically, the pre-fill node reads the key-value cache data corresponding to the candidate prefetch length from the remote storage system into the host memory, submits the key-value cache data from the host memory to the device memory, and performs pre-fill calculations on the tokens in the input token sequence that do not match the prefix, generating new key-value caches. Finally, the pre-fill node transmits the read prefix key-value cache data and the new key-value cache data to the decoding node.
[0315] Specifically, after generating initial prefetch information, the pre-fill node obtains feedback information from the decoding node by reading a preset metadata space. When confirmation information is received, the pre-fill node trims the key-value cache range to be transmitted according to the effective prefetch length, avoiding repeated transmission of the portion already prefetched by the decoding node, thus reducing network bandwidth consumption and transmission latency. When the second indication information is received, the pre-fill node promptly performs the prefetch operation, ensuring the continuity and correctness of the inference process, and achieving efficient collaboration between the pre-fill node and the decoding node, thereby improving the overall efficiency and resource utilization of the inference system.
[0316] This embodiment also provides a data prefetching method, which is applied to a scheduler. The method includes:
[0317] In response to receiving an inference request from the target user, the corresponding pre-filled node and decoding node are determined based on the inference request; the inference request includes the request data to be inferred;
[0318] Identify the target prefetch node and add the target decoding node to the inference request; the target prefetch node is used to indicate the node to perform prefetch processing.
[0319] The inference request is sent to the corresponding pre-filled node and decoding node.
[0320] In this embodiment of the application, the execution entity is a scheduler, which can be a scheduling service instance deployed on a server, used to receive inference requests submitted by clients and allocate pre-filled nodes and decoding nodes for the inference requests.
[0321] The target users are those who submit reasoning requests to the reasoning system.
[0322] The scheduler allocates appropriate pre-filled nodes and decoding nodes to inference requests based on the size of the inference request and the real-time load status of each pre-filled node and each decoding node.
[0323] For example, the scheduler obtains the load status of all current pre-fill nodes and decoding nodes, selects the pre-fill node with the shortest prefetch queue, the largest remaining device memory, and the fewest unprocessed tokens as the target pre-fill node, and selects the decoding node with the shortest prefetch queue, the largest remaining device memory, and the fewest unprocessed tokens as the target decoding node.
[0324] Optionally, the scheduler can maintain a load status table for each node and update it periodically. When a new inference request is received, the scheduler selects a node based on the latest load status table.
[0325] The target prefetch node is the node determined by the scheduler from the pre-filled nodes and the decoded nodes based on the load status of each pre-filled node and each decoded node, and is used to perform the prefetching process.
[0326] Optionally, the target prefetch node can be a pre-filled node or a decoded node.
[0327] The target prefetch node is used to indicate whether the node performing the prefetch operation is a prefill node or a decoding node.
[0328] For example, after determining the target prefetch node and the target decode node, the scheduler further determines whether the prefetch operation should be performed by the prefetch node or the decode node based on the load status of both nodes, such as their current prefetch queue length, remaining device memory capacity, and number of unprocessed tokens. If the decode node has a shorter prefetch queue and more remaining device memory, the scheduler determines the target prefetch node as the decode node. If the prefetch node has a shorter prefetch queue and more remaining device memory, the scheduler determines the target prefetch node as the prefetch node.
[0329] Optionally, in this embodiment, the scheduler may also obtain the prefetch queue lengths of the current prefilled nodes and decoded nodes, and select the node with the shortest prefetch queue length as the target prefetch node.
[0330] Optionally, the scheduler can add the target prefetch node's identification information to the inference request. For example, a new field can be added to the inference request to indicate whether the target prefetch node is a prefill node or a decode node.
[0331] The scheduler sends inference requests containing target prefetch node information to both the target prefill node and the target decode node. Upon receiving the inference request, the target prefill node and target decode node determine which node will perform the prefetch operation based on the target prefetch node information in the request.
[0332] Specifically, after receiving an inference request, the scheduler allocates appropriate pre-filling and decoding nodes to the request based on the real-time load status of each pre-filling and decoding node, and further determines the target prefetch node. By adding the target prefetch node information to the inference request and sending it to the pre-filling and decoding nodes, the pre-filling and decoding nodes can clearly identify which node will perform the prefetch operation. This enables dynamic allocation and load balancing of prefetch tasks among the pre-filling and decoding nodes, thus preventing a single node from becoming a bottleneck due to excessive prefetch tasks and improving the resource utilization and first-word latency performance of the inference system.
[0333] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.
[0334] Figure 4 A flowchart illustrating a data prefetching method provided in another embodiment of this application is shown below. Figure 4 As shown. This embodiment describes the prefetching process where the target prefetch node is the decoding node, specifically including the following steps:
[0335] S401: The target user sends an inference request to the scheduler.
[0336] S402: The scheduler determines the corresponding pre-filled node and decoding node based on the inference request, and determines the target prefetch node.
[0337] S403: The scheduler sends the inference request to the corresponding pre-filled node.
[0338] S404: The scheduler sends the inference request to the corresponding decoding node.
[0339] S405: After receiving the inference request, the pre-fill node performs prefix matching on the input lexical sequence to determine the candidate prefetch length.
[0340] S406: The pre-filled node determines the target prefetch node as the decoding node, generates initial prefetch information, and writes the initial prefetch information into the preset metadata space.
[0341] S407: After receiving the inference request, the decoding node generates the input word sequence based on the inference request.
[0342] S408: The decoding node determines to perform prefetching processing, performs prefix matching on the input word sequence, and determines the target key value matching length.
[0343] S409: The decoding node obtains initial prefetch information from the preset metadata space.
[0344] S410: The decoding node obtains the target payload information and determines the first indication information and the target prefetch length when performing prefetch based on the target key value matching length and the target payload information.
[0345] S411: In response to the first indication information indicating that prefetching is not to be performed, the decoding node writes the second indication information to the preset metadata space so that the prefilling node performs prefetching processing.
[0346] S412: The decoding node responds to the first indication information to perform prefetching and determines the target prefetch length.
[0347] S413: The decoding node asynchronously reads the key-value cache data corresponding to the key-value cache block information from the remote storage system into the host memory according to the target prefetch length.
[0348] S414: The decoding node will asynchronously read the key-value cache block information from the remote storage system into the host memory and send the corresponding key-value cache data to the pre-fill node.
[0349] S415: The decoding node submits the key-value cache data from the host memory to the device memory, generates confirmation information for the submitted key-value cache, and writes the confirmation information to the preset metadata space.
[0350] S416: Read confirmation information for pre-filled nodes and adjust the key-value cache range to be transmitted.
[0351] S417: The pre-filled node performs attention calculation on the words in the input word sequence that do not hit the prefix based on the key-value cache data corresponding to the key-value cache block information, and generates key-value cache data corresponding to the words in the input word sequence that do not hit the prefix.
[0352] S418: The pre-filled node sends the corresponding key-value cache data to the decoding node according to the adjusted key-value cache range to be transmitted.
[0353] Figure 5 A schematic flowchart of a data prefetching method provided in another embodiment of this application is shown below. Figure 5 As shown. This embodiment describes the prefetching process when the target prefetch node is a pre-filled node, specifically including the following steps:
[0354] S501: The scheduler responds to the inference request sent by the target user, determines the corresponding pre-fill node and decoding node based on the inference request, and determines the target prefetch node.
[0355] S502: The scheduler sends the inference request to the corresponding pre-filled node.
[0356] S503: The scheduler sends the inference request to the corresponding decoding node.
[0357] S504: After receiving the inference request, the pre-fill node performs prefix matching on the input word sequence to determine the length to be prefetched.
[0358] S505: After receiving the inference request, the decoding node performs prefix matching on the input word sequence to determine the target key value matching length.
[0359] S506: The decoding node writes the target key-value matching length into the preset metadata space.
[0360] S507: The pre-filled node responds to the pre-fetch length being greater than the second preset value by reading the key-value cache data corresponding to the key-value cache block information from the remote storage system into the host memory.
[0361] S508: Pre-filled nodes submit key-value cache data from host memory to device memory.
[0362] S509: The pre-filled node performs attention calculations on the words in the input word sequence that do not hit the prefix based on the prefetched key-value cache data, and generates key-value cache data corresponding to the words in the input word sequence that do not hit the prefix.
[0363] S510: The pre-filled node reads the target key-value matching length in the preset metadata space.
[0364] S511: The pre-filled node adjusts the range of the key-value buffer to be transmitted based on the target key-value matching length.
[0365] S512: The pre-filled node sends the corresponding key-value cache data to the decoding node according to the adjusted key-value cache range to be transmitted.
[0366] Figure 6 This is a schematic diagram of the structure of a data prefetching device provided in an embodiment of this application. Figure 6 As shown, the execution entity of the above data prefetching method is a data prefetching device, which can be implemented by a computer program; it can also be implemented by a medium storing the relevant computer program, such as a USB flash drive and / or optical disc; or it can be implemented by a physical device integrating or installing the relevant computer program, such as an electronic device. The electronic device can be a computer or a server device. The data prefetching device provided in this embodiment is located in an electronic device, and therefore includes: a first generation module 61, a first determination module 62, a receiving module 63, a first acquisition module 64, a first execution module 65, and a first sending module 66.
[0367] Specifically, the first generation module 61 is used to generate an input lexical sequence based on the inference request received from the scheduler; the inference request includes request data to be inferred and a target prefetch node; the first determination module 62 is used to perform prefix matching on the input lexical sequence to determine the target key-value matching length; the receiving module 63 is used to receive the key-value cache data corresponding to the input lexical sequence sent by the prefetch node in response to determining that the target prefetch node is a pre-fill node; the first acquisition module 64 is used to acquire from the preset metadata space in response to determining that the target prefetch node is a decoding node. The pre-fill node generates initial prefetch information, which includes key-value cache block information. A first execution module 65 is used to perform prefetch processing based on the target key-value matching length and the initial prefetch information. A first sending module 66 is used to send the key-value cache data corresponding to the key-value cache block information asynchronously read from the remote storage system to the host memory to the pre-fill node, so that the pre-fill node performs attention calculation on the words in the input word sequence that do not hit the prefix based on the key-value cache data corresponding to the key-value cache block information, and generates key-value cache data corresponding to the words in the input word sequence that do not hit the prefix.
[0368] Optionally, the first execution module 65, when performing prefetching processing based on the target key-value matching length and initial prefetching information, is specifically configured to: determine the prefetching execution state based on the target key-value matching length and target load information; the prefetching execution state includes a first indication of whether to perform prefetching and the target prefetching length when performing prefetching; in response to the first indication of performing prefetching, asynchronously read key-value cache data corresponding to the key-value cache block information from the remote storage system to the host memory according to the target prefetching length; submit the key-value cache data from the host memory to the device memory and generate confirmation information for the submitted key-value cache; write the confirmation information to a preset metadata space so that the prefilling node adjusts the range of the key-value cache to be transmitted based on the confirmation information; in response to the first indication of not performing prefetching, write a second indication to the preset metadata space so that the prefilling node performs prefetching processing; the second indication includes information on not performing prefetching.
[0369] Optionally, the initial prefetch information also includes the candidate prefetch length; the key-value cache block information includes the identifier information of the key-value cache block and the cache index of the inference request corresponding to the input lexical sequence.
[0370] Accordingly, the first determining module 62 is used to determine whether the candidate prefetch length is a first preset value after obtaining the initial prefetch information generated by the prefilled node from the preset metadata space; determine whether the cache index meets the first preset condition; determine whether the identification information of the key-value cache block is missing; and in response to the candidate prefetch length being a first preset value, the cache index not meeting the first preset condition, or the identification information of the key-value cache block being missing, determine the first indication information as not performing prefetching.
[0371] Optionally, the target load information includes the prefetch queue length, the number of prefetch tasks in progress, the number of prefetch tasks started in the current period, the bandwidth information of the remote storage system, and the number of tokens to be decoded.
[0372] Accordingly, the first execution module 65, when determining the prefetch execution state based on the target key-value matching length and target load information, is specifically used for: calculating the difference between the candidate prefetch length and the target key-value matching length to obtain the prefetch cache length; determining whether the prefetch cache length is less than a preset revenue threshold; in response to the prefetch cache length being less than the preset revenue threshold, determining the first indication information as not performing prefetch; in response to the prefetch cache length being greater than or equal to the preset revenue threshold, determining the executable prefetch cache length based on the prefetch cache length, the host memory capacity information, and the device memory capacity information; in response to the executable prefetch cache length being less than the preset revenue threshold, determining the first indication information as not performing prefetch; in response to the executable prefetch cache length being greater than or equal to the preset revenue threshold, comparing the prefetch queue length, the number of prefetch tasks in execution, the number of prefetch tasks started in the current period, the bandwidth information of the remote storage system, and the number of tokens to be decoded with the corresponding preset thresholds to obtain comparison results; and determining the prefetch execution state based on the executable prefetch cache length and the comparison results.
[0373] Optionally, when the first execution module 65 determines the executable prefetch cache length based on the length of the cache to be prefetched, the capacity information of the host memory, and the capacity information of the device memory, it is specifically used to: determine the first cache length of the host memory based on the capacity information of the host memory; the first cache length is the key-value cache length that the host memory can support; determine the second cache length of the device memory based on the capacity information of the device memory; the second cache length is the key-value cache length that the device memory can support; and determine the minimum value among the length of the cache to be prefetched, the first cache length, and the second cache length as the executable prefetch cache length.
[0374] Optionally, the preset thresholds include a first preset threshold, a second preset threshold, and a third preset threshold.
[0375] Accordingly, the first execution module 65, when determining the prefetch execution state based on the executable prefetch cache length and the comparison result, is specifically configured to: read the comparison result; if at least one of the indicators in the target load information is greater than or equal to the corresponding first preset threshold, determine the first indication information as not performing prefetching; if all indicators in the target load information are less than the first preset threshold and at least one is greater than or equal to the corresponding second preset threshold, compare the minimum value of the executable prefetch cache length and the first prefetch length with the preset revenue threshold; if the minimum value of the executable prefetch cache length and the first prefetch length is less than... A preset revenue threshold is used to determine that the first indication information is not to perform prefetching; if the minimum value between the executable prefetch cache length and the first prefetch length is greater than or equal to the preset revenue threshold, the target prefetch length is determined as the first prefetch length; if all indicators in the target load information are less than the second preset threshold and at least one is greater than or equal to the corresponding third preset threshold, the target prefetch length is determined as the minimum value between the executable prefetch cache length and the second prefetch length; if all indicators in the target load information are less than the third preset threshold, the target prefetch length is determined as the minimum value between the executable prefetch cache length and the third prefetch length.
[0376] Optionally, the confirmation message for the submitted key-value cache includes the valid prefetch length.
[0377] Accordingly, when the first execution module 65 submits the key-value cache data from the host memory to the device memory and generates confirmation information for the submitted key-value cache, it is specifically used to: obtain the prefetch completion length corresponding to each parallel execution unit; determine the minimum value among the prefetch completion lengths corresponding to each parallel execution unit as the effective prefetch length; and, based on the effective prefetch length, submit the key-value cache data corresponding to each parallel execution unit from the host memory to the corresponding device memory, and generate confirmation information for the submitted key-value cache.
[0378] Optionally, the data prefetching device may also include a creation module, an update module, and a recording module.
[0379] Accordingly, a creation module is used to create and start an asynchronous read task, and record the start time, progress update time, and read length of the asynchronous read task; the asynchronous read task reads key-value cache data corresponding to key-value cache block information from the remote storage system to the host memory according to the target prefetch length. A first determination module 62 is used to periodically determine the current read length of the asynchronous read task. An update module is used to update the read length to the current read length and update the progress update time to the current time if the current read length is greater than the read length. The first determination module 62 is used to periodically determine a first target stop time based on the start time and progress update time. A first execution module 65 is used to continue executing the asynchronous read task if the current time is less than the first target stop time and the asynchronous read task has not entered the completion state. If the current time is greater than or equal to the first target stop time and the asynchronous read task has not entered the completion state or the asynchronous read task has entered the read failure state, the asynchronous read task is stopped, and second indication information is written to the preset metadata space to cause the pre-filled node to perform prefetch processing. A recording module is used to record the completion time in response to the asynchronous read task entering the completion state.
[0380] Optionally, the data prefetching device may also include a comparison module.
[0381] Accordingly, the first determining module 62 is used to, in response to the first indication information, perform prefetching, asynchronously read the key-value cache data corresponding to the key-value cache block information from the remote storage system to the host memory according to the target prefetch length, and then determine the second target stop time based on the start time, completion time, and preset waiting time. The first obtaining module 64 is used to obtain the current time if it is determined that the key-value cache data has not been successfully submitted from the host memory to the device memory. The comparison module is used to compare the current time with the second target stop time. The first execution module 65 is used to, if the current time is greater than or equal to the second target stop time, stop submitting the key-value cache data from the host memory to the device memory, and write the second indication information to the preset metadata space so that the pre-filled node performs prefetching processing.
[0382] Optionally, the first execution module 65 is configured to stop submitting key-value cache data from host memory to device memory in response to the effective prefetch length not meeting the second preset condition, and to write second indication information to the preset metadata space so that the prefilled node performs prefetch processing.
[0383] Figure 7 This is a schematic diagram of a data prefetching device provided in another embodiment of this application. Figure 7As shown, the execution entity of the above data prefetching method is a data prefetching device, which can be implemented by a computer program; it can also be implemented by a medium storing the relevant computer program, such as a USB flash drive and / or optical disc; or it can be implemented by a physical device integrating or installing the relevant computer program, such as an electronic device. The electronic device can be a computer or a server device. The data prefetching device provided in this embodiment is located in an electronic device, and therefore includes: a second generation module 71, a second determination module 72, a second execution module 73, and a writing module 74.
[0384] Specifically, the second generation module 71 is used to generate an input lexical sequence based on the inference request received from the scheduler; the inference request includes the request data to be inferred and the target prefetch node; the second determination module 72 is used to perform prefix matching on the input lexical sequence to determine the candidate prefetch length; the second execution module 73 is used to perform prefetch processing based on the candidate prefetch length in response to determining that the target prefetch node is a pre-fill node; the second generation module 71 is used to generate initial prefetch information in response to determining that the target prefetch node is a decoding node; the writing module 74 is used to write the initial prefetch information into a preset metadata space; the initial prefetch information includes the candidate prefetch length and key-value cache block information; the candidate prefetch length is used to indicate a continuous range of lexical terms.
[0385] Optionally, the second execution module 73, when performing prefetching processing based on the candidate prefetch length, is specifically configured to: obtain key-value cache block information; the key-value cache block information is used to indicate the storage location of key-value cache data of the continuous word range corresponding to the candidate prefetch length in the remote storage system; determine the length to be prefetched from the candidate prefetch length; determine that the length to be prefetched is greater than a second preset value; in response to the length to be prefetched being greater than the second preset value, read the key-value cache data corresponding to the key-value cache block information from the remote storage system into the host memory; and submit the key-value cache data from the host memory to the device memory.
[0386] Optionally, the data prefetching device further includes a reading module, a second acquisition module, and a deletion module.
[0387] Accordingly, the reading module is used to read the preset metadata space after generating the initial prefetch information. The second acquisition module is used to obtain the valid prefetch length from the confirmation information in response to reading the confirmation information. The deletion module is used to delete the key-value cache data corresponding to the valid prefetch length from the key-value cache range to be transmitted, so as to obtain the adjusted key-value cache range to be transmitted. The second execution module 73 is used to perform prefetch processing in response to reading the second indication information.
[0388] Figure 8This is a schematic diagram of the structure of a data prefetching device provided in another embodiment of this application. (See attached diagram.) Figure 8 As shown, the execution entity of the above data prefetching method is a data prefetching device, which can be implemented by a computer program; it can also be implemented by a medium storing the relevant computer program, such as a USB flash drive and / or optical disc; or it can be implemented by a physical device integrating or installing the relevant computer program, such as an electronic device. The electronic device can be a computer or a server device. The data prefetching device provided in this embodiment is located in an electronic device, and therefore includes: a third determining module 81, an adding module 82, and a second sending module 83.
[0389] Specifically, the third determining module 81 is used to determine the corresponding pre-filled node and decoding node based on the inference request in response to receiving the inference request sent by the target user; the inference request includes the request data to be inferred; the third determining module 81 is also used to determine the target prefetch node; the adding module 82 is used to add the target decoding node into the inference request; the target prefetch node is used to indicate the node to perform prefetch processing; the second sending module 83 is used to send the inference request to the corresponding pre-filled node and decoding node.
[0390] For a description of the features in the embodiment corresponding to the data prefetching device, please refer to the relevant description in the embodiment corresponding to the data prefetching method, which will not be repeated here.
[0391] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 9 As shown, the electronic device 90 provided in this embodiment includes at least one processor 901 and a memory 902. Optionally, the electronic device 90 further includes a communication component 903. The processor 901, memory 902, and communication component 903 are connected via a bus.
[0392] In a specific implementation, at least one processor 901 executes computer execution instructions stored in memory 902, causing at least one processor 901 to perform the steps in any of the above data prefetching method embodiments.
[0393] The specific implementation process of processor 901 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0394] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.
[0395] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.
[0396] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0397] Embodiments of this application also provide a computer-readable storage medium storing a computer program configured to execute the steps in any of the above-described data prefetching method embodiments at runtime.
[0398] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0399] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described data prefetching method embodiments.
[0400] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described data prefetching method embodiments.
[0401] Any of the components, modules, units, parts, methods, and operations described herein can be implemented using software, firmware, hardware (e.g., fixed logic circuitry), manual processing, or any combination thereof. Alternatively or additionally, any functionality described herein can be executed at least in part by one or more hardware logic components, such as, but not limited to, a central processing unit (CPU), a field-programmable gate array (FPGA), an application-specific integrated circuit (ASIC), an application-specific standard product (ASSP), a system-on-a-chip (SoC), a complex programmable logic device (CPLD), a microprocessor (MCU), etc. The terms "system," "computing device," or "apparatus" as used herein encompass various means, devices, and machines for processing data, including, for example, one or more programmable processors, computers, SoCs, or combinations thereof. The apparatus may also include code that creates an execution environment for the computer program in question, such as code constituting processor firmware, a protocol stack, a database management system, an operating system, a cross-platform runtime environment, a virtual machine, or one or more combinations thereof. The aforementioned computer program (also known as a program, software, software application, app, script, or code) can be written in any form of programming language, including compiled or interpreted languages, declarative or procedural languages, and can be deployed in any form, including as a standalone program or as a module, component, subroutine, object, or other unit suitable for a computing environment.
[0402] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0403] The data prefetching method provided in this application has been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only for the purpose of helping to understand the method and its core ideas. It should be noted that those skilled in the art can make several improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of this application.
Claims
1. A data prefetching method, characterized in that, The method includes: In response to receiving an inference request sent by the scheduler, an input word sequence is generated based on the inference request; the inference request includes the request data to be inferred and the target prefetch node; Prefix matching is performed on the input word sequence to determine the target key value matching length; In response to determining that the target prefetch node is a prefill node, the key-value cache data corresponding to the input lexical sequence sent by the prefill node is received; In response to determining that the target prefetch node is a decoding node, the initial prefetch information generated by the prefilled node is obtained from the preset metadata space; the initial prefetch information includes key-value cache block information. Prefetching is performed based on the target key-value matching length and the initial prefetch information. The key-value cache data corresponding to the key-value cache block information asynchronously read from the remote storage system to the host memory is sent to the pre-fill node. This allows the pre-fill node to perform attention calculations on the lexical units in the input lexical sequence that do not have a prefix based on the key-value cache data corresponding to the key-value cache block information, thereby generating key-value cache data corresponding to the lexical units in the input lexical sequence that do not have a prefix.
2. The data prefetching method according to claim 1, characterized in that, The prefetching process based on the target key-value matching length and the initial prefetch information includes: The prefetch execution state is determined based on the target key-value matching length and the target load information; the prefetch execution state includes a first indication of whether to execute prefetch and the target prefetch length when executing prefetch; In response to the first indication information indicating that prefetching is to be performed, the key-value cache data corresponding to the key-value cache block information is asynchronously read from the remote storage system into the host memory according to the target prefetch length; The key-value cache data is submitted from the host memory to the device memory, and confirmation information for the submitted key-value cache is generated. The confirmation information is written into the preset metadata space so that the pre-filled node adjusts the key-value cache range to be transmitted based on the confirmation information; In response to the first indication information indicating that prefetching is not performed, a second indication information is written to the preset metadata space to cause the prefilled node to perform prefetching processing; the second indication information includes information indicating that prefetching is not performed.
3. The data prefetching method according to claim 2, characterized in that, The initial prefetch information also includes the candidate prefetch length; the key-value cache block information includes the identifier information of the key-value cache block and the cache index of the inference request corresponding to the input lexical sequence; After obtaining the initial prefetch information generated by the pre-filled nodes from the preset metadata space, the method further includes: Determine whether the candidate prefetch length is a first preset value; Determine whether the cache index meets the first preset condition; Determine whether the identification information of the key-value cache block is missing; In response to the candidate prefetch length being the first preset value, the cache index not meeting the first preset condition, or the identification information of the key-value cache block being missing, the first indication information is determined to not perform prefetching.
4. The data prefetching method according to claim 2, characterized in that, The target load information includes the prefetch queue length, the number of prefetch tasks in execution, the number of prefetch tasks started in the current period, the bandwidth information of the remote storage system, and the number of tokens to be decoded. The step of determining the prefetch execution state based on the target key-value matching length and target load information includes: Calculate the difference between the candidate prefetch length and the target key-value matching length to obtain the prefetch cache length; Determine whether the length of the cache to be prefetched is less than a preset revenue threshold; In response to the fact that the length of the cache to be prefetched is less than the preset revenue threshold, the first indication information is determined to not perform prefetching; In response to the prefetch cache length being greater than or equal to the preset revenue threshold, the executable prefetch cache length is determined based on the prefetch cache length, the host memory capacity information, and the device memory capacity information; In response to the executable prefetch cache length being less than the preset revenue threshold, the first indication information is determined to not perform prefetching; In response to the executable prefetch cache length being greater than or equal to the preset revenue threshold, the prefetch queue length, the number of prefetch tasks in execution, the number of prefetch tasks started in the current period, the bandwidth information of the remote storage system, and the number of tokens to be decoded are compared with the corresponding preset thresholds to obtain comparison results. The prefetch execution status is determined based on the executable prefetch cache length and the comparison result.
5. The data prefetching method according to claim 4, characterized in that, The determination of the executable prefetch cache length based on the length of the cache to be prefetched, the capacity information of the host memory, and the capacity information of the device memory includes: The first cache length of the host memory is determined based on the capacity information of the host memory; the first cache length is the key-value cache length that the host memory can support; The second cache length of the device memory is determined based on the capacity information of the device memory; the second cache length is the key-value cache length that the device memory can support; The minimum value among the prefetch cache length, the first cache length, and the second cache length is determined as the executable prefetch cache length.
6. The data prefetching method according to claim 4, characterized in that, The preset thresholds include a first preset threshold, a second preset threshold, and a third preset threshold; Determining the prefetch execution state based on the executable prefetch cache length and the comparison result includes: Read the comparison results; If at least one of the indicators in the target load information is greater than or equal to the corresponding first preset threshold, the first indication information will be determined as not performing prefetching. If all indicators in the target load information are less than the first preset threshold and at least one is greater than or equal to the corresponding second preset threshold, the minimum value between the executable prefetch cache length and the first prefetch length is compared with the preset revenue threshold. If the minimum value between the executable prefetch cache length and the first prefetch length is less than the preset revenue threshold, the first indication information will be determined as not performing prefetching; If the minimum value between the executable prefetch cache length and the first prefetch length is greater than or equal to the preset revenue threshold, the target prefetch length is determined as the first prefetch length. If all indicators in the target load information are less than the second preset threshold and at least one is greater than or equal to the corresponding third preset threshold, the target prefetch length is determined to be the minimum value between the executable prefetch cache length and the second prefetch length. If all indicators in the target load information are less than the third preset threshold, the target prefetch length is determined to be the minimum value between the executable prefetch cache length and the third prefetch length.
7. The data prefetching method according to claim 2, characterized in that, The confirmation information for the submitted key-value cache includes the valid prefetch length; The step of submitting the key-value cache data from the host memory to the device memory and generating confirmation information for the submitted key-value cache includes: Obtain the prefetch completion length for each parallel execution unit; The minimum value among the prefetch completion lengths corresponding to each of the parallel execution units is determined as the effective prefetch length; Based on the effective prefetch length, the key-value cache data corresponding to each parallel execution unit is submitted from the host memory to the corresponding device memory, and confirmation information of the submitted key-value cache is generated.
8. The data prefetching method according to claim 2, characterized in that, Also includes: Create and start an asynchronous read task, and record the start time, progress update time, and length read of the asynchronous read task; The asynchronous read task is to asynchronously read the key-value cache data corresponding to the key-value cache block information from the remote storage system to the host memory according to the target prefetch length; The current read length of the asynchronous read task is periodically determined; If the current read length is greater than the already read length, update the already read length to the current read length, and update the progress update time to the current time; The first target stop time is determined periodically based on the start time and the progress update time; If the current time is less than the first target stopping time and the asynchronous reading task has not yet entered the completion state, continue to execute the asynchronous reading task; If the current time is greater than or equal to the first target stop time and the asynchronous reading task has not entered the completion state or the asynchronous reading task has entered the reading failure state, stop executing the asynchronous reading task and write the second indication information to the preset metadata space so that the pre-filled node performs prefetching processing; In response to the asynchronous read task entering the completion state, the completion time is recorded.
9. The data prefetching method according to claim 8, characterized in that, After responding to the first indication information to perform prefetching, and asynchronously reading the key-value cache data corresponding to the key-value cache block information from the remote storage system to the host memory according to the target prefetch length, the method further includes: The second target stopping time is determined based on the start time, the completion time, and the preset waiting time. If it is determined that the key-value cache data has not been successfully submitted from the host memory to the device memory, obtain the current time; Compare the current time with the second target stopping time; If the current time is greater than or equal to the second target stop time, stop submitting the key-value cache data from the host memory to the device memory, and write the second indication information to the preset metadata space so that the pre-filled node performs prefetching processing.
10. The data prefetching method according to claim 7, characterized in that, Also includes: In response to the effective prefetch length not meeting the second preset condition, the submission of the key-value cache data from the host memory to the device memory is stopped, and the second indication information is written to the preset metadata space so that the prefill node performs prefetch processing.
11. A data prefetching method, characterized in that, The method includes: In response to receiving an inference request sent by the scheduler, an input word sequence is generated based on the inference request; the inference request includes the request data to be inferred and the target prefetch node; Prefix matching is performed on the input word sequence to determine the candidate prefetch length; In response to determining that the target prefetch node is a prefill node, prefetching processing is performed based on the candidate prefetch length; In response to determining that the target prefetch node is a decoding node, initial prefetch information is generated and written into a preset metadata space; the initial prefetch information includes candidate prefetch length and key-value cache block information; the candidate prefetch length is used to indicate a continuous lexical range.
12. The data prefetching method according to claim 11, characterized in that, The prefetching process based on the candidate prefetch length includes: Obtain key-value cache block information; the key-value cache block information is used to indicate the storage location of key-value cache data of the continuous word range corresponding to the candidate prefetch length in the remote storage system; The length to be prefetched is determined from the candidate prefetch lengths; It is determined that the length to be pre-fetched is greater than the second preset value; In response to the prefetch length being greater than a second preset value, the key-value cache data corresponding to the key-value cache block information is read from the remote storage system and stored in the host memory. The key-value cache data is submitted from the host memory to the device memory.
13. The data prefetching method according to claim 11, characterized in that, After generating the initial prefetch information, the process also includes: Read the preset metadata space; In response to reading the confirmation information, the valid prefetch length is obtained from the confirmation information, and the key-value cache data corresponding to the valid prefetch length is deleted from the key-value cache range to be transmitted, so as to obtain the adjusted key-value cache range to be transmitted. In response to reading the second instruction information, prefetching is performed.
14. A data prefetching method, characterized in that, The method includes: In response to receiving an inference request sent by a target user, the corresponding pre-filled node and decoding node are determined based on the inference request; the inference request includes request data to be inferred; The target prefetch node is determined, and the target decoding node is added to the inference request; the target prefetch node is used to indicate the node to perform the prefetch processing. The inference request is sent to the corresponding pre-filled node and the decoding node.
15. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the data prefetching method as described in any one of claims 1 to 14 when executing the computer program.
