Inference method and apparatus based on neural network

By storing the complete weight matrix on the accelerator and performing data sharding and interaction, and adopting All-to-All communication, the problem of high communication latency in distributed parallel deployment is solved, and inference efficiency is improved.

CN123159503APending Publication Date: 2026-11-24HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510661027.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-21
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

When deploying large models in a distributed and parallel manner, the communication latency between computing devices is relatively large, resulting in low overall inference efficiency.

Method used

By storing the complete weight matrix on each accelerator and performing data sharding and interaction, an all-to-all communication method is adopted to achieve parallel data processing and reduce the amount of communication between accelerators.

Benefits of technology

It effectively shortens communication latency and improves overall reasoning efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123159503A_ABST
    Figure CN123159503A_ABST
Patent Text Reader

Abstract

This application provides a neural network-based inference method and apparatus. The method includes: each accelerator acquiring a first data slice and the complete weight matrix corresponding to the first linear layer of the neural network. The first data slices acquired by N accelerators respectively form first data. Each accelerator interacts with other accelerators to obtain a portion of its own first data slice, resulting in a second data slice. Each accelerator performs inference on the second data slice based on the complete weight matrix corresponding to the first linear layer, obtaining a first inference result slice. The N accelerators aggregate their respective first inference result slices to obtain a first inference result for the first data, thereby improving inference efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence, and more particularly to a reasoning method and apparatus based on neural networks. Background Technology

[0002] In existing model inference solutions, large-scale model inference deployment scenarios often have very high requirements for inference latency in order to respond quickly to user input. As the scale of large models continues to grow, a distributed parallel deployment approach can be adopted to complete the deployment of large models, achieving larger-scale and more efficient model inference.

[0003] Currently, distributed parallel deployment schemes can include data parallelism, pipelined parallelism, and tensor parallelism. Among them, tensor parallelism enables the distributed deployment of large model weights by partitioning the weights. However, during inference, the computing devices need to communicate frequently to exchange their inference results. Due to bandwidth limitations, the communication latency between computing devices is relatively large, thus reducing the overall inference efficiency. Summary of the Invention

[0004] This application provides a reasoning method and apparatus based on neural networks, which can effectively improve reasoning efficiency.

[0005] In a first aspect, this application provides a neural network-based inference method applied to N accelerators. The method includes: each accelerator acquiring a first data slice and a complete weight matrix corresponding to the first linear layer of the neural network; wherein: the neural network includes multiple linear layers, each linear layer corresponds to a weight matrix, the multiple linear layers include a first linear layer, and the first data slices acquired by each of the N accelerators constitute first data; each accelerator interacts with other accelerators to obtain a portion of the data slices in its respective first data slice to obtain a second data slice, wherein the second data slice includes a portion of the data slices from other accelerators and a remaining data slice, the remaining data slice being the portion of its own corresponding first data slice excluding the portion of the data slices interacting with another accelerator; each accelerator performs inference on the second data slice based on the complete weight matrix corresponding to the first linear layer to obtain a first inference result slice; the N accelerators aggregate their respective first inference result slices to obtain a first inference result of the first data. In this way, by using a "store-to-transfer" approach, the accelerators obtain the complete weight matrix. Furthermore, the all-to-all exchange method among the accelerators ensures that each accelerator receives different data, thus achieving the effect of converting tensor parallelism into data parallelism. That is, each accelerator uses the same model, but the input data is different. Additionally, the data sharding method used in the interaction part of this embodiment effectively reduces the communication volume between accelerators, thereby shortening the overall communication latency and improving inference efficiency.

[0006] In one possible implementation, before each accelerator obtains the complete weight matrix corresponding to the first data slice and the first linear layer of the neural network, the method further includes: each accelerator obtaining the second data and the partial weight matrix corresponding to the second linear layer of the neural network; wherein: multiple linear layers include the second linear layer, and the partial weight matrices obtained by each of the N accelerators constitute the complete weight matrix corresponding to the second linear layer; each accelerator performs inference on the second data based on the partial weight matrix to obtain the first data slice. Thus, after the first matrix multiplication, this application obtains a first data slice with a dimension smaller than the first data, and interacts based on the smaller-dimensional partial data slices within the first data slice, thereby effectively reducing communication volume and shortening communication latency.

[0007] For example, the second linear layer is the layer preceding and adjacent to the first linear layer.

[0008] In one possible implementation, before each accelerator obtains the complete weight matrix corresponding to the first data shard and the first linear layer of the neural network, the method includes: each accelerator obtaining a first inference task, the first inference task instructing each accelerator to store the complete weight matrix corresponding to each of the multiple linear layers; each accelerator storing the complete weight matrix of each of the multiple linear layers based on the first inference task; wherein: the first inference task is generated by the cloud platform based on the current storage occupancy status of the N accelerators and sent to the N accelerators.

[0009] In one possible implementation, before each accelerator obtains the complete weight matrix corresponding to the first data shard and the first linear layer of the neural network, the method includes: each accelerator obtaining a second inference task, the second inference task instructing each accelerator to store the complete weight matrix corresponding to at least one linear layer among a plurality of linear layers, and partial weight matrices of the other linear layers besides the at least one linear layer, the at least one linear layer including the first linear layer; each accelerator, based on the second inference task, stores the complete weight matrix corresponding to at least one linear layer among a plurality of linear layers, and partial weight matrices of the other linear layers besides the at least one linear layer; wherein: the second inference task is generated by the cloud platform based on the current storage occupancy status of N accelerators and sent to the N accelerators. In this way, the cloud platform can rationally plan the linear layers using the "store-to-transfer" scheme of this application based on the storage occupancy status, so as to balance the relationship between memory consumption and communication volume.

[0010] In one possible implementation, each accelerator obtains the complete weight matrix corresponding to the first data slice and the first linear layer of the neural network, including: each accelerator obtains the complete weight matrix corresponding to the first linear layer from the stored weight matrix.

[0011] In one possible implementation, the method further includes: each accelerator acquiring a third inference task, which instructs each accelerator to acquire a partial weight matrix of a third linear layer, where multiple linear layers include the third linear layer; wherein: the third inference task is generated by the cloud platform based on the current memory usage of the N accelerators; each accelerator, based on the third inference task, acquires a partial weight matrix from the complete weight matrix of the third linear layer and the stored data; the partial weight matrices acquired by the N accelerators respectively form the complete weight matrix corresponding to the third linear layer; each accelerator performs inference on the third data based on the partial weight matrix to obtain a second inference result shard; the N accelerators aggregate their respective second inference result shards to obtain the second inference result of the third data. In this way, the cloud platform can monitor storage usage in real time and dynamically change strategies to adapt to different scenario requirements.

[0012] Secondly, this application provides a neural network-based inference device applied to each of N accelerators. The device includes: an acquisition module for acquiring a first data slice and a complete weight matrix corresponding to a first linear layer of the neural network; wherein: the neural network includes multiple linear layers, each linear layer corresponds to a weight matrix, the multiple linear layers include a first linear layer, and the first data slices acquired by each of the N accelerators constitute first data; an interaction module for interacting with other accelerators to obtain a second data slice, wherein the second data slice includes a partial data slice from other accelerators and a remaining data slice, the remaining data slice being the portion of its own corresponding first data slice excluding the partial data slice interacted with another accelerator; an inference module for inferring the second data slice based on the complete weight matrix corresponding to the first linear layer to obtain a first inference result slice; and a convergence module for converging the first inference result slices of each of the N accelerators to obtain a first inference result of the first data.

[0013] In one possible implementation, the feature is that the acquisition module is further configured to acquire the second data and the partial weight matrix corresponding to the second linear layer of the neural network; wherein: the multiple linear layers include the second linear layer, and the partial weight matrices acquired by each of the N accelerators form the complete weight matrix corresponding to the second linear layer; the inference module is further configured to perform inference on the second data based on the partial weight matrix to obtain the first data slice.

[0014] In one possible implementation, the acquisition module is further configured to acquire a first inference task, the first inference task instructing each accelerator to store the complete weight matrix corresponding to each of the multiple linear layers; the device further includes a storage module configured to store the complete weight matrix of each of the multiple linear layers based on the first inference task; wherein: the first inference task is generated by the cloud platform based on the current storage occupancy status of the N accelerators and sent to the N accelerators.

[0015] In one possible implementation, the feature is that the acquisition module is further configured to acquire a second inference task, the second inference task instructing each accelerator to store the complete weight matrix corresponding to at least one linear layer among a plurality of linear layers, and the partial weight matrices of the other linear layers besides the at least one linear layer, the at least one linear layer including a first linear layer; the storage module is configured to store, based on the second inference task, the complete weight matrix corresponding to at least one linear layer among a plurality of linear layers, and the partial weight matrices of the other linear layers besides the at least one linear layer; wherein: the second inference task is generated by the cloud platform based on the current storage occupancy status of N accelerators and sent to N accelerators.

[0016] In one possible implementation, the acquisition module is specifically used to: obtain the complete weight matrix corresponding to the first linear layer from the stored weight matrix.

[0017] In one possible implementation, the feature is that the acquisition module is further configured to acquire a third inference task, which instructs each accelerator to acquire a partial weight matrix of a third linear layer, wherein multiple linear layers include the third linear layer; wherein: the third inference task is generated by the cloud platform based on the current memory usage of the N accelerators; the acquisition module is further configured to acquire, based on the third inference task, a partial weight matrix from the complete weight matrix of the third linear layer and the stored data; the partial weight matrices acquired by each of the N accelerators form the complete weight matrix corresponding to the third linear layer; the inference module is further configured to perform inference on the third data based on the partial weight matrix to obtain a second inference result shard; the aggregation module is further configured to aggregate the respective second inference result shards to obtain a second inference result of the third data.

[0018] Thirdly, embodiments of this application provide a computing device cluster, including at least one computing device, each computing device including a processor and a memory, wherein the processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster performs the management method in the first aspect or any possible implementation of the first aspect.

[0019] Fourthly, embodiments of this application provide a computer program product containing instructions that, when executed by a computing device cluster, cause the computing device cluster to perform the management method in the first aspect or any possible implementation thereof.

[0020] Fifthly, embodiments of this application provide a computer-readable storage medium including computer program instructions, which, when executed by a cluster of computing devices, enable the cluster of computing devices to perform the management method in the first aspect or any possible implementation thereof. Attached Figure Description

[0021] Figure 1 This is an illustrative diagram illustrating the training and inference of a deep learning model.

[0022] Figure 2 This is a schematic diagram of a cloud system architecture as an example.

[0023] Figure 3 This is an example diagram illustrating the deployment of an AI model.

[0024] Figure 4 This is an example diagram illustrating the deployment of an AI model.

[0025] Figure 5 This is an example of a data parallelism diagram;

[0026] Figure 6 This is a schematic diagram of the tensor parallel mode;

[0027] Figure 7 This is a schematic diagram of the All-Reduce process as an example.

[0028] Figure 8 This is a schematic diagram of the structure of a cloud platform as an example.

[0029] Figure 9 This is a schematic diagram illustrating an exemplary neural network-based reasoning method.

[0030] Figure 10 An All-to-All diagram is shown as an example;

[0031] Figure 11 This is a schematic diagram illustrating the reasoning process as an example.

[0032] Figure 12 The comparison diagram is shown as an example.

[0033] Figure 13 This is a schematic diagram of the device structure as an example.

[0034] Figure 14This is a schematic diagram illustrating the structure of a computing device as an example.

[0035] Figure 15 This is a schematic diagram illustrating the structure of a computing device as an example.

[0036] Figure 16 This is a schematic diagram illustrating the structure of a computing device cluster as an example. Detailed Implementation

[0037] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.

[0038] Before describing the technical solutions of the embodiments of this application, a brief introduction to the technical background and technical terms involved in the embodiments of this application will be given first:

[0039] 1. Artificial Intelligence (AI) Model

[0040] The typical structure of current deep learning models is a deep neural network. A neural network is a mathematical or computational model that mimics the structure and function of biological neural networks (the central nervous system of animals, especially the brain). Neural networks perform computations through a large number of interconnected neurons. A neural network can include multiple neural network layers with different functions.

[0041] Depending on the calculation formula or function, different layers in a neural network have different names. For example, the layer that performs convolution calculations is called a convolutional layer, which is often used to extract features from input signals (e.g., images).

[0042] In this embodiment, each neural network layer may include at least one linear layer, also known as a fully connected layer (FC layer), which is one of the most fundamental components in deep learning. Each linear layer corresponds to a weight matrix, which includes multiple weight coefficients.

[0043] Let's take input data X and weight matrix W as an example. X has dimensions (b, s, h), and W has dimensions (h, h'). In this example, multiplying X and W yields Y, which also has dimensions (b, s, h'). Where:

[0044] b is batch_size, representing the batch size.

[0045] s is the sequence_length, representing the length of the input sequence.

[0046] h is hidden_size, representing the dimension of each token vector.

[0047] h' is the hidden_size of W.

[0048] Classic deep learning models include convolutional neural networks (CNN), recurrent neural networks (RNN), and recursive neural networks (RNN).

[0049] 2. Model Training and Inference

[0050] Reference Figure 1 , Figure 1 This is an illustrative diagram illustrating the training and inference processes of a deep learning model. Any AI model needs to be trained before it can be used to solve a specific technical problem. AI model training refers to using a specified initial model to compute on training data, and then adjusting the parameters of the initial model based on the computation results, allowing the model to gradually learn certain patterns and acquire specific functions. Once trained and possessing stable functionality, the AI ​​model can be used for inference. AI model inference is the process of using the trained AI model to compute on input data and obtain predicted inference results.

[0051] 3. AI Basic Development Platform

[0052] Reference Figure 2 , Figure 2 This is a schematic diagram of a cloud system architecture as an example. The public cloud AI basic development platform is a PaaS cloud service within the cloud platform (also known as the cloud management platform). It is a software platform that provides assistance to users (also known as tenants, AI developers, etc.) in building, training, and deploying AI models, as well as developing and deploying AI applications, based on the extensive basic resources and software capabilities possessed by the public cloud service provider.

[0053] like Figure 2 As shown, the main interaction patterns between users and the AI ​​basic development platform include: users log in to the cloud platform through a client webpage, select and purchase cloud services of the AI ​​basic development platform in the cloud platform, and after purchase, users can carry out the entire process of AI development based on the functions provided by the AI ​​basic development platform.

[0054] When users develop and train their own AI models on an AI infrastructure development platform, it is based on the basic resources (mainly computing resources, such as CPU, GPU, NPU, etc.) in the data center of the cloud service provider.

[0055] Reference Figure 3 , Figure 3 This is an illustrative diagram illustrating AI model deployment. For example, a trained, optimized, and / or transformed AI model can be deployed on nodes in a cloud environment or on nodes in an edge environment. Nodes in the cloud environment can be virtual machine instances, container instances, physical servers, etc. On one hand, when the AI ​​model is large-scale, it can be distributed and deployed across multiple nodes based on the concept of model parallelism. On the other hand, the AI ​​model can also be deployed independently on multiple nodes to support a large volume of online service access. Nodes in the edge environment can be various edge devices. Depending on the application requirements of the AI ​​model, the AI ​​infrastructure development platform can deploy AI applications to edge devices registered with the cloud platform.

[0056] Once deployed, the AI ​​model can become an AI application, or a part of an AI application. For example... Figure 4 As shown, users can access AI applications online via a webpage or a client app. When an AI application is used, it can invoke AI models deployed in edge or cloud environments to provide a response via online invocation.

[0057] Therefore, AI models developed and trained through the AI ​​infrastructure development platform can perform inference on online request data and return inference results. When providing online services using AI models, the cloud platform can charge based on the number of times the AI ​​model is invoked, or based on the resource consumption of the AI ​​model's inference.

[0058] During the process of the AI ​​model providing online inference services, the AI ​​basic development platform can continuously collect input and output data of the inference process, and continue to perform data optimization and model optimization updates based on the data of the inference process. That is, it can continue to enrich the training dataset with the data of the inference stage, and continue to optimize and train the AI ​​model based on the data of the inference stage and the corresponding results after manual confirmation.

[0059] It should be understood that in other cases, AI models developed and trained by the aforementioned AI infrastructure development platform may not be deployed online, but rather users can download the trained AI model to their local machine for free local deployment. For example, users can choose to save the trained AI model to OBS, and then download AI model A locally from OBS.

[0060] In other cases, after User 1 has trained an AI model using the aforementioned AI infrastructure development platform 100, it can publish the model to the AI ​​marketplace, where other users can subscribe to and use the AI ​​model.

[0061] During the pre-deployment phase, AI applications can be deployed independently on one or more computing devices. When deployed on multiple computing devices, each computing device runs all the functional operators of the AI ​​application, and each computing device can independently execute the functions of the AI ​​application. On the one hand, it can be combined with a load balancing module to distribute the request volume evenly among multiple computing devices. On the other hand, it can achieve disaster recovery, so that when one computing device fails, the AI ​​application on other computing devices can continue to provide services as usual.

[0062] In the pre-deployment phase, the various functional operators of an AI application can also be distributed across multiple computing devices, which then collaboratively run the AI ​​application according to its data dependencies. It should be understood that computing devices can be accelerators, such as AI chips (e.g., chips including central processing units (CPUs), graphics processing units (GPUs), field-programmable gate arrays (FPGAs), or application-specific integrated circuits (ASICs)).

[0063] 3. Distributed Parallel Mode

[0064] In large model frameworks, the computing power of a single computing node is insufficient to meet the demands of the increased data volume and model complexity. To improve inference efficiency and accelerate the inference process, distributed parallel inference can be adopted. Distributed parallel modes for AI models include, but are not limited to: data parallelism (DP), pipeline parallelism (PP), and tensor parallelism (TP).

[0065] 4. Data Parallel Mode

[0066] Reference Figure 5 , Figure 5 This is a schematic diagram illustrating data parallelism as an example.

[0067] Data parallelism specifically refers to deploying the same AI model on multiple nodes (e.g., nodes 1, 2, 3, ..., N), and dividing the dataset into multiple data subsets (also known as mini-batches), distributing them across various nodes (i.e., computing devices, or the accelerators described in this application embodiment). Each node independently uses its AI model to perform inference (or computation) on the data in its corresponding data subset to obtain the inference result.

[0068] Each node can be an accelerator as described in this application embodiment, such as a GPU, a virtual machine instance, or a container instance.

[0069] 5. Parallel pipeline mode

[0070] It divides the different layers of the model into different nodes (i.e., accelerators). After the input completes the calculation of the model layer on a node, it is transferred to the next card for calculation, thus forming a pipeline. Finally, the model is output on the last node in the pipeline.

[0071] 6. Tensor Parallel Mode

[0072] The TP parallel mode reduces the weight size loaded on each node by uniformly distributing model weights across multiple nodes, making it possible to train a billion-scale model in a large batch with multiple nodes.

[0073] Specifically, the weight matrix of the linear layers in the model can be partitioned according to the output dimension, so that each accelerator only processes a portion of the linear layer computation, and the outputs of different accelerators are independent of each other. For the next linear layer in the model, in order to ensure the consistency of the matrix multiplication inner product axis dimension, the weights of the linear layer need to be partitioned according to the inner product axis dimension, and after the linear layer, a summation operation of the activation values ​​between accelerators is required to ensure mathematical equivalence.

[0074] For example, refer to Figure 6 , Figure 6This is a schematic diagram of the tensor parallel mode. Accelerator 1 and Accelerator 2 acquire data A. The dimensions of data A are, for example, (b, s, h). The weight matrix B of the current linear layer is partitioned according to the output dimension. Accelerator 1 loads the partitioned matrix B1, and Accelerator 2 loads the partitioned matrix B2. The dimensions of weight matrix B are (h, h'), and the dimensions of B1 and B2 are (h, h' / N), where N is the number of accelerators participating in the tensor parallel mode, which is 2. Taking Accelerator 1 as an example, it uses matrix B1 and data A to perform calculations (i.e., matrix multiplication, which can be called the first matrix multiplication calculation), obtaining the calculation result C1 (which can also be called the inference result of the current linear layer, or the inference result of data A). The dimensions of matrix C1 are (b, s, h' / N). The weight matrix D of the next linear layer of the model is partitioned according to the inner product axis dimension, resulting in matrices D1 and D2. Accelerator 1 loads matrix D1, and Accelerator 2 loads matrix D2. Where D1 and D2 have dimensions (h' / N, h). Taking accelerator 1 as an example, accelerator 1 performs matrix multiplication (which can be called the second matrix multiplication) on matrix C1 and matrix D1 to obtain the inference result O1. Where matrix O1 has dimensions (b, s, h). The processing of accelerator 2 is similar to that of accelerator 1, and will not be described in detail here.

[0075] Accelerator 1 and Accelerator 2 communicate with each other to exchange their inference results. Thus, Accelerator 1 obtains O2, and Accelerator 2 obtains O1. Taking Accelerator 1 as an example again, Accelerator 1 merges O1 and O2 to obtain the superposition result O of O1 and O2. The dimensions of matrix O are (b, s, h). The calculation for the next linear layer can be repeated. Figure 6 The steps in the process.

[0076] Optionally, the convergence operation described in the embodiments of this application may include an overlay method (i.e., All-Reduce) and a splicing method (i.e., All-Gather). For example, Figure 6 The convergence operation of matrices O1 and O2 in the above example is called superposition, that is, adding matrices O1 and O2 together. For another example, if the computation result of the last linear layer in a neural network is as follows... Figure 6 As shown in matrices C1 and C2, accelerator 1 and accelerator 2 interact with each other's inference results. Taking accelerator 1 as an example, accelerator 1 obtains matrix C2, and then concatenates matrix C1 and matrix C2 to obtain a complete matrix C. The dimension of matrix C is (b,s,h'). This operation is called the All Gather operation.

[0077] 7. All-Reduce

[0078] The communication process of All-Reduce after the second matrix multiplication can be divided into two steps: the first step is Reduce-Scatter (aggregation-dispersion), and the second step is All-Gather (all aggregation).

[0079] Reference Figure 7 , Figure 7 This is a schematic diagram illustrating the All-Reduce process. Specifically, after the second matrix multiplication, accelerator 1 and accelerator 2 exchange their respective partial calculation results and perform superposition calculations to obtain a partial summation result. For example, accelerator 1 obtains O2_2, adds it to O1_2, and obtains the corresponding matrix. The exchanged partial calculation results represent data at equivalent positions in the matrices obtained by each accelerator. For instance, if accelerator 1 sends O1_2 to accelerator 2, O1_2 and O2_2 are equivalent data, meaning they occupy the same position in the matrix. Next, accelerator 1 and accelerator 2 exchange their respective All-Reduce execution results. Taking accelerator 1 as an example, accelerator 1 obtains the matrix (O1_2 + O2_2) sent by accelerator 2. Accelerator 1 concatenates its own matrix with the obtained matrix to obtain matrix O (also known as the activation data). The execution steps of accelerator 2 are similar and will not be described further here.

[0080] Therefore, in the tensor parallel mode of existing technologies, inference of a linear layer requires two inter-card communications. The amount of communication between these two interactions is large, resulting in a large communication latency and affecting the overall inference efficiency.

[0081] This application provides a neural network-based reasoning method that can effectively reduce the amount of data exchanged, thereby reducing communication latency and improving overall reasoning efficiency.

[0082] Reference Figure 8 , Figure 8 This is a schematic diagram illustrating the structure of a cloud platform as an example. In this embodiment, the cloud platform includes, but is not limited to, a detection module, a policy module, and a resource management module.

[0083] Specifically, the detection module is used to monitor the storage (e.g., memory) usage of each accelerator participating in this training in real time.

[0084] The strategy module is used to generate an inference strategy based on the current memory usage detected by the detection module, the memory space required for the neural network model parameters (i.e., the weight matrices of each linear layer), and the memory space required for the inference results of each linear layer. The inference strategy indicates the number of linear layers from which the inference method described in this embodiment can be used.

[0085] The resource management module is used to distribute inference tasks to each accelerator based on the inference strategy generated by the strategy module. The inference task indicates the model parameters to be loaded by each accelerator. The calculation of all or part of the linear layers in the model can use the inference method described in this embodiment, and the specific number depends on the number of layers calculated by the strategy module.

[0086] The inference method in this application can be applied to N accelerators, where N is an integer greater than 1. Accelerators can be GPUs, NPUs, etc., and in some instances, they can also be referred to as computing devices, computing nodes, etc., which is not limited in this application. A single accelerator can include, but is not limited to, a communication interface, storage, and operators. The communication interface is used to receive or send data. Storage is used to store data, such as a weight matrix. Operators are used to perform calculations on the data based on the weight matrix (i.e., perform the inference process) to obtain the calculation result (also referred to as the inference result).

[0087] Optionally, a single accelerator can execute one inference process or multiple inference processes in parallel. A single inference process can be understood as each layer of the neural network performing computations (i.e., inference) on the input data to obtain the final computation result. Among the N accelerators participating in the same inference process, some accelerators may be executing other inference processes.

[0088] Reference Figure 9 , Figure 9 The following is a flowchart illustrating an exemplary neural network-based inference method, which includes, but is not limited to, the following steps:

[0089] S901, each accelerator obtains the first data slice and the complete weight matrix corresponding to the first linear layer of the neural network; wherein: the neural network includes multiple linear layers, each linear layer corresponds to multiple weight matrices, the multiple linear layers include the first linear layer, and the first data slices obtained by each of the N accelerators constitute the first data.

[0090] In the embodiments of this application, each accelerator can subsequently obtain the complete weight coefficients corresponding to the first data slice and the first linear layer of the neural network (also known as the neural network model).

[0091] Optionally, the first data slice may be the computation result of the preceding linear layer adjacent to the first linear layer.

[0092] Optionally, the first data slices acquired by each of the N accelerators are different.

[0093] Optionally, the first data is a matrix, whose dimensions can be represented as (b, s, h'), as described above. It can be understood that by concatenating the first data slices acquired by N accelerators, we can obtain the first data with dimensions (b, s, h'). Each first data slice is actually a part of the first data, and its dimension can be understood as being obtained by dividing the first data according to the row dimension, or by dividing the first data according to the column dimension. It should be noted that this does not actually involve performing a division of the first data; it is merely to illustrate the correspondence between the first data slices and the first data.

[0094] For example, each accelerator also obtains the complete weight matrix corresponding to the first linear layer of the neural network. Specifically, each accelerator preloads and stores the complete weight matrix of the first linear layer. During the inference phase, each accelerator can retrieve the complete weight matrix of the first linear layer from storage (e.g., memory).

[0095] The neural network comprises multiple neural network layers, each layer including at least one linear layer. Each linear layer corresponds to a weight matrix. The dimensions of the weight matrices for each linear layer are the same, for example, (h, h'), as described above. Each weight matrix includes multiple weight coefficients.

[0096] Wherein: the first linear layer can be any linear layer other than the first linear layer.

[0097] S902, each accelerator interacts with other accelerators to obtain a portion of the data in its first data slice to obtain a second data slice. The second data slice includes a portion of the data from other accelerators and a remaining data slice. The remaining data slice is the portion of its corresponding first data slice excluding the portion of the data that interacts with another accelerator.

[0098] In the embodiments of this application, before performing calculations, each accelerator uses an All-to-All communication method to interact with other accelerators to obtain a portion of the data in its first data slice, in order to obtain a second data slice.

[0099] Reference Figure 10 , Figure 10This is an example illustrating an All-to-All diagram. Taking N = 2 (accelerator 1 and accelerator 2) as an example, the first data slices acquired by each accelerator 1 and accelerator 2 are shown in the shaded area. The first data formed by the first data slices of each accelerator 1 and accelerator 2 is the matrix shown by the dashed line. Accelerator 1 and accelerator 2 divide their respective first data slices into N equal parts, i.e., 2 parts, resulting in two matrices. For example, accelerator 1 obtains matrices a1 and b1, and accelerator 2 obtains matrices a2 and b2. Accelerator 1 and accelerator 2 exchange partial data slices of their respective first data slices. For example, accelerator 1 sends matrix b1 to accelerator 2, and accelerator 2 sends matrix a2 to accelerator 1.

[0100] Optionally, the positions corresponding to the partial data slices interacting with each accelerator are different. This position refers to the position of the matrix corresponding to the partial data slice within the matrix corresponding to the first data slice.

[0101] Optionally, Figure 10 This example uses only two accelerators. In some examples, each of the N accelerators can interact with at least one other accelerator. The purpose of this interaction is primarily to distribute local data to other accelerators and receive data distributed by other accelerators.

[0102] In this way, each accelerator can obtain a second data slice, which includes partial data slices from other accelerators and a remaining data slice. The remaining data slice is the portion of its corresponding first data slice excluding the data slice that interacts with another accelerator. For example, refer to... Figure 10 Taking accelerator 1 as an example, accelerator 1 sends matrix b1 to accelerator 2, which can delete matrix b1. Furthermore, accelerator 1 receives matrix a2 from accelerator 2. Accelerator 1 concatenates matrix a1 and matrix a2 to obtain the second data slice. Here, matrix a1 is the remaining data slice, and matrix a2 is the partial data slice from other accelerators.

[0103] S903, each accelerator performs inference on the second data slice based on the complete weight matrix corresponding to the first linear layer to obtain the first inference result slice.

[0104] Specifically, after each accelerator obtains its own second data slice, it can perform inference (or calculation) on the second data slice based on the complete weight matrix corresponding to the first linear layer to obtain the first inference result slice.

[0105] Reference Figure 11 , Figure 11 This is a schematic diagram illustrating the reasoning process as an example. Specifically, in conjunction with... Figure 10In the example shown, accelerator 1 and accelerator 2 each obtain the complete weight matrix W of the first linear layer. Taking accelerator 1 as an example, accelerator 1 uses the weight matrix W to infer the second data slice (i.e., matrix a1 and matrix a2), that is, to perform matrix multiplication to obtain the first inference result slice, i.e., matrix Y1. Its dimension can optionally be (b / 2, s, h').

[0106] S904, N accelerators will merge their respective first inference results into a single data set.

[0107] For example, such as Figure 11 As shown, each accelerator aggregates its own first inference result fragments. That is, each accelerator sends its own first inference result fragment to other accelerators; in other words, each accelerator can receive first inference result fragments sent by the other N-1 accelerators. Each accelerator then concatenates its own first inference result fragment with the first inference result fragments received from other accelerators to obtain the first inference result of the first data. This aggregation process can be understood as an All-Gather operation, where each accelerator exchanges all its own data and concatenates its own data with all the received data.

[0108] In other words, in the process of using the weight matrix of the first linear layer to infer the first data and obtain the first inference result, the accelerators in this embodiment first interact with data shards in an all-to-all manner, and each accelerator stores a complete weight matrix of a linear layer, thereby achieving a data parallel (DP) processing method. As mentioned above, in the data parallel mode, the model (i.e., weight matrix) loaded by each accelerator is the same, but the data input to each accelerator is different. Similarly, in the implementation of this application, the data obtained by each accelerator after exchange is different, but the weights used in the calculation are the same.

[0109] Thus, in this embodiment of the application, a store-in-the-loop approach is used, meaning that each accelerator can store the complete weight matrix corresponding to the linear layer without needing to execute the data again. Figure 7 The communication flow in the Reduce-Scatter process is simplified, while the newly added All-to-All communication volume is about one-Nth of the Reduce-Scatter communication volume, thereby effectively reducing the communication volume in the inference process, further reducing the overall communication latency, and improving the overall inference efficiency.

[0110] In one possible implementation, Figure 9Prior to the method shown, the following may also be included: each accelerator acquires a partial weight matrix corresponding to the second data and the second linear layer of the neural network; wherein: multiple linear layers include the second linear layer, and the partial weight matrices acquired by each of the N accelerators constitute the complete weight matrix corresponding to the second linear layer. Each accelerator performs inference on the second data based on the partial weight matrix to obtain the first data slice. Specifically, this process is the inference process of the first matrix multiplication described above, and its specific implementation can be found in [reference needed]. Figure 6 The second data is... Figure 6 In matrix A, the partial weight matrix of the second linear layer is... Figure 6 In the given matrix B1 or B2, the first data slice is either matrix C1 or C2. Thus, each accelerator can execute [the appropriate action] based on the acquired first data slice. Figure 9 The method shown here. That is, following the order of the linear layers in the neural network, each accelerator performs operations on the preceding linear layer. Figure 6 The tensor-parallel inference process in [the context of the original text] can be used for inference of the current linear layer. Figure 9 The method shown still employs the same approach when reasoning for the next linear layer. Figure 6 The method described in this application involves alternating between the traditional tensor parallel mode and the parallel mode described in this embodiment to perform inference operations on each linear layer of the neural network. Optionally, if the last linear layer uses... Figure 6 As mentioned above, the first matrix multiplication method involves each accelerator using an All-Gather approach to aggregate its inference results to obtain the final inference result.

[0111] In one possible implementation, the cloud platform (specifically, a detection module) can determine the number of linear layers to be executed using the inference method described in this embodiment, for example, M, where M is an integer greater than or equal to 0, based on the storage (e.g., memory) usage of the N accelerators. That is, in one example, if M is 0, the system can proceed according to... Figure 6 The tensor parallel mode is executed as shown. In another example, if the value of M is greater than 0 and less than N, then the M linear layers (typically the first M linear layers arranged in the order of the neural network) employ the inference method described in the embodiments of this application, i.e., as... Figure 10 and Figure 11 As shown, the other NM linear layers can be arranged in the following manner. Figure 6The process is as shown. Specifically, the cloud platform can obtain the current memory usage of each accelerator and, combined with the memory space required for each linear layer to execute according to the method described in this embodiment, and the memory space required for caching inference results during the computation process, infer the memory space required for different numbers of linear layers to perform the inference process. Based on the inferred results, the cloud platform can determine the number M of linear layers that can use the inference process described in this embodiment. For example, assuming the neural network includes 100 linear layers, the cloud platform obtains the memory space required for different numbers of linear layers and calculates the corresponding memory occupancy rate (i.e., the ratio of required memory space to total memory space). Among them, the memory occupancy rate corresponding to 60 linear layers is A, and the memory occupancy rate corresponding to 61 linear layers is B. Where A is less than or equal to the preset memory occupancy rate (which can be set according to actual needs), and the memory occupancy rate corresponding to 61 linear layers is greater than the preset memory occupancy rate, then the value of M is 60. The cloud platform can issue inference tasks to each accelerator. These tasks instruct each accelerator to load (i.e., store) the complete weight matrix of each of the first 60 linear layers of the neural network and to load the partial weight matrix of each of the remaining 40 linear layers. The partial weight matrices obtained by N accelerators constitute the complete weight matrix of the corresponding linear layer. In this example, during inference, for any one of the first 60 linear layers, each accelerator can retrieve the complete weight matrix from storage and load it according to... Figure 9 , Figure 10 and Figure 11 The process is executed accordingly. For any one of the other 40 linear layers, each accelerator can retrieve a portion of the linear layer's weight matrix from storage and execute it according to... Figure 6 Execute as shown.

[0112] In yet another instance, if the value of M equals N, meaning all linear layers can be handled according to... Figure 9 , Figure 10 and Figure 11 The process shown is executed as follows. Specifically, the cloud platform can obtain the current memory usage of each accelerator and infer that the value of M equals N. The specific inference process can be referred to the above section and will not be repeated here. The cloud platform issues inference tasks to each accelerator, and the inference tasks instruct each accelerator to load (i.e., store) the complete weight matrix of all linear layers. In this example, each accelerator is executing... Figure 9 The process shown allows you to obtain the complete weight matrix of the corresponding linear layer.

[0113] In one possible implementation, during inference execution, the cloud platform can also obtain the memory usage rate of each accelerator in real time. The specific acquisition method is described above and will not be repeated here. In this example, the cloud platform can update the value of M in real time based on the current memory usage rate. For example, if the cloud platform determines that the M value needs updating based on the current memory usage rate, the updated M value can be greater than or less than the previous M value. In one example, if the updated M value can be greater than the previous M value, no processing is required, or a new inference task can be issued to each accelerator, causing each accelerator to load the unloaded complete weight values ​​from the updated M linear layers. In another instance, if the updated M value is less than the previous M value, the cloud platform can issue a new inference task to each accelerator, allowing each accelerator to obtain a partial weight matrix from the stored complete weight matrix when inferring linear layers not indicated by the updated M value. The partial weight matrices obtained by the N accelerators form the complete weight matrix, and are then processed according to... Figure 6 This is executed in a manner that... Specifically, each accelerator is based on a portion of the weight matrix of the third linear layer (e.g., ... Figure 6 The matrix D1 in the matrix is ​​used to infer the third data, resulting in a second inference result fragment (e.g., ...). Figure 6 (O1 in the context). N accelerators will merge their respective second inference results to obtain the second inference result of the third data (e.g., O1). Figure 6 (O in the middle).

[0114] In another possible implementation, Figure 7 In the illustrated scheme, the data transmission type of Reduce-Scatter requires half-precision format (FP16 / BF16). However, in this embodiment, the accelerator may further include a quantization module, which can quantize the first inference result into 8-bit format (INT8) data for transmission, further reducing communication overhead.

[0115] In another possible implementation, All-Gather can be understood as aggregating the DP-quantized data to complete the batch axis data. Therefore, All-Gather does not necessarily need to follow the summation operation immediately; it can be performed by placing All-Gather after the quantization operation to achieve the purpose of DP parallel computation operators between All-To-All and All-Gather. Furthermore, in the quantization module, All-Gather can be placed after quantization processing, thereby gaining the advantage of reduced communication overhead.

[0116] In another possible implementation, the cloud platform can receive user instructions, which may include, but are not limited to, input data and model parameters. Model parameters may include, but are not limited to, tensor parameters. In some instances, data parallelism parameters may also be included. Tensor parameters can be understood as the number of accelerators participating in tensor parallelism. It should be noted that the number of accelerators can be less than or equal to the number of accelerators participating in this inference. For example, if the data parallelism parameter is 2 and the tensor parameter is 4, then the number of accelerators participating in this inference is 8 (i.e., 2*4), where the 8 accelerators are divided into 2 data parallel groups, each containing 4 accelerators. The 4 accelerators in each data parallel group perform inference using tensor parallelism. The cloud platform can issue inference tasks (or computation tasks) to each accelerator based on user instructions and current memory usage. Specifically, the cloud platform can determine the number of accelerators participating in this computation based on user instructions. In this embodiment, the example uses a data parallelism and traffic parallelism of 1 and a tensor parallelism parameter of N, meaning the number of accelerators participating in this inference is N. The cloud platform can distribute inference tasks to N accelerators based on the current memory usage. For details, please refer to the above text, which will not be repeated here.

[0117] Reference Figure 12 , Figure 12 This is an illustrative comparison diagram. The inference process of the Attention layer is used as an example for explanation. The Attention layer consists of two linear layers, denoted as Matmul1 and Matmul2. In this example, N is 4. The processing flow of any one of the accelerators is used as an example. Specifically, in... Figure 12 In the existing technical process shown in (1), when performing inference operations on Matmul1, the accelerator (i.e., any accelerator) obtains a partial weight matrix w1 from Matmul1 and uses matrix w1 to perform the first matrix multiplication. The accelerator uses a partial weight matrix w2 from Matmul2 to perform the second matrix multiplication and performs the All-Reduce operation. The specific method can be found in [reference needed]. Figure 6 This will not be elaborated upon here. (Refer to...) Figure 12In embodiment (1) of this application, when performing inference operations on Matmul1, the accelerator (i.e., any accelerator) obtains a portion of the weight matrix w1 in Matmul1 and performs a first matrix multiplication using matrix w1. Then, the accelerator performs an All-to-All operation to interactively partition the data, and performs matrix multiplication with the data partition using the complete weight matrix W of Matmul2 to obtain the inference result partition. Finally, it performs an All-Gather operation to obtain the complete inference result. In this embodiment, before All-to-All and All-Gather are executed, a quantization module can perform a quantization operation to obtain 8 bits of transmitted data. Based on this method, the communication volume in this embodiment is reduced by 71.875% compared to existing technologies, thereby shortening the overall communication latency (e.g., by 14%-32%) and improving the overall inference efficiency. Note: The above values ​​are all obtained experimentally.

[0118] Optionally, in this embodiment, before the All-Gather step, each accelerator can also calculate other vector values ​​in the neural network. The inference method in this embodiment is mainly applied to the calculation of the inference process of the linear layer.

[0119] In one possible implementation, the graphite method in this application embodiment can be applied to different neural network model frameworks.

[0120] This application provides a neural network-based inference device, such as... Figure 13 As shown, the device, applied to each of N accelerators, includes: an acquisition module for acquiring a first data slice and the complete weight matrix corresponding to the first linear layer of the neural network; wherein: the neural network includes multiple linear layers, each linear layer corresponds to a weight matrix, the multiple linear layers include the first linear layer, and the first data slices acquired by each of the N accelerators constitute the first data; an interaction module for interacting with other accelerators to obtain a second data slice, wherein the second data slice includes a partial data slice from other accelerators and a remaining data slice, the remaining data slice being the portion of its own corresponding first data slice excluding the partial data slice interacted with another accelerator; an inference module for inferring the second data slice based on the complete weight matrix corresponding to the first linear layer to obtain a first inference result slice; and a convergence module for converging the first inference result slices of each of the N accelerators to obtain a first inference result of the first data.

[0121] This application also provides a computing device 1400. For example... Figure 14As shown, the computing device 1400 includes a bus 1402, a processor 1404, a memory 1406, and a communication interface 1409. The processor 1404, the memory 1406, and the communication interface 1409 communicate with each other via the bus 1402. The computing device 1400 can be a cloud server or a vehicle. It should be understood that this application does not limit the number of processors and memories in the computing device 1400.

[0122] Bus 1402 can be 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 representation, Figure 14 The bus 1402 may be represented by a single line, but this does not mean that there is only one bus or one type of bus. The bus 1402 may include a path for transmitting information between various components of the computing device 1400 (e.g., memory 1406, processor 1404, communication interface 1409).

[0123] The processor 1404 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0124] Memory 1406 may include volatile memory, such as random access memory (RAM). Memory 1406 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).

[0125] The memory 1406 stores executable program code, and the processor 1404 executes the executable program code to implement... Figure 13 The functions of each module shown are configured to implement the reasoning method in this embodiment. That is, the memory 1406 stores instructions for executing the reasoning method.

[0126] The communication interface 1409 uses transceiver modules, such as, but not limited to, network interface cards and transceivers, to enable communication between the computing device 1400 and other devices or communication networks.

[0127] This application also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a vehicle or other device with an autonomous driving mode.

[0128] like Figure 15 As shown, the computing device cluster includes at least one computing device 1500. The memory 1506 of one or more computing devices 1500 in the computing device cluster may store the same instructions for executing inference methods.

[0129] The computing device 1500 includes a bus 1502, a processor 1504, a memory 1506, and a communication interface 1508. The processor 1504, the memory 1506, and the communication interface 1508 communicate with each other via the bus 1502.

[0130] In some possible implementations, the memory 1506 of one or more computing devices 1500 in the computing device cluster may also store a portion of the instructions for executing the inference method. In other words, a combination of one or more computing devices 1500 can jointly execute the instructions for executing the inference method.

[0131] It should be noted that the memory 1506 in different computing devices 1500 within the computing device cluster can store different instructions, each for execution. Figure 13 The diagram shows some of the functions of each module.

[0132] In some possible implementations, one or more computing devices in a computing device cluster can be connected via a network. This network can be a wide area network (WAN) or a local area network (LAN), etc. Figure 16 One possible implementation is shown. For example... Figure 16 As shown, the two computing devices 1600A and 1600B are connected via a network. Specifically, they are connected to the network through the communication interface 1608 in each computing device.

[0133] The computing device 1600A includes a bus 1602, a processor 1604, a memory 1606, and a communication interface 1608. The processor 1604, the memory 1606, and the communication interface 1608 communicate with each other via the bus 1602.

[0134] The computing device 1600B includes a bus 1602, a processor 1604, a memory 1606, and a communication interface 1608. The processor 1604, the memory 1606, and the communication interface 1608 communicate with each other via the bus 1602.

[0135] In this type of possible implementation, the memory 1606 in computing device 1600A stores instructions for performing the functions of the aforementioned acquisition module and interaction module. Meanwhile, the memory 1606 in computing device 1600B stores instructions for performing the functions of the aforementioned inference module and aggregation module.

[0136] It should be understood that Figure 16 The functions of computing device 1600A shown can also be performed by multiple computing devices 1600. Similarly, the functions of computing device 1600B can also be performed by multiple computing devices 1600.

[0137] This application also provides another computing device cluster. The connection relationships between the computing devices in this computing device cluster can be similarly referred to... Figure 14 and Figure 15 The connection method of the computing device cluster. The difference is that the memory 1606 of one or more computing devices 1600 in the computing device cluster can store the same instructions for executing inference methods.

[0138] In some possible implementations, the memory 1606 of one or more computing devices 1600 in the computing device cluster may also store a portion of the instructions for executing the inference method. In other words, a combination of one or more computing devices 1600 can jointly execute the instructions for executing the inference method.

[0139] It should be noted that the memory 1606 in different computing devices 1600 in the computing device cluster can store different instructions for executing some of the functions of the aforementioned inference device.

[0140] This application also provides a computer program product containing instructions. The computer program product may be a software or program product containing instructions, capable of running on a computing device or stored on any usable medium. When the computer program product is run on at least one computing device, it causes the at least one computing device to perform the inference method described in the above embodiments.

[0141] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that a computing device can store, or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to execute the inference method described in the above embodiments.

[0142] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.

[0143] The terms "first" and "second," etc., used in the specification and claims of this application are used to distinguish different objects, not to describe a specific order of objects. For example, "first target object" and "second target object," etc., are used to distinguish different target objects, not to describe a specific order of target objects.

[0144] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0145] In the description of the embodiments in this application, unless otherwise stated, "multiple" means two or more. For example, multiple processing units means two or more processing units; multiple systems means two or more systems.

[0146] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A reasoning method based on neural networks, characterized in that, The method, applied to N accelerators, includes: Each accelerator acquires a first data slice and a complete weight matrix corresponding to the first linear layer of the neural network; wherein: the neural network includes multiple linear layers, each linear layer corresponds to a weight matrix, the multiple linear layers include the first linear layer, and the first data slices acquired by each of the N accelerators constitute the first data; Each accelerator interacts with other accelerators to obtain a portion of its first data slice to obtain a second data slice. The second data slice includes a portion of the data slice from other accelerators and a remaining data slice. The remaining data slice is the portion of its corresponding first data slice other than the portion of the data slice that interacts with another accelerator. Each accelerator performs inference on the second data slice based on the complete weight matrix corresponding to the first linear layer to obtain the first inference result slice; The N accelerators will merge their respective first inference results into a single first inference result for the first data.

2. The method according to claim 1, characterized in that, Before each of the accelerators obtains the complete weight matrix corresponding to the first data slice and the first linear layer of the neural network, the method further includes: Each accelerator acquires the second data and a partial weight matrix corresponding to the second linear layer of the neural network; wherein: the plurality of linear layers include the second linear layer, and the partial weight matrices acquired by each of the N accelerators constitute the complete weight matrix corresponding to the second linear layer; Each of the accelerators infers the second data based on the partial weight matrix to obtain the first data slice.

3. The method according to claim 1, characterized in that, Before each of the accelerators obtains the complete weight matrix corresponding to the first data slice and the first linear layer of the neural network, the method includes: Each of the accelerators acquires a first inference task, which instructs each of the accelerators to store the complete weight matrix corresponding to each of the plurality of linear layers; Each of the accelerators stores the complete weight matrix of each of the plurality of linear layers based on the first inference task; wherein: the first inference task is generated by the cloud platform based on the current storage occupancy status of the N accelerators and sent to the N accelerators.

4. The method according to claim 1, characterized in that, Before each of the accelerators obtains the complete weight matrix corresponding to the first data slice and the first linear layer of the neural network, the method includes: Each of the accelerators acquires a second inference task, which instructs each of the accelerators to store the complete weight matrix corresponding to at least one of the plurality of linear layers, and partial weight matrices of the other linear layers besides the at least one linear layer, the at least one linear layer including the first linear layer; Each accelerator stores, based on the second inference task, the complete weight matrix corresponding to at least one of the multiple linear layers, and partial weight matrices of the other linear layers besides the at least one linear layer; wherein: the second inference task is generated by the cloud platform based on the current storage occupancy status of the N accelerators and sent to the N accelerators.

5. The method according to claim 3 or 4, characterized in that, Each of the accelerators acquires the complete weight matrix corresponding to the first data slice and the first linear layer of the neural network, including: Each accelerator obtains the complete weight matrix corresponding to the first linear layer from the stored weight matrix.

6. The method according to claim 3, characterized in that, The method further includes: Each accelerator acquires a third inference task, which instructs each accelerator to acquire a partial weight matrix of a third linear layer, wherein the plurality of linear layers include the third linear layer; wherein the third inference task is generated by the cloud platform based on the current memory usage of the N accelerators. Each accelerator, based on the third inference task, obtains a partial weight matrix from the third data and the stored full weight matrix of the third linear layer; the partial weight matrices obtained by the N accelerators respectively form the full weight matrix corresponding to the third linear layer; Each accelerator performs inference on the third data based on the partial weight matrix to obtain a second inference result slice; The N accelerators will merge their respective second inference results into a single second inference result for the third data.

7. A reasoning device based on a neural network, characterized in that, The apparatus, applied to each of N accelerators, comprises: An acquisition module is used to acquire the complete weight matrix corresponding to the first data slice and the first linear layer of the neural network; wherein: the neural network includes multiple linear layers, each linear layer corresponds to a weight matrix, the multiple linear layers include the first linear layer, and the first data slices acquired by the N accelerators respectively constitute the first data; An interaction module is used to interact with other accelerators to obtain a second data slice from their respective first data slices. The second data slice includes a partial data slice from other accelerators and a remaining data slice. The remaining data slice is the part of its corresponding first data slice other than the partial data slice interacting with another accelerator. The inference module is used to infer the second data slice based on the complete weight matrix corresponding to the first linear layer to obtain the first inference result slice. The aggregation module is used to aggregate the first inference results of the N accelerators in segments to obtain the first inference result of the first data.

8. The apparatus according to claim 7, characterized in that, The acquisition module is further configured to acquire the second data and a partial weight matrix corresponding to the second linear layer of the neural network; wherein: the plurality of linear layers include the second linear layer, and the partial weight matrices acquired by each of the N accelerators constitute the complete weight matrix corresponding to the second linear layer; The inference module is further configured to infer the second data based on the partial weight matrix to obtain the first data slice.

9. The apparatus according to claim 7, characterized in that, The acquisition module is further configured to acquire a first inference task, wherein the first inference task instructs each of the accelerators to store the complete weight matrix corresponding to each of the plurality of linear layers; The device further includes a storage module for storing the complete weight matrix of each of the plurality of linear layers based on the first inference task; wherein: the first inference task is generated by the cloud platform based on the current storage occupancy status of the N accelerators and sent to the N accelerators.

10. The apparatus according to claim 7, characterized in that, The acquisition module is further configured to acquire a second inference task, the second inference task instructing each of the accelerators to store the complete weight matrix corresponding to at least one of the plurality of linear layers, and the partial weight matrices of the other linear layers besides the at least one linear layer, wherein the at least one linear layer includes the first linear layer; The storage module is used to store, based on the second inference task, the complete weight matrix corresponding to at least one linear layer among the plurality of linear layers, and the partial weight matrices of the other linear layers besides the at least one linear layer; wherein: the second inference task is generated by the cloud platform based on the current storage occupancy status of the N accelerators and sent to the N accelerators.

11. The apparatus according to claim 9 or 10, characterized in that, The acquisition module is specifically used for: Obtain the complete weight matrix corresponding to the first linear layer from the stored weight matrix.

12. The apparatus according to claim 9, characterized in that, The acquisition module is further configured to acquire a third inference task, which instructs each accelerator to acquire a partial weight matrix of a third linear layer, wherein the plurality of linear layers include the third linear layer; wherein the third inference task is generated by the cloud platform based on the current memory usage of the N accelerators; The acquisition module is further configured to acquire, based on the third inference task, a partial weight matrix from the complete weight matrix of the third linear layer and the stored third data; the partial weight matrices acquired by each of the N accelerators constitute the complete weight matrix corresponding to the third linear layer. The inference module is also used to infer the third data based on the partial weight matrix to obtain a second inference result slice; The aggregation module is also used to aggregate the respective second inference results to obtain the second inference result of the third data.

13. A computing device cluster, characterized in that, It includes at least one computing device, each computing device including a processor and memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device to cause the cluster of computing devices to perform the method as described in any one of claims 1 to 6.

14. A computer program product containing instructions, characterized in that, When the instruction is executed by the computing device cluster, the computing device cluster causes the computing device cluster to perform the method as described in any one of claims 1 to 6.

15. A computer-readable storage medium, characterized in that, Includes computer program instructions, which, when executed by a cluster of computing devices, perform the method as described in any one of claims 1 to 6.