Code debugging method, device, equipment and storage medium of federated learning compiler
By receiving debugging instructions in the federated learning compiler and executing them in the compiled code, the problem of the inability to debug mpc modified code under the federated learning compiler solution is solved, and an efficient code debugging experience is achieved.
Patent Information
- Application Number
- CN202011379984.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-30
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2040-11-30
AI Technical Summary
The code blocks modified by mpc under the federated learning compiler solution cannot use the existing Python program debugging functions, resulting in developers' inefficient debugging of federated learning code and poor debugging experience.
By receiving the debugging instructions at the first position in the pre-compilation code, and executing the debugging instructions at the second position in the compiled code, the first debugging result is obtained, and the second debugging result corresponding to the pre-compilation code is obtained based on the result, and displaying it to the debugger.
It realizes direct debugging of pre-compilation code modified by mpc under the federated learning compiler solution, improving debugging efficiency and experience, allowing developers to intuitively understand the debugging results of pre-compilation code.
Smart Images

Figure CN114580650B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of federated learning technology, and in particular to a code debugging method, device, equipment and storage medium for a federated learning compiler. Background Art
[0002] In the federated learning scenario, since it involves information transmission and scheduling of multiple parties, developers need to implement different code logic for each participant with different roles, which makes the code complex and difficult to develop and maintain. In order to solve this problem, a new code writing method and a federated learning compiler are proposed based on python (a computer programming language). Specifically, in the new code writing method, a function modifier named mpc is set. The function modified by this modifier is compiled by the federated learning compiler and converted into code that can be directly executed by the python interpreter. In the function under mpc, all variables, operators, control symbols, etc. will be compiled into intermediate code. The intermediate code consists of OP (operator), including three categories: data OP, operation OP, and control OP.
[0003] The current problem is that the Python program provides an interactive source code debugging function, such as setting breakpoints, viewing the current code, etc., but this debugging function can only be used in ordinary Python code. For code blocks modified by mpc under the federated learning compiler solution, the existing debugging function cannot be used, resulting in low debugging efficiency and poor debugging experience for developers in the federated learning code. Summary of the invention
[0004] The main purpose of the present invention is to provide a code debugging method, device, equipment and readable storage medium for a federated learning compiler, aiming to solve the problem that the code blocks modified by mpc under the current federated learning compiler solution cannot use the debugging function of the python program.
[0005] To achieve the above object, the present invention provides a code debugging method for a federated learning compiler, the method comprising the following steps:
[0006] receiving a debugging instruction for code at a first position in the pre-compiled code;
[0007] Executing the debugging instruction on the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result, wherein the compiled code is obtained by compiling the pre-compiled code through the federated learning compiler;
[0008] A second debugging result corresponding to the pre-compiled code is obtained according to the first debugging result, and the second debugging result is displayed.
[0009] Optionally, when the method is applied to a federated learning code executor, the code executor is in communication with a federated learning process initiator, and the step of executing the debugging instruction for the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes:
[0010] Sending the first position to the process initiator, so that the process initiator compiles the pre-compiled code to obtain the compiled code, and then returns the compiled code and a second position in the compiled code corresponding to the first position to the code executor;
[0011] The compiled code and the second position are received, and the debugging instruction is executed on the code at the second position in the compiled code to obtain a first debugging result.
[0012] Optionally, when the method is applied to a federated learning process initiator, the process initiator is in communication with a federated learning code executor, and the step of executing the debugging instruction for the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes:
[0013] After compiling the pre-compiled code to obtain the compiled code, the compiled code and a second position in the compiled code corresponding to the first position are sent to the code executor, so that after receiving the compiled code and the second position, the code executor executes the debugging instruction for the code at the second position in the compiled code to obtain a first debugging result, and returns the first debugging result;
[0014] Receive the first debugging result returned by the code executor.
[0015] Optionally, when the debugging instruction is an instruction to set a breakpoint at a first position in the pre-compiled code, the step of executing the debugging instruction on the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes:
[0016] Setting an actual breakpoint at a second position in the compiled code corresponding to the first position;
[0017] Running the compiled code and stopping at the actual breakpoint, and taking the first code line after the actual breakpoint in the compiled code as a first debugging result;
[0018] The step of obtaining a second debugging result corresponding to the pre-compiled code according to the first debugging result comprises:
[0019] A second code line in the pre-compiled code corresponding to the first code line is used as a second debugging result.
[0020] Optionally, when the debugging instruction is a viewing instruction for viewing a variable value at a first position in the pre-compiled code, the step of executing the debugging instruction on a code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes:
[0021] After running the compiled code, obtaining a variable value at a second position in the compiled code corresponding to the first position, and using the variable value as a first debugging result;
[0022] The step of obtaining a second debugging result corresponding to the pre-compiled code according to the first debugging result comprises:
[0023] The first debugging result is used as the second debugging result corresponding to the pre-compiled code.
[0024] Optionally, when the debugging instruction is a change instruction for changing a variable value at a first position in the pre-compiled code, the step of executing the debugging instruction on a code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes:
[0025] Changing the variable value at a second position corresponding to the first position in the compiled code to a target variable value carried in the change instruction;
[0026] Running the compiled code after changing the variable value to obtain a running result, and using the running result as a first debugging result;
[0027] The step of obtaining a second debugging result corresponding to the pre-compiled code according to the first debugging result comprises:
[0028] The first debugging result is used as the second debugging result corresponding to the pre-compiled code.
[0029] Optionally, when the debugging instruction is a view current code instruction for the code at a first position in the pre-compiled code, the step of executing the debugging instruction for the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes:
[0030] Obtaining a first code segment within a preset number of lines before and after a code line at a second position corresponding to the first position in the compiled code, and using the first code segment as the first debugging result;
[0031] The step of obtaining a second debugging result corresponding to the pre-compiled code according to the first debugging result comprises:
[0032] A second code segment in the pre-compiled code corresponding to the first code segment is used as a second debugging result.
[0033] To achieve the above object, the present invention provides a code debugging device for a federated learning compiler, the device comprising:
[0034] A receiving module, used for receiving a debugging instruction for a code at a first position in the pre-compiled code;
[0035] a debugging module, configured to execute the debugging instruction on the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result, wherein the compiled code is the code before compilation compiled by the federated learning compiler;
[0036] The display module is used to obtain a second debugging result corresponding to the pre-compiled code according to the first debugging result, and display the second debugging result.
[0037] To achieve the above-mentioned purpose, the present invention also provides a code debugging device for a federated learning compiler, wherein the code debugging device for a federated learning compiler comprises: a memory, a processor, and a code debugging program for the federated learning compiler stored in the memory and executable on the processor, wherein the code debugging program for the federated learning compiler implements the steps of the code debugging method for the federated learning compiler as described above when executed by the processor.
[0038] In addition, to achieve the above-mentioned purpose, the present invention also proposes a computer-readable storage medium, on which a code debugging program of a federated learning compiler is stored. When the code debugging program of the federated learning compiler is executed by a processor, the steps of the code debugging method of the federated learning compiler as described above are implemented.
[0039] In addition, to achieve the above-mentioned purpose, the present invention also proposes a computer program product, including a computer program, which, when executed by a processor, implements the steps of the code debugging method of the federated learning compiler as described above.
[0040] In the present invention, by receiving a debugging instruction for the code at the first position in the pre-compiled code, executing the debugging instruction for the code at the second position corresponding to the first position in the compiled code, a first debugging result is obtained, and then a second debugging result corresponding to the pre-compiled code is obtained according to the first debugging result, and the second debugging result is displayed. That is, in the present invention, the position correspondence between the pre-compiled code and the compiled code is utilized, and the debugging function is realized by actually debugging the compiled code, but a way to debug the pre-compiled code is provided to the debugger, and the debugging effect of the pre-compiled code can be displayed, so that the debugger can directly debug the pre-compiled code modified by mpc, and can directly and intuitively understand the debugging result of the pre-compiled code. Compared with debugging complex compiled code, the debugging efficiency is higher and the debugging experience is better. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 A schematic diagram of the structure of the hardware operating environment involved in the embodiment of the present invention;
[0042] Figure 2 This is a flow chart of the first embodiment of the code debugging method of the federated learning compiler of the present invention;
[0043] Figure 3 A schematic diagram of a code debugging process involved in an embodiment of the present invention;
[0044] Figure 4 This is a functional schematic module diagram of a preferred embodiment of the code debugging device of the federated learning compiler of the present invention.
[0045] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0046] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0047] like Figure 1 As shown, Figure 1 It is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present invention.
[0048] It should be noted that the code debugging device of the federated learning compiler in the embodiment of the present invention can be a smart phone, a personal computer, a server and other devices, and no specific limitation is made here.
[0049] like Figure 1As shown, the code debugging device of the federated learning compiler may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0050] Those skilled in the art will understand that Figure 1 The device structure shown in the figure does not constitute a limitation on the code debugging device of the federated learning compiler, and may include more or fewer components than shown in the figure, or a combination of certain components, or a different arrangement of components.
[0051] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a code debugger of a federated learning compiler. The operating system is a program that manages and controls the hardware and software resources of a device, and supports the operation of the code debugger of a federated learning compiler and other software or programs. Figure 1 In the device shown, the user interface 1003 is mainly used to communicate data with the client; the network interface 1004 is mainly used to establish a communication connection with the server; the processor 1001 can be used to call the code debugging program of the federated learning compiler stored in the memory 1005, and perform the following operations:
[0052] receiving a debugging instruction for code at a first position in the pre-compiled code;
[0053] Executing the debugging instruction on the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result, wherein the compiled code is obtained by compiling the pre-compiled code through the federated learning compiler;
[0054] A second debugging result corresponding to the pre-compiled code is obtained according to the first debugging result, and the second debugging result is displayed.
[0055] Further, when the method is applied to a federated learning code executor, the code executor is in communication with a federated learning process initiator, and the step of executing the debugging instruction for the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes:
[0056] Sending the first position to the process initiator, so that the process initiator compiles the pre-compiled code to obtain the compiled code, and then returns the compiled code and a second position in the compiled code corresponding to the first position to the code executor;
[0057] The compiled code and the second position are received, and the debugging instruction is executed on the code at the second position in the compiled code to obtain a first debugging result.
[0058] Further, when the method is applied to a federated learning process initiator, the process initiator is in communication with a federated learning code executor, and the step of executing the debugging instruction for the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes:
[0059] After compiling the pre-compiled code to obtain the compiled code, the compiled code and a second position in the compiled code corresponding to the first position are sent to the code executor, so that after receiving the compiled code and the second position, the code executor executes the debugging instruction for the code at the second position in the compiled code to obtain a first debugging result, and returns the first debugging result;
[0060] Receive the first debugging result returned by the code executor.
[0061] Further, when the debugging instruction is an instruction to set a breakpoint at a first position in the pre-compiled code, the step of executing the debugging instruction on the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes:
[0062] Setting an actual breakpoint at a second position in the compiled code corresponding to the first position;
[0063] Running the compiled code and stopping at the actual breakpoint, and taking the first code line after the actual breakpoint in the compiled code as a first debugging result;
[0064] The step of obtaining a second debugging result corresponding to the pre-compiled code according to the first debugging result comprises:
[0065] A second code line in the pre-compiled code corresponding to the first code line is used as a second debugging result.
[0066] Further, when the debugging instruction is a viewing instruction for viewing a variable value at a first position in the pre-compiled code, the step of executing the debugging instruction for a code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes:
[0067] After running the compiled code, obtaining a variable value at a second position in the compiled code corresponding to the first position, and using the variable value as a first debugging result;
[0068] The step of obtaining a second debugging result corresponding to the pre-compiled code according to the first debugging result comprises:
[0069] The first debugging result is used as the second debugging result corresponding to the pre-compiled code.
[0070] Further, when the debugging instruction is a change instruction for changing the value of a variable at a first position in the pre-compiled code, the step of executing the debugging instruction on the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes:
[0071] Changing the variable value at a second position corresponding to the first position in the compiled code to a target variable value carried in the change instruction;
[0072] Running the compiled code after changing the variable value to obtain a running result, and using the running result as a first debugging result;
[0073] The step of obtaining a second debugging result corresponding to the pre-compiled code according to the first debugging result comprises:
[0074] The first debugging result is used as the second debugging result corresponding to the pre-compiled code.
[0075] Further, when the debugging instruction is a view current code instruction for the code at a first position in the pre-compiled code, the step of executing the debugging instruction for the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes:
[0076] Obtaining a first code segment within a preset number of lines before and after a code line at a second position corresponding to the first position in the compiled code, and using the first code segment as the first debugging result;
[0077] The step of obtaining a second debugging result corresponding to the pre-compiled code according to the first debugging result comprises:
[0078] A second code segment in the pre-compiled code corresponding to the first code segment is used as a second debugging result.
[0079] Based on the above structure, various embodiments of the code debugging method of the federated learning compiler are proposed.
[0080] Reference Figure 2 , Figure 2 The flowchart of the first embodiment of the code debugging method of the federated learning compiler of the present invention is shown. It should be noted that although the logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than here. The code debugging method of the federated learning compiler of the present invention may be executed by devices such as smart phones, personal computers, and servers. The following embodiments are described with the debugger as the execution subject. In this embodiment, the code debugging method of the federated learning compiler includes:
[0081] Step S10, receiving a debugging instruction for the code at the first position in the pre-compiled code;
[0082] Federated learning is a scheme in which multiple devices act as participants and jointly perform modeling. The embodiments of the present invention can be applied to various types of federated learning, such as horizontal federated learning and vertical federated learning, that is, there is no restriction on the type of federated learning. In the federated learning compiler scheme, the federated learning process is initiated by a party participating in the federated learning (hereinafter referred to as the process initiator). The specific initiator is not limited in the embodiments. For example, in vertical federated learning, the Guest (data application party among the participants) can generally be used as the process initiator.
[0083] The process initiator determines which participant (also called site) will execute the following code based on the with role statement in the code. The participant that executes the code is called the code executor. For example, G represents Guest, H represents Host (data owner), with role (G, H) means that sites G and H will execute the following public code, and with role (G) means that the sub-block code is only executed by site G.
[0084] In this embodiment, the debugging party, that is, a participant selected by the debugging personnel to perform code debugging operations, may be a process initiator or a code executor.
[0085] The code debugging method of this embodiment can be obtained by improving the existing Python debugging tool, for example, it can be improved on pdb (pdb is a package that comes with python and provides an interactive source code debugging function for python programs), but it is not limited to pdb.
[0086] The debugging party receives a debugging instruction for the code at the first position in the pre-compiled code. Among them, according to the different code debugging interactive methods provided by the debugging tool, the triggering method of the debugging instruction is different. In this embodiment, the triggering method of the debugging instruction is not limited. For example, in one embodiment, the debugging party can display a debugging interactive interface, which includes an input box for the debugger to enter the debugging command, and the debugging instruction types corresponding to different commands are pre-defined. The debugger enters the corresponding command to trigger the corresponding debugging instruction. The debugging instruction may include commonly used debugging instructions such as setting breakpoints, viewing variable values, viewing current code, single-step execution, etc. The debugging instruction points to the code at a certain position in the pre-compiled code, and the position is called the first position for distinction. Specifically, the first position can be represented by the number of the code line, and the debugging instruction can point to one or more lines of code. Correspondingly, the first position can be represented by one number or multiple numbers; or, in other embodiments, other methods can be used to represent the first position, such as the code line itself.
[0087] Step S20, executing the debugging instruction for the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result, wherein the compiled code is obtained by compiling the pre-compiled code through the federated learning compiler;
[0088] The debugging party executes the debugging instruction on the code at the second position corresponding to the first position in the compiled code to obtain a first debugging result. The compiled code is the code before compilation compiled by the federated learning compiler. When the debugging party is not the process initiator, the compiled code can be compiled by the process initiator and sent to the debugging party; when the debugging party is the process initiator but not the code executor, the debugging party can send the compiled code to the code executor to control the code executor to execute the debugging instruction.
[0089] There is a correspondence between each code line of the pre-compiled code and each code line of the compiled code, that is, after the code line at a certain position in the pre-compiled code is compiled, the code line at a certain position in the compiled code is obtained. According to the correspondence, the second position in the compiled code corresponding to the first position in the pre-compiled code can be determined. Since the existing debugging function can only debug the compiled code, after receiving the debugging instruction for the pre-compiled code, the debugging party actually has to execute the debugging instruction in the compiled code, and execute the debugging instruction for the code at the second position corresponding to the first position, so as to accurately achieve the purpose of debugging the compiled code. The way in which the debugging party executes the debugging instruction for the code at the second position in the compiled code can adopt the way in which the debugging instruction is executed in the existing debugging tool, which will not be described in detail here.
[0090] After the debugger executes the debug command on the compiled code, it obtains the debug result, which corresponds to the compiled code (hereinafter referred to as the first debug result). It is understandable that different debug commands correspond to different forms of debug results; for example, the debug command for setting a breakpoint may correspond to the line of code where the code stops after running; the debug command for viewing the value of a variable may correspond to the variable value corresponding to the variable name to be viewed.
[0091] Step S30, obtaining a second debugging result corresponding to the pre-compiled code according to the first debugging result, and displaying the second debugging result.
[0092] The debugging party obtains the second debugging result corresponding to the pre-compiled code based on the first debugging result. There are two possibilities. One is that there is no content related to the compiled code in the first debugging result, which can be directly displayed to the debugger, for example, results that are not related to the code content, such as successful operation and failed operation; for this first debugging result, the first debugging result can be directly used as the second debugging result. The other is that the first debugging result involves the content in the compiled code, for example, the first debugging result is a certain line of code in the compiled code; for this first debugging result, the part of the first debugging result involving the content of the compiled code can be converted into the content corresponding to the pre-compiled code according to the correspondence between the pre-compiled code and the compiled code, and the converted result can be used as the second debugging result.
[0093] After obtaining the second debugging result, the debugging party displays the second debugging result, so that the debugging personnel can directly and intuitively understand the debugging result of the pre-compiled code.
[0094] In this embodiment, by receiving a debugging instruction for the code at the first position in the pre-compiled code, executing the debugging instruction for the code at the second position corresponding to the first position in the compiled code, a first debugging result is obtained, and then a second debugging result corresponding to the pre-compiled code is obtained according to the first debugging result, and the second debugging result is displayed. That is, in this embodiment, the position correspondence between the pre-compiled code and the compiled code is used to implement the debugging function by actually debugging the compiled code, but a way to debug the pre-compiled code is provided to the debugger, and the debugging effect of the pre-compiled code can be displayed, so that under the federated learning compiler solution, the debugger can directly debug the pre-compiled code modified by mpc, and can directly and intuitively understand the debugging result of the pre-compiled code. Compared with debugging complex compiled code, the debugging efficiency is higher and the debugging experience is better.
[0095] Further, based on the above first embodiment, a second embodiment of the code debugging method of the federated learning compiler of the present invention is proposed. In this embodiment, when the method is applied to a federated learning code executor, the code executor is connected to a federated learning process initiator in communication, and step S20 includes:
[0096] Step S201, sending the first position to the process initiator, so that the process initiator compiles the pre-compiled code to obtain the compiled code, and then returns the compiled code and a second position in the compiled code corresponding to the first position to the code executor;
[0097] In this embodiment, when the debugger is the code executor but not the process initiator, a copy of the pre-compilation code is stored in the debugger. The pre-compilation code may be a code segment that needs to be executed on the debugger. After receiving the debugging instruction for the code at the first position in the pre-compilation code, the debugger sends the first position to the process initiator. The process initiator compiles the pre-compilation code using a federated learning compiler to obtain the compiled code, and when it is determined that the compiled code is executed by the debugger, the compiled code is sent to the debugger. After receiving the first position sent by the debugger, the process initiator can determine the second position in the compiled code corresponding to the first position, and return the second position to the code executor, that is, the debugger.
[0098] It should be noted that the process initiator may send the compiled code and the second location to the debugger together, or separately. In this embodiment, the timing of sending the compiled code and the second location by the process initiator is not limited.
[0099] It should be noted that, in other implementations, the process initiator may also send all correspondences between the compiled code and each code line in the pre-compiled code to the debugger when sending the compiled code. Then, the debugger can directly determine the second position based on the correspondence, without sending the first position to the process initiator for the process initiator to determine the second position.
[0100] Step S202: receiving the compiled code and the second position, and executing the debugging instruction on the code at the second position in the compiled code to obtain a first debugging result.
[0101] The debugger receives the compiled code and the second position sent by the process initiator, and executes the debug instruction for the code at the second position in the compiled code to obtain a first debug result.
[0102] Furthermore, when the first debugging result includes relevant content in the compiled code, the debugger may send the position of the relevant content in the compiled code to the process initiator, and the process initiator determines the position corresponding to the position in the pre-compiled code, and sends the determined position in the pre-compiled code to the debugger; the debugger replaces the relevant content in the first debugging result with the content at the position in the pre-compiled code, and the debugging result after replacement serves as the second debugging result.
[0103] In this embodiment, the first position is sent to the process initiator so that the process initiator compiles the pre-compiled code to obtain the compiled code, and then the compiled code and the second position in the compiled code corresponding to the first position are returned to the code executor (i.e., the debugger). The debugger receives the compiled code and the second position, and executes the debugging instruction on the code at the second position in the compiled code to obtain the first debugging result, so that when the debugger is not the process initiator, the compiled code can be accurately debugged, thereby achieving the corresponding debugging effect.
[0104] Further, based on the above first embodiment, a third embodiment of the code debugging method of the federated learning compiler of the present invention is proposed. In this embodiment, when the method is applied to the initiator of the federated learning process, the process initiator is connected to the federated learning code executor in communication, and step S20 includes:
[0105] Step S211, after compiling the pre-compiled code to obtain the compiled code, the compiled code and a second position in the compiled code corresponding to the first position are sent to the code executor, so that after receiving the compiled code and the second position, the code executor executes the debugging instruction for the code at the second position in the compiled code to obtain a first debugging result, and returns the first debugging result;
[0106] In this embodiment, when the debugging party is the process initiator but not the code executor, the debugging party compiles the pre-compiled code using a federated learning compiler to obtain the compiled code. When it is determined that the compiled code is executed by another party (that is, the code executor of the compiled code), the compiled code is sent to the code debugging party, and after receiving the debugging instruction for the code at the first position in the pre-compiled code, the second position corresponding to the first position in the compiled code is determined, and the second position is sent to the code executor. In the debugging scenario where the code executor is willing to share code and data, after receiving the compiled code and the second position, the code executor executes the debugging instruction for the code at the second position in the compiled code to obtain the first debugging result, and returns the first debugging result to the debugging party.
[0107] When the debugging party sends the second location, the debugging instruction may be sent to the code execution party in a network request manner.
[0108] It should be noted that the debugger can send the compiled code and the second location to the code executor together, or separately. In this embodiment, the timing of sending the compiled code and the second location by the debugger is not limited.
[0109] Step S212: receiving the first debugging result returned by the code executor.
[0110] The debugging party receives the first debugging result returned by the code executor.
[0111] In this embodiment, after compiling the pre-compiled code to obtain the compiled code, the compiled code and the second position in the compiled code corresponding to the first position are sent to the code executor, so that after receiving the compiled code and the second position, the code executor executes the debugging instruction for the code at the second position in the compiled code to obtain the first debugging result, and returns the first result to the debugger, so that the code can be debugged on the debugger even when the code is not executed locally on the debugger.
[0112] Further, based on the first, second and / or third embodiments above, a fourth embodiment of a code debugging method of a federated learning compiler of the present invention is proposed. In this embodiment, when the debugging instruction is an instruction to set a breakpoint at a first position in the pre-compiled code, step S20 includes:
[0113] Step S221, setting an actual breakpoint at a second position corresponding to the first position in the compiled code;
[0114] In this embodiment, the effect of setting the breakpoint debugging function can be that the debugger types a breakpoint between two lines of code, then runs the code and stops at the breakpoint, and finally displays the line of code after the breakpoint. In order to enable the debugger to use the debugging function on the pre-compiled code, specifically, when the debugging instruction is an instruction to set a breakpoint at the first position in the pre-compiled code, that is, when the debugging instruction is an instruction to set a breakpoint, the debugger sets an actual breakpoint at the second position corresponding to the first position in the compiled code. It should be noted that when the debugger is not the code executor, the debugger sends the compiled code and the determined second position to the code executor, and the code executor sets the actual breakpoint at the second position in the compiled code.
[0115] Step S222, running the compiled code and stopping at the actual breakpoint, taking the first code line after the actual breakpoint in the compiled code as the first debugging result;
[0116] The debugger runs the compiled code and stops at the actual breakpoint, and takes a line of code after the actual breakpoint in the compiled code (hereinafter referred to as the first code line for distinction) as the first debugging result. It should be noted that when the debugger is not the code executor, the debugger can send a running instruction to the code executor so that the code executor runs the compiled code and stops at the actual breakpoint, and returns the first debugging result to the debugger.
[0117] The step S30 comprises:
[0118] Step S301: taking a second code line in the pre-compiled code corresponding to the first code line as a second debugging result.
[0119] After obtaining the first debugging result, the debugging party can search for the second code line in the pre-compiled code corresponding to the first code line as the first debugging result, and use the second code line as the second debugging result corresponding to the pre-compiled code. It can be understood that the first code line is obtained after the second code line is compiled. The debugging party displays the second code line as the second debugging result to the debugging personnel, so that the debugging personnel can directly and intuitively see the debugging effect of setting breakpoints on the pre-compiled code, thereby realizing the setting breakpoint debugging function for the pre-compiled code.
[0120] Further, in one embodiment, when the debugging instruction is a viewing instruction for viewing the value of a variable at a first position in the pre-compiled code, the step S20 includes:
[0121] Step S231, after running the compiled code, obtaining a variable value at a second position in the compiled code corresponding to the first position, and using the variable value as a first debugging result;
[0122] When the debugging instruction is a viewing instruction for viewing the variable value at the first position in the pre-compiled code, the debugger can run the compiled code once, and then obtain the variable value at the second position in the compiled code corresponding to the first position, and use the variable value as the first debugging result. It should be noted that when the debugger is not the code executor, the debugger can send the compiled code and the determined second position to the code executor, so that the code executor can run the compiled code and return the first debugging result to the debugger after obtaining the first debugging result.
[0123] The step S30 comprises:
[0124] Step S311: using the first debugging result as the second debugging result corresponding to the pre-compiled code.
[0125] The debugging party uses the first debugging result as the second debugging result corresponding to the pre-compiled code, and displays the second debugging result to the debugging personnel. That is, when the debugging personnel wants to view the value of a variable in the pre-compiled code, the debugging party actually displays the value of the variable at the corresponding position in the compiled code to the debugging personnel, so that the debugging personnel can directly and intuitively see the debugging effect of viewing the variable value of the pre-compiled code, thereby realizing the debugging function of viewing the variable value of the pre-compiled code.
[0126] Further, in one embodiment, when the debugging instruction is a change instruction for changing the value of a variable at a first position in the pre-compiled code, step S20 includes:
[0127] Step S241, changing the variable value at the second position corresponding to the first position in the compiled code to the target variable value carried in the change instruction;
[0128] When the debugging instruction is a change instruction to change the variable value at the first position in the pre-compiled code, the debugger can find the variable value at the second position corresponding to the first position in the compiled code, and change the variable value to the target variable value carried in the change instruction.
[0129] Step S242, running the compiled code after the variable value is changed to obtain a running result, and taking the running result as the first debugging result;
[0130] The debugging party runs the compiled code after the variable value is changed to obtain an operation result, and uses the operation result as the first debugging result. The operation result can be a result of operation failure or operation success.
[0131] It should be noted that when the debugging party is not the code executor, the debugging party may send the compiled code, the determined second position, and the change instruction to the code executor, so that the code executor can modify the variable value at the second position in the compiled code to the target variable value carried in the change instruction, and run the compiled code after the variable value is changed, and return it to the debugging party after obtaining the first debugging result.
[0132] The step S30 comprises:
[0133] Step S321: Use the first debugging result as the second debugging result corresponding to the pre-compiled code.
[0134] The debugger can directly use the first debugging result as the second debugging result corresponding to the pre-compiled code, that is, the running result of the compiled code can also be displayed to the debugger as the running result of the pre-compiled code, so that the debugger can directly and intuitively see the debugging effect of changing the variable value of the pre-compiled code, thereby realizing the debugging function of changing the variable value of the pre-compiled code.
[0135] Further, in one embodiment, when the debugging instruction is a view current code instruction for the code at the first position in the pre-compiled code, the step S20 includes:
[0136] Step S251, obtaining a first code segment within a preset number of lines before and after a code line at a second position corresponding to the first position in the compiled code, and using the first code segment as the first debugging result;
[0137] When the debugging instruction is a view current code instruction for viewing the code at the first position in the pre-compiled code, the first position points to a code line in the pre-compiled code, and the debugger can determine the code line at the second position in the compiled code corresponding to the first position, and obtain the first code segment within a preset line range before and after the code line. The preset line range is pre-set in the debugging tool, for example, it can be set to 5 lines, then the debugger obtains the 5 lines of code before and after the code line, a total of 11 lines of code as the first code segment.
[0138] The debugger uses the first code segment as the first debugging result. It should be noted that when the debugger is not the code executor, the debugger can send the compiled code and the determined second position to the code executor, so that the code executor can return the first debugging result to the debugger after obtaining it.
[0139] The step S30 comprises:
[0140] Step S331: taking a second code segment in the pre-compiled code corresponding to the first code segment as a second debugging result.
[0141] The debugging party determines the second code segment corresponding to the first code segment in the pre-compiled code according to the correspondence between the code lines before compilation and the code after compilation, and uses the second code segment as the second debugging result corresponding to the pre-compiled code. It can be understood that the first code segment is obtained after the second code segment is compiled. The debugging party displays the second debugging result to the debugging personnel so that the debugging personnel can directly and intuitively see the debugging effect of viewing the current code on the pre-compiled code, thereby realizing the debugging function of viewing the current code on the pre-compiled code.
[0142] In other implementations, the debugging instructions may also be single-step execution (single-step debugging), entering function debugging, and viewing call stack, etc. The specific implementation details are similar to the implementation details of the above-mentioned debugging instructions such as setting breakpoints, viewing variable values, and changing variable values.
[0143] In one embodiment, if Figure 3As shown, it is a schematic diagram of a code debugging process involved in an embodiment of the present invention. The federated learning program process is initiated by server G, and the role of the local server (debugging party) is G:
[0144] 1. Set breakpoints in the code and record the breakpoint locations.
[0145] 2. Record the variable name defined before the breakpoint position.
[0146] 3. After compiling the code, generate a series of OPs, record the position of the OP corresponding to the breakpoint position in step 1, and mark the actual breakpoint; record the OP corresponding to the variable in step 2.
[0147] 4. Start executing the code. The code will stop at the actual breakpoint in step 3, but by modifying pdb, the breakpoint position set in step 1 is displayed to the user.
[0148] 5. At the breakpoint, when the user views the variable value, he is viewing the value of the corresponding OP; when viewing the current code, he is viewing the pre-compiled code under the mpc modifier; when dynamically changing variables, he is changing the value of the variable corresponding to the OP; when single-step execution is performed, the pre-compiled code under the mpc modifier is displayed to the user line by line, which is actually the execution of the compiled OP.
[0149] In addition, the embodiment of the present invention also provides a code debugging device for a federated learning compiler, referring to Figure 4 , the device comprises:
[0150] The receiving module 10 is used to receive a debugging instruction for the code at the first position in the pre-compiled code;
[0151] A debugging module 20, configured to execute the debugging instruction on the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result, wherein the compiled code is the code before compilation compiled by the federated learning compiler;
[0152] The display module 30 is used to obtain a second debugging result corresponding to the pre-compiled code according to the first debugging result, and display the second debugging result.
[0153] Further, when the method is applied to a federated learning code executor, the code executor is connected in communication with a federated learning process initiator, and the debugging module 20 includes:
[0154] A first sending unit is configured to send the first position to the process initiator, so that after the process initiator compiles the pre-compiled code to obtain the compiled code, the compiled code and a second position in the compiled code corresponding to the first position are returned to the code executor;
[0155] The debugging unit is used to receive the compiled code and the second position, and execute the debugging instruction on the code at the second position in the compiled code to obtain a first debugging result.
[0156] Further, when the method is applied to a federated learning process initiator, the process initiator is connected in communication with a federated learning code executor, and the debugging module 20 includes:
[0157] a second sending unit, configured to, after compiling the pre-compiled code to obtain the compiled code, send the compiled code and a second position in the compiled code corresponding to the first position to the code executor, so that after receiving the compiled code and the second position, the code executor executes the debugging instruction for the code at the second position in the compiled code to obtain a first debugging result, and returns the first debugging result;
[0158] A receiving unit is used to receive the first debugging result returned by the code executor.
[0159] Further, when the debugging instruction is an instruction to set a breakpoint at a first position in the pre-compiled code, the debugging module 20 includes:
[0160] A setting unit, configured to set an actual breakpoint at a second position corresponding to the first position in the compiled code;
[0161] A first determining unit, configured to run the compiled code and stop at the actual breakpoint, and take a first code line after the actual breakpoint in the compiled code as a first debugging result;
[0162] The display module 30 includes:
[0163] The second determining unit is configured to use a second code line in the pre-compiled code corresponding to the first code line as a second debugging result.
[0164] Further, when the debugging instruction is a viewing instruction for viewing the value of a variable at a first position in the pre-compiled code, the debugging module 20 includes:
[0165] a first running unit, configured to obtain a variable value at a second position in the compiled code corresponding to the first position after running the compiled code, and use the variable value as a first debugging result;
[0166] The display module 30 includes:
[0167] The third determining unit is configured to use the first debugging result as a second debugging result corresponding to the pre-compiled code.
[0168] Further, when the debugging instruction is a change instruction for changing the value of a variable at a first position in the pre-compiled code, the debugging module 20 includes:
[0169] a changing unit, configured to change a variable value at a second position corresponding to the first position in the compiled code to a target variable value carried in the changing instruction;
[0170] A second running unit is used to run the compiled code after the variable value is changed to obtain a running result, and use the running result as the first debugging result;
[0171] The display module 30 includes:
[0172] The fourth determining unit is configured to use the first debugging result as the second debugging result corresponding to the pre-compiled code.
[0173] Further, when the debugging instruction is a view current code instruction for the code at the first position in the pre-compiled code, the debugging module 20 includes:
[0174] An acquiring unit, configured to acquire a first code segment within a preset number of lines before and after a code line at a second position corresponding to the first position in the compiled code, and use the first code segment as the first debugging result;
[0175] The display module 30 includes:
[0176] The fifth determining unit is configured to use a second code segment in the pre-compiled code corresponding to the first code segment as a second debugging result.
[0177] The expanded content of the specific implementation method of the code debugging device of the federated learning compiler of the present invention is basically the same as the various embodiments of the code debugging method of the federated learning compiler mentioned above, and will not be repeated here.
[0178] In addition, an embodiment of the present invention further proposes a computer-readable storage medium, on which a code debugging program of a federated learning compiler is stored. When the code debugging program of the federated learning compiler is executed by a processor, the steps of the code debugging method of the federated learning compiler as described above are implemented.
[0179] In addition, an embodiment of the present invention further proposes a computer program product, including a computer program, which, when executed by a processor, implements the steps of the code debugging method of the federated learning compiler as described above.
[0180] The various embodiments of the code debugging device, computer-readable storage medium, and computer program product of the federated learning compiler of the present invention can all refer to the various embodiments of the code debugging method of the federated learning compiler of the present invention, and will not be repeated here.
[0181] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0182] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0183] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the embodiments of the present invention.
[0184] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A code debugging method based on a federated learning compiler, characterized in that: The method comprises the following steps: receiving a debugging instruction for code at a first position in the pre-compiled code; Executing the debugging instruction on the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result, wherein the compiled code is obtained by compiling the pre-compiled code through the federated learning compiler; Obtaining a second debugging result corresponding to the pre-compiled code according to the first debugging result, and displaying the second debugging result; When the method is applied to a federated learning code executor, the code executor is in communication with a federated learning process initiator, and the step of executing the debugging instruction for the code at the second position corresponding to the first position in the compiled code to obtain the first debugging result includes: Sending the first position to the process initiator, so that the process initiator compiles the pre-compiled code to obtain the compiled code, and then returns the compiled code and a second position in the compiled code corresponding to the first position to the code executor; The compiled code and the second position are received, and the debugging instruction is executed on the code at the second position in the compiled code to obtain a first debugging result.
2. The code debugging method of the federated learning compiler according to claim 1, characterized in that: When the method is applied to a federated learning process initiator, the process initiator is in communication with a federated learning code executor, and the step of executing the debugging instruction for the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes: After compiling the pre-compiled code to obtain the compiled code, the compiled code and a second position in the compiled code corresponding to the first position are sent to the code executor, so that after receiving the compiled code and the second position, the code executor executes the debugging instruction for the code at the second position in the compiled code to obtain a first debugging result, and returns the first debugging result; Receive the first debugging result returned by the code executor.
3. The code debugging method of the federated learning compiler according to claim 1, characterized in that: When the debugging instruction is an instruction to set a breakpoint at a first position in the pre-compiled code, the step of executing the debugging instruction on the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes: Setting an actual breakpoint at a second position in the compiled code corresponding to the first position; Running the compiled code and stopping at the actual breakpoint, and taking the first code line after the actual breakpoint in the compiled code as a first debugging result; The step of obtaining a second debugging result corresponding to the pre-compiled code according to the first debugging result comprises: A second code line in the pre-compiled code corresponding to the first code line is used as a second debugging result.
4. The code debugging method of the federated learning compiler according to claim 1, characterized in that: When the debugging instruction is a viewing instruction for viewing a variable value at a first position in the pre-compiled code, the step of executing the debugging instruction for a code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes: After running the compiled code, obtaining a variable value at a second position in the compiled code corresponding to the first position, and using the variable value as a first debugging result; The step of obtaining a second debugging result corresponding to the pre-compiled code according to the first debugging result comprises: The first debugging result is used as the second debugging result corresponding to the pre-compiled code.
5. The code debugging method of the federated learning compiler according to claim 1, characterized in that: When the debugging instruction is a change instruction for changing the value of a variable at a first position in the pre-compiled code, the step of executing the debugging instruction for the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes: Changing the variable value at a second position corresponding to the first position in the compiled code to a target variable value carried in the change instruction; Running the compiled code after changing the variable value to obtain a running result, and using the running result as a first debugging result; The step of obtaining a second debugging result corresponding to the pre-compiled code according to the first debugging result comprises: The first debugging result is used as the second debugging result corresponding to the pre-compiled code.
6. The code debugging method of the federated learning compiler according to any one of claims 1 to 5, characterized in that: When the debugging instruction is a view current code instruction for the code at a first position in the pre-compiled code, the step of executing the debugging instruction for the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result includes: Obtaining a first code segment within a preset number of lines before and after a code line at a second position corresponding to the first position in the compiled code, and using the first code segment as the first debugging result; The step of obtaining a second debugging result corresponding to the pre-compiled code according to the first debugging result comprises: A second code segment in the pre-compiled code corresponding to the first code segment is used as a second debugging result.
7. A code debugging device for a federated learning compiler, characterized in that: The device comprises: A receiving module, used for receiving a debugging instruction for a code at a first position in the pre-compiled code; a debugging module, configured to execute the debugging instruction on the code at a second position corresponding to the first position in the compiled code to obtain a first debugging result, wherein the compiled code is the code before compilation compiled by the federated learning compiler; A display module, configured to obtain a second debugging result corresponding to the pre-compiled code according to the first debugging result, and display the second debugging result; When the device is applied to a federated learning code executor, the code executor is connected in communication with a federated learning process initiator, and the debugging module includes: A first sending unit is configured to send the first position to the process initiator, so that after the process initiator compiles the pre-compiled code to obtain the compiled code, the compiled code and a second position in the compiled code corresponding to the first position are returned to the code executor; The debugging unit is used to receive the compiled code and the second position, and execute the debugging instruction on the code at the second position in the compiled code to obtain a first debugging result.
8. A code debugging device for a federated learning compiler, characterized in that: The code debugging device of the federated learning compiler includes: a memory, a processor, and a code debugging program of the federated learning compiler stored in the memory and executable on the processor. When the code debugging program of the federated learning compiler is executed by the processor, the steps of the code debugging method of the federated learning compiler as described in any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a code debugging program of a federated learning compiler, and when the code debugging program of the federated learning compiler is executed by a processor, the steps of the code debugging method of the federated learning compiler according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the code debugging method of the federated learning compiler according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
A flow control engine system supporting breakpoint debugging is realized in federated learning
CN111796811A
Compiling Source Code For Debugging With User Preferred Snapshot Locations
US20130275947A1