Parallel accelerated reasoning method and device for time series prediction autoregression model and medium

Through the parallel acceleration inference method, the main logical thread and the parallel inference acceleration thread are used to reason separately, and tolerance checks and results are combined, which solves the problem of slow response time of the autoregressive model in long-time series prediction scenarios, and efficient long-sequence timing inference is achieved, and the practical application performance of the model is improved.

CN119849628APending Publication Date: 2025-04-18SHANGHAI ELECTRIC SMART CITY INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411931240.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-04-18

Smart Images

  • Figure CN119849628A_ABST
    Figure CN119849628A_ABST
Patent Text Reader

Abstract

The invention discloses a parallel accelerated reasoning method and device for a time sequence prediction autoregression model, and a medium, and relates to the technical field of passenger flow time sequence prediction. The method comprises the following steps: acquiring historical time sequence data; based on the historical time sequence data, a main logic thread and a parallel reasoning acceleration thread are used for reasoning respectively, and a main logic thread fine-grained result and a parallel reasoning acceleration thread fine-grained result are obtained; the parallel reasoning acceleration thread comprises draft model reasoning and multi-thread queue pipeline parallel reasoning; splicing and fusing the fine-grained result of the main logic thread and the fine-grained result of the parallel reasoning acceleration thread to obtain a final result, and outputting the final result; and closing the reasoning and logic operation threads, and releasing the corresponding video memory and content space. According to the method, the acceleration of the long-sequence time sequence reasoning process can be realized on the premise of not obviously influencing the precision through the draft model, the parallel reasoning assembly line, the tolerance check and the result fusion operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of passenger flow prediction, and in particular to a parallel accelerated inference method, device and medium for a time series prediction autoregressive model. Background Art

[0002] Passenger flow time series prediction plays an important role in many fields such as transportation, energy and manufacturing. Traditional prediction methods mainly rely on statistical models (such as ARIMA) and machine learning models, which are suitable for scenarios with limited data. However, with the development of deep learning techniques (such as NHITS and Dlinear), the prediction ability has been significantly improved, but these methods usually require separate training models for each data set, and a universal prediction model has not yet been achieved.

[0003] In recent years, the powerful generalization ability of large language models (LLMs) has inspired the development of basic models for time series prediction. These studies can be mainly divided into two categories: enhancing pre-trained LLMs with natural language cues, and retraining specialized LLMs for time series tasks. These methods build a bridge between specialized models and general methods, avoiding the need to train from scratch for each task. However, the existing autoregressive mechanism and large model size lead to slow response times of these models, especially in long-term prediction scenarios, which limits the practical application performance of the models and increases the cost of use. Summary of the invention

[0004] The purpose of the present invention is to provide a parallel accelerated reasoning method, device and medium for time series prediction autoregressive model, which can accelerate the long sequence time series reasoning process without significantly affecting the accuracy through draft model, parallel reasoning pipeline, tolerance check and result fusion operation.

[0005] To achieve the above object, the present invention provides the following solutions:

[0006] A parallel accelerated inference method for an autoregressive model for time series forecasting, comprising:

[0007] Get historical time series data;

[0008] Based on the historical time series data, the main logic thread and the parallel reasoning acceleration thread are used to perform reasoning respectively to obtain the fine-grained results of the main logic thread and the fine-grained results of the parallel reasoning acceleration thread; the parallel reasoning acceleration thread includes the draft model reasoning and the multi-thread queue pipeline parallel reasoning;

[0009] The fine-grained result of the main logic thread and the fine-grained result of the parallel reasoning acceleration thread are spliced ​​and merged to obtain the final result output;

[0010] The reasoning and logic operation threads are closed to release the corresponding video memory and content space.

[0011] Optionally, before performing the inference, it also includes: performing a legitimacy check on the timestamp of the historical time series data; the legitimacy check process includes: determining whether the number of data points of the historical time series data is greater than or equal to 3, and if so: proceeding to the next step when the recording time intervals of adjacent data points are equal, and reporting an error when the recording time intervals of adjacent data points are not equal; if not, skipping the legitimacy check.

[0012] Optionally, the process of using the main logic thread and the parallel reasoning acceleration thread to perform reasoning respectively specifically includes:

[0013] Start a main logic thread to perform fine-grained result reasoning and obtain the fine-grained result of the main logic thread;

[0014] At the same time, in another parallel reasoning acceleration thread, the draft model is used to quickly generate coarse-grained results, and the coarse-grained results are divided into M groups in a step-by-step manner according to the number of parallel reasoning threads M, and pipeline job reasoning is performed in the parallel threads of each group to obtain temporary fine-grained results, and the job results are stored in independent cache areas respectively;

[0015] A tolerance check is performed on the temporary fine-grained result until the loop reaches the number of time series prediction digits to obtain a fine-grained result of a parallel reasoning acceleration thread; the tolerance check is as follows: if the tolerance of the temporary fine-grained result is greater than or equal to a preset threshold, the result is confirmed to be valid and the reasoning is continued; if the tolerance of the temporary fine-grained result is less than the preset threshold, the reasoning is continued after being updated using the standard result.

[0016] Optionally, the process of dividing the coarse-grained results into M groups in a step-by-step manner specifically includes:

[0017] When the number of cycles of the tolerance check is I, the input data of the parallel reasoning threads number M includes the historical time series data and the first (I+M) bits of the coarse-grained results.

[0018] Optionally, the tolerance calculation process is: within the same loop round, cosine similarity is calculated based on the complete temporary fine-grained result of the thread M-1 queue and the complete temporary fine-grained result of the adjacent thread M queue, and the cosine similarity is determined as the tolerance of the temporary fine-grained result.

[0019] Optionally, the step of splicing and fusing the fine-grained result of the main logic thread and the fine-grained result of the parallel reasoning acceleration thread to obtain a final result output specifically includes:

[0020] Pull all fine-grained results currently inferred by the main logic thread, obtain the fine-grained results of the main logic thread, and end the main logic thread;

[0021] The main logic thread fine-grained result replaces the corresponding temporary fine-grained result in the parallel reasoning acceleration thread fine-grained result to obtain the final result output.

[0022] The present invention also provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the above-mentioned parallel accelerated inference method for the autoregressive model for time series prediction.

[0023] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the parallel accelerated inference method for the time series prediction autoregressive model as described above.

[0024] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:

[0025] The present invention discloses a parallel accelerated reasoning method, device and medium for time series prediction autoregressive model, the method comprising obtaining historical time series data; based on the historical time series data, using the main logic thread and the parallel reasoning acceleration thread to reason respectively, obtaining the main logic thread fine-grained result and the parallel reasoning acceleration thread fine-grained result; the parallel reasoning acceleration thread includes the draft model reasoning and the multi-thread queue pipeline parallel reasoning; the main logic thread fine-grained result and the parallel reasoning acceleration thread fine-grained result are spliced ​​and fused to obtain the final result output; the reasoning and logic operation threads are closed to release the corresponding video memory and content space. The present invention can accelerate the long sequence time series reasoning process without significantly affecting the accuracy through the draft model, parallel reasoning pipeline, tolerance check and result fusion operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0027] Figure 1 This is a flow chart of the parallel accelerated inference method for the time series prediction autoregressive model of the present invention;

[0028] Figure 2 This is an example effect diagram of the stepped temporary fine-grained result grouping in this embodiment;

[0029] Figure 3 This is a visualization diagram of the final output result of the passenger flow time series prediction in this embodiment. DETAILED DESCRIPTION

[0030] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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 are within the scope of protection of the present invention.

[0031] The purpose of the present invention is to provide a parallel accelerated reasoning method, device and medium for time series prediction autoregressive model, which can accelerate the long sequence time series reasoning process without significantly affecting the accuracy through draft model, parallel reasoning pipeline, tolerance check and result fusion operation.

[0032] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0033] like Figure 1 As shown, the present invention provides a parallel accelerated inference method for a time series prediction autoregressive model, comprising:

[0034] Get historical time series data;

[0035] Based on the historical time series data, the main logic thread and the parallel reasoning acceleration thread are used to perform reasoning respectively to obtain the fine-grained results of the main logic thread and the fine-grained results of the parallel reasoning acceleration thread; the parallel reasoning acceleration thread includes the draft model reasoning and the multi-thread queue pipeline parallel reasoning;

[0036] The fine-grained result of the main logic thread and the fine-grained result of the parallel reasoning acceleration thread are spliced ​​and merged to obtain the final result output;

[0037] The reasoning and logic operation threads are closed to release the corresponding video memory and content space.

[0038] As a specific implementation, the above steps are described in detail as follows:

[0039] Step 1: Obtain historical time series data, which must contain at least two attributes: timestamp and corresponding value, and then perform a validity check on the timestamp.

[0040] Assume that the time series data is T = {(t 1 ,x 1 ),(t 2 ,x2 ),…,(t N ,x N )}, if N ≥ 3, check that all i satisfy: Δt i =t i+1 -t i ,

[0041] And Δt i =Δt i+1 , otherwise an error is reported.

[0042] Step 2: Start a main model thread to slowly perform fine-grained result inference.

[0043] Let the main model be f main , whose output is the fine-grained result: y main =f main (X).

[0044] Step 3: While executing step 2, use the draft model to quickly generate coarse-grained results, and divide the coarse-grained results into M groups in a step-by-step manner according to the number of parallel inference threads M.

[0045] The draft model is f draft , whose output is the coarse-grained result: y draft =f draft (X).

[0046] y draft Divided into M group: y draft ={y 1 ,y 2 ,…,y M}.

[0047] Step 4: Start parallel threads to infer temporary fine-grained results of pipeline jobs, and store the job results in independent cache areas.

[0048] The output of each parallel thread m is: y m =f parallel (X,y m ).

[0049] Step 5: Perform tolerance check on the inference results in real time. Whenever a new Token result is stored in the cache queue, compare the result with the corresponding bit in the adjacent queue for tolerance.

[0050] Calculate cosine similarity:

[0051]

[0052] Step 6: Determine whether the temporary fine-grained result falls within the tolerance interval. If it meets the requirements, confirm that the result is valid and continue to complete the reasoning; otherwise, discard the temporary fine-grained result and continue to complete the reasoning after updating it with the standard result.

[0053] If: cos_sim(y m-1 ,y m )≤γ, the result is valid.

[0054] Step 7: Repeat steps 3-6 until the time series prediction digit requirement is met to obtain the final result.

[0055] Step 8: Pull all fine-grained results currently inferred by the slow main model and end the main model thread.

[0056] The final fine-grained result is: y final =y max .

[0057] Step 9: splice and fuse the temporary fine-grained results. Use the result obtained in step 8 to partially replace the corresponding temporary fine-grained results, and output the replaced results as the final results.

[0058] Step 10: Close all reasoning and logic operation threads and release the corresponding video memory and memory space.

[0059] The above is the specific processing process of each step, among which the specific process for the legitimacy of the timestamp in step 1 is: determine whether the number of data points N is greater than or equal to 3. If the condition is met, check whether the recording time intervals of each group of adjacent data points are equal to ensure that the time granularity of all recorded data is the same. If they are the same, proceed to the next step, otherwise an error will be reported; if the number of data points is less than 3, skip step 1 directly and proceed to the next step.

[0060] The specific process for the step-by-step grouping of the coarse-grained results in step 3 is as follows: when the number of loops is I, the input data of thread M is composed of the historical time series data superimposed with the first (I+M) bits of the coarse-grained results; the number of loops corresponds to the iterative operation mentioned in step 7.

[0061] The specific process of the tolerance check in step 5 is as follows: within the same loop round, the complete temporary fine-grained result (length P bits) of the thread (M-1) queue and the complete temporary fine-grained result (truncated first P bits) of the adjacent thread M queue calculate the cosine similarity.

[0062] The specific process of determining the tolerance interval in step 6 is as follows: within the same cycle, based on the cosine similarity obtained in step 5, determine whether it is greater than or equal to a preset threshold γ; if it is less than this value, it is determined to meet the tolerance requirements; otherwise, it is determined to exceed the tolerance boundary.

[0063] Based on the above technical solution, the following embodiments are provided.

[0064] Embodiment 1: This embodiment provides a method for accelerating the parallel reasoning of an autoregressive model in a passenger flow time series prediction scenario. All logical operations are executed serially in the CPU, and all reasoning operations are executed in parallel in the GPU. In passenger flow prediction, the method steps of the present invention are as follows:

[0065] Step 1: Obtain historical passenger flow data and perform a legitimacy check:

[0066] Collect data T = {(t 1 ,x 1 ),(t 2 ,x 2 ),…,(t N ,x N )}.

[0067] For N≤3, check the time interval Δt i =t i+1 -t i Are they equal?

[0068] Step 2: Start fine-grained reasoning of the main model:

[0069] Use model f main , calculate y main =f main (X).

[0070] Step 3: Introduce the draft model to generate coarse-grained results:

[0071] Use f draft , generating y draft =f draft (X).

[0072] Divide the results into M groups: y draft ={y 1 ,y 2 ,…,y M}.

[0073] Set M = 5 as a hyperparameter, such as Figure 2 shown.

[0074] Step 4: Start the parallel pipeline job:

[0075] Start M threads to execute m Fine-grained reasoning is performed and the results are stored in a cache.

[0076] Step 5: Perform real-time tolerance check:

[0077] Calculate cosine similarity:

[0078] Step 6, determine the tolerance interval:

[0079] Determine cos_sim≤γ, hyperparameter γ=0.95, if satisfied, confirm that the result is valid.

[0080] Step 7, perform the iterative process:

[0081] Repeat steps 3 to 6 until the required number of prediction quantiles is reached.

[0082] Step 8: Get the main model results:

[0083] Pull the main model fine-grained result y final =y main .

[0084] Step 9, fusion results:

[0085] The temporary results are concatenated and fused, and the corresponding positions are replaced with the main model results to obtain the final output, such as Figure 3 shown.

[0086] Step 10, release resources:

[0087] Close all threads and release video memory and internal memory.

[0088] Embodiment 2: This embodiment provides a method for accelerating the parallel reasoning of an autoregressive model in a single-point OD flow time series prediction scenario for a subway station. All logical operations are executed serially in the CPU, and all reasoning operations are executed in parallel in the GPU. In the single-point OD flow prediction of a subway station, the method steps of the present invention are as follows:

[0089] Step 1: Get historical OD flow data and perform a validity check:

[0090] Collect data T = {(t 1 ,o 1 ,d 1 ),(t 2 ,o 2 ,d 2 ),…,(t N ,o N ,d N )}.

[0091] For N≤3, check the time interval Δt i =t i+1 -t i Are they equal?

[0092] Step 2: Start fine-grained reasoning of the main model:

[0093] Use model fmain , calculate y main =f main (X).

[0094] Step 3: Introduce the draft model to generate coarse-grained results:

[0095] Use f draft , generating y draft =f draft (X).

[0096] Divide the results into M groups: y draft ={y 1 ,y 2 ,…,y M}.

[0097] Set M=4 as a hyperparameter.

[0098] Step 4: Start the parallel pipeline job:

[0099] Start the M thread and run m Fine-grained reasoning is performed and the results are stored in a cache.

[0100] Step 5: Perform real-time tolerance check:

[0101] Calculate cosine similarity:

[0102] Step 6, determine the tolerance interval:

[0103] Determine cos_sim≤γ, hyperparameter γ=0.90, if satisfied, confirm that the result is valid.

[0104] Step 7, perform the iterative process:

[0105] Repeat steps 3 to 6 until the required number of prediction quantiles is reached.

[0106] Step 8: Get the main model results:

[0107] Pull the main model fine-grained result y final =y main .

[0108] Step 9, fusion results:

[0109] Concatenate and fuse the temporary results, replace the corresponding bits with the main model results, and get the final output.

[0110] Step 10, release resources:

[0111] Close all threads and release video memory and internal memory.

[0112] Therefore, the advantages and positive effects of the present invention are:

[0113] 1. Significantly improve the reasoning speed: By introducing the draft model, the coarse-grained results are generated in parallel with the main model, which accelerates the reasoning process. The parallel pipeline strategy is used to group the coarse-grained results for parallel processing, making full use of multi-threading and hardware resources, greatly shortening the reasoning time. Compared with the traditional single-threaded reasoning method, the overall efficiency has been significantly improved, especially when processing large-scale time series data, the performance is better.

[0114] Improve the accuracy and stability of results: The present invention uses a tolerance check mechanism to monitor each temporary fine-grained result in real time to ensure that the result is within the preset tolerance range. The consistency of the results is evaluated by calculating the cosine similarity, the better reasoning results are screened out, and the results are updated when necessary. This method not only improves the accuracy of the results, but also enhances the robustness of the system, enabling it to adapt to different application scenarios and data changes, and ensuring the reliability and stability of the output results.

[0115] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0116] This article uses specific examples to illustrate the principles and implementation methods of the present invention. The above examples are only used to help understand the core idea of ​​the present invention. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A parallel accelerated inference method for time series prediction autoregressive model, characterized in that: include: Get historical time series data; Based on the historical time series data, the main logic thread and the parallel reasoning acceleration thread are used to perform reasoning respectively to obtain the fine-grained results of the main logic thread and the fine-grained results of the parallel reasoning acceleration thread; the parallel reasoning acceleration thread includes the draft model reasoning and the multi-thread queue pipeline parallel reasoning; The fine-grained result of the main logic thread and the fine-grained result of the parallel reasoning acceleration thread are spliced ​​and merged to obtain the final result output; The reasoning and logic operation threads are closed to release the corresponding video memory and content space.

2. The parallel accelerated inference method for time series prediction autoregressive model according to claim 1, characterized in that: Before performing the inference, it also includes: performing a legitimacy check on the timestamp of the historical time series data; the legitimacy check process includes: determining whether the number of data points of the historical time series data is greater than or equal to 3, and if so, then: proceeding to the next step when the recording time intervals of adjacent data points are equal, and reporting an error when the recording time intervals of adjacent data points are not equal; if not, skipping the legitimacy check.

3. The parallel accelerated inference method for time series prediction autoregressive model according to claim 1, characterized in that: The process of using the main logic thread and the parallel reasoning acceleration thread to reason separately specifically includes: Start a main logic thread to perform fine-grained result reasoning and obtain the fine-grained result of the main logic thread; At the same time, in another parallel reasoning acceleration thread, the draft model is used to quickly generate coarse-grained results, and the coarse-grained results are divided into M groups in a step-by-step manner according to the number of parallel reasoning threads M, and pipeline job reasoning is performed in the parallel threads of each group to obtain temporary fine-grained results, and the job results are stored in independent cache areas respectively; A tolerance check is performed on the temporary fine-grained result until the loop reaches the number of time series prediction digits to obtain a fine-grained result of a parallel reasoning acceleration thread; the tolerance check is as follows: if the tolerance of the temporary fine-grained result is greater than or equal to a preset threshold, the result is confirmed to be valid and the reasoning is continued; if the tolerance of the temporary fine-grained result is less than the preset threshold, the reasoning is continued after being updated using the standard result.

4. The parallel accelerated inference method for time series prediction autoregressive model according to claim 3, characterized in that: The process of dividing the coarse-grained results into M groups in a step-by-step manner specifically includes: When the number of cycles of the tolerance check is I, the input data of the parallel reasoning threads number M includes the historical time series data and the first (I+M) bits of the coarse-grained results.

5. The parallel accelerated inference method for time series prediction autoregressive model according to claim 3, characterized in that: The tolerance calculation process is: in the same loop round, cosine similarity is calculated based on the complete temporary fine-grained result of the thread M-1 queue and the complete temporary fine-grained result of the adjacent thread M queue, and the cosine similarity is determined as the tolerance of the temporary fine-grained result.

6. The parallel accelerated inference method for time series prediction autoregressive model according to claim 1, characterized in that: The process of splicing and fusing the fine-grained result of the main logic thread and the fine-grained result of the parallel reasoning acceleration thread to obtain the final result output specifically includes: Pull all fine-grained results currently inferred by the main logic thread, obtain the fine-grained results of the main logic thread, and end the main logic thread; The main logic thread fine-grained result replaces the corresponding temporary fine-grained result in the parallel reasoning acceleration thread fine-grained result to obtain the final result output.

7. An electronic device, characterized in that: It includes a memory and a processor, the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the parallel accelerated inference method for a time series prediction autoregressive model according to any one of claims 1-6.

8. A computer-readable storage medium, characterized in that: It stores a computer program, which, when executed by a processor, implements the parallel accelerated inference method for a time series prediction autoregressive model as described in any one of claims 1 to 6.