Large model reasoning method and device, storage medium and program product

Through the combination of hybrid scheduling strategies and target segmentation parallel strategies, the problem of inference efficiency of existing large models is solved, and more efficient resource utilization and inference performance are achieved.

CN119005341APending Publication Date: 2024-11-22BEIJING SUIYUAN INTELLIGENT TECH CO LTD
View PDF 0 Cites 9 Cited by

Patent Information

Application Number
CN202411281440.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-13
Publication Date
2024-11-22

AI Technical Summary

Technical Problem

Existing large-scale model inference adopts the same slicing and parallel strategies on input tensors and weight tensors of different shapes of the calculation task, resulting in inefficiency and inability to fully utilize hardware resources.

Method used

Use mixed scheduling strategies to schedule batch inference requests to obtain fine-grained computing tasks and scheduling order, and determine the target segmentation strategy and parallel strategy based on the shape of the input tensor and weight tensor, and map the computing tasks to multiple computing units for calculate.

Benefits of technology

It improves the efficiency and resource utilization of large-scale model inference, meets user needs, and optimizes the utilization of hardware equipment resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119005341A_ABST
    Figure CN119005341A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, and discloses a large model reasoning method and device, a storage medium and a program product. The method comprises the following steps: acquiring a batch reasoning request, performing task scheduling on the batch reasoning request by adopting a hybrid scheduling strategy, and acquiring a plurality of calculation tasks and a corresponding scheduling sequence; obtaining an input tensor and shape and a large model weight tensor and shape corresponding to each calculation task, and obtaining a target segmentation strategy and a target parallel strategy corresponding to each calculation task according to the input tensor shape and the large model weight tensor shape; and performing large model reasoning according to the scheduling sequence, the target segmentation strategy, the target parallel strategy, the input tensor and the large model weight tensor corresponding to each calculation task, mapping the calculation tasks to a plurality of calculation units for calculation, and obtaining reasoning results corresponding to the batch reasoning requests. According to the scheme of the embodiment, hardware equipment resources can be better utilized, the efficiency of large model reasoning can be improved, and the resource utilization rate can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a large model reasoning method, device, storage medium and program product. Background Art

[0002] In the actual deployment of large models, it is usually necessary to fine-tune the basic large model according to the business scenario to achieve task scenario adaptation.

[0003] At present, in the existing large-model inference deployment, the same segmentation strategy and parallel strategy are usually used for input tensors and weight tensors of different shapes for each computing task, which easily leads to low efficiency of large-model inference and inability to fully utilize hardware resources. Summary of the invention

[0004] The present invention provides a large model reasoning method, device, storage medium and program product, which can better utilize hardware device resources while meeting user needs, improve the efficiency of large model reasoning, and improve resource utilization.

[0005] According to one aspect of the present invention, a large model reasoning method is provided, comprising:

[0006] Obtain real-time multi-user coarse-grained batch inference requests, and use a hybrid scheduling strategy to schedule the batch inference requests, obtaining multiple fine-grained computing tasks and the corresponding scheduling order;

[0007] Obtain the input tensor, input tensor shape, large model weight tensor and large model weight tensor shape corresponding to each of the computing tasks, and obtain the target segmentation strategy and target parallel strategy corresponding to each of the computing tasks according to the input tensor shape and the large model weight tensor shape;

[0008] Large model inference is performed according to the scheduling order, target segmentation strategy, target parallel strategy, input tensor and large model weight tensor corresponding to each of the computing tasks, the computing tasks are mapped to multiple computing units for calculation, and the inference results corresponding to the batch inference requests are obtained.

[0009] According to another aspect of the present invention, there is provided a large model reasoning device, comprising:

[0010] The task scheduling module is used to obtain real-time multi-user coarse-grained batch reasoning requests, and use a hybrid scheduling strategy to schedule batch reasoning requests, obtaining multiple fine-grained computing tasks and corresponding scheduling orders;

[0011] A strategy determination module, used to obtain the input tensor, input tensor shape, large model weight tensor and large model weight tensor shape corresponding to each of the computing tasks, and obtain the target segmentation strategy and target parallel strategy corresponding to each of the computing tasks according to the input tensor shape and the large model weight tensor shape;

[0012] The task computing module is used to perform large model inference according to the scheduling order, target segmentation strategy, target parallel strategy, input tensor and large model weight tensor corresponding to each of the computing tasks, map the computing tasks to multiple computing units for calculation, and obtain the inference results corresponding to the batch inference request.

[0013] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0014] at least one processor, and

[0015] a memory communicatively connected to the at least one processor; wherein,

[0016] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the large model reasoning method described in any embodiment of the present invention.

[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and the computer program is used to enable a processor to implement the large model reasoning method described in any embodiment of the present invention when executed.

[0018] According to another aspect of the present invention, a computer program product is provided, including a computer program, which implements the large model reasoning method described in any embodiment of the present invention when executed by a processor.

[0019] The technical solution of the embodiment of the present invention obtains real-time multi-user coarse-grained batch inference requests, and adopts a hybrid scheduling strategy to schedule the batch inference requests, thereby obtaining multiple fine-grained computing tasks and corresponding scheduling orders; obtaining the input tensor, input tensor shape, large model weight tensor and large model weight tensor shape corresponding to each computing task, and obtaining the target segmentation strategy and target parallel strategy corresponding to each computing task according to the input tensor shape and the large model weight tensor shape; performing large model inference according to the scheduling order, target segmentation strategy, target parallel strategy, input tensor and large model weight tensor corresponding to each computing task, mapping the computing tasks to multiple computing units for calculation, obtaining the inference results corresponding to the batch inference requests, and scheduling the inference tasks by adopting a hybrid scheduling strategy, and determining the optimal target segmentation strategy and target parallel strategy according to the input tensor shape and the large model weight tensor shape, so that the hardware device resources can be better utilized while meeting user needs, the efficiency of large model inference can be improved, and the resource utilization rate can be improved.

[0020] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0022] Figure 1 is a flow chart of a large model reasoning method provided according to the first embodiment of the present invention;

[0023] Figure 2 is a schematic diagram of the structure of a large model reasoning system provided according to the first embodiment of the present invention;

[0024] Figure 3 is a schematic diagram of a prefill priority scheduling method provided according to the first embodiment of the present invention;

[0025] Figure 4 is a schematic diagram of a decode priority scheduling method provided according to Embodiment 1 of the present invention;

[0026] Figure 5 is a schematic diagram of the principle of a hybrid scheduling strategy provided according to Embodiment 1 of the present invention;

[0027] Figure 6is a schematic diagram of a page table structure provided according to Embodiment 1 of the present invention;

[0028] Figure 7 is a flow chart of a large model reasoning method provided according to the second embodiment of the present invention;

[0029] Figure 8 is a flow chart of another large model reasoning method provided according to the second embodiment of the present invention;

[0030] Fig. 9 2 is a schematic diagram of the principle of multi-stream parallel scheduling provided according to Embodiment 2 of the present invention;

[0031] Fig.10 is a schematic diagram of the structure of a large model reasoning device provided according to Embodiment 3 of the present invention;

[0032] Fig.11 It is a schematic diagram of the structure of an electronic device for implementing the large model reasoning method of an embodiment of the present invention. DETAILED DESCRIPTION

[0033] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0034] It should be noted that the terms "first", "second", "target", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0035] Embodiment 1

[0036] Figure 1A flowchart of a large model inference method is provided for the first embodiment of the present invention. This embodiment is applicable to the case where model inference is performed based on a large language model pre-trained for different users and different scenarios. The method can be executed by a large model inference device, which can be implemented in the form of hardware and / or software. Typically, the large model inference device can be configured in an electronic device, such as a computer device or a server. Figure 1 As shown, the method includes:

[0037] S110, obtaining real-time multi-user coarse-grained batch inference requests, and adopting a hybrid scheduling strategy to perform task scheduling on the batch inference requests, and obtaining multiple fine-grained computing tasks and corresponding scheduling orders.

[0038] It should be noted that, in order to facilitate the understanding of the technical solution of this embodiment, the structure of the large model reasoning system used in this embodiment is first introduced. Typically, the structure of the large model reasoning system can be as follows: Figure 2 As shown. Among them, the weight memory is used to store the LoRA (Low-Rank Adaptation of large language models) model weights suitable for different scenarios. The LoRA model weights are composed of basic model weights and adapter weights. In this embodiment, the LoRA method can be used to fine-tune the basic model to obtain adapter weights suitable for different scenarios. The load monitor is used to monitor the load status of each computing unit in real time and provide data support for computing task allocation.

[0039] Specifically, after receiving coarse-grained batch inference requests from different users, the inference task corresponding to each inference request can be generated through the request analysis and assembler, and the inference task can be converted into a fine-grained computing task through the inference task scheduler; then, the shape cost analysis module and the parallel scheduling analysis and segmentation module can be used to analyze the input tensor and shape corresponding to each computing task, as well as the LoRA model weight tensor and shape, to obtain the optimal segmentation strategy and parallel strategy for each computing task; further, the computing tasks can be allocated to multiple computing units of the computing device cluster for calculation according to the optimal segmentation strategy and parallel strategy to obtain the calculation result of each computing task; finally, the calculation results of multiple corresponding computing tasks can be spliced ​​to obtain the inference result corresponding to the inference request.

[0040] Among them, batch inference requests can be a collection of inference requests from different users and different scenarios, for example, they can be question-answering requests, translation requests, etc. In this embodiment, batch inference requests can be processed synchronously. First, inference requests from different users can be received, and each inference request can be analyzed and converted to obtain an inference task executable by the inference server; then, the inference task can be added to the task queue for caching; further, a certain number of inference tasks are taken out from the task queue each time for synchronous processing. Typically, each inference task can be divided into multiple fine-grained computing tasks, and different types of computing tasks corresponding to different inference tasks can be interspersed and scheduled to determine the scheduling order corresponding to each computing task.

[0041] Optionally, a hybrid scheduling strategy is used to schedule batch inference requests to obtain multiple fine-grained computing tasks and corresponding scheduling orders, which may include:

[0042] Obtaining a pre-filling computing task and a decoding computing task corresponding to each inference request, and dividing the pre-filling computing task into a plurality of fine-grained pre-filling sub-computing tasks based on a preset segmentation granularity;

[0043] The pre-filled sub-computation tasks and decoding computing tasks corresponding to different inference requests are interspersed and scheduled according to the task type to determine the scheduling order corresponding to each computing task.

[0044] It should be noted that for large language models (LLM), model reasoning can generally be divided into two stages: prefill and decode. The two stages have completely opposite computational characteristics. The prefill stage processes longer sequences and is computationally intensive, which is not greatly affected by the batch size, while the decode stage processes unit elements (tokens) and is memory-intensive, which is greatly affected by the batch size. There are two indicators for measuring the reasoning performance of large models, T1 (corresponding to the prefill stage, that is, the time it takes for the reasoning to generate the first token) and T2 (corresponding to the decode stage, that is, the time it takes for the reasoning to generate two tokens in succession).

[0045] Existing reasoning task scheduling methods, or using Figure 3 The prefill priority scheduling method shown in Figure 4The decode priority scheduling method shown in the figure has its own bias. The decode priority method is biased towards latency, while the prefill priority method is biased towards throughput. Neither method can achieve a perfect balance, resulting in low device resource utilization and affecting inference performance. To address the above problems, this embodiment proposes a hybrid scheduling strategy for computing task scheduling, so that a batch includes both prefill computing tasks and decode computing tasks.

[0046] In a specific example, the principle of the hybrid scheduling strategy can be as follows Figure 5 As shown, A and B can be inference requests from different users. Specifically, first, the coarse-grained prefill computing task is divided into fine-grained prefill sub-computing tasks, namely block prefill computing tasks, based on the preset segmentation granularity; then, the decode computing task requested by A and the block prefill computing task requested by B are interspersed and scheduled to determine the scheduling order of each computing task. At this point, there is no obvious waiting for requests A and B, which improves system utilization while taking into account latency and throughput.

[0047] S120. Obtain the input tensor, input tensor shape, large model weight tensor and large model weight tensor shape corresponding to each of the computing tasks, and obtain the target segmentation strategy and target parallel strategy corresponding to each of the computing tasks based on the input tensor shape and the large model weight tensor shape.

[0048] Among them, the splitting strategy can be a scheme for splitting the input tensor and the large model weight tensor corresponding to each computing task. For example, the splitting strategy may include the splitting position, the splitting spacing, and the number of splits. By splitting the input tensor and the large model weight tensor based on the splitting strategy, the general matrix multiplication operation between the original input tensor and the large model weight tensor can be split into multiple general matrix multiplication operations with smaller granularity. The parallel strategy can be a way for the computing unit to execute multiple general matrix multiplication operations in parallel after the splitting, which may include the number of parallel streams, the execution order, etc.

[0049] In this embodiment, after completing the division and scheduling of computing tasks, the large model weight tensor and shape (i.e., vector dimension) corresponding to each inference request can be queried from the storage manager according to the request type corresponding to the inference request, and then the large model weight tensor and shape corresponding to each computing task can be obtained; secondly, the input tensor and shape corresponding to each computing task can be obtained according to the user input vector corresponding to each inference request. Furthermore, according to the mapping relationship between the preset input tensor shape, large model weight tensor shape, splitting strategy and parallel strategy, the target splitting strategy and target parallel strategy corresponding to the current input tensor shape and the large model weight tensor shape can be determined, thereby obtaining the target splitting strategy and target parallel strategy corresponding to each computing task.

[0050] Optionally, obtaining a target segmentation strategy and a target parallel strategy corresponding to each of the computing tasks according to the input tensor shape and the large model weight tensor shape may include:

[0051] According to the input tensor shape and the large model weight tensor shape corresponding to the current computing task, obtain the time cost corresponding to different splitting strategies and parallel strategies;

[0052] The segmentation strategy and parallel strategy corresponding to the minimum time cost are obtained, and they are used as the target segmentation strategy and target parallel strategy corresponding to the current computing task respectively.

[0053] In this embodiment, a certain number of splitting strategies and parallel strategies can be set in advance. After the scheduling of the computing tasks is completed, several matching splitting strategies can be determined in the preset splitting strategies according to the input tensor shape and the large model weight tensor shape corresponding to each computing task; then, the determined splitting strategies and the preset parallel strategies can be paired to form a strategy set, and the time cost corresponding to each strategy set can be obtained according to the preset relationship between the preset splitting strategy, parallel strategy and time cost; finally, the target strategy set corresponding to the minimum time cost can be found in each strategy set, and the splitting strategy and parallel strategy in the target strategy set can be used as the target splitting strategy and target parallel strategy corresponding to the computing task, respectively.

[0054] Among them, according to the input tensor shape and the large model weight tensor shape corresponding to each computing task, when determining several matching splitting strategies in the preset splitting strategies, if it is detected that the size of the minimum splitting unit corresponding to a preset splitting strategy is smaller than the input tensor shape and the large model weight tensor shape, then the detected splitting strategy can be determined as the matching splitting strategy.

[0055] S130. Perform large model inference according to the scheduling order, target segmentation strategy, target parallel strategy, input tensor and large model weight tensor corresponding to each of the computing tasks, map the computing tasks to multiple computing units for calculation, and obtain the inference results corresponding to the batch inference request.

[0056] In this embodiment, a corresponding computing unit can be assigned to each computing task, and the matrix multiplication operation between the input tensor and the large model weight tensor corresponding to each computing task can be divided into multiple finer-grained general matrix multiplication (GEMM) data streams according to the target segmentation strategy; then, the corresponding GEMM data stream can be calculated by each computing unit according to the corresponding target parallel strategy to obtain the calculation result corresponding to each computing task; finally, the calculation results of each computing task corresponding to each inference request can be spliced ​​to obtain the inference result corresponding to each inference request, and then the inference result corresponding to the batch inference request can be obtained. For example, when the inference request is a question-and-answer request, the inference result can be the answer corresponding to the question entered by the user.

[0057] The technical solution of the embodiment of the present invention obtains real-time multi-user coarse-grained batch inference requests, and adopts a hybrid scheduling strategy to schedule the batch inference requests, thereby obtaining multiple fine-grained computing tasks and corresponding scheduling orders; obtaining the input tensor, input tensor shape, large model weight tensor and large model weight tensor shape corresponding to each computing task, and obtaining the target segmentation strategy and target parallel strategy corresponding to each computing task according to the input tensor shape and the large model weight tensor shape; performing large model inference according to the scheduling order, target segmentation strategy, target parallel strategy, input tensor and large model weight tensor corresponding to each computing task, mapping the computing tasks to multiple computing units for calculation, obtaining the inference results corresponding to the batch inference requests, and scheduling the inference tasks by adopting a hybrid scheduling strategy, and determining the optimal target segmentation strategy and target parallel strategy according to the input tensor shape and the large model weight tensor shape, so that the hardware device resources can be better utilized while meeting user needs, the efficiency of large model inference can be improved, and the resource utilization rate can be improved.

[0058] In an optional implementation of this embodiment, obtaining the large model weight tensor corresponding to each of the computing tasks may include:

[0059] In the weight memory, obtaining the primary label, primary page number and secondary label corresponding to each of the computing tasks;

[0060] According to the first-level tag and the first-level page number, the first-level memory block number corresponding to each of the computing tasks is searched in the first-level page table, and according to the first-level memory block number and the second-level tag, the second-level memory block number corresponding to each of the computing tasks is searched in the second-level page table;

[0061] In the physical memory blocks that match the secondary memory block numbers, obtain the large model weight tensor corresponding to each of the computing tasks.

[0062] It should be noted that in the multi-user and multi-request large model inference process based on LoRA, the following challenges are faced: the LoRA model weights of different users and different scenarios have different ranks, so the weights are different; different LoRA model weights will use different optimal data streams when participating in GEMM calculations, so the granularity of the LoRA model weights is different; there is frequent swapping in and out of LoRA model weights between device memory and host memory, which can easily cause device memory fragmentation disasters and reduce the operating efficiency of system equipment.

[0063] In view of the above problems, this embodiment proposes a LoRA model weight management method based on a secondary page table. The page table structure can be as follows Figure 6 As shown, the first-level page table includes a first-level tag, a first-level page number, and a first-level memory block number, and the second-level page table includes a second-level tag, a second-level page number, and a second-level memory block number, and each second-level memory block number corresponds to a physical memory block.

[0064] When searching for LoRA model weights, first obtain the first-level tag, first-level page number, and second-level tag as search conditions, and based on the first-level tag (rank) and the first-level page number, find the matching first-level memory block number in the first-level page table; then, use the first-level memory block number found as the second-level page number to be searched, and based on the second-level page number and the second-level tag (tile), find the matching second-level memory block number in the second-level page table; finally, read the LoRA model weight to be found in the physical memory block that matches the second-level memory block number.

[0065] Optionally, the technical solution of this embodiment may further include: in the weight memory, according to the probability label corresponding to each physical memory block, obtaining the recent use probability corresponding to each stored weight tensor;

[0066] Based on the least recently used strategy, the stored weight tensors are swapped out to the host memory according to the recent usage probabilities corresponding to the stored weight tensors.

[0067] In this embodiment, the page table structure can be as follows Figure 6As shown, each physical memory block is set with a corresponding probability label, and the value of the probability label is the recent usage probability corresponding to the stored weight tensor in the physical memory block. For example, for physical memory block 0, its corresponding probability label probability = 0.1, which means that the recent usage probability of the stored weight tensor is 0.1. Among them, the recent usage probability can be the ratio of the number of times the current stored weight tensor is used to the total number of times all stored weight tensors are used within a set time.

[0068] Specifically, a probability-based least recently used strategy can be used to swap in and out the cache entries (i.e., stored weight tensors) of the LoRA weight memory. Typically, based on the historical data of inference requests, the required LoRA model weights can be asynchronously moved from the host memory to the device memory through the storage manager, and the contents in the page table entries and tags (e.g., probability, etc.) can be updated. Asynchronous transfer can hide the input and output overhead of the LoRA model weight transfer. Secondly, when the device memory is insufficient, the stored weight tensor with the lowest probability of recent use can be selected and swapped out to the host memory.

[0069] Embodiment 2

[0070] Figure 7 This is a flowchart of another large model reasoning method provided in the second embodiment of the present invention. This embodiment is a further refinement of the above technical solution. The technical solution in this embodiment can be combined with one or more of the above implementations. Figure 7 As shown, the method includes:

[0071] S210, obtaining real-time multi-user coarse-grained batch inference requests, and adopting a hybrid scheduling strategy to perform task scheduling on the batch inference requests, and obtaining multiple fine-grained computing tasks and corresponding scheduling orders.

[0072] S220. Obtain the input tensor, input tensor shape, large model weight tensor and large model weight tensor shape corresponding to each of the computing tasks, and obtain the target segmentation strategy and target parallel strategy corresponding to each of the computing tasks based on the input tensor shape and the large model weight tensor shape.

[0073] S230. Based on the load balancing strategy, obtain the computing unit corresponding to each of the computing tasks.

[0074] Specifically, the load condition of each computing unit can be obtained through a load monitor, and based on a load balancing strategy and the load condition of each computing unit, the computing unit corresponding to each computing task is determined.

[0075] S240. According to the target segmentation strategy, input tensor and large model weight tensor corresponding to each of the computing tasks, obtain the general matrix multiplication data stream corresponding to each of the computing tasks, and perform large model inference according to the scheduling order, target parallel strategy and general matrix multiplication data stream corresponding to each of the computing tasks, map the computing tasks to multiple computing units for calculation, and obtain the inference results corresponding to the batch inference request.

[0076] Specifically, for each computing task, the corresponding coarse-grained GEMM operation data can be obtained according to the corresponding input tensor and large model weight tensor; then, the coarse-grained GEMM operation data can be divided into fine-grained GEMM data streams (composed of multiple fine-grained GEMM operations) according to the corresponding target segmentation strategy; further, the fine-grained GEMM data streams can be sent to the corresponding computing unit through multiple parallel streams according to the corresponding target parallel strategy. The computing unit calculates the received GEMM data stream to obtain the calculation result corresponding to each computing task; finally, according to the scheduling order corresponding to the computing task, the calculation results corresponding to multiple computing tasks are integrated to obtain the inference result corresponding to each inference request.

[0077] Optionally, performing large model reasoning according to the scheduling order, target parallel strategy and general matrix multiplication data flow corresponding to each of the computing tasks, mapping the computing tasks to multiple computing units for calculation, and obtaining the reasoning results corresponding to the batch reasoning request may include:

[0078] According to the target parallel strategy corresponding to each of the computing tasks and the general matrix multiplication data flow, the computing tasks are mapped to multiple computing units for computing, and the computing results corresponding to each of the computing tasks are obtained;

[0079] According to the scheduling order and calculation results corresponding to each of the computing tasks, the inference results corresponding to the batch inference request are obtained.

[0080] In a specific example, the computing unit can execute each GEMM operation in the received GEMM data stream in sequence to obtain multiple GEMM operation results, and the multiple GEMM operation results can be spliced ​​together to obtain the calculation result corresponding to each computing task; then, according to the scheduling order corresponding to each computing task, the computing tasks belonging to the same inference request can be determined, and the calculation results corresponding to the computing tasks belonging to the same inference request can be spliced ​​again to obtain the inference result corresponding to each inference request.

[0081] The technical solution of the embodiment of the present invention is to obtain the target segmentation strategy and target parallel strategy corresponding to each computing task according to the input tensor shape and the large model weight tensor shape, and then obtain the computing unit corresponding to each computing task based on the load balancing strategy; then, according to the target segmentation strategy, input tensor and large model weight tensor corresponding to each computing task, obtain the general matrix multiplication data stream corresponding to each computing task, and perform large model inference according to the scheduling order, target parallel strategy and general matrix multiplication data stream corresponding to each computing task, map the computing tasks to multiple computing units for calculation, and obtain the inference results corresponding to the batch inference request; by allocating computing tasks based on the load balancing strategy and performing distributed computing based on multiple computing units, the efficiency of large model inference can be further improved.

[0082] In a specific implementation of this embodiment, the process of the large model reasoning method can be as follows: Figure 8 As shown. First, through the inference task scheduler, a hybrid scheduling strategy is used to schedule the batch inference requests in the request queue to generate computing tasks, and the input tensor and shape corresponding to each computing task and the LoRA model weight tensor and shape are obtained through the storage manager; then, according to the obtained input tensor shape and LoRA model weight tensor shape, the time cost under different splitting strategies and parallel strategies is obtained, and the target splitting strategy and target parallel strategy corresponding to the minimum time cost are selected; further, based on the target splitting strategy, the GEMM data stream corresponding to each computing task is obtained, and according to the GEMM data stream and the target parallel strategy, based on the multi-stream parallel scheduling mechanism, the computing task is mapped to the corresponding computing unit for calculation, and the inference result corresponding to the batch inference request is obtained.

[0083] When copying the LoRA model weight tensor to the computing unit, an asynchronous copy method can be used to hide the copy overhead. Each computing unit can perform multiple computing tasks.

[0084] In this embodiment, by combining the characteristics of the LoRA model weight and the request load, time cost analysis and parallel strategy analysis are performed on the computing tasks, and the computing tasks are divided and mapped to different device clusters and computing units. This can effectively improve computing efficiency and device utilization, improve the parallelism of the device, effectively reduce the communication overhead between computing units, and balance matrix calculations and communication loads.

[0085] It should be noted that the decode phase calculation of the same inference request depends on the calculation result of the prefill phase. Therefore, when the prefill calculation task and the decode calculation task are assigned to different computing units, the computing unit that executes the decode calculation task needs to wait for the calculation result of the prefill calculation task executed by another computing unit. This will cause bubbles on the pipeline, that is, waiting in vain. To address the above problems, when performing multi-stream parallel scheduling, this embodiment can intersperse the block prefill calculation tasks of different inference requests, so that the block prefill calculation tasks of different inference requests are superimposed on each other, so as to reduce bubbles on the computing units and improve the utilization rate of the computing units. For example, the principle of multi-stream parallel scheduling can be as follows: Fig. 9 As shown in the figure, bubbles can be effectively reduced by dividing the prefill computing tasks and interleaving the blockprefill computing tasks of different inference requests.

[0086] The technical solution of this embodiment can also perform superposition scheduling of the decode computing task of this reasoning request and the block prefill computing task of other reasoning requests through de-dependency analysis to hide the decode overhead and reduce bubbles on the computing unit, thereby further improving the utilization of the computing unit. Optionally, while interleaving and scheduling different computing tasks of different reasoning requests, the multi-stream mechanism of CUDA can also be used to complete the transmission of intermediate results between computing units by superimposing the sending and receiving communication primitives (each primitive is bound to a CUDA stream) and computing (computation is bound to another CUDA stream) to hide the communication overhead between computing units and improve the utilization of computing units.

[0087] Embodiment 3

[0088] Fig.10 This is a schematic diagram of the structure of a large model reasoning device provided in the third embodiment of the present invention. Fig.10 As shown, the device includes: a task scheduling module 310, a strategy determination module 320 and a task calculation module 330; wherein,

[0089] The task scheduling module 310 is used to obtain real-time multi-user coarse-grained batch reasoning requests, and use a hybrid scheduling strategy to perform task scheduling on the batch reasoning requests to obtain multiple fine-grained computing tasks and corresponding scheduling orders;

[0090] A strategy determination module 320 is used to obtain the input tensor, input tensor shape, large model weight tensor and large model weight tensor shape corresponding to each of the computing tasks, and obtain the target segmentation strategy and target parallel strategy corresponding to each of the computing tasks according to the input tensor shape and the large model weight tensor shape;

[0091] The task computing module 330 is used to perform large model inference according to the scheduling order, target segmentation strategy, target parallel strategy, input tensor and large model weight tensor corresponding to each of the computing tasks, map the computing tasks to multiple computing units for calculation, and obtain the inference results corresponding to the batch inference request.

[0092] The technical solution of the embodiment of the present invention obtains real-time multi-user coarse-grained batch inference requests, and adopts a hybrid scheduling strategy to schedule the batch inference requests, thereby obtaining multiple fine-grained computing tasks and corresponding scheduling orders; obtaining the input tensor, input tensor shape, large model weight tensor and large model weight tensor shape corresponding to each computing task, and obtaining the target segmentation strategy and target parallel strategy corresponding to each computing task according to the input tensor shape and the large model weight tensor shape; performing large model inference according to the scheduling order, target segmentation strategy, target parallel strategy, input tensor and large model weight tensor corresponding to each computing task, mapping the computing tasks to multiple computing units for calculation, obtaining the inference results corresponding to the batch inference requests, and scheduling the inference tasks by adopting a hybrid scheduling strategy, and determining the optimal target segmentation strategy and target parallel strategy according to the input tensor shape and the large model weight tensor shape, so that the hardware device resources can be better utilized while meeting user needs, the efficiency of large model inference can be improved, and the resource utilization rate can be improved.

[0093] Optionally, the strategy determination module 320 is specifically configured to obtain the primary label, primary page number and secondary label corresponding to each of the computing tasks in the weight memory;

[0094] According to the first-level tag and the first-level page number, the first-level memory block number corresponding to each of the computing tasks is searched in the first-level page table, and according to the first-level memory block number and the second-level tag, the second-level memory block number corresponding to each of the computing tasks is searched in the second-level page table;

[0095] In the physical memory blocks that match the secondary memory block numbers, obtain the large model weight tensor corresponding to each of the computing tasks.

[0096] Optionally, the large model reasoning device also includes:

[0097] The probability acquisition module is used to obtain the recent usage probability corresponding to each stored weight tensor in the weight memory according to the probability label corresponding to each physical memory block;

[0098] The weight swap module is used to swap out the stored weight tensors to the host memory based on the least recently used strategy and according to the recent use probability corresponding to each of the stored weight tensors.

[0099] Optionally, a task scheduling module 310 is specifically used to obtain a pre-filled computing task and a decoding computing task corresponding to each inference request, and divide the pre-filled computing task into a plurality of fine-grained pre-filled sub-computing tasks based on a preset segmentation granularity;

[0100] The pre-filled sub-computation tasks and decoding computing tasks corresponding to different inference requests are interspersed and scheduled according to the task type to determine the scheduling order corresponding to each computing task.

[0101] Optionally, the task computing module 330 is specifically configured to obtain a computing unit corresponding to each computing task based on a load balancing strategy;

[0102] According to the target segmentation strategy, input tensor and large model weight tensor corresponding to each of the computing tasks, the general matrix multiplication data stream corresponding to each of the computing tasks is obtained, and large model reasoning is performed according to the scheduling order, target parallel strategy and general matrix multiplication data stream corresponding to each of the computing tasks, and the computing tasks are mapped to multiple computing units for calculation, and the reasoning results corresponding to the batch reasoning requests are obtained.

[0103] Optionally, a task computing module 330 is specifically used to map the computing tasks to multiple computing units for computing according to the target parallel strategy and general matrix multiplication data flow corresponding to each computing task, and obtain the computing results corresponding to each computing task;

[0104] According to the scheduling order and calculation results corresponding to each of the computing tasks, the inference results corresponding to the batch inference request are obtained.

[0105] Optionally, a strategy determination module 320 is specifically used to obtain the time costs corresponding to different segmentation strategies and parallel strategies according to the input tensor shape and the large model weight tensor shape corresponding to the current computing task;

[0106] The segmentation strategy and parallel strategy corresponding to the minimum time cost are obtained, and they are used as the target segmentation strategy and target parallel strategy corresponding to the current computing task respectively.

[0107] The large model reasoning device provided in the embodiment of the present invention can execute the large model reasoning method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0108] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0109] Embodiment 4

[0110] Fig.11 A schematic diagram of an electronic device 40 that can be used to implement an embodiment of the present invention is shown. The electronic device 40 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device 40 can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0111] like Fig.11 As shown, the electronic device 40 includes at least one processor 41, and a memory connected to the at least one processor 41, such as a read-only memory (ROM) 42, a random access memory (RAM) 43, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 41 can perform various appropriate actions and processes according to the computer program stored in the read-only memory 42 or the computer program loaded from the storage unit 48 to the random access memory 43. In the RAM 43, various programs and data required for the operation of the electronic device 40 can also be stored. The processor 41, the ROM 42 and the RAM 43 are connected to each other through a bus 44. The input / output (I / O) interface 45 is also connected to the bus 44.

[0112] A number of components in the electronic device 40 are connected to the I / O interface 45, including: an input unit 46, such as a keyboard, a mouse, etc.; an output unit 47, such as various types of displays, speakers, etc.; a storage unit 48, such as a disk, an optical disk, etc.; and a communication unit 49, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 49 allows the electronic device 40 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0113] The processor 41 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 41 include, but are not limited to, a central processing unit, a graphics processing unit, various special artificial intelligence computing chips, various processors running machine learning model algorithms, digital signal processors, and any appropriate processors, controllers, microcontrollers, etc. The processor 41 performs the various methods and processes described above, such as the large model reasoning method.

[0114] In some embodiments, the large model reasoning method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 48. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 40 via the ROM 42 and / or the communication unit 49. When the computer program is loaded into the RAM 43 and executed by the processor 41, one or more steps of the large model reasoning method described above may be performed. Alternatively, in other embodiments, the processor 41 may be configured to execute the large model reasoning method in any other appropriate manner (e.g., by means of firmware).

[0115] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays, application specific integrated circuits, application specific standard products, systems on a chip, load programmable logic devices, computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0116] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0117] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, an optical fiber, a portable compact disk read-only memory, an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0118] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device 40 having: a display device (e.g., a cathode ray tube or a liquid crystal display) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which the user can provide input to the electronic device 40. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0119] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local area networks, wide area networks, blockchain networks, and the Internet.

[0120] A computing system may include clients and servers. Clients and servers are generally remote from each other and typically interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other. The server may be a cloud server.

[0121] This embodiment may also include a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the large model reasoning method provided by any embodiment of the present invention.

[0122] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0123] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A large model reasoning method, characterized in that: include: Obtain real-time multi-user coarse-grained batch inference requests, and use a hybrid scheduling strategy to schedule the batch inference requests, obtaining multiple fine-grained computing tasks and the corresponding scheduling order; Obtain the input tensor, input tensor shape, large model weight tensor and large model weight tensor shape corresponding to each of the computing tasks, and obtain the target segmentation strategy and target parallel strategy corresponding to each of the computing tasks according to the input tensor shape and the large model weight tensor shape; Large model inference is performed according to the scheduling order, target segmentation strategy, target parallel strategy, input tensor and large model weight tensor corresponding to each of the computing tasks, the computing tasks are mapped to multiple computing units for calculation, and the inference results corresponding to the batch inference requests are obtained.

2. The method according to claim 1, characterized in that: Obtain the large model weight tensor corresponding to each of the computing tasks, including: In the weight memory, obtaining the primary label, primary page number and secondary label corresponding to each of the computing tasks; According to the first-level tag and the first-level page number, the first-level memory block number corresponding to each of the computing tasks is searched in the first-level page table, and according to the first-level memory block number and the second-level tag, the second-level memory block number corresponding to each of the computing tasks is searched in the second-level page table; In the physical memory blocks that match the secondary memory block numbers, obtain the large model weight tensor corresponding to each of the computing tasks.

3. The method according to claim 2, characterized in that Also includes: In the weight memory, according to the probability label corresponding to each physical memory block, the recent usage probability corresponding to each stored weight tensor is obtained; Based on the least recently used strategy, the stored weight tensors are swapped out to the host memory according to the recent usage probabilities corresponding to the stored weight tensors.

4. The method according to claim 1, characterized in that: A hybrid scheduling strategy is used to schedule batch inference requests and obtain multiple fine-grained computing tasks and corresponding scheduling orders, including: Obtaining a pre-filling computing task and a decoding computing task corresponding to each inference request, and dividing the pre-filling computing task into a plurality of fine-grained pre-filling sub-computing tasks based on a preset segmentation granularity; The pre-filled sub-computation tasks and decoding computing tasks corresponding to different inference requests are interspersed and scheduled according to the task type to determine the scheduling order corresponding to each computing task.

5. The method according to claim 1, characterized in that Performing large model reasoning according to the scheduling order, target segmentation strategy, target parallel strategy, input tensor and large model weight tensor corresponding to each of the computing tasks, mapping the computing tasks to multiple computing units for calculation, and obtaining the reasoning results corresponding to the batch reasoning request, including: Based on the load balancing strategy, obtaining the computing unit corresponding to each of the computing tasks; According to the target segmentation strategy, input tensor and large model weight tensor corresponding to each of the computing tasks, the general matrix multiplication data stream corresponding to each of the computing tasks is obtained, and large model reasoning is performed according to the scheduling order, target parallel strategy and general matrix multiplication data stream corresponding to each of the computing tasks, and the computing tasks are mapped to multiple computing units for calculation, and the reasoning results corresponding to the batch reasoning requests are obtained.

6. The method according to claim 5, characterized in that Performing large model reasoning according to the scheduling order, target parallel strategy and general matrix multiplication data flow corresponding to each of the computing tasks, mapping the computing tasks to multiple computing units for calculation, and obtaining reasoning results corresponding to the batch reasoning request, including: According to the target parallel strategy corresponding to each of the computing tasks and the general matrix multiplication data flow, the computing tasks are mapped to multiple computing units for computing, and the computing results corresponding to each of the computing tasks are obtained; According to the scheduling order and calculation results corresponding to each of the computing tasks, the inference results corresponding to the batch inference request are obtained.

7. The method according to claim 1, characterized in that According to the input tensor shape and the large model weight tensor shape, the target segmentation strategy and the target parallel strategy corresponding to each of the computing tasks are obtained, including: According to the input tensor shape and the large model weight tensor shape corresponding to the current computing task, obtain the time cost corresponding to different splitting strategies and parallel strategies; The segmentation strategy and parallel strategy corresponding to the minimum time cost are obtained, and they are used as the target segmentation strategy and target parallel strategy corresponding to the current computing task respectively.

8. An electronic device, characterized in that: The electronic device comprises: at least one processor, and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the large model reasoning method according to any one of claims 1 to 7.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is used to enable a processor to implement the large model reasoning method according to any one of claims 1 to 7 when executed.

10. A computer program product, characterized in that The invention comprises a computer program, which implements the large model reasoning method according to any one of claims 1 to 7 when being executed by a processor.

Citation Information

Cited By

  • Large model reasoning scheduling method based on off-network computing power server

    CN119537032A

  • Target detection and identification task processing method and device, electronic equipment and storage medium

    CN121053369A

  • Parallel reasoning method, device and equipment for multiple LoRA large models and medium

    CN122287920A

  • Parallel inference method, device and equipment of multi-lora large model and medium

    CN122287920B

  • Large model reasoning method and device, equipment, medium and product

    CN122412113A