A task execution method and device, electronic equipment and storage medium
By establishing a first list and a second list in the quantum computing task execution device and using parallel threads for multi-level scheduling, the problem of low efficiency in quantum computing task execution is solved, and multi-task parallel execution and efficient processing of priority tasks are achieved.
Patent Information
- Application Number
- CN202311124180.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-31
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2043-08-31
AI Technical Summary
During the quantum computing process, when multiple users send quantum computing tasks to the task execution device at the same time, the task execution device will execute them sequentially according to the order in which the quantum computing tasks were received, resulting in low computing efficiency.
By establishing a first list and a second list, multi-level scheduling is performed using parallel threads to find and cache quantum computing tasks that meet the preset parallel requirements and have the highest priority. When there are idle threads in the parallel threads, tasks are directly obtained from the second list for parallel execution.
It realizes the parallel execution of multiple quantum computing tasks, improves computing efficiency, reduces task acquisition time, and increases the execution probability of higher priority tasks.
Smart Images

Figure CN119539106B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of quantum computing technology, and in particular to a task execution method, device, electronic device and storage medium. Background Art
[0002] Quantum computing is a computational model that uses the basic properties of quantum mechanics to solve problems. By building a quantum physics hardware system that can be precisely operated and running quantum computing software to implement quantum algorithms, computational problems can be solved and applied to specific problems or fields.
[0003] During quantum computing, users can directly send quantum computing tasks to the task execution device, which then executes the received quantum computing tasks and obtains the task execution results. For example, when the task execution device is a measurement and control device in a quantum computing measurement and control system, upon receiving a quantum computing task such as a quantum state test sent by the user, the measurement and control device will execute the quantum computing task and obtain the corresponding task execution results.
[0004] In related technologies, when multiple users send quantum computing tasks to a task execution device at the same time, the task execution device will execute each quantum computing task in sequence according to the order of the received quantum computing tasks. The execution time of all quantum computing tasks is relatively long, which affects the efficiency of quantum computing. Summary of the Invention
[0005] The purpose of the embodiments of the present invention is to provide a task execution method, device, electronic device, and storage medium to enable the parallel execution of multiple quantum computing tasks and improve quantum computing efficiency. The specific technical solutions are as follows:
[0006] This embodiment of the present application provides a task execution method, the method comprising:
[0007] Obtaining a first judgment result according to a first state of a first list, a second state of a second list, and a third state of a parallel thread at a current moment, wherein the first list is used to cache first quantum computing tasks queued for execution, the second list is used to cache second quantum computing tasks obtained from the first list, and the parallel thread includes multiple threads for executing quantum computing tasks in parallel;
[0008] When the first judgment result indicates to perform a search operation in the first list, searching the first list for a quantum computing task that meets a preset parallel requirement according to the third quantum computing task currently being executed in the parallel thread;
[0009] Obtaining the quantum computing task with the highest priority from the quantum computing tasks that meet the preset parallel requirement and caching it in the second list;
[0010] When it is determined according to the fourth state that there is an idle thread in the parallel thread, obtaining a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task from the second list, wherein the fourth state is the thread state corresponding to each thread in the parallel thread at the current moment, and the fourth quantum computing task is the quantum computing task being executed in the parallel thread at the current moment;
[0011] The fifth quantum computing task is performed using the idle thread.
[0012] The present application also provides a task execution device, comprising:
[0013] a first acquisition module, configured to acquire a first judgment result based on a first state of a first list, a second state of a second list, and a third state of a parallel thread at a current moment, wherein the first list is used to cache first quantum computing tasks queued for execution, the second list is used to cache second quantum computing tasks obtained from the first list, and the parallel thread includes multiple threads for executing quantum computing tasks in parallel;
[0014] a first search module configured to search the first list for a quantum computing task that meets a preset parallel requirement based on a third quantum computing task currently being executed in the parallel thread when the first judgment result indicates that a search operation is to be performed in the first list;
[0015] A first cache module is configured to obtain the quantum computing task with the highest priority from the quantum computing tasks that meet the preset parallel requirement and cache it in the second list;
[0016] a second acquisition module configured to acquire, from the second list, a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task when it is determined according to a fourth state that an idle thread exists in the parallel thread, wherein the fourth state is a thread state corresponding to each thread in the parallel thread at a current moment, and the fourth quantum computing task is a quantum computing task being executed in the parallel thread at a current moment;
[0017] An execution module is configured to execute the fifth quantum computing task using the idle thread.
[0018] An embodiment of the present application further provides an electronic device, characterized in that it includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
[0019] Memory for storing computer programs;
[0020] The processor is configured to implement any of the above-mentioned task execution method steps when executing the program stored in the memory.
[0021] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any of the above-mentioned task execution method steps is implemented.
[0022] An embodiment of the present application also provides a quantum computer to implement any of the above-mentioned task execution methods.
[0023] An embodiment of the present invention further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above-mentioned task execution methods.
[0024] Beneficial effects of the embodiments of the present invention:
[0025] The technical solution provided by an embodiment of the present invention is that when the first judgment result indicates that a search operation is to be performed in the first list, the quantum computing task in the first list that meets the preset parallel requirements can be searched based on the quantum computing task currently being executed in the parallel thread, and the quantum computing task that meets the preset parallel requirements and has the highest priority can be cached in the second list. When it is determined that there is an idle thread in the parallel thread based on the thread state corresponding to the parallel thread at the current moment, a quantum computing task that can be executed in parallel with the quantum computing task currently being executed is obtained from the second list, that is, a fifth quantum computing task is obtained, and the fifth quantum computing task is executed using the idle thread. This allows the fifth quantum computing task to be executed in parallel with the quantum computing task currently being executed in the parallel thread, realizing the parallel execution of multiple quantum computing tasks and improving quantum computing efficiency.
[0026] Furthermore, because the quantum computing tasks cached in the second list are second quantum computing tasks that meet the preset parallelism requirement, the preset parallelism requirement allows for preliminary screening of the first quantum computing tasks cached in the first list, effectively reducing the number of quantum computing tasks cached in the second list. When an idle thread exists in the parallel threads, the fifth quantum computing task can be directly obtained from the second list. Compared to obtaining the fifth quantum computing task from the first list, this effectively reduces the number of quantum computing tasks included in the screening sample and shortens the time required to obtain the fifth quantum computing task, thereby reducing the idle time of the thread and improving quantum computing efficiency.
[0027] Furthermore, since the quantum computing tasks cached in the second list have a relatively high priority, this increases the probability that the quantum computing tasks with higher priority are cached in the second list, thereby increasing the probability that the quantum computing tasks with higher priority are executed first.
[0028] Of course, it is not necessary to achieve all of the advantages described above simultaneously in order to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0030] Figure 1 A structural diagram of a task execution system in related technology;
[0031] Figure 2 A first flow chart of the task execution method provided in an embodiment of the present application;
[0032] Figure 3 A second flowchart of the task execution method provided in an embodiment of the present application;
[0033] Figure 4 A third flow chart of the task execution method provided in an embodiment of the present application;
[0034] Figure 5 A fourth flow chart of the task execution method provided in an embodiment of the present application;
[0035] Figure 6 A fifth flow chart of the task execution method provided in an embodiment of the present application;
[0036] Figure 7 A sixth flow chart of the task execution method provided in an embodiment of the present application;
[0037] Figure 8 A seventh flowchart of the task execution method provided in an embodiment of the present application;
[0038] Figure 9 This is a schematic diagram of an eighth flow chart of the task execution method provided in an embodiment of the present application;
[0039] Figure 10 A ninth flowchart of the task execution method provided in an embodiment of the present application;
[0040] Figure 11 A schematic diagram of the structure of a task execution device provided in an embodiment of the present application;
[0041] Figure 12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0042] 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 the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0043] like Figure 1 As shown, Figure 1 FIG. 1 is a structural diagram of a task execution system in the related art. The task execution system includes a user terminal 101 and a task execution device 102. The task execution device 102 can be connected to multiple user terminals 101 for communication ( Figure 1 not shown).
[0044] Different users can send quantum computing tasks to the task execution device through their respective client terminals. The task execution device needs to process each received quantum computing task one by one and obtain the task execution results. Because all quantum computing tasks in the task execution device need to be executed one by one, it will take a long time to complete all quantum computing tasks.
[0045] In addition, with the continuous growth in the number of connected user terminals and the continuous increase in the number of quantum computing tasks that users need to perform, quantum computing tasks may be queued in the task execution devices, resulting in the inability to execute quantum computing tasks for a long time, affecting the user experience.
[0046] In order to solve the problems in the related art, the embodiment of the present application provides a task execution method. The method can be applied to any electronic device. Figure 2 As shown, Figure 2 This is a first flow chart of a task execution method provided in an embodiment of the present application. The method includes the following steps.
[0047] Step S201: Obtain a first judgment result based on the first state of the first list, the second state of the second list, and the third state of the parallel thread at the current moment, where the first list is used to cache first quantum computing tasks queued for execution, and the second list is used to cache second quantum computing tasks obtained from the first list. The parallel thread includes multiple threads for executing quantum computing tasks in parallel.
[0048] Step S202: When the first judgment result indicates to perform a search operation in the first list, a quantum computing task that meets the preset parallel requirement is searched in the first list according to the third quantum computing task currently being executed in the parallel thread.
[0049] Step S203: Obtain the quantum computing task with the highest priority from the quantum computing tasks that meet the preset parallel requirements and cache it in the second list.
[0050] Step S204: When it is determined that there is an idle thread in the parallel thread according to the fourth state, a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task is obtained from the second list. The fourth state is the thread state corresponding to each thread in the parallel thread at the current moment, and the fourth quantum computing task is the quantum computing task being executed in the parallel thread at the current moment.
[0051] Step S205: Use the idle thread to execute the fifth quantum computing task.
[0052] In the embodiment of the present application, the electronic device can be the above Figure 1 The task execution device that performs quantum computing tasks can also be a server that connects the user terminal and the task execution device. The electronic device mentioned above is not specifically limited here.
[0053] In steps S201-S205 above, multi-level scheduling of quantum computing tasks is implemented. Steps S201-S202 represent the high-level scheduling process, step S203 represents the mid-level scheduling process, and steps S204-S205 represent the low-level scheduling process. The details of each level of scheduling are described below and are not detailed here.
[0054] Through the method provided by the embodiment of the present application, when the first judgment result indicates that a search operation is to be performed in the first list, the quantum computing task in the first list that meets the preset parallel requirements can be searched based on the quantum computing task being executed in the parallel thread at the current moment, and the quantum computing task that meets the preset parallel requirements and has the highest priority is cached in the second list. When it is determined that there is an idle thread in the parallel thread based on the thread state corresponding to the parallel thread at the current moment, a quantum computing task that can be executed in parallel with the quantum computing task being executed at the current moment is obtained from the second list, that is, a fifth quantum computing task is obtained, and the fifth quantum computing task is executed using the idle thread. This allows the fifth quantum computing task to be executed in parallel with the quantum computing task currently being executed in the parallel thread, realizing the parallel execution of multiple quantum computing tasks and improving quantum computing efficiency.
[0055] Furthermore, because the quantum computing tasks cached in the second list are second quantum computing tasks that meet the preset parallelism requirement, the preset parallelism requirement allows for preliminary screening of the first quantum computing tasks cached in the first list, effectively reducing the number of quantum computing tasks cached in the second list. When an idle thread exists in the parallel threads, the fifth quantum computing task can be directly obtained from the second list. Compared to obtaining the fifth quantum computing task from the first list, this effectively reduces the number of quantum computing tasks included in the screening sample and shortens the time required to obtain the fifth quantum computing task, thereby reducing the idle time of the thread and improving quantum computing efficiency.
[0056] Furthermore, since the quantum computing tasks cached in the second list have a relatively high priority, this increases the probability that the quantum computing tasks with higher priority are cached in the second list, thereby increasing the probability that the quantum computing tasks with higher priority are executed first.
[0057] The embodiments of the present application are described below through specific examples.
[0058] For the above step S201, that is, according to the first state of the first list at the current moment, the second state of the second list, and the third state of the parallel thread, a first judgment result is obtained, the first list is used to cache the first quantum computing task queued for execution, the second list is used to cache the second quantum computing task obtained from the first list, and the parallel thread includes multiple threads for executing quantum computing tasks in parallel.
[0059] In the embodiment of the present application, a first list and a second list are cached in the electronic device.
[0060] The first list is used to cache quantum computing tasks queued for execution (referred to as first quantum computing tasks). Each first quantum computing task is sent by a user via a user terminal to the electronic device. The electronic device can simultaneously communicate with one or more user terminals. Whenever a user triggers a quantum computing task via a user terminal, the user terminal sends the quantum computing task to the electronic device. After receiving the quantum computing tasks sent by each user terminal, the electronic device can cache each quantum computing task in the first list according to the time each quantum computing task was received.
[0061] The second list is used to cache second quantum computing tasks obtained from the first list. The second quantum computing tasks are the first quantum computing tasks in the first list that meet the preset parallelism requirements and have the highest priority. Through the high-level and mid-level scheduling processes, the electronic device can filter the second quantum computing tasks from the first list and cache them in the second list.
[0062] The second quantum computing tasks cached in the second list may include parallelizable quantum computing tasks and / or replaceable quantum computing tasks. A parallelizable quantum computing task is a quantum computing task that can be executed in parallel with all currently executing quantum computing tasks, as determined when searching for quantum computing tasks that meet the preset parallelization requirements. A replaceable quantum computing task is a quantum computing task that can replace a target quantum computing task among all currently executing quantum computing tasks, as determined when searching for quantum computing tasks that meet the preset parallelization requirements, and can be executed in parallel with other quantum computing tasks.
[0063] For ease of understanding, let's take the example of searching for quantum computing tasks that meet the preset parallelism requirements, where the quantum computing tasks currently being executed in parallel threads are Tasks 1-5. In the first list, any quantum computing task that can be executed in parallel with all quantum computing tasks in Tasks 1-5 is a parallelizable quantum computing task that meets the preset parallelism requirements. For any quantum computing task in Tasks 1-5, such as Task 1, any quantum computing task that can be executed in parallel with the remaining quantum computing tasks (i.e., Tasks 2-5) is a replaceable quantum computing task that meets the preset parallelism requirements (denoted as the replaceable quantum computing task corresponding to Task 1). The method for searching for quantum computing tasks that meet the preset parallelism requirements can be found in the description below and will not be explained in detail here.
[0064] In an optional embodiment, the number of second quantum computing tasks cached in the second list is limited, i.e., the number is a first preset number. The number of cached parallel quantum computing tasks is at most one, and the number of cached replaceable quantum computing tasks (referred to as the second preset number) is at most the number of threads included in the parallel threads. The first preset number is equal to the second preset number plus one. The first preset number and the second preset number are not specifically limited herein.
[0065] For the first list, the second list, and the parallel threads, the electronic device can obtain a first judgment result based on the current cache state of the first list (recorded as the first state), the cache state of the second list (recorded as the second state), and the thread state corresponding to each thread in the parallel threads (recorded as the third state). The first judgment result is used to indicate whether to perform a search operation in the first list.
[0066] In an optional embodiment, the first judgment result may indicate not to perform a search operation in the first list, or may indicate to perform a search operation in the first list. When the first judgment result indicates to perform a search operation in the first list, the first judgment result may indicate to perform a search in the first list for parallelizable quantum computing tasks, or the first judgment result may indicate to perform a search in the first list for replaceable quantum computing tasks. The determination of the first state, second state, third state, and first judgment result may be described below and will not be detailed here.
[0067] In an optional embodiment, the cached quantum computing tasks in the first and second lists may be represented as task information for the quantum computing tasks. This task information may include a task identifier for the quantum computing task and parallelism determination data for the quantum computing task. The parallelism determination data is used to determine whether different quantum computing tasks can be executed in parallel. Alternatively, the task information may include a task identifier for the quantum computing task and all computational data required for executing the quantum computing task. The parallelism determination data is a portion of the total computational data. The representation of the quantum computing tasks cached in the first and second lists is not specifically limited.
[0068] In the embodiment of the present application, the first list and the second list may be queues, data tables, etc. Here, the representation methods of the first list and the second list are not specifically limited.
[0069] Regarding the above step S202, that is, when the first judgment result indicates to perform a search operation in the first list, a quantum computing task that meets the preset parallel requirement is searched in the first list according to the third quantum computing task currently being executed in the parallel thread.
[0070] In an optional embodiment, when the above-mentioned first judgment result indicates to search for parallel quantum computing tasks in the first category list, the electronic device can search for quantum computing tasks that can be executed in parallel with all third quantum computing tasks in the first list based on the quantum computing tasks being executed in the parallel thread at the current moment (recorded as third quantum computing tasks). That is, the quantum computing tasks in the first list that can be executed in parallel with the currently executing quantum computing tasks are the quantum computing tasks that meet the preset parallel requirements.
[0071] In another optional embodiment, when the first judgment result indicates searching the first list for a replaceable quantum computing task, the electronic device may search the first list for a target quantum computing task currently being executed in a parallel thread and for which no corresponding replaceable quantum computing task exists. In other words, a quantum computing task in the first list that can be executed in parallel with all other third quantum computing tasks other than the target quantum computing task is a quantum computing task that meets the preset parallelism requirement.
[0072] The above-mentioned preset parallel requirements are used to measure whether any first quantum computing task in the first list can be executed in parallel with all quantum computing tasks currently being executed, or to measure whether any first quantum computing task in the first list can take over the target quantum computing task and be executed in parallel with other quantum computing tasks currently being executed.
[0073] In an optional embodiment, the aforementioned parallelism determination data is used to determine whether different quantum computing tasks can be executed in parallel. Therefore, the aforementioned preset parallelism requirement can be set based on the aforementioned parallelism determination data. The aforementioned preset parallelism requirement will also vary depending on the parallelism determination data. Details regarding the setting of the preset parallelism requirement are described below and are not further detailed here.
[0074] After executing steps S201 and S202, the electronic device completes the high-level scheduling process. Based on the number of quantum computing tasks found in step S202 that meet the preset parallelism requirement, the electronic device may choose to enter the intermediate-level scheduling process, or skip the intermediate-level scheduling process and directly enter the low-level scheduling process. For details, see the following description and are not detailed here.
[0075] Through the above-mentioned high-level scheduling process, the electronic device can preliminarily screen the quantum computing tasks in the first list that meet the preset parallel requirements. This allows the electronic device to directly obtain quantum computing tasks that can be executed in parallel from the second list that stores a relatively small number of quantum computing tasks once an idle thread appears during the subsequent low-level scheduling execution process, rather than obtaining quantum computing tasks that can be executed in parallel from the first list that stores a relatively large number of quantum computing tasks. This effectively shortens the time required to obtain quantum computing tasks in the later stage and improves the execution efficiency of quantum computing tasks.
[0076] Regarding the above step S203, that is, from the quantum computing tasks that meet the preset parallel requirements, the quantum computing task with the highest priority is obtained and cached in the second list.
[0077] In this step, when the electronic device executes step S202 above, if the number of quantum computing tasks that meet the preset parallelism requirement is determined to be multiple, the electronic device may enter the intermediate scheduling process, that is, select the quantum computing task with the highest priority from the quantum computing tasks that meet the preset parallelism requirement as the second quantum computing task, and cache the second quantum computing task in the second list.
[0078] In an embodiment of the present application, for each first quantum computing task in the first list, the electronic device may determine the priority corresponding to each first quantum computing task based on the attribute information corresponding to the first quantum computing task.
[0079] The attribute information includes, but is not limited to, the user authority level corresponding to the user who triggered the first quantum computing task, the queue length of the first quantum computing task, and the expected execution time of the first quantum computing task. The attribute information of the quantum computing task is not specifically limited herein.
[0080] In an optional embodiment, the electronic device may perform a weighted calculation based on the numerical values corresponding to each dimension of the attribute information and a preset weight, and use the weighted sum obtained as the priority of the quantum computing task. The method for determining the priority corresponding to each first quantum computing task is not specifically limited herein.
[0081] In an optional embodiment, when the number of quantum computing tasks that meet the preset parallel requirements found in the above step S202 is one, the electronic device can directly obtain the quantum computing task and cache the quantum computing task as a second quantum computing task in the above second list.
[0082] In another optional embodiment, when the number of quantum computing tasks that meet the preset parallel requirements found in the above step S202 is empty, that is, when no quantum computing tasks that meet the preset parallel requirements are found in the first list, the electronic device can skip the above intermediate scheduling process and directly enter the low-level scheduling process.
[0083] In an embodiment of the present application, once the above-mentioned high-level scheduling process finds that there are multiple quantum computing tasks that meet the preset parallel requirements, by executing the above-mentioned intermediate scheduling process, the number of quantum computing tasks cached in the second list can be effectively reduced, thereby shortening the time it takes for the subsequent low-level scheduling process to obtain quantum computing tasks that can be executed in parallel, thereby improving the execution efficiency of quantum computing tasks.
[0084] Moreover, since the intermediate scheduling process is performed according to the priority of the quantum computing task, the probability that the quantum computing task with a higher priority is cached in the second list is increased, thereby increasing the probability that the quantum computing task with a higher priority is executed first.
[0085] Regarding the above step S204, that is, when it is determined according to the fourth state that there is an idle thread in the parallel thread, a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task is obtained from the second list. The fourth state is the thread state corresponding to each thread in the parallel thread at the current moment, and the fourth quantum computing task is the quantum computing task being executed in the parallel thread at the current moment.
[0086] After caching the second quantum computing task in the second list, the electronic device can directly enter the low-level scheduling process. At this time, the electronic device can obtain the thread state corresponding to each thread in the parallel thread at the current moment (recorded as the fourth state).
[0087] Based on the fourth state, the electronic device can determine the current state information of each of the parallel threads, such as its occupied / locked or idle state. For each thread in the occupied / locked state, the electronic device can determine the quantum computing task currently being executed by the thread (referred to as the fourth quantum computing task) based on the thread state.
[0088] In the fourth state, if the thread state corresponding to a particular thread is the idle state, the electronic device may determine that an idle thread exists among the parallel threads. Upon determining that an idle thread exists among the parallel threads based on the fourth state, the electronic device may obtain, from the second list, a quantum computing task (referred to as a fifth quantum computing task) that can be executed in parallel with all currently executing quantum computing tasks (referred to as the fourth quantum computing task). The method for obtaining the fifth quantum computing task is described below and is not further elaborated here.
[0089] In an optional embodiment, for the above step S204, if the electronic device does not find the above fifth quantum computing task in the second list, the electronic device can return to execute the above step S201, that is, execute the step of obtaining the first judgment result based on the first state of the first list at the current moment, the second state of the second list and the third state of the parallel thread.
[0090] In an optional embodiment, when the electronic device determines that there are no idle threads in the parallel threads based on the fourth state, that is, when each thread is executing a quantum computing task, the electronic device may return to execute the step S201, that is, return to execute the step of obtaining the first judgment result based on the first state of the first list at the current moment, the second state of the second list, and the third state of the parallel thread.
[0091] Regarding the above step S205, the fifth quantum computing task is executed by using the idle thread.
[0092] In an optional embodiment, when the electronic device is the server, the electronic device can send the fifth quantum computing task obtained in step S204 to the task execution device. When receiving the fifth quantum computing task, the task execution device invokes the idle thread to execute the fifth quantum computing task, and obtains the task execution result.
[0093] In another optional embodiment, when the electronic device is the task execution device, the electronic device can directly invoke the idle thread to execute the fifth quantum computing task obtained in step S204, and obtain the task execution result.
[0094] In the embodiments of the present application, the process of executing the quantum computing task by the parallel thread is not described in detail.
[0095] In an optional embodiment, according to the method shown in Figure 2 The embodiments of the present application also provide a task execution method. As shown in Figure 3 Figure 3 A second flow diagram of the task execution method provided by the embodiments of the present application. The method comprises the following steps.
[0096] Step S301: obtaining the cache state of the first list at the current time as the first state.
[0097] The first state is the cache state of the first list, which can include state information and cache information corresponding to each storage space in the first list. The state information can include an idle state indicating that there is no quantum computing task cached, and an occupied state indicating that there is a quantum computing task cached. The cache information is the quantum computing task cached in the corresponding storage space.
[0098] Step S302: obtaining the cache state of the second list at the current time as the second state.
[0099] The second state is the cache state of the second list, which includes state information and cache information corresponding to each storage space in the second list. The description of the second state can refer to the description of the first state, which is not described in detail here.
[0100] Step S303: obtaining the thread state corresponding to each thread in the parallel thread at the current time as the third state.
[0101] The third state is the thread state of each parallel thread, which may include state information and thread information for the corresponding thread. The state information may include an occupied / locked state, indicating that the thread is executing a quantum computing task, and an idle state, indicating that the thread is not executing a quantum computing task. The thread information may include information related to the quantum computing task being executed by the thread when it is in the occupied / locked state, such as the task identifier of the quantum computing task. The thread information in the third state is not specifically limited herein.
[0102] In the embodiment of the present application, the above steps S301 to S303 are executed simultaneously, that is, the current moments in the above steps S301 to S303 are the same moment.
[0103] Step S304: judging whether to perform a search operation in the first list according to the first state, the second state and the third state, and obtaining a first judgment result.
[0104] For the first state, the electronic device can determine whether the first quantum computing task cached in the first list is empty based on the state information in the first state, and obtain a first determination result. That is, when each state information included in the first state is the idle state, the electronic device can determine that no quantum computing tasks are stored in the first list, and in this case, the electronic device can obtain a first determination result indicating that the first list is empty. When any one or more state information included in the first state is the occupied state, the electronic device can determine that a quantum computing task is cached in the cache space corresponding to the occupied state, and in this case, the electronic device can obtain a first determination result indicating that the first list is not empty.
[0105] For the second state, the electronic device can determine whether the second quantum computing task cached in the second list is empty based on the state information in the second state, thereby obtaining a second determination result. The method for determining the second determination result can refer to the method for determining the first determination result and is not described in detail here.
[0106] Furthermore, considering that the second quantum computing tasks cached in the second list include the parallelizable quantum computing tasks and the replaceable quantum computing tasks, to facilitate differentiation, the electronic device may cache the parallelizable quantum computing tasks in the first cache space and the replaceable quantum computing tasks in the second cache space. Therefore, based on the state information in the second state, the second determination result may also indicate whether there are any parallelizable quantum computing tasks cached in the second list, and whether the number of replaceable quantum computing tasks cached in the second list equals a second preset number.
[0107] In an optional embodiment, for the second state, when the state information corresponding to the first cache space is the occupied state, the electronic device can determine that the first cache space caches the parallelizable quantum computing task, and the electronic device can obtain the second list indicating that the parallelizable quantum computing task is cached.
[0108] In the embodiments of the present application, since the number of the replaceable quantum computing tasks cached in the second list is the second preset number, the number of the second cache spaces can be the second preset number.
[0109] For the second state, when the state information corresponding to each second cache space in the second list is the occupied state, the electronic device can determine that each second cache space in the second list caches a quantum computing task, and the electronic device can obtain the second determination result indicating that the number of the replaceable quantum computing tasks cached in the second list is equal to the second preset number. When the state information corresponding to any one or more second cache spaces in the second list is the idle state, the electronic device can determine that the second cache space corresponding to the idle state does not cache the replaceable quantum computing task, and the electronic device can obtain the second determination result indicating that the number of the replaceable quantum computing tasks cached in the second list is less than the second preset number.
[0110] For the third state, the electronic device can determine whether there is an idle thread in the parallel thread according to the state information in the third state, and obtain a third determination result. That is, when each thread state included in the third state is the occupied state / locked state, the electronic device can obtain the third determination result indicating that there is no idle thread in the parallel thread; when any one or more thread states included in the third state is the idle thread, the electronic device can obtain the third determination result indicating that there is an idle thread in the parallel thread.
[0111] According to the first determination result, the second determination result and the third determination result, the electronic device can determine whether to perform a search operation on the first list, and obtain a first determination result.
[0112] For the first determination result, the second determination result and the third determination result, at least the following cases exist.
[0113] Case one, the first determination result indicates that the first list is empty. That is, the first list does not cache a quantum computing task.
[0114] When the case one occurs, the electronic device can not consider the second determination result and the third determination result.
[0115] Case two, the first determination result indicates that the first list is not empty, and the second determination result indicates that the number of the second quantum computing tasks cached in the second list is equal to the first preset number. That is, the first quantum computing task is cached in the first list, and the second quantum computing task is cached in each cache space in the second list.
[0116] When the above case two occurs, for each thread in the parallel thread, the thread can execute a quantum computing task or can not execute a quantum computing task. That is, the third determination result can indicate that there is an idle thread or can indicate that there is no idle thread at this time.
[0117] Case three, the first determination result indicates that the first list is not empty, the second determination result indicates that no parallel second quantum computing task is cached in the second list, and the third determination result indicates that there is an idle thread. That is, the first quantum computing task is cached in the first list, and no quantum computing task is cached in the first cache space of the second list. At this time, the second list can be empty, that is, no quantum computing task is stored; the second list can also be non-empty, that is, the second cache space of the second list caches a replaceable quantum computing task.
[0118] Case four, the first determination result indicates that the first list is not empty, the second determination result indicates that the number of replaceable quantum computing tasks cached in the second list is less than the second preset number, and the third determination result indicates that there is no idle thread. That is, the first quantum computing task is cached in the first list, the number of replaceable quantum computing tasks cached in the second list does not reach the maximum value, and there is no idle thread in the parallel thread. At this time, the second list can be empty or can store part of the second quantum computing tasks.
[0119] Case five, the first determination result indicates that the first list is not empty, and the second determination result indicates that the second list caches a parallel quantum computing task. That is, the first quantum computing task is cached in the first list, and the first cache space of the second list caches a parallel quantum computing task.
[0120] When the above case five occurs, there can be an idle thread in the parallel thread or there can be no idle thread.
[0121] For the above five cases, the electronic device will obtain different first determination results, which can be seen from the following description and will not be described here.
[0122] The above steps S301-S304 are a refinement of the above step S201.
[0123] Through the above steps S301 to S304, the electronic device can determine whether to perform a search operation in the first list based on the cache status of the first list, the cache status of the second list, and the thread status of each thread in the parallel thread at the current moment. This enables the electronic device to cache the first quantum computing task that meets the requirements in the first list to the second list in a timely manner, thereby maintaining the stability of the second quantum computing task cached in the second list.
[0124] Step S305: When the first judgment result indicates to perform a search operation in the first list, a quantum computing task that meets the preset parallel requirement is searched in the first list according to the third quantum computing task currently being executed in the parallel thread.
[0125] Step S306: Obtain the quantum computing task with the highest priority from the quantum computing tasks that meet the preset parallel requirements and cache it in the second list.
[0126] Step S307: When it is determined that there is an idle thread in the parallel thread according to the fourth state, a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task is obtained from the second list, where the fourth state is the thread state corresponding to each thread in the parallel thread at the current moment, and the fourth quantum computing task is the quantum computing task being executed in the parallel thread at the current moment.
[0127] Step S308: Use the idle thread to execute the fifth quantum computing task.
[0128] The above steps S305 to S308 are the same as the above steps S202 to S205.
[0129] In an optional embodiment, according to the above Figure 3 The method shown in the embodiment of the present application also provides a task execution method. Figure 4 As shown, Figure 4 This is a third flow chart of the task execution method provided in the embodiment of the present application. Figure 4 In the method shown, the above step S304 is refined into the following steps, namely, step S3041 to step S3043.
[0130] Step S3041: When the first list is determined to be empty according to the first state, or when the first list is determined to be non-empty according to the first state and the number of second quantum computing tasks cached in the second list is determined to be equal to a first preset number according to the second state, a first judgment result indicating that a search operation is not performed in the first list is obtained.
[0131] In the embodiment of the present application, after the electronic device determines the first determination result, the second determination result and the third determination result respectively according to the first state, the second state and the third state, any one of the above situations 1 to 5 may occur.
[0132] When the above situation 1 or situation 2 occurs, the first judgment result obtained by the electronic device may indicate that the search operation is not performed in the first list.
[0133] In the embodiment of the present application, the electronic device will perform other steps ( Figure 4 For details, please refer to the following description and will not be described here.
[0134] Step S3042: When it is determined according to the first state that the first list is not empty, it is determined according to the second state that no parallelizable quantum computing tasks are cached in the second list, and it is determined according to the third state that there are idle threads in the parallel threads, a first judgment result is obtained indicating that a parallelizable quantum computing task is searched in the first list.
[0135] In this step, for the above situations 1 to 5, when the above situation 3 occurs, the first judgment result obtained by the electronic device may indicate to search for parallelizable quantum computing tasks in the first list.
[0136] Step S3043: When it is determined according to the first state that the first list is not empty, it is determined according to the second state that the number of replaceable quantum computing tasks cached in the second list is less than the second preset number, and it is determined according to the third state that no idle thread exists among the multiple threads, or when it is determined according to the first state that the first list is not empty, it is determined according to the second state that parallelizable quantum computing tasks are cached in the second list and the number of replaceable quantum computing tasks cached in the second list is less than the second preset number, a first judgment result indicating searching the first list for replaceable quantum computing tasks is obtained.
[0137] In this step, for the above situations 1 to 5, when the above situation 4 or 5 occurs, the first judgment result obtained by the electronic device may indicate to search the first list for a replaceable quantum computing task.
[0138] In the embodiment of the present application, the above steps S3041 to S3043 are steps respectively executed by the electronic device according to the differences among the above first determination result, the second determination result, and the third determination result.
[0139] In the above Figure 4 In the illustrated embodiment, the electronic device may execute the above-mentioned step S305 after executing the above-mentioned step S3042 or step S3043.
[0140] Through steps S3041-S3043, the electronic device can obtain different first determination results for different situations, and thus execute the high-level scheduling process according to different first determination results, thereby improving the flexibility of quantum computing task scheduling.
[0141] In the above embodiment, the electronic device determines the first determination result according to the first state, the second state, and the third state. In addition, the electronic device can also determine the first determination result according to the result of the last round of high-level scheduling process. For example, in the last round of high-level scheduling process, the first determination result indicates to find a parallelizable quantum computing task in the first list. However, the electronic device does not find a parallelizable quantum computing task in the first list. At this time, in the new round of high-level scheduling process, the electronic device can directly obtain the first determination result indicating to find a replaceable quantum computing task in the first list.
[0142] In an optional embodiment, according to the method shown in Figure 2 The embodiment of the present application also provides a task execution method. As shown in Figure 5 The fourth flowchart of the task execution method provided by the embodiment of the present application is shown in Figure 5 The method shown in the above embodiment is increased with the following steps, i.e., steps S206-S208. Figure 5
[0143] In step S206, when the first determination result indicates not to perform the search operation in the first list, the thread state of each thread in the parallel thread at the current time is obtained as the fifth state.
[0144] In this step, when the first determination result indicates not to perform the search operation in the first list, the electronic device can skip the middle-level scheduling process and perform the low-level scheduling process. At this time, considering that the first determination result acquisition needs to consume a certain amount of time, during which the thread state of each thread in the parallel thread may be updated or may not be updated. Therefore, in order to ensure the accuracy of task execution, the electronic device can reacquire the thread state of each thread in the parallel thread at the current time as the fifth state when the first determination result indicates not to perform the search operation in the first list.
[0145] The fifth state can be the same as the third state, or can be different from the third state.
[0146] In the embodiment of the present application, steps S206 and S202 are steps executed when the first determination result is different. Herein, the execution of steps S202 and S206 is not specifically limited.
[0147] Step S207: When it is determined according to the fifth state that there is an idle thread in the parallel threads and it is determined according to the second state that the second list is not empty, a step of obtaining a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task from the second list is performed.
[0148] In an embodiment of the present application, after obtaining the fifth state, the electronic device can determine whether there is an idle thread among the parallel threads based on the fifth state, thereby obtaining a fourth determination result. The fourth determination result can be determined by referring to the third determination result, and will not be described in detail here.
[0149] According to the difference between the fourth determination result and the second determination result, the electronic device will respectively perform different steps. The determination results corresponding to the fourth determination result and the second determination result may include the following situations.
[0150] Case six: the fourth determination result indicates that there is an idle thread in the parallel threads, and the second determination result indicates that the second list is not empty.
[0151] Case seven: the fourth determination result indicates that there is an idle thread in the parallel threads, and the second determination result indicates that the second list is empty.
[0152] Case eight: the fourth determination result indicates that there is no idle thread in the parallel threads, and the second determination result indicates that the second list is empty.
[0153] Case nine: the fourth determination result indicates that there is no idle thread in the parallel threads, and the second determination result indicates that the second list is not empty.
[0154] In the embodiment of the present application, considering that when the first judgment result indicates that a search operation is not to be performed in the first list, the electronic device does not execute the above step S203 and has not yet begun to execute the above step S204, the cache state of the second list at the current moment has not changed, that is, the cache state remains in the above second state. Therefore, in the above step S206, when obtaining the fifth state, the cache state of the second list at the current moment is not re-obtained.
[0155] In an optional embodiment, in order to ensure the accuracy of the cache status of the second list at the current moment, the electronic device may also synchronously obtain the cache status of the second list while obtaining the fifth status.
[0156] In an embodiment of the present application, when the fourth determination result and the second determination result satisfy the sixth condition, the electronic device may determine that there is an idle thread in the parallel threads that can be used to execute the quantum computing task, and that the second list also contains parallelizable quantum computing tasks and / or replaceable quantum computing tasks waiting to be executed. At this point, the electronic device may execute step S204 above, obtaining a quantum computing task from the second list to be executed in parallel with the fourth quantum computing task, as a step for executing the fifth quantum computing task.
[0157] Step S208, when it is determined that there are no idle threads in the parallel threads according to the fifth state, and / or when it is determined that the second list is empty according to the second state, return to the step of obtaining the first judgment result according to the first state of the first list at the current moment, the second state of the second list and the third state of the parallel threads.
[0158] In this step, when the fourth determination result and the second determination result satisfy any one of the above-mentioned situations seven, eight or nine, the electronic device may return to execute the above-mentioned step S201, that is, return to execute the step of executing the first state of the first list at the current moment, the second state of the second list and the third state of the parallel thread.
[0159] In the embodiment of the present application, the above steps S207 and S208 are respectively executed when the above fourth determination result and the second determination result are different. Here, the execution of the above steps S207 and S208 is not specifically limited.
[0160] Through the above steps S206 to S208, when the electronic device determines that no search operation is to be performed in the first list, it can directly enter the low-level scheduling process. Thus, according to the thread state at the current moment and the cache state of the second list, it can choose to obtain a quantum computing task that can be executed in parallel with the currently executing quantum computing task and execute the quantum computing task, or choose to re-enter the high-level scheduling process. This improves the flexibility of multi-level scheduling while ensuring the orderly execution of the quantum computing tasks cached in the second list.
[0161] In an optional embodiment, when the first judgment result indicates to search for parallelizable quantum computing tasks in the first list, according to the above Figure 2 The method shown in the embodiment of the present application also provides a task execution method. Figure 6 As shown, Figure 6 This is a fifth flow chart of the task execution method provided in the embodiment of the present application. Figure 6 In the method shown, the above step S202 is refined into the following steps, namely step S2021.
[0162] In step S2021, when the first judgment result indicates that parallel quantum computing tasks are to be searched in the first list, based on the task information corresponding to each first quantum computing task and the task information corresponding to each third quantum computing task currently being executed in the parallel thread, the quantum computing tasks in the first list that can be executed in parallel with all the third quantum computing tasks are searched as quantum computing tasks that meet the preset parallel requirements.
[0163] In this step, when the first judgment result indicates that a parallelizable quantum computing task is being searched in the first list, the electronic device may traverse each first quantum computing task in the first list. For each traversed first quantum computing task, the electronic device may determine, based on the task information of the first quantum computing task and the task information corresponding to each third quantum computing task currently being executed in the parallel thread, whether the first quantum computing task can be executed in parallel with all third quantum computing tasks. If the first quantum computing task can be executed in parallel with all third quantum computing tasks, the electronic device may determine that the first quantum computing task meets the preset parallel requirement; if the first quantum computing task cannot be executed in parallel with all third quantum computing tasks, the electronic device may determine that the first quantum computing task does not meet the preset parallel requirement. The electronic device may determine that all first quantum computing tasks in the first list that meet the preset parallel requirement are each a determined parallelizable quantum computing task.
[0164] In an optional embodiment, the task information may include qubit identifiers. These qubit identifiers represent the identifiers of all qubits required to execute the corresponding quantum computing task. Furthermore, the task information may include other information, such as the read frequency of the read cavity. The information included in the task information for the quantum computing task is not specifically limited.
[0165] In an optional embodiment, when the task information includes a quantum bit identifier, step S2021 may be specifically expressed as follows:
[0166] When the first judgment result indicates searching for parallelizable quantum computing tasks in the first list, based on the first quantum bit identifier in the task information corresponding to each first quantum computing task in the first list and the second quantum bit identifier in the task information corresponding to each third quantum computing task currently being executed in the parallel thread, search the first list for the first quantum computing task whose corresponding task information does not include the second quantum bit identifier as the quantum computing task that meets the preset parallel requirement.
[0167] In this step, if the first judgment result indicates that a parallelizable quantum computing task is to be searched in the first list, then for each first quantum computing task in the first list, the electronic device may compare the quantum bit identifier (recorded as the first quantum bit identifier) in the task information corresponding to the first quantum computing task with the quantum bit identifier (recorded as the second quantum bit identifier) in the task information corresponding to all third quantum computing tasks currently being executed in the parallel thread. If the first quantum bit identifier and the second quantum bit identifier are different, the electronic device may determine that the first quantum computing task corresponding to the first quantum bit identifier can be executed in parallel with all third quantum computing tasks. If the first quantum bit identifier and the second quantum bit identifier contain the same quantum bit identifier, the electronic device may determine that the first quantum computing task corresponding to the first quantum bit cannot be executed in parallel with all third quantum computing tasks. The electronic device selects all first quantum computing tasks that can be executed in parallel with the third quantum computing tasks as quantum computing tasks that meet the preset parallelization requirements.
[0168] Through the above-mentioned step S2021, when the first judgment result indicates that the electronic device searches for parallelizable quantum computing tasks in the first list, it can determine whether there is a bit conflict between the quantum bits required for executing the first quantum computing task and the quantum bits required for executing all the third quantum computing tasks by comparing the first quantum bit identifier corresponding to the first quantum computing task with the second quantum bit identifiers corresponding to all the third quantum computing tasks, thereby avoiding the impact of the quantum bit conflict on the parallel execution of quantum computing tasks, providing a guarantee for the parallel execution of different quantum computing tasks, and improving the accuracy and effectiveness of the second quantum computing tasks that are later cached in the second list.
[0169] In an optional embodiment, when the first judgment result indicates to search for a replaceable quantum computing task in the first list, Figure 2 The method shown in the embodiment of the present application also provides a task execution method. Figure 7 As shown, Figure 7 This is a sixth flow chart of the task execution method provided in the embodiment of the present application. Figure 7 In the method shown, the above step S202 is refined into the following steps, namely step S2022 to step S2024.
[0170] Step S2022: When the first judgment result indicates searching for a replaceable quantum computing task in the first list, for each third quantum computing task currently being executed in the parallel thread, determine whether a replaceable quantum computing task corresponding to the third quantum computing task is cached in the second list, and obtain a second judgment result.
[0171] In this embodiment of the present application, for each replaceable quantum computing task cached in the second cache space of the second list, the second list may also record the currently executing quantum computing task corresponding to each replaceable quantum computing task. For ease of understanding, the third quantum computing task described above is used as an example. Based on the correspondence between the third quantum computing task and the replaceable quantum computing task corresponding to the third quantum computing task, the electronic device may cache the corresponding replaceable quantum computing task in the second list.
[0172] For each third quantum computing task being executed in the parallel thread at the current moment, the electronic device can determine whether a replaceable quantum computing task corresponding to the third quantum computing task is cached in the above second list to obtain a second judgment result.
[0173] The above second judgment result can indicate whether each third quantum computing task has a corresponding replaceable quantum computing task.
[0174] Step S2023: Based on the second judgment result, the sixth quantum computing task with the shortest remaining execution time is selected as the target quantum computing task; the sixth quantum computing task is the third quantum computing task for which there is no corresponding quantum computing task that can be replaced.
[0175] In this embodiment of the present application, based on the second determination result, the electronic device can determine whether there is a corresponding replaceable quantum computing task in the second list for each third quantum computing task. Third quantum computing tasks that do not correspond to a corresponding replaceable quantum computing task are recorded as sixth quantum computing tasks.
[0176] For each third quantum computing task, the electronic device can determine the remaining execution time corresponding to the third quantum computing task. The remaining execution time corresponding to each third quantum computing task can be determined based on the historical execution time of historical quantum computing tasks and the task execution time corresponding to the third quantum computing task at the current moment. For example, for a certain third quantum computing task, the electronic device can obtain the historical execution time of the same historical quantum computing task as the third quantum computing task as the expected execution time of the third quantum computing task. The electronic device can calculate the difference between the expected execution time and the task execution time of the third quantum computing task at the current moment to obtain the remaining execution time corresponding to the third quantum computing task.
[0177] According to the remaining execution time corresponding to each third quantum computing task, the electronic device can determine the quantum computing task with the shortest remaining execution time among the above-mentioned sixth quantum computing tasks as the target quantum computing task.
[0178] Step S2024: Based on the task information corresponding to each first quantum computing task and the task information corresponding to each seventh quantum computing task, search the first list for a quantum computing task that can be executed in parallel with all seventh quantum computing tasks as a quantum computing task that meets the preset parallelization requirement; the seventh quantum computing task is a third quantum computing task other than the target quantum computing task.
[0179] In an optional embodiment, the above step S2024 can be specifically expressed as follows:
[0180] According to the first quantum bit identifier in the task information corresponding to each first quantum computing task and the third quantum bit identifier in the task information corresponding to each seventh quantum computing task, the first quantum computing task whose corresponding task information does not include the third quantum bit identifier is searched in the first list as the quantum computing task that meets the preset parallel requirements.
[0181] The quantum computing task that meets the preset parallel requirement determined in the above step S2024 is the replaceable quantum computing task corresponding to the above target quantum computing task.
[0182] Through steps S2022-S2024, when determining to search for a replaceable quantum computing task in the first list, the sixth quantum computing task with the shortest remaining execution time is selected as the target quantum computing task, thereby searching the first list for the replaceable quantum computing task corresponding to the target quantum computing task. This allows the quantum computing task with a relatively short remaining execution time to be prioritized in determining its corresponding replaceable quantum computing task. This allows the replaceable quantum computing task corresponding to the target quantum computing task to be executed promptly after the quantum computing task is completed, achieving a seamless connection between the target quantum computing task and the replaceable quantum computing task, thereby improving the execution efficiency of the quantum computing task.
[0183] In an optional embodiment, according to the above Figure 2 The method shown in the embodiment of the present application also provides a task execution method. Figure 8 As shown, Figure 8 This is a seventh flow chart of the task execution method provided in the embodiment of the present application. Figure 8 The above step S204 is refined into the following steps, namely step S2041-step S2044.
[0184] Step S2041: When it is determined according to the fourth state that there is an idle thread in the parallel threads, it is determined whether there is a target replaceable quantum computing task cached in the second list, and a third judgment result is obtained. The target replaceable quantum computing task corresponds to the eighth quantum computing task executed before the idle thread state is updated.
[0185] In an optional embodiment, for each thread in the parallel threads, when the thread state of the thread is updated, the electronic device may record the thread update information. When it is determined based on the fourth state that there is an idle thread in the parallel threads, the electronic device may determine the quantum computing task (recorded as the eighth quantum computing task) executed before the idle thread state was updated based on the recorded update information.
[0186] For the eighth quantum computing task, the electronic device may search the second list to see whether there is a replaceable quantum computing task corresponding to the eighth quantum computing task (recorded as the target replaceable quantum computing task) to obtain a third judgment result.
[0187] The third judgment result is used to indicate whether there is a replaceable quantum computing task corresponding to the eighth quantum computing task cached in the second list.
[0188] Step S2042: If the third judgment result is yes, then when the target replaceable quantum computing task meets the preset parallel requirement, the target replaceable quantum computing task is obtained as a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task.
[0189] In an embodiment of the present application, when the above-mentioned third judgment result is yes, that is, when the third judgment result indicates that the target replaceable quantum computing task corresponding to the above-mentioned eighth quantum computing task is cached in the second list, the electronic device can determine whether the target replaceable quantum computing task meets the above-mentioned preset parallel requirements, that is, determine whether the target replaceable quantum computing task can be executed in parallel with the currently executing quantum computing task.
[0190] When the target replaceable quantum computing task meets the preset parallelism requirement, the electronic device may determine that the target replaceable quantum computing task can be executed in parallel with the currently executing fourth quantum computing task. At this point, the electronic device may acquire the target replaceable quantum computing task as the fifth quantum computing task.
[0191] Step S2043: If the third judgment result is no, or if the target replaceable quantum computing task does not meet the preset parallel requirement, then obtain the parallelizable quantum computing tasks cached in the second list.
[0192] In an optional embodiment, when the third judgment result is no, that is, when the third judgment result indicates that the target replaceable quantum computing task corresponding to the eighth quantum computing task is not cached in the second list, the electronic device can obtain the parallelizable quantum computing task from the first cache space of the second list.
[0193] In another optional embodiment, when the target replaceable quantum computing task does not meet the preset parallel requirements, that is, when the target replaceable quantum computing task cannot be executed in parallel with the fourth quantum computing task currently being executed, the electronic device can obtain the parallelizable quantum computing task from the first cache space in the second list.
[0194] In the embodiment of the present application, step S2043 may be performed after step S2041, that is, when the result of the third judgment is No. Step S2043 may also be performed after step S2042, that is, when the target replaceable quantum computing task does not meet the preset parallelism requirement.
[0195] Step S2044: When the obtained parallelizable quantum computing task meets the preset parallel requirement, the parallelizable quantum computing task is determined as a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task.
[0196] In this step, after obtaining the parallelizable quantum computing tasks in the second list, the electronic device may determine whether the parallelizable quantum computing tasks meet the preset parallelism requirement, that is, whether the parallelizable quantum computing tasks can be executed in parallel with all fourth quantum computing tasks. If the parallelizable quantum computing tasks meet the preset parallelism requirement, the electronic device may determine that the parallelizable quantum computing tasks can be executed in parallel with all fourth quantum computing tasks. At this point, the electronic device may determine that the parallelizable quantum computing tasks are the fifth quantum computing tasks.
[0197] In an optional embodiment, when the parallelizable quantum computing task obtained in the above step S2023 does not meet the above preset parallel requirements, the electronic device may return to execute the above step S201, that is, return to execute the above step of obtaining the first judgment result based on the first state of the first list at the current moment, the second state of the second list, and the third state of the parallel thread.
[0198] Through the above steps S2041 to S2044, during the low-level scheduling process, the electronic device re-determines whether the quantum computing task obtained from the second list meets the preset parallel requirements, that is, re-determines whether the quantum computing task can be executed in parallel with the currently executing quantum computing task. This ensures that the determined fifth quantum computing task can be executed in parallel with all fourth quantum computing tasks, thereby improving the accuracy of the determined fifth quantum computing task and providing a guarantee for the parallel execution of different quantum computing tasks.
[0199] In an optional embodiment, according to the above Figure 2 The method shown in the embodiment of the present application also provides a task execution method. Figure 9 As shown, Figure 9 The eighth flowchart of the task execution method provided in the embodiments of the present application is shown. The method comprises the following steps.
[0200] In step S901, a first determination result is obtained according to the first state of the first list, the second state of the second list and the third state of the parallel threads. The first list is used to cache the first quantum computing tasks waiting for execution in a queue, the second list is used to cache the second quantum computing tasks obtained from the first list, and the parallel threads comprise a plurality of threads used to execute quantum computing tasks in parallel.
[0201] In step S902, when the first determination result indicates that a search operation is performed in the first list, a quantum computing task satisfying the preset parallel requirement is searched in the first list according to the third quantum computing task being executed at the current time in the parallel threads.
[0202] In step S903, the quantum computing task with the highest priority is obtained from the quantum computing tasks satisfying the preset parallel requirement and cached in the second list.
[0203] In step S904, when it is determined according to the fourth state that there is an idle thread in the parallel threads, the fifth quantum computing task capable of being executed in parallel with the fourth quantum computing task is obtained from the second list. The fourth state is the thread state corresponding to each thread in the parallel threads at the current time, and the fourth quantum computing task is the quantum computing task being executed in the parallel threads at the current time.
[0204] In step S905, the idle thread is used to execute the fifth quantum computing task.
[0205] The steps S901-S905 are the same as the steps S201-S205.
[0206] In step S906, the tenth quantum computing task not satisfying the preset parallel requirement is searched in the second list according to the ninth quantum computing task being executed in the parallel threads at the current time.
[0207] In the embodiments of the present application, when the electronic device executes the fifth quantum computing task by using the idle thread, the quantum computing tasks executed in parallel in the parallel threads are changed. The quantum computing task being executed in the parallel threads at this time is recorded as the ninth quantum computing task.
[0208] In an optional embodiment, for the parallelizable quantum computing tasks in the second list, the electronic device may determine whether the parallelizable quantum computing task can be executed in parallel with all of the ninth quantum computing tasks, thereby determining whether the parallelizable quantum computing task meets the preset parallelism requirement. If it is determined that the parallelizable quantum computing task cannot be executed in parallel with all of the ninth quantum computing tasks, the electronic device may determine that the parallelizable quantum computing task is a tenth quantum computing task that does not meet the preset parallelism requirement.
[0209] In another optional embodiment, for the replaceable quantum computing tasks in the second list above, the electronic device can determine whether the replaceable quantum computing task can replace its corresponding ninth quantum computing task and be executed in parallel with other ninth quantum computing tasks, and determine the replaceable quantum computing task that cannot be executed in parallel with other ninth quantum computing tasks as a tenth quantum computing task that does not meet the preset parallel requirements.
[0210] Step S907: caching the tenth quantum computing task into the first list.
[0211] In this step, since the tenth quantum computing task does not meet the preset parallel requirements, in order to avoid the tenth quantum computing task in the second list interfering with the subsequent low-level scheduling process, the electronic device can cache the tenth quantum computing task determined in step S906 in the first list.
[0212] In an optional embodiment, when re-caching the above-mentioned tenth quantum computing task to the first list, the electronic device may re-cache the tenth quantum computing task to the same position in the first list before the tenth quantum computing task is cached to the second list.
[0213] Through the above steps S906 and S907, the electronic device can re-cache the tenth quantum computing task in the second list to the first list when the quantum computing task currently being executed in parallel changes. This effectively avoids the impact of the conflict between the above-mentioned ninth quantum computing task and the tenth quantum computing task in the second list on the parallel execution of quantum computing tasks, and improves the accuracy and effectiveness of the second quantum computing task cached in the second list.
[0214] In an optional embodiment, according to the above Figure 2 The method shown in the embodiment of the present application also provides a task execution method. Figure 10 As shown, Figure 10 This is a ninth flow chart of the task execution method provided in the embodiment of the present application. The method includes the following steps.
[0215] Step S1001: Obtain a first judgment result based on the first state of the first list, the second state of the second list, and the third state of the parallel thread at the current moment, where the first list is used to cache first quantum computing tasks queued for execution, and the second list is used to cache second quantum computing tasks obtained from the first list. The parallel thread includes multiple threads for executing quantum computing tasks in parallel.
[0216] Step S1002: When the first judgment result indicates to perform a search operation in the first list, a quantum computing task that meets the preset parallel requirement is searched in the first list according to the third quantum computing task currently being executed in the parallel thread.
[0217] Step S1003: Obtain the quantum computing task with the highest priority from the quantum computing tasks that meet the preset parallel requirements and cache it in the second list.
[0218] Step S1004: When it is determined that there is an idle thread in the parallel thread according to the fourth state, a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task is obtained from the second list. The fourth state is the thread state corresponding to each thread in the parallel thread at the current moment, and the fourth quantum computing task is the quantum computing task being executed in the parallel thread at the current moment.
[0219] Step S1005: Use the idle thread to execute the fifth quantum computing task.
[0220] The above steps S1001 to S1005 are the same as the above steps S201 to S205.
[0221] Step S1006: Based on the task information of the fifth quantum computing task, lock the idle thread to obtain a locked thread.
[0222] In an optional embodiment, when the electronic device uses an idle thread to execute the fifth quantum computing task, it can lock the idle thread according to the quantum bit identifier in the task information corresponding to the fifth quantum computing task to obtain a locked thread.
[0223] Step S1007 : for each locked thread, when the locking time corresponding to the locked thread is greater than a preset time threshold, release the locked thread.
[0224] In this step, for each locked thread, the electronic device can determine the lock duration corresponding to the locked thread and compare the lock duration corresponding to the locked thread with a preset duration threshold. If the lock duration corresponding to the locked thread is greater than the preset duration threshold, the electronic device can determine that the locked thread is an abnormal thread. At this time, the electronic device can release the locked thread.
[0225] The above-mentioned preset duration threshold can be set according to the expected execution time of the quantum computing task corresponding to the locked thread. Here, the above-mentioned preset duration threshold is not specifically limited.
[0226] In an embodiment of the present application, when the electronic device releases the above-mentioned locked thread, the quantum computing task corresponding to the locked thread is an abnormal task. The electronic device can discard the abnormal task, or issue an abnormal alarm to the user who triggered the task for the abnormal task.
[0227] In addition, when the electronic device releases the locked thread, the thread state of the locked thread will change, that is, from the locked state to the idle state.
[0228] In an optional embodiment, when the locking time corresponding to the locking thread is not greater than a preset time threshold, the electronic device may not perform any processing.
[0229] Through the above steps S1006 and S1007, the electronic device can release the thread in time when the locking time of the thread is greater than the preset time threshold, thereby avoiding the impact of abnormal threads on the quantum computing task process and improving the fault tolerance of the task execution process.
[0230] In the above Figure 10 In the illustrated embodiment, abnormal threads are identified by comparing their lock duration with a preset duration threshold. Furthermore, for each locked thread, the electronic device can extend the corresponding thread lock when the lock duration of the locked thread equals the expected execution duration of the corresponding quantum computing task. If the number of extensions exceeds a preset threshold, the electronic device can determine that the locked thread is an abnormal thread and release the locked thread.
[0231] Based on the same inventive concept, according to the task execution method provided in the above embodiment of the present application, the embodiment of the present application also provides a task execution device. Figure 11 As shown, Figure 11 A schematic diagram of the structure of a task execution device provided in an embodiment of the present application. The method includes the following modules.
[0232] A first acquisition module 1101 is configured to acquire a first judgment result based on a first state of a first list, a second state of a second list, and a third state of a parallel thread at a current moment, wherein the first list is configured to cache first quantum computing tasks queued for execution, the second list is configured to cache second quantum computing tasks obtained from the first list, and the parallel thread includes multiple threads configured to execute quantum computing tasks in parallel;
[0233] A first search module 1102 is configured to search the first list for a quantum computing task that meets a preset parallel requirement based on the third quantum computing task currently being executed in the parallel thread when the first judgment result indicates that a search operation is to be performed in the first list;
[0234] A first cache module 1103 is configured to obtain the quantum computing task with the highest priority from the quantum computing tasks that meet the preset parallel requirements and cache it in a second list;
[0235] A second obtaining module 1104 is configured to obtain, from the second list, a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task when it is determined that an idle thread exists in the parallel thread according to the fourth state, where the fourth state is the thread state corresponding to each thread in the parallel thread at the current moment, and the fourth quantum computing task is the quantum computing task being executed in the parallel thread at the current moment;
[0236] The execution module 1105 is configured to execute the fifth quantum computing task using the idle thread.
[0237] Optionally, the first obtaining module 1101 may be specifically configured to obtain a cache state of the first list at a current moment as the first state;
[0238] Obtain the cache state of the second list at the current moment as the second state;
[0239] Obtaining the thread state corresponding to each thread in the parallel threads at the current moment as the third state;
[0240] According to the first state, the second state and the third state, it is determined whether a search operation is performed in the first list to obtain a first determination result.
[0241] Optionally, the first acquisition module 1101 may be specifically configured to obtain a first judgment result indicating that a search operation is not performed in the first list when the first list is determined to be empty according to the first state, or when the first list is determined to be non-empty according to the first state and the number of second quantum computing tasks cached in the second list is determined to be equal to a first preset number according to the second state;
[0242] When it is determined according to the first state that the first list is not empty, when it is determined according to the second state that no parallelizable quantum computing tasks are cached in the second list, and when it is determined according to the third state that there are idle threads in the parallel threads, a first judgment result is obtained indicating that a parallelizable quantum computing task is searched for in the first list;
[0243] When it is determined according to the first state that the first list is not empty, it is determined according to the second state that the number of replaceable quantum computing tasks cached in the second list is less than a second preset number, and it is determined according to the third state that no idle thread exists among the multiple threads, or when it is determined according to the first state that the first list is not empty, it is determined according to the second state that parallelizable quantum computing tasks are cached in the second list and the number of replaceable quantum computing tasks cached in the second list is less than the second preset number, obtaining a first judgment result instructing to search the first list for replaceable quantum computing tasks;
[0244] Among them, the parallelizable quantum computing task is a quantum computing task that can be executed in parallel with all quantum computing tasks being executed at the current moment when searching for quantum computing tasks that meet the preset parallel requirements; the replaceable quantum computing task is a quantum computing task that can be replaced by the target quantum computing task among all quantum computing tasks being executed at the current moment and executed in parallel with other quantum computing tasks when searching for quantum computing tasks that meet the preset parallel requirements.
[0245] Optionally, the task execution device may further include:
[0246] a third obtaining module, configured to obtain, when the first judgment result indicates that the search operation is not to be performed in the first list, a thread state of each thread in the parallel threads at a current moment as a fifth state;
[0247] a first calling module, configured to, when determining according to the fifth state that there is an idle thread in the parallel threads and determining according to the second state that the second list is not empty, call the second obtaining module 1104 to execute the step of obtaining, from the second list, a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task;
[0248] The second calling module is used to call the first acquisition module 1101 to return to execute the step of obtaining the first judgment result based on the first state of the first list at the current moment, the second state of the second list and the third state of the parallel thread when it is determined that there is no idle thread in the parallel thread according to the fifth state and / or the second list is determined to be empty according to the second state.
[0249] Optionally, the first search module 1102 may be specifically configured to, when the first judgment result indicates searching for parallelizable quantum computing tasks in the first list, search, based on task information corresponding to each first quantum computing task and task information corresponding to each third quantum computing task currently being executed in the parallel thread, for a quantum computing task in the first list that can be executed in parallel with all third quantum computing tasks, as a quantum computing task that meets the preset parallel requirement.
[0250] Optionally, the first search module 1102 may be configured to, when the first judgment result indicates searching for a replaceable quantum computing task in the first list, determine, for each third quantum computing task currently being executed in the parallel thread, whether a replaceable quantum computing task corresponding to the third quantum computing task is cached in the second list, to obtain a second judgment result.
[0251] Based on the second judgment result, the sixth quantum computing task with the shortest remaining execution time is selected as the target quantum computing task; the sixth quantum computing task is the third quantum computing task for which there is no corresponding quantum computing task that can take over;
[0252] Based on the task information corresponding to each first quantum computing task and the task information corresponding to each seventh quantum computing task, search the first list for a quantum computing task that can be executed in parallel with all seventh quantum computing tasks as a quantum computing task that meets the preset parallelization requirement; the seventh quantum computing task is the third quantum computing task other than the target quantum computing task.
[0253] Optionally, the above task information may include a quantum bit identifier;
[0254] The first search module 1102 may be specifically configured to search the first list for a first quantum computing task whose corresponding task information does not include the second quantum bit identifier, based on the first quantum bit identifier in the task information corresponding to each first quantum computing task in the first list and the second quantum bit identifier in the task information corresponding to each third quantum computing task currently being executed in the parallel thread, as a quantum computing task that meets the preset parallelization requirement.
[0255] The step of searching, in the first list, for a quantum computing task that can be executed in parallel with all the seventh quantum computing tasks based on the task information corresponding to each first quantum computing task and the task information corresponding to each seventh quantum computing task as a quantum computing task that meets the preset parallel requirement includes:
[0256] According to the first quantum bit identifier in the task information corresponding to each first quantum computing task and the third quantum bit identifier in the task information corresponding to each seventh quantum computing task, the first quantum computing task whose corresponding task information does not include the third quantum bit identifier is searched in the first list as the quantum computing task that meets the preset parallel requirements.
[0257] Optionally, the second obtaining module 1104 may be specifically configured to determine whether a target replaceable quantum computing task is cached in the second list, and obtain a third determination result that the target replaceable quantum computing task corresponds to the eighth quantum computing task executed before the idle thread state is updated.
[0258] If the third judgment result is yes, then when the target replaceable quantum computing task meets the preset parallel requirement, the target replaceable quantum computing task is obtained as a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task;
[0259] If the third judgment result is no, or if the target replaceable quantum computing task does not meet the preset parallel requirement, obtaining the parallelizable quantum computing tasks cached in the second list;
[0260] When the obtained parallelizable quantum computing task meets the preset parallel requirement, the parallelizable quantum computing task is determined as a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task.
[0261] Optionally, the task execution device may further include:
[0262] A second search module is configured to search, in the second list, for a tenth quantum computing task that does not meet the preset parallel requirement based on the ninth quantum computing task currently being executed in the parallel thread after executing the fifth quantum computing task using the idle thread;
[0263] The second cache module is used to cache the tenth quantum computing task into the first list.
[0264] Optionally, the task execution device may further include:
[0265] A locking module, configured to lock the idle thread based on task information of the fifth quantum computing task after executing the fifth quantum computing task using the idle thread, thereby obtaining a locked thread;
[0266] The task execution device may further include:
[0267] The release module is configured to release each locked thread when the locking time corresponding to the locked thread is greater than a preset time threshold.
[0268] Through the device provided by the embodiment of the present application, when the first judgment result indicates that a search operation is to be performed in the first list, the quantum computing task in the first list that meets the preset parallel requirements can be searched based on the quantum computing task currently being executed in the parallel thread, and the quantum computing task that meets the preset parallel requirements and has the highest priority can be cached in the second list. When it is determined that there is an idle thread in the parallel thread based on the thread state corresponding to the parallel thread at the current moment, a quantum computing task that can be executed in parallel with the quantum computing task currently being executed is obtained from the second list, that is, a fifth quantum computing task is obtained, and the fifth quantum computing task is executed using the idle thread. This allows the fifth quantum computing task to be executed in parallel with the quantum computing task currently being executed in the parallel thread, realizing the parallel execution of multiple quantum computing tasks and improving quantum computing efficiency.
[0269] Furthermore, because the quantum computing tasks cached in the second list are second quantum computing tasks that meet the preset parallelism requirement, the preset parallelism requirement allows for preliminary screening of the first quantum computing tasks cached in the first list, effectively reducing the number of quantum computing tasks cached in the second list. When an idle thread exists in the parallel threads, the fifth quantum computing task can be directly obtained from the second list. Compared to obtaining the fifth quantum computing task from the first list, this effectively reduces the number of quantum computing tasks included in the screening sample and shortens the time required to obtain the fifth quantum computing task, thereby reducing the idle time of the thread and improving quantum computing efficiency.
[0270] Furthermore, since the quantum computing tasks cached in the second list have a relatively high priority, this increases the probability that the quantum computing tasks with higher priority are cached in the second list, thereby increasing the probability that the quantum computing tasks with higher priority are executed first.
[0271] Based on the same inventive concept, according to the task execution method provided in the above embodiment of the present application, the embodiment of the present application also provides an electronic device, such as Figure 12 As shown, it includes a processor 1201, a communication interface 1202, a memory 1203 and a communication bus 1204, wherein the processor 1201, the communication interface 1202, and the memory 1203 communicate with each other through the communication bus 1204.
[0272] Memory 1203, used for storing computer programs;
[0273] The processor 1201 is configured to execute the program stored in the memory 1203, and implement the following steps:
[0274] Obtaining a first judgment result according to a first state of the first list, a second state of the second list, and a third state of the parallel thread at a current moment, wherein the first list is used to cache first quantum computing tasks queued for execution, the second list is used to cache second quantum computing tasks obtained from the first list, and the parallel thread includes multiple threads for executing quantum computing tasks in parallel;
[0275] When the first judgment result indicates to perform a search operation in the first list, searching the first list for a quantum computing task that meets the preset parallel requirement according to the third quantum computing task currently being executed in the parallel thread;
[0276] Obtain the quantum computing task with the highest priority from the quantum computing tasks that meet the preset parallel requirements and cache it in the second list;
[0277] When it is determined according to the fourth state that there is an idle thread in the parallel thread, obtaining a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task from the second list, where the fourth state is the thread state corresponding to each thread in the parallel thread at the current moment, and the fourth quantum computing task is the quantum computing task being executed in the parallel thread at the current moment;
[0278] The fifth quantum computing task is performed using the idle thread.
[0279] Through the electronic device provided by the embodiment of the present application, when the first judgment result indicates that a search operation is to be performed in the first list, the quantum computing task in the first list that meets the preset parallel requirements can be searched based on the quantum computing task being executed in the parallel thread at the current moment, and the quantum computing task that meets the preset parallel requirements and has the highest priority can be cached in the second list. When it is determined that there is an idle thread in the parallel thread based on the thread state corresponding to the parallel thread at the current moment, a quantum computing task that can be executed in parallel with the quantum computing task being executed at the current moment is obtained from the second list, that is, a fifth quantum computing task is obtained, and the fifth quantum computing task is executed using the idle thread. This allows the fifth quantum computing task to be executed in parallel with the quantum computing task currently being executed in the parallel thread, realizing the parallel execution of multiple quantum computing tasks and improving quantum computing efficiency.
[0280] Furthermore, because the quantum computing tasks cached in the second list are second quantum computing tasks that meet the preset parallelism requirement, the preset parallelism requirement allows for preliminary screening of the first quantum computing tasks cached in the first list, effectively reducing the number of quantum computing tasks cached in the second list. When an idle thread exists in the parallel threads, the fifth quantum computing task can be directly obtained from the second list. Compared to obtaining the fifth quantum computing task from the first list, this effectively reduces the number of quantum computing tasks included in the screening sample and shortens the time required to obtain the fifth quantum computing task, thereby reducing the idle time of the thread and improving quantum computing efficiency.
[0281] Furthermore, since the quantum computing tasks cached in the second list have a relatively high priority, this increases the probability that the quantum computing tasks with higher priority are cached in the second list, thereby increasing the probability that the quantum computing tasks with higher priority are executed first.
[0282] The communication bus mentioned in the electronic device mentioned above may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.
[0283] The communication interface is used for communication between the above electronic device and other devices.
[0284] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.
[0285] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0286] Based on the same inventive concept, according to the task execution method provided in the above-mentioned embodiments of the present application, the embodiments of the present application also provide a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of any of the above-mentioned task execution methods are implemented.
[0287] Based on the same inventive concept, according to the task execution method provided in the above-mentioned embodiments of the present application, the embodiments of the present application also provide a quantum computer to implement any of the above-mentioned task execution methods.
[0288] Based on the same inventive concept, according to the task execution method provided in the above-mentioned embodiments of the present application, the embodiments of the present application also provide a computer program product containing instructions, which, when running on a computer, enables the computer to execute any task execution method in the above-mentioned embodiments.
[0289] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
[0290] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device 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 device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0291] Each embodiment in this specification is described in a related manner. Similar portions between embodiments can be referenced to each other. Each embodiment focuses on the differences between other embodiments. In particular, embodiments such as apparatuses, electronic devices, computer-readable storage media, quantum computers, and computer program products are generally similar to method embodiments, so their descriptions are simplified. For related portions, reference can be made to the descriptions of the method embodiments.
[0292] The above description is only a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention are included in the scope of protection of the present invention.
Claims
1. A task execution method, characterized in that: The method comprises: Obtaining a first judgment result according to a first state of a first list, a second state of a second list, and a third state of a parallel thread at a current moment, wherein the first list is used to cache first quantum computing tasks queued for execution, the second list is used to cache second quantum computing tasks obtained from the first list, and the parallel thread includes multiple threads for executing quantum computing tasks in parallel; When the first judgment result indicates to perform a search operation in the first list, searching the first list for a quantum computing task that meets a preset parallel requirement according to the third quantum computing task currently being executed in the parallel thread; Obtaining the quantum computing task with the highest priority from the quantum computing tasks that meet the preset parallel requirement and caching it in the second list; When it is determined according to the fourth state that there is an idle thread in the parallel thread, obtaining a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task from the second list, wherein the fourth state is the thread state corresponding to each thread in the parallel thread at the current moment, and the fourth quantum computing task is the quantum computing task being executed in the parallel thread at the current moment; The fifth quantum computing task is performed using the idle thread.
2. The method according to claim 1, characterized in that The step of obtaining the first judgment result according to the first state of the first list, the second state of the second list, and the third state of the parallel thread at the current moment includes: Get the cache state of the first list at the current moment as the first state; Obtain the cache state of the second list at the current moment as the second state; Obtaining the thread state corresponding to each thread in the parallel threads at the current moment as the third state; According to the first state, the second state and the third state, it is determined whether a search operation is performed in the first list to obtain a first determination result.
3. The method according to claim 2, characterized in that The step of determining whether to perform a search operation in the first list based on the first state, the second state, and the third state to obtain a first determination result includes: When it is determined according to the first state that the first list is empty, or when it is determined according to the first state that the first list is not empty and when it is determined according to the second state that the number of second quantum computing tasks cached in the second list is equal to a first preset number, obtaining a first judgment result indicating that a search operation is not to be performed in the first list; When it is determined according to the first state that the first list is not empty, when it is determined according to the second state that no parallelizable quantum computing tasks are cached in the second list, and when it is determined according to the third state that an idle thread exists in the parallel threads, a first judgment result is obtained indicating that the first list is searched for a parallelizable quantum computing task; When it is determined according to the first state that the first list is not empty, when it is determined according to the second state that the number of replaceable quantum computing tasks cached in the second list is less than a second preset number, and when it is determined according to the third state that no idle thread exists among the multiple threads, or when it is determined according to the first state that the first list is not empty, when it is determined according to the second state that parallelizable quantum computing tasks are cached in the second list and the number of replaceable quantum computing tasks cached in the second list is less than the second preset number, a first judgment result indicating searching the first list for replaceable quantum computing tasks is obtained; Among them, the parallelizable quantum computing task is a quantum computing task that can be executed in parallel with all quantum computing tasks currently being executed when searching for a quantum computing task that meets the preset parallel requirements; the replaceable quantum computing task is a quantum computing task that can replace the target quantum computing task among all quantum computing tasks currently being executed and be executed in parallel with other quantum computing tasks when searching for a quantum computing task that meets the preset parallel requirements.
4. The method according to claim 3, characterized in that The method further comprises: When the first judgment result indicates that the search operation is not to be performed in the first list, obtaining the thread state of each thread in the parallel threads at the current moment as a fifth state; When it is determined according to the fifth state that there is an idle thread in the parallel threads, and it is determined according to the second state that the second list is not empty, performing the step of obtaining, from the second list, a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task; When it is determined that there are no idle threads in the parallel threads according to the fifth state, and / or when it is determined that the second list is empty according to the second state, return to the step of obtaining the first judgment result according to the first state of the first list at the current moment, the second state of the second list and the third state of the parallel threads.
5. The method according to claim 3, characterized in that When the first judgment result indicates that a search operation is to be performed in the first list, the step of searching the first list for a quantum computing task that meets a preset parallel requirement according to the third quantum computing task currently being executed in the parallel thread includes: When the first judgment result indicates that parallelizable quantum computing tasks are to be searched in the first list, based on the task information corresponding to each first quantum computing task and the task information corresponding to each third quantum computing task currently being executed in the parallel thread, a quantum computing task in the first list that can be executed in parallel with all the third quantum computing tasks is searched as a quantum computing task that meets the preset parallel requirement.
6. The method according to claim 3, characterized in that When the first judgment result indicates that a search operation is to be performed in the first list, the step of searching the first list for a quantum computing task that meets a preset parallel requirement according to the third quantum computing task currently being executed in the parallel thread includes: When the first judgment result indicates searching for a replaceable quantum computing task in the first list, determining, for each third quantum computing task currently being executed in the parallel thread, whether a replaceable quantum computing task corresponding to the third quantum computing task is cached in the second list, to obtain a second judgment result; Based on the second judgment result, selecting a sixth quantum computing task with the shortest remaining execution time as the target quantum computing task; the sixth quantum computing task is the third quantum computing task for which there is no corresponding quantum computing task that can take over; Based on the task information corresponding to each first quantum computing task and the task information corresponding to each seventh quantum computing task, a quantum computing task that can be executed in parallel with all the seventh quantum computing tasks is searched in the first list as a quantum computing task that meets the preset parallelization requirement; the seventh quantum computing task is a third quantum computing task other than the target quantum computing task.
7. The method according to claim 5 or 6, characterized in that The task information includes a quantum bit identifier; The step of searching, based on the task information corresponding to each first quantum computing task and the task information corresponding to each third quantum computing task currently being executed in the parallel thread, for a quantum computing task in the first list that can be executed in parallel with all the third quantum computing tasks as a quantum computing task that meets the preset parallel requirement includes: According to the first qubit identifier in the task information corresponding to each first quantum computing task in the first list and the second qubit identifier in the task information corresponding to each third quantum computing task currently being executed in the parallel thread, searching the first list for a first quantum computing task whose corresponding task information does not include the second qubit identifier as a quantum computing task that meets the preset parallelization requirement; The step of searching, in the first list, for a quantum computing task that can be executed in parallel with all seventh quantum computing tasks based on the task information corresponding to each first quantum computing task and the task information corresponding to each seventh quantum computing task, as a quantum computing task that meets the preset parallelization requirement, includes: According to the first quantum bit identifier in the task information corresponding to each first quantum computing task, and the third quantum bit identifier in the task information corresponding to each seventh quantum computing task, the first quantum computing task whose corresponding task information does not include the third quantum bit identifier is searched in the first list as the quantum computing task that meets the preset parallel requirements.
8. The method according to claim 1, characterized in that The step of obtaining from the second list a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task includes: Determine whether a target replaceable quantum computing task is cached in the second list, and obtain a third determination result, wherein the target replaceable quantum computing task corresponds to the eighth quantum computing task executed before the idle thread state is updated; If the third judgment result is yes, then when the target replaceable quantum computing task meets the preset parallel requirement, the target replaceable quantum computing task is obtained as a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task; If the third judgment result is no, or if the target replaceable quantum computing task does not meet the preset parallel requirement, obtaining the parallelizable quantum computing tasks cached in the second list; When the obtained parallelizable quantum computing task meets the preset parallel requirement, the parallelizable quantum computing task is determined as a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task.
9. The method according to claim 1, characterized in that After executing the fifth quantum computing task using the idle thread, the method further includes: Searching the second list for a tenth quantum computing task that does not meet the preset parallel requirement according to the ninth quantum computing task currently being executed in the parallel thread; The tenth quantum computing task is cached in the first list.
10. The method according to claim 1, characterized in that After executing the fifth quantum computing task using the idle thread, the method further includes: Locking the idle thread based on the task information of the fifth quantum computing task to obtain a locked thread; The method further comprises: For each locked thread, when the locking time corresponding to the locked thread is greater than a preset time threshold, the locked thread is released.
11. A task execution device, characterized in that: The device comprises: a first acquisition module, configured to acquire a first judgment result based on a first state of a first list, a second state of a second list, and a third state of a parallel thread at a current moment, wherein the first list is used to cache first quantum computing tasks queued for execution, the second list is used to cache second quantum computing tasks obtained from the first list, and the parallel thread includes multiple threads for executing quantum computing tasks in parallel; a first search module configured to search the first list for a quantum computing task that meets a preset parallel requirement based on a third quantum computing task currently being executed in the parallel thread when the first judgment result indicates that a search operation is to be performed in the first list; A first cache module is configured to obtain the quantum computing task with the highest priority from the quantum computing tasks that meet the preset parallel requirement and cache it in the second list; a second acquisition module configured to acquire, from the second list, a fifth quantum computing task that can be executed in parallel with the fourth quantum computing task when it is determined according to a fourth state that an idle thread exists in the parallel thread, wherein the fourth state is a thread state corresponding to each thread in the parallel thread at a current moment, and the fourth quantum computing task is a quantum computing task being executed in the parallel thread at a current moment; An execution module is configured to execute the fifth quantum computing task using the idle thread.
12. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory for storing computer programs; A processor, configured to implement the method steps described in any one of claims 1 to 10 when executing a program stored in a memory.
13. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps of any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Thread scheduling method and device
CN112395064A
Task processing method, working node device, main node device and storage medium
CN114756356A