A processing method for iterative tasks, an optoelectronic hybrid device medium, and a product
Through the photoelectric hybrid calculation method, the difference calibration between the optical processor and the electrical processor is used to improve the accuracy and efficiency of iterative tasks, solving the problem of low processing accuracy of iterative tasks and achieving the performance improvement of photoelectric hybrid computing.
Patent Information
- Application Number
- CN202510705471.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2045-05-29
AI Technical Summary
In the prior art, iterative tasks have low accuracy and low efficiency, especially in optical calculations, which are susceptible to environmental factors, resulting in phase drift and interference fringe instability.
The execution results of the iteration task are sent to the electrical processor through the optical processor. The electrical processor performs iteration tasks based on the results of the optical processor and calibrates the results of the optical processor through the difference, reducing the number of iterations of the electrical processor, and using the low latency characteristics of the optical processor to improve the accuracy and efficiency of the iteration task.
It improves the processing accuracy and convergence efficiency of iterative tasks, reduces the actual number of iterations of the electrical processor, and improves the overall performance of photoelectric hybrid computing.
Smart Images

Figure CN120256129B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method for processing iterative tasks, optoelectronic hybrid equipment medium, and products. Background Art
[0002] With the rapid development of artificial intelligence, the demand for computing power has exploded. In many tasks, such as pre-trained model inference tasks, multiple iterations are required to gradually approach the final result in order to achieve the required accuracy.
[0003] To improve the efficiency of iterative task processing, related technologies have adopted optical computing. This leverages the properties of light to achieve efficient data processing. However, optical signals have poor coherence and are easily affected by environmental factors, leading to phase drift and unstable interference fringes, thus affecting computational accuracy.
[0004] It can be seen that how to improve the accuracy of iterative task processing while ensuring the efficiency of iterative task processing is a technical problem that people in this field urgently need to solve. Summary of the Invention
[0005] The present invention provides an iterative task processing method, an optoelectronic hybrid device medium and a product, so as to at least solve the problem of low iterative task processing accuracy in related technologies.
[0006] The present invention provides a method for processing an iterative task, which is applied to an optical processor. The method includes sending a first execution result obtained by executing the iterative task to an electronic processor; so that the electronic processor executes the iterative task according to the first execution result and obtains a second execution result; obtaining the difference between the first execution result and the second execution result at the same number of iterations; wherein the number of iterations of the electronic processor is the sum of the number of iterations corresponding to the first execution result and the actual number of iterations of the electronic processor; selecting a target difference that meets preset requirements from the obtained difference, and using the same number of iterations corresponding to the target difference as the target same number of iterations; and using the second execution result at the target same number of iterations to execute the iterative task.
[0007] The beneficial effects of the present invention are as follows: first, in this method, since the second execution result is the result obtained after the electronic processor executes the iterative task, and the electronic processor is not easily disturbed by the environment when executing the iterative task, the execution result obtained after the electronic processor executes the iterative task has high accuracy. Therefore, the optical processor uses the second execution result of the same target iteration to execute the iterative task, thereby calibrating the execution result of the optical processor and improving the accuracy of the iterative task processing; moreover, on the basis of the improved iterative task processing accuracy of the optical processor, the convergence efficiency of the execution result obtained after executing the iterative task is improved; secondly, compared with the method of directly using the electronic processor to execute the iterative task, in the method provided by the present invention, the optical processor sends the first execution result obtained by executing the iterative task to the electronic processor, and then the electronic processor executes the iterative task according to the execution result of the optical processor. Since the optical processor has a low latency and the electronic processor has a high latency, this method can reduce the actual number of iterations of the electronic processor and improve the efficiency of ensuring the accuracy of the iterative task processing.
[0008] The present invention also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of the processing method of any of the above-mentioned iterative tasks are implemented.
[0009] The present invention also provides a computer program product, comprising a computer program, which implements the steps of any of the above-mentioned iterative task processing methods when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0011] Figure 1 A schematic diagram of a system for processing iterative tasks provided by an embodiment of the present invention;
[0012] Figure 2 A flowchart of a method for processing an iterative task provided by an embodiment of the present invention;
[0013] Figure 3 A flowchart of a method for processing iterative tasks based on back-off sampling optoelectronic hybrid computing is provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0014] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present invention.
[0015] It should be noted that, in the description of the present invention, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. The terms "first," "second," etc., in the present invention are used to distinguish similar objects, and are not used to describe a particular order or precedence.
[0016] Iterative tasks are a computational technique that incrementally approaches the solution to a problem by repeatedly applying a process or function to gradually improve the estimate of the solution. Convergence is crucial in iterative tasks, directly determining the effectiveness, reliability, and practicality of the iterative algorithm. Convergence in iterative tasks refers to whether the iterative sequence can gradually approach the target solution and eventually stabilize as the number of iterations increases. Figure 1 A schematic diagram of a system for processing iterative tasks provided by an embodiment of the present invention is shown in FIG. Figure 1 As shown, the system includes an optical processor and an electrical processor. The interaction between the optical and electrical processors improves the accuracy and efficiency of iterative tasks. Optical computing is performed on the optical processor. Optical computing is a technology that uses photons for information processing and computing. It leverages the physical properties of light, such as propagation, interference, and modulation, to achieve data transmission and computation. The electrical processor performs electrical computing. Electrical computing primarily processes information based on the flow of electrons in circuits. It uses electronic devices (such as transistors, resistors, and capacitors) and circuits to achieve data storage, transmission, and computation.
[0017] In order to enable those skilled in the art to better understand the solutions of the present invention, the present invention is further described in detail below with reference to the accompanying drawings and specific implementation methods. Figure 2 A flowchart of a method for processing an iterative task provided by an embodiment of the present invention, the method being applied to a light processor, the method comprising:
[0018] S10: sending a first execution result obtained by executing the iterative task to the electronic processor, so that the electronic processor executes the iterative task according to the first execution result and obtains a second execution result;
[0019] S11: Obtaining a difference between a first execution result and a second execution result at the same iteration number; wherein the number of iterations of the electronic processor is the sum of the number of iterations corresponding to the first execution result received by the electronic processor and the actual number of iterations of the electronic processor;
[0020] S12: Selecting a target difference value that meets preset requirements from the obtained difference values, and taking the same number of iterations corresponding to the target difference value as the target same number of iterations;
[0021] S13: Execute the iterative task using the second execution result of the same iteration as the target.
[0022] There are no restrictions on iterative tasks, such as model reasoning tasks, numerical solutions to differential equations, and Ising model / combinatorial optimization problems. If an electronic processor is used directly to execute iterative tasks, the high latency of the electronic processor results in low efficiency. Therefore, in the method provided by the present invention, the optical processor sends the first execution result obtained from executing the iterative task to the electronic processor. The electronic processor then executes the iterative task based on the execution result of the optical processor, thereby reducing the actual number of iterations of the electronic processor and improving the efficiency of iterative task processing.
[0023] Specifically, the optical processor executes an iterative task and sends a first execution result obtained from executing the iterative task to the electronic processor. If the optical processor executes multiple iterations, one or more first execution results obtained from the multiple iterations may be selected and sent to the electronic processor. After receiving the execution results sent by the optical processor, the electronic processor uses each received first execution result as input to execute the iterative task and obtain a second execution result.
[0024] When using an optical processor to process iterative tasks, the optical signal is easily interfered with, resulting in low iteration accuracy. Therefore, the present invention uses the execution results of the electronic processor to correct the execution results of the optical processor to improve the iteration accuracy of the optical processor.
[0025] In implementation, the difference between the first execution result and the second execution result at the same iteration (i.e., the same iteration) is obtained. The number of iterations of the optical processor is its own number of iterations. For example, it is r times. The number of iterations of the electrical processor in the present invention is the sum of the number of iterations corresponding to the first execution result received by the electrical processor and the actual number of iterations of the electrical processor. If the number of iterations corresponding to the first execution result received by the electrical processor is r-1 times, and the actual number of iterations is 1, then the number of iterations of the electrical processor is r times. Obtain the first execution result of the optical processor and the second execution result of the electrical processor at the r-th iteration, and obtain the difference between the execution results of the two (optical processor and electrical processor) for the r-th time. Select the target difference that meets the preset requirements from the obtained difference, and use the same number of iterations corresponding to the target difference as the target same number of iterations. It is worth noting that after selecting the target difference that meets the preset requirements from the obtained difference, and before using the same number of iterations corresponding to the target difference as the target same number of iterations, it also includes:
[0026] Obtain the number of target differences that meet preset requirements;
[0027] When it is detected that the number of target differences that meet the preset requirements is one, the same number of iterations corresponding to the target differences is used as the target same number of iterations;
[0028] When it is detected that there are multiple target difference values that meet the preset requirements, the target difference value corresponding to the minimum number of iterations is obtained from all the target difference values, and the same number of iterations with the minimum number of iterations is used as the target same number of iterations.
[0029] If the difference between the third and sixth iterations meets the preset requirements, the third iteration is selected as the target iteration, and the execution result of the optical processor is corrected using the third execution result of the electrical processor.
[0030] In this method, by giving priority to the previous execution results for calibration, the cumulative error caused by multiple iterations can be reduced, thereby achieving accurate calibration of the optical calculation results more quickly.
[0031] The default requirement is that the difference be less than a threshold. There is no limit on the threshold. Since more iterations result in greater light offset, the accuracy of the light processor decreases. Therefore, in order to select an appropriate threshold, in practice, determining the threshold includes: obtaining the current number corresponding to the current iteration; determining the threshold corresponding to the current number based on a pre-set relationship between the number and the threshold; wherein, in this relationship, the number and the threshold are positively correlated. For example, the threshold set for the 20th iteration is greater than the threshold set for the 5th iteration.
[0032] When determining the target iteration, you need to first find the target difference that meets the preset requirements. The target difference that meets the preset requirements is selected from the obtained differences, including:
[0033] Get the difference value at the same current iteration and compare the relationship between the difference value and the threshold;
[0034] If the difference is less than or equal to the threshold, the difference at the same iteration is used as the target difference;
[0035] If the difference is greater than the threshold, obtain the difference at the new current same iteration, where the number of times corresponding to the new current same iteration is less than the number of times corresponding to the previous current same iteration; return to the step of comparing the relationship between the difference and the threshold.
[0036] For example, if the number of iterations corresponding to the same order in the previous iteration was 10, then the number of iterations corresponding to the same order in the new iteration is less than 10, such as the 8th iteration. If the difference between the two results in the 10th iteration is too large, and the difference between the two results in the 12th iteration is compared, then because the difference between the two results in the 10th iteration is too large, that is, the accuracy of the optical processor has already been significantly offset, if the difference between the two results in the 12th iteration is compared, invalid iterations of the electronic processor will occur and the iteration efficiency will be low. Therefore, in the method provided by the present invention, the difference between the execution results of the two results in the same order is analyzed back-off to reduce invalid iterations and improve iteration efficiency.
[0037] To further improve iteration efficiency, in implementation, obtaining a new current iteration number includes:
[0038] When it is detected that the number of times corresponding to the previous current same iteration is an even number, half of the number of times corresponding to the previous current same iteration is used as the number of times corresponding to the new current same iteration; and a new current same iteration is obtained according to the number of times corresponding to the new current same iteration;
[0039] When it is detected that the number corresponding to the previous current same iteration is an odd number, half of the number corresponding to the previous current same iteration is rounded up, and the number obtained after rounding up is used as the number corresponding to the new current same iteration; the new current same iteration is obtained according to the number corresponding to the new current same iteration.
[0040] If the previous iteration of the same order was 10, the new iteration of the same order will be 5; if the previous iteration of the same order was 11, the new iteration of the same order will be 6. By designing the number of electronic computation sampling times (i.e., backing off by half), a worst-case Clog(c) level of electronic computation speedup is achieved, where c is the number of consecutive optical computations and C is the total number of cycles.
[0041] After obtaining the new current number of identical iterations, the difference value for the new current number of identical iterations is obtained, and the relationship between the difference value and the threshold is compared to determine the target number of identical iterations. After obtaining the target number of identical iterations, the iterative task is executed using the second execution result for the target number of identical iterations. If the target number of identical iterations is determined to be 5, the optical processor uses the execution result obtained from the fifth execution of the iterative task by the electronic processor as input and continues to execute the iterative task.
[0042] In practice, after the optical processor performs a large number of iterative calculations, its accuracy is checked and calibrated by the electronic processor. Since the more iterations, the more optical offset, resulting in reduced accuracy of the execution result. Therefore, in order to improve the accuracy of the execution result, an iteration cycle is set here. It should be noted that the iteration cycle in the present invention is divided according to the number of iterations included, and the process of performing 10 iterations is called an iteration cycle. The accuracy is checked and calibrated by the electronic processor in each iteration cycle. Specifically, sending the first execution result obtained by executing the iterative task to the electronic processor includes:
[0043] Sending a first execution result obtained by executing the iterative task a target number of times within the current iteration cycle to the electronic processor; wherein multiple iterations are executed within the current iteration cycle, and the target number of times is any one of the remaining iterations except the last iteration;
[0044] The difference between the first execution result and the second execution result when obtaining the same number of iterations includes:
[0045] Get the difference between the first execution result and the second execution result at the same iteration in the current iteration cycle.
[0046] If the optical processor executes 10 times in the current iteration cycle, the 10th execution result is given to the electrical processor. When the electrical processor executes an iteration task based on the 10th execution result transmitted by the optical processor, the electrical processor obtains the 11th execution result. Accordingly, the optical processor needs to execute the iteration task for the 11th time. In the method provided by the present invention, if the optical processor executes 10 iterations in the current iteration cycle, it will give the execution result obtained for the 9th or any one before the 9th to the electrical processor. The electrical processor executes another iteration task based on the execution result obtained for the 9th time, that is, it obtains the 10th execution result. At the same time, since the optical processor has obtained the 10th execution result, when the electrical processor executes the 10th iteration task, the optical processor does not need to execute the iteration task, thereby improving the efficiency of the precision verification and correction of the optical processor.
[0047] In practice, after receiving the first execution result, the electronic processor may execute multiple iterations of the task. Due to the high latency of the electronic processor when processing iterative tasks, if the electronic processor executes multiple iterations of the task after receiving the first execution result, the optical processor's precision correction efficiency will decrease. Therefore, in order to reduce the latency of electronic calculations and improve task processing efficiency, in this method, the electronic processor executes an actual iteration task based on the first execution result. Obtaining the difference between the first execution result and the second execution result for the same number of iterations includes: using the number of iterations of the electronic processor as the number corresponding to the same number of iterations; and obtaining the difference between the first execution result and the second execution result for the same number of iterations.
[0048] In this method, the electronic processor executes an actual iterative task according to the first execution result, and the number of iterations of the electronic processor is used as the number corresponding to the same iteration. Since the number of iterations of the electronic processor is reduced, the delay of the electronic calculation is reduced and the task processing efficiency is improved.
[0049] When processing an iterative task, in order to avoid invalid iterations, after executing the iterative task using the second execution result of the same target iteration, the method further includes:
[0050] Obtaining a preset termination condition for the iterative task; wherein the termination condition includes at least the loss function of the iterative task being less than a preset loss value, the iteration reaching a preset iteration cycle, or the change between two adjacent execution results being less than a preset change value;
[0051] When it is detected that the iterative task does not meet the termination condition, a new current iterative cycle is obtained, and a first execution result obtained by executing the iterative task a target number of times within the current iterative cycle is sent to the electronic processor;
[0052] When it is detected that the iterative task meets the termination condition, the execution result of the iterative task is output.
[0053] There are no restrictions on the preset loss value, preset iteration period, and preset change value, which are determined based on actual conditions. By determining whether an iterative task meets or does not meet the termination conditions, the iterative task can be continued or terminated, thus avoiding invalid iterations as much as possible.
[0054] After completing the iterative task, in order to facilitate understanding of the processing process of the iterative task, in implementation, after executing the iterative task using the second execution result of the same target iteration, the following is further included:
[0055] From the start of determining the target identical number of iterations until the target identical number of iterations is determined, obtaining the number of differences obtained, and determining the total number of backoff sampling times of the electronic processor in the current iteration cycle according to the number of differences;
[0056] Get the difference between the number of iterations corresponding to the same target and the number of iterations in the current iteration cycle, and use the difference as the number of backoff steps in the current iteration cycle;
[0057] The number of iterations in the current iteration cycle, the total number of backoff samplings of the electronic processor in the current iteration cycle, and the number of backoff steps in the current iteration cycle are used as processing parameters of the iterative task in the current iteration cycle.
[0058] In the method provided above, the optical processor uses the second execution result from the same target iteration to execute the iterative task, thereby calibrating the optical processor's execution results and improving the accuracy of iterative task processing. Furthermore, based on the improved iterative task processing accuracy of the optical processor, the convergence efficiency of the execution results obtained after executing the iterative task is improved. Furthermore, the optical processor sends the first execution result obtained from executing the iterative task to the electrical processor, which then executes the iterative task based on the execution result of the optical processor. Because the optical processor has low latency and the electrical processor has high latency, this method can reduce the actual number of iterations of the electrical processor and improve the efficiency of ensuring the accuracy of iterative task processing. Furthermore, by using back-off sampling, the results of the electrical calculation are used to verify and correct the results of the optical calculation, thereby improving the convergence efficiency of the optical calculation.
[0059] In order to make the number of iterations (k) in the set iteration cycle more reasonable, in implementation, determining the number of iterations in the current iteration cycle includes:
[0060] obtaining a scale of a matrix for adjusting an optical signal;
[0061] Different strategies are used to determine the number of iterations in the current iteration cycle according to the size of the matrix.
[0062] Specifically, different strategies are adopted according to the size of the matrix to determine the number of iterations in the current iteration cycle, including:
[0063] When it is detected that the size of the matrix is less than or equal to the preset size, the predicted number of iterations in the current iteration cycle is output according to the pre-established time series prediction model; the actual number of back-off steps in the current iteration cycle is obtained; and the number of iterations in the current iteration cycle is determined according to the predicted number of iterations and the actual number of back-off steps;
[0064] When it is detected that the size of the matrix is larger than the preset size, the predicted number of iterations in the current iteration cycle is output according to the pre-established time series prediction model; and the number of iterations in the current iteration cycle is determined according to the predicted number of iterations.
[0065] There is no limit on the preset scale, which will be determined based on actual conditions.
[0066] When the size of the matrix is larger than the preset size, the number of iterations in the current iteration cycle is determined based on the predicted number of iterations and the actual number of backoff steps.
[0067] Fitting the actual number of backoff steps in the current iteration cycle to determine the final actual number of backoff steps;
[0068] Using a first weighting coefficient to perform weighted processing on the number of predicted iterations and the final actual back-off step number;
[0069] Obtain the weighted average and round it up;
[0070] The number of iterations in the current iteration cycle is determined based on the result after rounding up.
[0071] When the size of the matrix is less than or equal to the preset size, determining the number of iterations in the current iteration cycle based on the predicted number of iterations includes:
[0072] Get the result obtained by processing the predicted number of iterations using the actual number of backoff steps;
[0073] The result obtained after processing is used as the number of iterations in the current iteration cycle;
[0074] The processing of the predicted number of iterations using the actual number of backoff steps includes:
[0075] Fitting the actual number of backoff steps in the current iteration cycle to determine the final actual number of backoff steps;
[0076] Using a second weighting coefficient to perform weighted processing on the predicted number of iterations and the final actual backoff step number; wherein the second weighting coefficient is greater than the first weighting coefficient;
[0077] Get the weighted average and round it up.
[0078] In order to help those skilled in the art better understand the above method for determining the adaptive update k, the process of determining k will be described below in conjunction with specific embodiments. The specific method for adaptively updating k is as follows:
[0079] (1) When the calculation matrix size N is less than the specified threshold ε, build a time series prediction model (preferably, choose a deep learning model that is good at sequence prediction, such as a recurrent neural network (RNN) or Transformer).
[0080] (2) Collect a large amount of sequence data in advance to form a data set, set the initial iteration step number k0 (set to a fixed value, such as 5, 10, 20, etc.), count the actual backoff step number t at k0, the total number of backoff sampling times p, and use (p, k0, t) as input samples to train the prediction model. Preferably, the loss function Loss is set as:
[0081] ;
[0082] in, Predict the results for the model.
[0083] (3) Train this model and use it as a prediction model after training. As the initial value of k. And the actual number of steps t each time i Perform a one-variable multi-time equation fitting (the number of times is set to s, preferably, 6), and obtain the actual number of steps t' after fitting.
[0084] (4) The optimal setting of k each time is determined by the following formula:
[0085] ;
[0086] Among them, α is the first weight coefficient; Indicates rounding up.
[0087] (5) When the calculation matrix size N is larger than the specified threshold ε, the above model can be used to predict As an approximation, a similar formula is used, as follows:
[0088] ;
[0089] Wherein, β is the second weight coefficient, which should generally be greater than α.
[0090] In order to enable those skilled in the art to better understand the above-mentioned iterative task processing method, the following further describes the embodiments corresponding to the above-mentioned method. Figure 3 A flowchart of a method for processing iterative tasks based on back-sampling optoelectronic hybrid computing provided by an embodiment of the present invention is shown in FIG. Figure 3 As shown, the method includes:
[0091] S14: Initialize the computing task;
[0092] S15: Set the number of iteration steps k in the iteration cycle. The result of the light calculation completes k iterations. Set the result of the kth light calculation iteration to R k ;
[0093] S16: The k-1 optical calculation results are transferred to the electronic processor for calculation, and R is obtained.k ';
[0094] S17: R k With R k 'Then the data are sent to the comparator for comparison to determine whether the difference between the two is less than δ1; if so, proceed to step S18; if not, proceed to step S19;
[0095] S18: receiving this result and continuing to iterate using the light processor;
[0096] S19: Back off to the middle position (e.g., the k / 2 iteration), and calculate R again using the processor. (k / 2) ', and detect R (k / 2) 'with R (k / 2) The relationship between the difference and the threshold δ2;
[0097] S20: And so on, until the difference between the optical processor result and the electrical processor result is less than the threshold δ m until;
[0098] S21: When a result smaller than the threshold is found, the result of the electronic calculation is directly used as the initial input, thus completing the back-off sampling process;
[0099] S22: When the termination condition is reached, the calculation process is completed.
[0100] In implementation, the method for processing iterative tasks based on back-off sampling optoelectronic hybrid computing includes:
[0101] Step 1: Initialize the calculation task, preload the optical calculation parameters, and obtain all parameters used to adjust the optical signal.
[0102] Step 2: Set the number of iterations, k, within the iteration cycle (the initial setting can be based on experience and manual setting of k). Each time the optical computation completes k iterations, the result is passed to the electronic processor for another electronic computation iteration. The electronic processor here refers to an electronic processor capable of performing high-precision computations, such as a central processing unit (CPU) or graphics processing unit (GPU) capable of performing computations with arbitrary effective bits of precision, such as FP32 and FP64.
[0103] Step 3: Set the result of the kth light calculation iteration to R k , the k-1 calculation results R k-1 Transfer it to the electronic chip for calculation and get R k '.
[0104] Step 4: R k and R k'Pass it to the comparator for comparison. If the difference between the two is less than the custom threshold δ1, accept this result and continue to use the light processor iteration.
[0105] Step 5: If the difference between the two is greater than the custom threshold δ1, then return to the middle position (such as the k / 2th iteration) and use the processor to calculate R again. (k / 2) ', and judge whether it is greater than the custom threshold δ2, δ2 can be the same as δ1 or different.
[0106] Step 6: Repeat this process until the photoelectric result difference is less than the threshold δ m So far, m is the total number of times the electronic chip calculates in the same round (i.e., the same iteration cycle) (the worst case directly falls back to iteration step 1, which is equivalent to invalidating all the results of the optical calculation in this round).
[0107] Step 7: When a result smaller than the threshold is found, the result of the electronic calculation is directly used as the initial input, thus completing the back-off sampling process.
[0108] Step 8: Perform a new round of iteration, refer to the previous iteration number, update k according to the above method of adaptively updating k, and return to step 2.
[0109] Step 9: The calculation process is completed until the objective function is lower than the specified threshold, or the iteration reaches the specified number of rounds, or the convergence criterion is reached (the change between two results is less than the threshold d).
[0110] The method provides a method for processing iterative tasks of optoelectronic hybrid computing based on back-off sampling. By introducing back-off sampling, the result of electrical computing is used to judge whether to sample the result of optical computing, so as to improve the convergence efficiency of optical computing. By adaptively optimizing the number of sampling times, the sampling frequency of electrical computing is limited, the computing performance of the entire optoelectronic system is optimized, and the effect of accelerating optoelectronic hybrid computing is achieved. The method solves the technical problems of poor accuracy and difficult convergence of optical computing equipment in related technologies. By combining the accuracy of electrical computing and the low latency and high energy efficiency characteristics of optical computing, the advantages of both are fully utilized, thereby improving the performance of optoelectronic hybrid computing in processing computing problems involving iterations.
[0111] The following will further illustrate the above method by taking the iterative task of the Ising Model as an example.
[0112] The core idea of the Ising model is to view the magnetic material as a lattice, with each lattice point representing an atom or ion. Its magnetic moment can be represented by a spin variable, typically taking the value of +1 (up) or -1 (down). The spin interaction between adjacent lattice points is described by an energy function, which generally assumes that the interaction between spins is neighborly, meaning that only adjacent spins interact. The energy of this interaction is typically proportional to the product of the spins, with a lower energy when adjacent spins have the same orientation and a higher energy when adjacent spins have opposite orientations. The model may also include an external magnetic field term to describe the effect of the external magnetic field on the spins.
[0113] The Ising model is used to simulate optimization problems of complex systems, such as combinatorial optimization problems like the maximum cut problem. In addition, variants of the Ising model are used to describe and simulate various complex interacting systems.
[0114] Hamiltonian of the Ising model It can be written as:
[0115] ;
[0116] in, Indicates the A particle with spin up or down, whose value can be {-1, 1}, Indicates the a particle with its spin up or down, Represents the element of row i and column j of the N*N matrix, used to describe and The interaction between represents the external magnetic field.
[0117] All Composition vector , iterative vector (Equation 1), where Depend on Derived, the noise can be system noise or artificially added random noise. The next iteration vector The expression is:
[0118] ; (Equation 2)
[0119] in, Represents the decision vector, which is calculated by the following formula:
[0120] ; (Equation 3)
[0121] The goal of the iterative solution of the Ising model is to give a , seeking a stable According to the above description, it can be calculated by iterative method: first randomly set an arbitrary , and then substitute into equation 1 to obtain , and then update according to equation 2 to get , and so on, until the iteration vector convergence.
[0122] The specific implementation example of the iterative solution of the Ising model is as follows:
[0123] (1) The optical processor is preloaded Matrix parameters, initialize a (for example =[-1,1,1,1]), which is input into the light processor for calculation.
[0124] (2) Set the number of iteration steps k (k is initialized according to the existing model), and after completing k iterations, obtain ,for example ,Will It is transferred to the electronic processor for calculation and obtained .
[0125] (3) and Pass it to the comparator for comparison. If the difference between the two (using the root mean square calculation, the difference between the two is (0.15-0.75)^2=0.36), the custom threshold δ1=0.5, assuming it is less than the custom threshold, then accept this result ( ), convert this result into an integer , continue to iterate using the light processor.
[0126] (4) If the difference between the two is greater than the custom threshold δ1, then return to the middle position of the kth iteration of this round (such as the result obtained after the k / 2th iteration) and calculate again using the processor , and judge whether it is greater than the custom threshold δ2.
[0127] (5) And so on, until the photoelectric result difference is found to be less than the threshold δ m So far, m is the total number of times the electronic processor calculates in the same round of backoff (the worst case directly backs off to iteration step 1, which is equivalent to invalidating all the results of the optical calculation in this round).
[0128] (6) When a result smaller than the threshold is found, the result of the electronic calculation is directly used as the initial input, that is, the back-sampling process is completed (for example, the final result is , then the fallback sampling is based on this result and passed to subsequent calculations).
[0129] (7) Perform a new round of iteration, refer to the previous iteration steps, adaptively update k, and re-enter step (2).
[0130] (8) The calculation process is completed until the objective function is lower than the specified threshold, or the iteration reaches the specified number of rounds, or convergence is achieved.
[0131] In this method, through the coordination of optoelectronic computing, the computational accuracy and convergence of the iterative tasks in the Ising model are improved by back-sampling, and the optoelectronic hybrid processing iterative tasks are efficiently realized; by adaptively optimizing the number of sampling times to limit the sampling frequency of electrical computing, the performance of optoelectronic hybrid computing in processing computational problems involving iterations is improved; while sacrificing some computational efficiency by back-sampling, the worst electrical computing acceleration of the Clog(c) level is achieved by designing the number of electrical computing sampling times, where c is the number of continuous optical calculations and C is the total number of cycles.
[0132] A method for processing an iterative task is described above. This embodiment further provides an optoelectronic hybrid device, which includes an optical processor and an electrical processor, wherein the optical processor is connected to the electrical processor.
[0133] The optical processor is used to send a first execution result obtained by executing an iterative task by itself to the electronic processor; so that the electronic processor executes the iterative task according to the first execution result and obtains a second execution result; obtains the difference between the first execution result and the second execution result at the same number of iterations; wherein the number of iterations of the electronic processor is the sum of the number of iterations corresponding to the first execution result and the actual number of iterations of the electronic processor; selects a target difference that meets the preset requirements from the obtained difference, and uses the same number of iterations corresponding to the target difference as the target same number of iterations; uses the second execution result at the target same number of iterations to execute the iterative task; the electronic processor is used to execute the iterative task according to the first execution result and obtain the second execution result.
[0134] The optoelectronic hybrid device provided in this embodiment has the same or corresponding technical features as the method for processing iterative tasks described above. The embodiment of the method for processing iterative tasks has been described in detail above and will not be repeated here.
[0135] An embodiment of the present invention further provides an iterative task processing device, comprising:
[0136] a sending module, configured to send a first execution result obtained by executing the iterative task to the electronic processor, so that the electronic processor executes the iterative task according to the first execution result and obtains a second execution result;
[0137] a first acquisition module, configured to acquire a difference between a first execution result and a second execution result at the same number of iterations; wherein the number of iterations of the electronic processor is the sum of the number of iterations corresponding to the first execution result received by the electronic processor and the actual number of iterations of the electronic processor;
[0138] A selection module is used to select a target difference value that meets preset requirements from the obtained difference values, and use the same number of iterations corresponding to the target difference value as the target same number of iterations;
[0139] The execution module is used to execute the iterative task using the second execution result when the target is the same as the iteration.
[0140] In some embodiments, the selection and use module includes a selection module for selecting a target difference value that meets preset requirements from the obtained difference values.
[0141] The selected modules include:
[0142] The acquisition and comparison module is used to obtain the difference value at the same iteration and compare the relationship between the difference value and the threshold value;
[0143] The first module is used to use the difference value at the same iteration as the target difference value if the difference value is less than or equal to the threshold value;
[0144] The second acquisition module is used to obtain the difference value of the new current same iteration if the difference value is greater than the threshold value, wherein the number corresponding to the new current same iteration is less than the number corresponding to the previous current same iteration; return to trigger the comparison module; wherein the comparison module is used to compare the relationship between the difference value and the threshold value.
[0145] In some embodiments, the second acquisition module includes:
[0146] The first detection and acquisition module is configured to, when detecting that the number of times corresponding to the previous current same iteration is an even number, use half of the number of times corresponding to the previous current same iteration as the number of times corresponding to the new current same iteration; and obtain a new current same iteration based on the number of times corresponding to the new current same iteration;
[0147] The second detection and acquisition module is used to round up half of the number corresponding to the previous current same iteration when it is detected that the number corresponding to the previous current same iteration is an odd number, and use the number obtained after rounding up as the number corresponding to the new current same iteration; and obtain the new current same iteration according to the number corresponding to the new current same iteration.
[0148] In some embodiments, the sending module includes:
[0149] a sending submodule, configured to send a first execution result obtained by executing the iterative task a target number of times within a current iteration cycle to the electronic processor; wherein a plurality of iterations are executed within the current iteration cycle, and the target number of times is any one of the remaining iterations except the last iteration;
[0150] The first acquisition module is specifically used to obtain the difference between the first execution result and the second execution result at the same iteration in the current iteration cycle.
[0151] In some embodiments, the electronic processor executes an actual iterative task according to the first execution result.
[0152] The first acquisition module is specifically configured to include:
[0153] The second module is used to set the number of iterations of the electronic processor as the number corresponding to the same iteration;
[0154] The first acquisition submodule is used to obtain the difference between the first execution result and the second execution result in the same iteration.
[0155] In some embodiments, the apparatus for processing an iterative task further includes a first determination module configured to determine a threshold.
[0156] The first determination module specifically includes:
[0157] The third acquisition module is used to obtain the current number of times corresponding to the same iteration;
[0158] The first determination submodule is configured to determine a threshold value corresponding to the current number of times according to a preset correspondence relationship between the number of times and the threshold value; wherein, in the correspondence relationship, the number of times and the threshold value are positively correlated.
[0159] In some embodiments, the iterative task processing device further includes:
[0160] A fourth acquisition module is configured to acquire a preset termination condition for the iterative task; wherein the termination condition includes at least the loss function of the iterative task being less than a preset loss value, the iteration reaching a preset iteration cycle, or the change between two consecutive execution results being less than a preset change value;
[0161] A fifth acquisition module is configured to acquire a new current iteration cycle and return to trigger the first acquisition module when detecting that the iterative task does not meet the termination condition;
[0162] The output module is used to output the execution result of the iterative task when it is detected that the iterative task meets the termination execution condition.
[0163] In some embodiments, the iterative task processing device further includes:
[0164] A sixth acquisition module is configured to acquire the number of differences from the start of determining the target number of iterations to the determination of the target number of iterations, and determine the total number of backoff sampling times of the electronic processor in the current iteration cycle based on the number of differences;
[0165] A seventh acquisition module is used to obtain the difference between the number of iterations corresponding to the same target and the number of iterations in the current iteration cycle, and use the difference as the number of backoff steps in the current iteration cycle;
[0166] The third module is used to use the number of iterations in the current iteration cycle, the total number of backoff samplings of the electronic processor in the current iteration cycle, and the number of backoff steps in the current iteration cycle as processing parameters of the iteration task in the current iteration cycle.
[0167] In some embodiments, the apparatus for processing an iterative task includes a second determining module configured to determine the number of iterations in a current iteration cycle.
[0168] The second determination module includes:
[0169] an eighth acquisition module, configured to acquire a scale of a matrix for adjusting an optical signal;
[0170] The third determination module is used to determine the number of iterations in the current iteration cycle using different strategies according to the size of the matrix.
[0171] In some embodiments, the third determining module specifically includes:
[0172] The second determination submodule is configured to output a predicted number of iterations in the current iteration cycle according to a pre-established time series prediction model when it is detected that the size of the matrix is less than or equal to a preset size; obtain the actual number of back-off steps in the current iteration cycle; and determine the number of iterations in the current iteration cycle according to the predicted number of iterations and the actual number of back-off steps;
[0173] The third determination submodule is used to output the predicted number of iterations in the current iteration cycle according to the pre-established time series prediction model when it is detected that the size of the matrix is greater than the preset size; and determine the number of iterations in the current iteration cycle according to the predicted number of iterations.
[0174] In some embodiments, the second determining submodule specifically includes:
[0175] A fitting module is used to fit the actual number of backoff steps in the current iteration cycle to determine the final actual number of backoff steps;
[0176] A weighted processing module, configured to perform weighted processing on the predicted number of iterations and the final actual backoff step number using a first weighting coefficient;
[0177] a ninth obtaining module, configured to obtain a weighted average value and round up the weighted average value;
[0178] The fourth determining submodule is configured to determine the number of iterations in the current iteration cycle according to a result after rounding up.
[0179] In some embodiments, the third determination submodule specifically includes:
[0180] a tenth acquisition module, configured to obtain a result obtained by processing the predicted number of iterations using the actual number of backoff steps;
[0181] The fourth module is used to use the result obtained after processing as the number of iterations in the current iteration cycle.
[0182] For the description of the features in the embodiment corresponding to the iterative task processing device, please refer to the relevant description of the embodiment corresponding to the iterative task processing method, which will not be repeated here.
[0183] An embodiment of the present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in the embodiment of the processing method for any of the above-mentioned iterative tasks.
[0184] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned iterative task processing method embodiments when run.
[0185] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0186] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any of the above-mentioned processing method embodiments for iterative tasks are implemented.
[0187] An embodiment of the present invention also provides another computer program product, including a non-volatile computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps in the processing method embodiment of any of the above-mentioned iterative tasks.
[0188] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0189] The above is a detailed introduction to the iterative task processing method, optoelectronic hybrid device medium and product provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, the present invention can also be improved and modified in several ways, and these improvements and modifications also fall within the scope of protection of the present invention.
Claims
1. A method for processing an iterative task, characterized in that: Applied to an optical processor, the method comprises: sending a first execution result obtained by executing the iterative task to the electronic processor, so that the electronic processor executes the iterative task according to the first execution result and obtains a second execution result; Obtaining a difference between a first execution result and a second execution result at the same iteration number; wherein the number of iterations of the electronic processor is the sum of the number of iterations corresponding to the first execution result received by the electronic processor and the actual number of iterations of the electronic processor; Select a target difference value that meets the preset requirements from the obtained difference values, and use the same number of iterations corresponding to the target difference value as the target same number of iterations; Execute the iterative task using the second execution result when the target is the same as the iteration; Sending a first execution result obtained by executing the iterative task to the electronic processor includes: Sending a first execution result obtained by executing the iterative task a target number of times within the current iteration cycle to the electronic processor; wherein multiple iterations are executed within the current iteration cycle, and the target number of times is any one of the remaining iterations except the last iteration; The difference between the first execution result and the second execution result when obtaining the same number of iterations includes: Get the difference between the first execution result and the second execution result at the same iteration in the current iteration cycle.
2. The method for processing iterative tasks according to claim 1, characterized in that: The step of selecting a target difference value that meets preset requirements from the obtained difference values includes: Get the difference value at the same current iteration and compare the relationship between the difference value and the threshold; If the difference is less than or equal to the threshold, the difference at the same current iteration is used as the target difference; If the difference is greater than the threshold, obtain the difference at the new current same iteration, where the number of times corresponding to the new current same iteration is less than the number of times corresponding to the previous current same iteration; return to the step of comparing the relationship between the difference and the threshold.
3. The method for processing iterative tasks according to claim 2, characterized in that: Getting the new current iteration includes: When it is detected that the number of times corresponding to the previous current same iteration is an even number, half of the number of times corresponding to the previous current same iteration is used as the number of times corresponding to the new current same iteration; and a new current same iteration is obtained according to the number of times corresponding to the new current same iteration; When it is detected that the number corresponding to the previous current same iteration is an odd number, half of the number corresponding to the previous current same iteration is rounded up, and the number obtained after rounding up is used as the number corresponding to the new current same iteration; the new current same iteration is obtained according to the number corresponding to the new current same iteration.
4. The method for processing iterative tasks according to claim 1, characterized in that: The electronic processor executes an actual iterative task according to the first execution result; The difference between the first execution result and the second execution result when obtaining the same number of iterations includes: Taking the number of iterations of the electronic processor as the number corresponding to the same iteration; Get the difference between the first and second execution results at the same iteration.
5. The method for processing an iterative task according to any one of claims 2 to 4, characterized in that: Determining the threshold includes: Get the current number of iterations. The threshold value corresponding to the current number of times is determined according to a predetermined correspondence relationship between the number of times and the threshold value; wherein, in the correspondence relationship, the number of times and the threshold value are positively correlated.
6. The method for processing iterative tasks according to claim 1, characterized in that: After executing the iterative task using the second execution result of the same target iteration, the method further includes: Obtaining a preset termination condition for the iterative task; wherein the termination condition includes at least that the loss function of the iterative task is less than a preset loss value, the iteration reaches a preset iteration cycle, or the change between two adjacent execution results is less than a preset change value; When it is detected that the iterative task does not meet the execution termination condition, obtaining a new current iterative cycle, and returning to the step of sending the first execution result obtained by executing the iterative task for the target number of times within the current iterative cycle to the electronic processor; When it is detected that the iterative task satisfies the execution termination condition, the execution result of the iterative task is output.
7. The method for processing iterative tasks according to claim 6, characterized in that: After executing the iterative task using the second execution result of the same target iteration, the method further includes: From the start of determining the target same number of iterations until the target same number of iterations is determined, obtaining a number of differences, and determining a total number of backoff samplings of the electronic processor in the current iteration cycle according to the number of differences; Get the difference between the number of iterations corresponding to the same target and the number of iterations in the current iteration cycle, and use the difference as the number of backoff steps in the current iteration cycle; The number of iterations in the current iteration cycle, the total number of backoff samplings of the electronic processor in the current iteration cycle, and the number of backoff steps in the current iteration cycle are used as processing parameters of the iterative task in the current iteration cycle.
8. The method for processing iterative tasks according to claim 7, characterized in that: Determining the number of iterations in the current iteration cycle includes: obtaining a scale of a matrix for adjusting an optical signal; Different strategies are used to determine the number of iterations in the current iteration cycle according to the size of the matrix.
9. The method for processing iterative tasks according to claim 8, characterized in that: The method of determining the number of iterations in the current iteration cycle by adopting different strategies according to the size of the matrix includes: When it is detected that the size of the matrix is less than or equal to the preset size, outputting the predicted number of iterations in the current iteration cycle according to the pre-established time series prediction model; obtaining the actual number of back-off steps in the current iteration cycle; and determining the number of iterations in the current iteration cycle according to the predicted number of iterations and the actual number of back-off steps; When it is detected that the size of the matrix is larger than the preset size, the predicted number of iterations in the current iteration cycle is output according to the pre-established time series prediction model; and the number of iterations in the current iteration cycle is determined according to the predicted number of iterations.
10. The method for processing iterative tasks according to claim 9, characterized in that: Determining the number of iterations in the current iteration cycle according to the predicted number of iterations and the actual number of back-off steps includes: Fitting the actual number of backoff steps in the current iteration cycle to determine the final actual number of backoff steps; Using a first weighting coefficient to perform weighted processing on the predicted number of iterations and the final actual back-off step number; Obtain the weighted average and round it up; The number of iterations in the current iteration cycle is determined based on the result after rounding up.
11. The method for processing iterative tasks according to claim 9, characterized in that: Determining the number of iterations in the current iteration cycle according to the predicted number of iterations includes: Obtaining a result obtained by processing the predicted number of iterations using the actual number of backoff steps; The result obtained after processing is used as the number of iterations in the current iteration cycle; The processing of the predicted number of iterations using the actual number of backoff steps includes: Fitting the actual number of backoff steps in the current iteration cycle to determine the final actual number of backoff steps; Using a second weighting coefficient to perform weighted processing on the predicted number of iterations and the final actual backoff step number; wherein the second weighting coefficient is greater than the first weighting coefficient; Get the weighted average and round it up.
12. A photoelectric hybrid device, characterized in that: include: an optical processor and an electrical processor, wherein the optical processor is connected to the electrical processor; The optical processor is used to send a first execution result obtained by executing the iterative task to the electronic processor; so that the electronic processor executes the iterative task according to the first execution result and obtains a second execution result; obtains the difference between the first execution result and the second execution result at the same number of iterations; wherein the number of iterations of the electronic processor is the sum of the number of iterations corresponding to the first execution result and the actual number of iterations of the electronic processor; selects a target difference that meets preset requirements from the obtained difference, and uses the same number of iterations corresponding to the target difference as the target same number of iterations; and executes the iterative task using the second execution result at the target same number of iterations; The electronic processor is used to execute the iterative task according to the first execution result and obtain a second execution result; Sending a first execution result obtained by executing the iterative task to the electronic processor includes: Sending a first execution result obtained by executing the iterative task a target number of times within the current iteration cycle to the electronic processor; wherein multiple iterations are executed within the current iteration cycle, and the target number of times is any one of the remaining iterations except the last iteration; The difference between the first execution result and the second execution result when obtaining the same number of iterations includes: Get the difference between the first execution result and the second execution result at the same iteration in the current iteration cycle.
13. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the method for processing an iterative task according to any one of claims 1 to 11 are implemented.
14. 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 for processing an iterative task as claimed in any one of claims 1 to 11 are implemented.
Citation Information
Patent Citations
Task processing method and heterogeneous system
CN119166336A
Satellite information processing system and method based on photoelectric hybrid calculation
CN119814149A