GPU-enabled multi-level tensor CP decomposition distributed parallel acceleration method in Spark framework

By combining the Spark framework and GPU module, using the P-CPALS method and GPU multi-threaded parallel computing, the problem of slow processing of large-scale tensor data CP decomposition is solved, and an efficient and scalable multi-level tensor CP decomposition algorithm is realized. Significantly improves processing speed.

CN118642863BActive Publication Date: 2024-11-15NANJING UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411126419.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-16
Publication Date
2024-11-15
Estimated Expiration
2044-08-16

Smart Images

  • Figure CN118642863B_ABST
    Figure CN118642863B_ABST
Patent Text Reader

Abstract

The present invention discloses a GPU-enabled multi-level tensor CP decomposition distributed parallel acceleration method under the Spark framework, comprising: reading large-scale hyperspectral tensor data of rank R and initializing factor matrix parameters; updating each factor matrix in distributed parallel using the P‑CPALS method; calculating error , and judge whether the iteration in this round meets the iteration stop condition. The present invention achieves the effect of multi-level parallel computing by combining the Spark platform with different parallel mechanisms and the GPU high-performance technology, explores the division mechanism between different subtasks, and reasonably uses the efficient computing power of multi-level parallelism to achieve parallel CP decomposition of dense tensor data with higher efficiency and scalability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of big data distributed processing, and in particular relates to a GPU-enabled multi-level tensor CP decomposition distributed parallel acceleration method under a Spark framework. Background Art

[0002] Tensors can be seen as high-order generalizations of vectors and matrices. Their own structural characteristics have a natural advantage in preserving the intrinsic structural connections of high-dimensional data, and are widely used in signal processing, data mining, image processing and other application fields. Tensor decomposition can further mine the main components or implicit information in high-order data by decomposing high-order data into intrinsic low-dimensional structural representations. CP decomposition is one of the current mainstream tensor decomposition methods. It decomposes a tensor into the sum of multiple single-rank tensors, which can effectively process high-order tensors and explore the deep connections within high-order data. However, with the explosive growth of data, CP decomposition faces huge challenges in practical applications, such as the dimensionality disaster brought by high-order tensors and the computational consumption of large-scale data. There is an urgent need to accelerate the processing of CP decomposition of tensor big data.

[0003] With the development of high-performance computing models and hardware, distributed parallel computing technology and high-performance computing modules are gradually being used to solve large-scale complex computing problems. Among them, Spark is a high-performance distributed computing framework based on memory computing running on the CPU. It stores data in memory through elastic data sets (RDD), thereby greatly improving the performance of iterative computing. Graphics Processing Unit (GPU) is a microprocessor that specializes in processing image and graphics related operations. In recent years, it has also been used in general computing fields. Compared with CPU, GPU has more computing cores, higher storage bandwidth, and smaller thread switching cost, so it can execute parallel threads to a greater extent, which makes its computing power far exceed that of CPU. Using GPU to process computationally intensive tasks can greatly improve the processing efficiency of intensive data. Summary of the invention

[0004] The purpose of the present invention is to provide a GPU-enabled multi-level tensor CP decomposition distributed parallel acceleration method under the Spark framework. By combining Spark technology with the GPU module, Spark is used as a distributed parallel framework to control logical calculations and task division, and the GPU is responsible for the calculation of intensive tasks. This can break through the speed bottleneck of the Spark cluster and provide a distributed computing collaboration framework for multiple GPUs, thereby realizing multi-level tensor CP decomposition distributed computing and greatly improving the processing speed of CP decomposition of large-scale tensors.

[0005] The technical solution to achieve the purpose of the present invention is: a GPU-enabled multi-level tensor CP decomposition distributed parallel acceleration method under the Spark framework, comprising:

[0006] Step 1, read the large-scale hyperspectral tensor data of rank R and initialize the factor matrix parameters;

[0007] Step 2, using the P-CPALS method to update each factor matrix in distributed parallel;

[0008] Step 3, calculate , determine whether this round of iteration meets the iteration stop condition.

[0009] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the steps of the above method are implemented when the processor executes the program.

[0010] A computer-readable storage medium stores a computer program, which implements the steps of the above method when executed by a processor.

[0011] A computer program product comprises a computer program, which implements the steps of the above method when executed by a processor.

[0012] Compared with the prior art, the present invention has the following significant advantages: the GPU-enabled multi-level tensor CP decomposition distributed parallel acceleration method under the Spark framework of the present invention achieves the effect of multi-level parallel computing by combining the Spark platform with different parallel mechanisms and the GPU high-performance technology, explores the division mechanism between different subtasks, and rationally uses the efficient computing power of multi-level parallelism, thereby realizing a parallel CP decomposition algorithm for intensive tensor data with higher efficiency and high scalability. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 A GPU-enabled multi-level tensor CP distributed decomposition framework for Spark.

[0014] Figure 2 Flowchart of the GPU-enabled multi-level tensor CP decomposition algorithm under the Spark framework.

[0015] Figure 3 This is a diagram of the distributed architecture of multi-level tensor CP decomposition enabled by GPU under the Spark framework. DETAILED DESCRIPTION

[0016] 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.

[0017] In order to overcome the difficulties in the prior art, the present invention proposes a GPU-enabled multi-level tensor CP decomposition distributed parallel acceleration method under the Spark framework. Assume that there is a rank N-order tensor This method is based on the Alternating Least Squares (ALS) method. By integrating the Spark (CPU processing module) platform and the GPU computing module, the GPU multi-threaded parallel computing based on GUDA programming is introduced into the computing tasks in MapReduce. The distributed parallel factor matrix The update achieves the effect of distributed parallel acceleration of multi-level tensor CP decomposition. The factor matrix The update method is:

[0018] .

[0019] Combination Figure 1~Figure 3 The specific process of the GPU-enabled multi-level tensor CP decomposition distributed parallel acceleration method under the Spark framework is as follows:

[0020] Step 1: Read large-scale tensor data of rank R , randomly initialize the factor matrix , the update order of the factor matrix is ​​specified as For dimensions Spark reads the binary file of the tensor from HDFS and reorders the dimensions of the read data to obtain a Dimensional array According to the tensor rank Randomly initialize the factor matrix , so that .

[0021] Step 2: Based on the Spark framework, multi-GPU distributed parallel accelerated alternating least squares method is used to solve the CP decomposition (P-CPALS). According to the update sequence of the factor matrix, other factor matrices are fixed, and each factor matrix is ​​updated in distributed parallel in the sequence. .

[0022] The objective function is given as

[0023] .

[0024] in Represents the F norm of the matrix, symbol Denotes the Khatrirao product. When solving the above objective function, follow the factor matrix update sequence, fix other factor matrices, and update one factor matrix according to the update sequence , and use multiple GPUs for distributed computing based on the Spark framework and ,in yes Model Expand, For Hadamard, Expressed as the inverse of the matrix. Then calculate .

[0025] First, Spark will Divide into rows evenly , of which The number of cluster nodes, record each exist The starting row position in as well as number of rows .Will , and Broadcasting.

[0026] for The calculation of the tensor according to Expand the module to get ,according to The corresponding segmentation method is Split by column, share yes No. Column to The matrix is ​​formed by columns and abstracted into RDD through Spark, recorded as YRDD. Then the Map operation is performed on YRDD to calculate In the Map phase, get the broadcast variable , and Each slice calls a GPU, and the GPU threads are divided by CUDA kernel functions to achieve parallel computing within each slice. In the calculation of a single GPU, a grid is set, and the grid is divided into 1024 (32×32) thread blocks in two dimensions. Each thread block executes a kernel function. At the same time, for the data responsible for each thread Divide evenly by column, and only record the starting column of each block of data after division. The position and the corresponding number of columns are stored in the array and . Initialize a block result with all zeros And set it to be globally shared. Inside each thread, the thread gets the row where the current thread is located. and column ,in and They are respectively represented as the coordinates of the current thread block along the x-axis and y-axis in the grid, and Represented as the number of threads in the x and y dimensions in a single thread block. ,in It is the number of loops that increases from 0. The stop condition is equal ,in , Represents the rank modulo n. Then perform __syncthreads() synchronization to ensure Global synchronization. After all threads have completed the calculation, the result of the slice is obtained. After all the shards are completed, perform the reduce operation and get .

[0027] for The calculation of ,in The number of cluster nodes. During the Map operation, each shard obtains the broadcast variable. , call GPU parallel computing According to the rank The size of the grid is divided. If Less than or equal to 32, set the thread block to indivual, ,right this The matrix is ​​divided into columns and recorded as , using length The array records each column in Starting position in , and the corresponding blocks , here The elements of are all 1. If it is greater than 32, the thread block is set to indivual, ,right this The factor matrix is ​​evenly divided by column, using a length of The array records each column in Starting position in , and the number of columns of the corresponding block . Set a Record the operation results of each block. Each thread in each thread block obtains the row where the current thread is located. and column , each thread calculates and updates , calculated as After all the shards are completed, perform the reduce operation and get Finally, Take the inverse and get .

[0028] Final calculation , and update the broadcast variable .

[0029] Step 3: Calculation , mainly calculate and . First get the broadcast variable , and For reuse. The corresponding segmentation method is Along the mold Cut , Tensors can be used and Expressed as , and abstracted into RDD through Spark, recorded as ErrorRDD. Map operation is performed on ErrorRDD, and each shard calls GPU to perform and In a single GPU, set global variables and Record and The value of is initialized to 0. Set the number of thread blocks to 32×32. Divide the rows evenly, using a length of The array Index records the partitioning method of each matrix, and each element records the partitioning of each block of the factor matrix. Split start position and end position ,in Less than or equal to the number of slices of the factor matrix. Cartesian operations are performed on the collections of each element of Index to form a set IndexSet, whose elements can be expressed as , divide the IndexSet into 32×32 parts, and use a 32×32 two-dimensional array Record the elements of each copy. In the kernel function, each thread block obtains the row where the current thread is located. and column , loop reading The elements in and calculate and . Then perform __syncthreads() synchronization operation to ensure and Global synchronization. Wait until all shards have completed the calculation, and then perform a reduce operation on the results of each shard to calculate and Then calculate . judge Does the value of satisfy the iteration stop condition? If so, the iteration is stopped and the factor matrix of this round of iteration is The final result is stored on the cloud platform; if it is not reached, it will jump to step 2 to continue the iteration.

[0030] The GPU-enabled multi-level tensor CP decomposition distributed parallel acceleration method under the Spark framework of the present invention achieves the effect of multi-level parallel computing by combining the Spark platform with different parallel mechanisms and the GPU high-performance technology, explores the division mechanism between different subtasks, and rationally uses the efficient computing power of multi-level parallelism to realize a parallel CP decomposition algorithm for intensive tensor data with higher efficiency and high scalability.

[0031] Example

[0032] This method is based on the Pavia Center hyperspectral remote sensing data collected by the ROSIS sensor in Italy. In this case, the data size is 1096*715*102. The case uses a CPU-GPU cluster consisting of two servers, where the CPU model of the slave is INTEL(R) Core(TM) i9-10980XE with 32 cores, the main frequency is 3.00GHZ, the GPU model is NVIDIA RTX 2080 Ti, the number of CUDA cores is 4352, and the memory size is 11264MB. The CPU model of the master is Inter(R) Core(TM) i7-9700K with 8 cores, the main frequency is 3.60GHZ, the GPU model is NVIDIA GTX 1080Ti, the number of CUDA cores is 3584, and the memory size is 11264MB. According to step 1, first read the tensor data with a rank of 6 from HDFS , the update order is specified as {1,2,3}, according to the rank Randomly initialize the factor matrix ,in According to step 2, by integrating the Spark platform and the GPU computing module, GPU multi-threaded parallel computing is introduced into the computing tasks in MapReduce. First, according to the update order of the factor matrix, fix the other factor matrices, and update a factor matrix according to the sequence. As an example, the distributed computing and , then calculate According to step 3, after updating the factor matrix in sequence, calculate , determine whether this round of iteration meets the iteration stop condition, if it does, stop the iteration, and change the factor matrix of this round of iteration The final result is stored in the cloud platform; if it is not reached, continue to jump to step 2 to iteratively update the factor matrix.

[0033] The GPU-enabled parallel computing under the Spark framework is compared with the Spark parallel computing, and the results are shown in Table 1. From Table 1, it can be seen that the error values ​​of the two calculations are almost the same, which shows that the Spark-GPU algorithm has higher accuracy.

[0034] Table 1 Comparison of Spark-GPU parallel computing error and Spark parallel computing error

[0035] Spark-GPU parallel computing error Spark parallel computing error 0.677662 0.4714268

[0036] The average running time of the parallel CP decomposition algorithm enabled by the GPU under the Spark framework and the parallel CP decomposition algorithm under the Spark platform at different degrees of parallelism is compared. The results are shown in Table 2:

[0037] Table 2 Comparison of average running time of the parallel CP decomposition algorithm enabled by GPU under Spark framework and the parallel CP decomposition algorithm under Spark platform at different parallelism levels

[0038] Number of nodes Spark-GPU parallel computing time (seconds) Spark parallel computing time (seconds) 1 11.181 138.441 2 9.433 97.192 4 6.891 40.404 8 5.624 29.671

[0039] As can be seen from Table 2, the execution efficiency of the GPU-enabled CP decomposition algorithm under the Spark framework proposed by this method on the Spark platform of heterogeneous CPU / GPU is higher than that of the parallel CP decomposition algorithm on the Spark platform of homogeneous CPU. The maximum speedup ratio of the two algorithms can reach 8.7 times.

[0040] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A GPU-enabled multi-level tensor CP decomposition distributed parallel acceleration method under Spark framework, characterized in that: The following steps are involved: Step 1, read the rank Large-scale tensor data , randomly initialize the factor matrix , the update order of the factor matrix is ​​specified as , as follows: (1.1) For rank The dimension is Spark reads the binary file of the tensor from HDFS and reorders the dimensions of the read data to obtain a Dimensional array ; (1.2) According to the rank Randomly initialize the factor matrix , so that ; Step 2: Using the P-CPALS method, follow the factor matrix update sequence, fix other factor matrices, and update a factor matrix in sequence , distributed computing based on Spark and GPU and ,in yes Model Expand, For Hadamard, Expressed as the inverse of the matrix; then calculate ; The details are as follows: (2.1) First, Spark will Divide into rows evenly Record each copy exist The starting line position in as well as number of rows ;Will , and to broadcast; (2.2) For The calculation of the tensor according to Expand the module to get ,according to The corresponding segmentation method is Split by column, share yes No. Column to The matrix is ​​formed by columns and abstracted into RDD through Spark, recorded as YRDD; then the Map operation is performed on YRDD to calculate ; In the Map phase, get the broadcast variable , and Each slice calls a GPU, and the GPU threads are divided by CUDA kernel functions to achieve parallel computing within each slice. In the calculation of a single GPU, a grid is set according to the configuration of Nvidia GPU, and a thread block is divided into 1024 threads in two dimensions. Each thread executes a kernel function. At the same time, for the data responsible for each thread Divide evenly by column, and only record the starting column of each block of data after division. The position and the corresponding number of columns are stored in the array and ; Initialize a block result with all 0s And set it to be globally shared; inside each thread, the thread gets the row where the current thread is located and columns ,in and They are respectively represented as the coordinates of the current thread block along the x-axis and y-axis in the grid, and Represented as the number of threads in the x and y dimensions in a single thread block; loop calculation ,in It is the number of loops that increases from 0. The stop condition is equal ,in , Represents the rank modulo n; then perform __syncthreads() synchronization operation to ensure Global synchronization; after all threads have completed the calculation, the result of the slice is obtained ; After all the shards are completed, perform the reduce operation and get ; (2.3) For The calculation of ; During the Map operation, each shard obtains the broadcast variable. , call GPU parallel computing According to the rank The size of the grid is divided; if Less than or equal to 32, set the thread block to indivual, ,right this The matrix is ​​divided into columns, using a length of The array records each column in Starting position in , and the corresponding blocks , here The elements of are all 1; if If it is greater than 32, the thread block is set to indivual, ,right this The factor matrix is ​​evenly divided into columns and recorded as , using length The array records each column in Starting position in , and the number of columns of the corresponding block ; Set a Record the calculation results of each block; each thread in each thread block obtains the row where the current thread is located and columns , each thread calculates and updates , calculated as ; After all the shards are completed, perform the reduce operation and get ; Finally Take the inverse and get ; (2.4) Calculation , and update the broadcast variable ; Step 3, calculate , determine whether this round of iteration meets the iteration stop condition.

2. The GPU-enabled multi-level tensor CP decomposition distributed parallel acceleration method under the Spark framework according to claim 1, characterized in that: In step 3, calculate , as follows: (3.1) First get the broadcast variable , and for reuse; (3.2) According to The corresponding segmentation method is Along the mold Cut , Tensor and Expressed as , and abstracted into RDD through Spark, recorded as ErrorRDD; (3.3) Map the ErrorRDD, and call the GPU for each shard and Parallel computation within the GPU; in a single GPU, set global variables and Record and The value of is initialized to 0; (3.4) Set the number of thread blocks to 32×32. Divide evenly by row, using a length of The array Index records the partitioning method of each matrix, and each element records the partitioning of each block of the factor matrix. Split start position and end position ,in Less than or equal to the number of slices of the factor matrix; (3.5) Cartesian operations are performed on the collections of each element of Index to form a set IndexSet, whose elements are represented as , divide the IndexSet into 32×32 parts evenly, and use a 32×32 two-dimensional array Record each element; in the kernel function, each thread block obtains the row where the current thread is located and columns , loop reading The elements in and calculate and ; Then perform __syncthreads() synchronization operation to ensure and Global synchronization; (3.6) Wait until all shards have completed the calculation, and perform a reduce operation on the results of each shard to calculate and ; (3.7) Calculation ;judge Does the value of satisfy the iteration stop condition? If so, the iteration is stopped and the factor matrix of this round of iteration is The final result is stored on the cloud platform; if it is not reached, it will jump to step 2 to continue the iteration.

3. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method according to any one of claims 1 to 2 are implemented.

4. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 2 are implemented.

5. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 2 are implemented.