Random number generation control method and device, medium and distributed computing system
By sending seed variables and temporary offsets to the target computing device in the model computing system, using its local random number generator to generate random numbers and update the status, the problem of inefficiency of random number generators when accessing different computing devices is solved, and efficient access and resource utilization are achieved.
Patent Information
- Application Number
- CN202412000106.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-12-31
AI Technical Summary
In the model computing system, the access efficiency of random number generators when using different computing devices is low, which leads to difficult development and high workload, and it is difficult to fully utilize the computing performance of computing devices.
The main processor responds to the random number generator call command of the model computing framework, determines the target computing device, and sends the seed variable and temporary offset of the first random number generator to the target computing device, causing it to call the local second random number generator to generate the random number. The status information of the target computing device is received and the temporary offset of the first random number generator is updated.
The random number generator access efficiency of different computing devices in the model computing system is improved, the computing performance of computing devices is fully utilized, and the development difficulty and workload are reduced.
Smart Images

Figure CN119718254A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a random number generation control method, device, medium and distributed computing system. Background Art
[0002] With the development of artificial intelligence technology, the computing tasks of artificial intelligence models are becoming more complex and diversified. In the design and training process of artificial intelligence models, random number generators play an indispensable role. They can improve the performance, robustness and generalization ability of artificial intelligence models by generating a series of random numbers to achieve functions such as data enhancement, model initialization, hyperparameter tuning, stochastic gradient descent, and generative models.
[0003] In model computing tasks, the random number generator (RNG) is designed by the computing device based on the hardware architecture and instruction set. However, there are various types of computing devices on the market, and the same type of computing devices also have various models. For example, there are different models of graphics processing units (GPUs). There are significant differences in the random number generation methods of computing devices of different types and models. This leads to the need to adapt the random number generators of each computing device before scheduling different computing devices to generate random numbers in a computing system with multiple computing devices, which brings great development difficulty and development workload.
[0004] Therefore, how to improve the access efficiency of the random number generator when using different computing devices in the model computing system and make full use of the computing performance of the computing devices is a technical problem that technical personnel in this field need to solve. Summary of the invention
[0005] The purpose of the present invention is to provide a random number generation control method, device, medium and distributed computing system, which are used to improve the access efficiency of the random number generator when different computing devices are used in the model computing system, and make full use of the computing performance of the computing devices.
[0006] In order to solve the above technical problems, the present invention provides a random number generation control method, which is applied to a main processor, comprising: In response to a random number generator call command of the model computing framework, determining a target computing device to be called; Sending a seed variable of a first random number generator in the model computing framework and a temporary offset of the first random number generator to the target computing device, so that the target computing device calls a local second random number generator to generate a random number according to the seed variable and the temporary offset and performs a random generation task according to the random number; receiving status information of the second random number generator returned by the target computing device after generating the random number; The temporary offset of the first random number generator is updated according to the state information of the second random number generator.
[0007] On the one hand, it also includes: Determine whether the device information of the target computing device to be called and the state information of the second random number generator of the target computing device are stored in a local device state information array; If not, the device information of the target computing device and the state information of the second random number generator are stored in the device state information array.
[0008] On the other hand, receiving the state information of the second random number generator returned by the target computing device after generating the random number includes: receiving a state information pointer of the second random number generator fed back by the target computing device after generating the random number; The state information pointer is updated to a position corresponding to the target computing device in the local device state information array.
[0009] On the other hand, updating the temporary offset of the first random number generator according to the state information of the second random number generator includes: The device information of the target computing device, the seed variable and the state information of the second random number generator are encapsulated into a class function corresponding to the model computing framework to update the temporary offset of the first random number generator.
[0010] On the other hand, it also includes: Upon receiving a resource deletion command, determining device information of a target device to be deleted; According to the device information of the target device to be deleted, the corresponding device information and the corresponding status information of the second random number generator are deleted in the local device status information array.
[0011] On the other hand, in response to a random number generator call command of the model computing framework, determining a target computing device to be called includes: In response to the random number generator call command to the random number management module, determining the target computing device; Wherein, the random number management module is created as a singleton mode.
[0012] On the other hand, in response to a random number generator call command of the model computing framework, determining a target computing device to be called includes: In response to the random number generator call command to the random number management module, determining the target computing device; Sending a seed variable of a first random number generator in the model computing framework and a temporary offset of the first random number generator to the target computing device includes: Acquire the seed variable of the first random number generator at the current moment and the temporary offset of the first random number generator at the current moment based on the random number management module; Encapsulating the seed variable and the temporary offset into a first data packet; Invoke a communication bus between the main processor and the target computing device to send the first data packet to the target computing device; The target computing device calls a local second random number generator to generate a random number according to the seed variable and the temporary offset and performs a random generation task according to the random number, including: The target computing device parses the first data packet to obtain the seed variable and the temporary offset; The target computing device calls the local second random number generator to generate the random number according to the seed variable and the temporary offset; The target computing device performs the random generation task according to the random number; The target computing device generates a second data packet using the state information of the second random number generator after generating the random number, and calls the communication bus to send the second data packet to the main processor; Receiving state information of the second random number generator returned by the target computing device after generating the random number, comprising: Receive the second data packet sent by the target computing device, and parse the second data packet to obtain status information of the second random number generator.
[0013] In order to solve the above technical problems, the present invention also provides a random number generation control method, which is applied to a computing device, comprising: Receiving a seed variable of a first random number generator and a temporary offset of the first random number generator in a model calculation framework of the main processor sent by a main processor; Calling a local second random number generator to generate a random number according to the seed variable and the temporary offset; Execute a random generation task according to the random number; The state information of the second random number generator after generating the random number is sent to the main processor, so that the main processor updates the temporary offset of the first random number generator according to the state information of the second random number generator.
[0014] To solve the above technical problems, the present invention further provides a distributed computing system, including a main processor and a computing device; The main processor is used to determine the target computing device to be called in response to the random number generator call command of the model computing framework; send the seed variable of the first random number generator in the model computing framework and the temporary offset of the first random number generator to the target computing device; receive the status information of the second random number generator returned by the target computing device after generating the random number; and update the temporary offset of the first random number generator according to the status information of the second random number generator; The target computing device is used to call the local second random number generator to generate the random number according to the seed variable and the temporary offset and perform a random generation task according to the random number.
[0015] In order to solve the above technical problems, the present invention also provides a random number generation control device, comprising: Memory for storing computer programs; A processor is used to execute the computer program, and when the computer program is executed by the processor, the steps of the random number generation control method as described in any one of the above items are implemented.
[0016] In order to solve the above technical problems, the present invention also provides a non-volatile storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the random number generation control method as described in any one of the above items are implemented.
[0017] The random number generation control method provided by the present invention has the beneficial effect that when the main processor responds to the random number generator call command of the model computing framework and determines the target computing device to be called, the seed variable of the first random number generator in the model computing framework and the temporary offset of the first random number generator are sent to the target computing device, so that the target computing device calls the local second random number generator to generate a random number according to the seed variable and the temporary offset and performs a random generation task according to the random number, and receives the status information of the second random number generator returned by the target computing device after generating the random number, and updates the temporary offset of the first random number generator according to the status information of the second random number generator. The parameters transmitted between the main processor and the computing device are all parameters decoupled from the model computing framework and the hardware of the computing device, so that there is no need to adapt the hardware random number generator of the computing system when the model computing system is connected to a new computing device, and the computing resources of the computing device can be fully utilized to realize random number generation and subsequent random generation tasks, while improving the access efficiency of the random number generator when different computing devices are used in the model computing system, and fully utilizing the computing performance of different computing devices.
[0018] The random number generation control device, non-volatile storage medium and distributed computing system provided by the present invention have the above-mentioned beneficial effects, which will not be described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0020] Figure 1 A flowchart of a random number generation control method provided by an embodiment of the present invention; Figure 2 A connection diagram of a random number generator management module provided by an embodiment of the present invention; Figure 3 A schematic diagram of the structure of a random number generation control device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0021] The core of the present invention is to provide a random number generation control method, device, medium and distributed computing system, which are used to improve the access efficiency of the random number generator when different computing devices are used in the model computing system, and make full use of the computing performance of the computing devices.
[0022] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0023] To facilitate understanding of the technical solution provided by the embodiment of the present invention, some key terms used in the embodiment of the present invention are first explained here.
[0024] In the design and training process of artificial intelligence models, random number generators (RNGs) play an indispensable role. Random number generators can generate a series of pseudo-random numbers that can be uniformly distributed or follow a specific probability distribution. In artificial intelligence models, random number generators are widely used, covering data enhancement, model initialization, hyperparameter tuning, stochastic gradient descent, generative models, and many other aspects. Reasonable use of random number generators can improve the performance, robustness, and generalization ability of the model.
[0025] In the computing tasks of artificial intelligence models, random number generators can be implemented on computing devices based on hardware architecture and instruction sets, such as on central processing units (CPUs) or graphics processing units (GPUs), or on other types of computing devices. Random number generators on different types of computing devices differ significantly in architecture, parallel processing capabilities, random number generation algorithms, performance, and application scenarios. In large-scale model computing, such as model computing under a deep learning framework, artificial intelligence model training and reasoning mostly use random number generators with multi-computing device architectures to improve performance.
[0026] Due to the different types, models, and manufacturers of computing devices, the hardware architecture and instruction sets of different computing devices may be different, resulting in different solutions when connecting the random number generator of the model computing framework to different computing devices in distributed model computing tasks. This has poor flexibility, and the development difficulty and workload will increase significantly when connecting to new computing devices. In addition, the hardware interfaces of different computing devices are different, and there is a lack of unified management, which reduces the versatility, scalability, and code readability of the model computing framework.
[0027] Looking at the random number generator access solutions in the existing model computing framework, they can be mainly divided into two categories.
[0028] The first category is that under the model computing framework, the random number generator is connected to different computing devices so as to make full use of the performance and resources of the computing devices when executing model computing tasks. However, due to the different hardware architectures and instruction sets of different computing devices, each time a new computing device is connected, the corresponding model computing code needs to be modified. For example, when connecting to a certain model of computing device provided by manufacturer A, the model computing framework code provided by manufacturer A needs to be used. When connecting to another model of computing device provided by manufacturer B, the model computing framework code provided by manufacturer B needs to be used. The model computing framework code provided by manufacturer A needs to be modified by manufacturer A according to the needs of its own computing device. It can be seen that under this random number generator access scheme, although the performance of the random number generator is high after deployment, the scalability of the model computing framework code is poor. Each computing device manufacturer needs to modify the corresponding model computing code according to its own computing device. The model computing framework lacks unified management of hardware, resulting in difficulties in the access function of different computing devices, and poor portability and scalability.
[0029] The second category is to implement the random number generator through a centralized processor under the model computing framework, such as using the central processing unit to implement random number generation, and realize hardware decoupling of the random number generator from other computing devices. Although this solution supports the access of multiple computing devices and has high hardware scalability, its implementation method of the random number generator on the central processing unit does not connect the random number generator to other computing devices. When random generation tasks need to be performed, only the central processing unit generates random numbers and performs random generation tasks, such as sample amplification, and sends the results of the random generation tasks to other computing devices to perform model calculations (such as performing iterative training based on the training samples amplified by the central processing unit, and performing addition, subtraction, multiplication, division, convolution and other operations). Although this method simplifies the efficiency of connecting different computing devices in the model computing system, it does not connect the random number generator to other computing devices, and has limitations in performance and resource utilization.
[0030] In order to connect a random number generator to different computing devices to fully utilize the performance and resources of the computing devices and reduce the difficulty of access, an embodiment of the present invention provides a random number generation control scheme. When a main processor responds to a random number generator call command of a model computing framework and determines a target computing device to be called, the main processor sends the seed variable of a first random number generator in the model computing framework and the temporary offset of the first random number generator to the target computing device, so that the target computing device calls a local second random number generator to generate a random number according to the seed variable and the temporary offset and performs a random generation task according to the random number, receives the status information of the second random number generator returned by the target computing device after generating the random number, and updates the temporary offset of the first random number generator according to the status information of the second random number generator. The parameters transmitted between the main processor and the computing device are all parameters decoupled from the model computing framework and the hardware of the computing device, so that there is no need to adapt the hardware random number generator of the computing system when the model computing system is connected to a new computing device, and the computing resources of the computing device can be fully utilized to realize random number generation and subsequent random generation tasks. While improving the access efficiency of the random number generator when different computing devices are used in the model computing system, the computing performance of different computing devices is fully utilized.
[0031] The random number generation control method provided by the embodiment of the present invention is described below with reference to the accompanying drawings.
[0032] Figure 1 A flowchart of a random number generation control method provided by an embodiment of the present invention; Figure 2 A connection diagram of a random number generator management module provided by an embodiment of the present invention.
[0033] like Figure 1As shown, applied to a main processor, the random number generation control method provided by an embodiment of the present invention may include: S101: In response to a random number generator call command of a model computing framework, determining a target computing device to be called; S102: Sending the seed variable of the first random number generator in the model computing framework and the temporary offset of the first random number generator to the target computing device, so that the target computing device calls the local second random number generator to generate a random number according to the seed variable and the temporary offset and performs a random generation task according to the random number; S103: receiving status information of a second random number generator returned by the target computing device after generating a random number; S104: Update the temporary offset of the first random number generator according to the state information of the second random number generator.
[0034] In a specific implementation, the random number generation control method provided by the embodiment of the present invention can be applied to a single server or a distributed system composed of multiple servers. When applied to a single server, the main processor in the embodiment of the present invention can be a central processing unit in a centralized management server, and the computing device or target computing device in the embodiment of the present invention can be other computing devices in the server for expanding computing performance, which can be but not limited to a central processing unit, a graphics processor, a digital signal processor (Digital Signal Processor, DSP), a field programmable gate array (Field-Programmable Gate Array, FPGA), etc., that is, it can be a heterogeneous computing device, and can also include computing devices of the same type and different models, and also think that they are completely the same computing devices. If applied to a distributed system, the main processor in the embodiment of the present invention can be a processor on a server used for centralized scheduling in the distributed system, and the computing device or target computing device in the embodiment of the present invention is other servers deployed as computing nodes in the distributed system.
[0035] In the embodiments of the present invention, no matter which of the above scenarios it is applied to, the system composed of a main processor and a computing device for executing model computing tasks can be called a distributed computing system.
[0036] The model computing framework in the embodiment of the present invention can be a deep learning framework, or other types of model computing frameworks deployed in a distributed model computing system. In the embodiment of the present invention, when introducing the model computing framework, it mainly refers to a software framework deployed on the main processor for implementing distributed model computing scheduling. After connecting to the distributed model computing system, different computing devices execute the model computing tasks assigned by the main processor based on the model computing framework according to their own model computing programs.
[0037] The first random number generator of the model calculation framework is a software random number generator, and the second random number generator of the computing device is a hardware random number generator implemented according to the hardware architecture and instruction set of the computing device. The random number generation control method provided by the embodiment of the present invention is applied. On the basis of using the second random number generator of the computing device, there is no need to modify the control code of the second random number generator of the computing device. Instead, the random number generator management module provided by the embodiment of the present invention realizes the connection between the first random number generator and the second random number generator.
[0038] That is to say, the random number generation control method provided in the embodiment of the present invention can be implemented by developing a random number generator management module, that is, by developing a random number generator management module to implement the method steps in the embodiment of the present invention, the random number generator management module is used to achieve the adaptation of the first random number generator of the model calculation framework and the second random number generator of the computing device. The random number generator management module provided in the embodiment of the present invention is a software module, which can be deployed on the main processor together with the model calculation framework.
[0039] like Figure 2 As shown, the random number generator management module provided by the embodiment of the present invention is located between the model computing framework and the computing device, and is used to transfer the seed variables and temporary offsets required for random number generation, and to perform information management of multiple computing devices.
[0040] In the embodiment of the present invention, the random number generator call command of the model computing framework in S101 is a random number generator call command issued by an operator that needs to generate random numbers and perform random generation tasks under the model computing framework. The random generation task can be one or more of a data enhancement task, a model initialization task, a hyperparameter tuning task, a stochastic gradient descent task, and a generation model task, or other types of tasks that need to be performed using random numbers.
[0041] In the embodiment of the present invention, the random number generator management module can be deployed in each operator module of the model computing framework according to the operator that needs to generate random numbers in the model computing framework.
[0042] Since the random number generator in the model computing framework usually exists as a global variable, each update will output a random number according to the state of the current random number generator. Therefore, in an embodiment of the present invention, the random number generator management module can also be created and managed in a singleton mode to ensure that the first random number generator in the model computing framework corresponds to only one random number generator management module to ensure the global uniqueness of the random number generator state, which is convenient for maintenance and expansion, while avoiding multiple creation and destruction of generator instances, thereby saving memory and computing resources. In addition, the singleton mode provides a global access point, making it more convenient to access the state of the random number generator in different parts of the model computing framework. Then, in S101, in response to the random number generator call command of the model computing framework, determining the target computing device to be called may include: determining the target computing device in response to the random number generator call command of the random number management module; wherein the random number management module is created as a singleton mode.
[0043] In a random number generator, the random number seed is the initial value used to initialize the state of the random number generator, and different seed values determine the starting point of the generated random number sequence. The offset refers to generating random numbers from a certain position in the random number sequence, rather than from the beginning. The offset can be used to skip part of the sequence to generate different subsequences. The combination of the random number seed and the offset can ensure that the generated random number sequence is both deterministic and diverse. Therefore, in the random number generation control method provided in an embodiment of the present invention, the key to implementing the hardware decoupled random number generator access strategy is to pass the random number seed in the model calculation framework to the computing device, and update the offset in the model calculation framework through the state after the random number is calculated by the second random number generator on the computing device, so as to pave the way for the next random number generation.
[0044] So Figure 2 As shown, the variables of the random number generator management module provided in the embodiment of the present invention only include a seed variable and a temporary offset. The seed variable is bound to the random number seed in the model calculation framework, and the temporary offset is used to transfer the offset information between the model calculation framework and the computing device. This design not only minimizes the resource usage of the random number generator management module, but also can efficiently transfer the information of the model calculation framework to the computing device.
[0045] Furthermore, when the random number generator management module provided in the embodiment of the present invention needs to call a computing device to generate a random number, it determines the seed variable according to the random number seed of the first random number generator in the model computing framework, determines the temporary offset according to the current temporary offset of the first random number generator, and sends the seed variable and the temporary offset to the computing device. After the computing device uses the local second random number generator to generate a random number according to the seed variable and the temporary offset, the state of the second random number generator is updated, and the computing device returns the state information of the second random number generator to the main processor. The random number generator management module collects the updated state information of the second random number generator, encapsulates it and sends it to the model computing framework to update the temporary offset in the first random number generator.
[0046] The random number generation control method provided by the embodiment of the present invention, when the main processor responds to the random number generator call command of the model computing framework and determines the target computing device to be called, sends the seed variable of the first random number generator in the model computing framework and the temporary offset of the first random number generator to the target computing device, so that the target computing device calls the local second random number generator to generate a random number according to the seed variable and the temporary offset and performs a random generation task according to the random number, and receives the status information of the second random number generator returned by the target computing device after generating the random number, and updates the temporary offset of the first random number generator according to the status information of the second random number generator. The parameters transmitted between the main processor and the computing device are all parameters decoupled from the model computing framework and the hardware of the computing device, so that there is no need to adapt the hardware random number generator of the computing system when the model computing system is connected to a new computing device, and the computing resources of the computing device can be fully utilized to realize random number generation and subsequent random generation tasks, and the computing performance of different computing devices is fully utilized while improving the access efficiency of the random number generator when different computing devices are used in the model computing system.
[0047] Based on the above embodiment, the embodiment of the present invention further illustrates the steps of the random number management module executing the control task of random number generation.
[0048] In the above embodiment, it is introduced that in order to implement the hardware decoupled random number generator access strategy, the random number generator management module provided by the embodiment of the present invention transmits the seed variable and temporary offset required for random number generation between the model computing framework and the target computing device. In order to implement access management of multiple computing devices and facilitate the model computing framework, the random number generator management module provided by the embodiment of the present invention can be specifically used to implement three functions: obtaining device information, obtaining the status information of the second random number generator, and updating the status information of the first random number generator.
[0049] Among them, obtaining device information is to obtain the identification information of the currently running computing device through the docking model computing framework, which is mainly used to maintain the operation of a distributed system with multiple card devices or multiple computing nodes.
[0050] The state information of the second random number generator is obtained by passing the device information of the model computing framework (which may be the device number of the computing device), the seed variable, and the temporary offset to the target computing device, and then obtaining the state information of the second random number generator on the target computing device. The device information, random number seed, and offset exist in different model computing frameworks, so the information transmission between the model computing framework and the computing device can be completed with the least variables.
[0051] In an embodiment of the present invention, receiving the status information of the second random number generator returned by the target computing device after generating the random number in S103 may include: receiving the status information pointer of the second random number generator fed back by the target computing device after generating the random number; and updating the status information pointer to a position corresponding to the target computing device in the local device status information array.
[0052] That is, for the convenience of maintenance, the random number generator management module can unify the status information of the second random number generator of different models of computing devices returned into a pointer form, which can improve the versatility and compatibility of the random number generator management module. At the same time, in different model computing frameworks, array information is usually saved in the form of pointers. Therefore, the design can also encapsulate the information of the random number generator management module into an array form and directly pass it to the computing device, further simplifying the access form of the random number generator.
[0053] When the target computing device completes generating random numbers using the second random number generator, the random number generator management module updates the offset, and passes the device information, seed variable, and updated temporary offset to the first random number generator of the model computing framework to update the state of the first random number generator. In an embodiment of the present invention, updating the temporary offset of the first random number generator according to the state information of the second random number generator in S104 may include: encapsulating the device information, seed variable, and state information of the target computing device into a class function corresponding to the model computing framework to update the temporary offset of the first random number generator. That is, the random number generator management module can access the model computing framework by encapsulating the device information, seed variable, and updated temporary offset into a class function required by the model computing framework, and completes the state update of the variables in the first random number generators of different model computing frameworks.
[0054] In the random number generation control method provided in the embodiment of the present invention, the second random number generator of the computing device is used. The biggest difference from the related art that only uses the random number generator in the central processing unit (similar to the main processor in the embodiment of the present invention) is that the number of computing devices is not unique, and each computing device has a second random number generator, which can ensure high concurrency in model calculation. In order to uniformly manage all computing devices, such as Figure 2 As shown, in the random number generator management module provided in the embodiment of the present invention, an associated container can be used to store device information of the computing device (such as Figure 2 The device information 0, device information 1, ...) shown in FIG. 1 and the status information of the second random number generator of the computing device (such as Figure 2 Device status 0, device status 1, ... are shown).
[0055] In an embodiment of the present invention, the device information of the computing device and the state information of the second random number generator of the computing device may be stored in the main processor in the form of a key-value pair. Specifically, the key-value pair may be stored in the above-mentioned associated container.
[0056] The random number generation control method provided by an embodiment of the present invention may also include: determining whether the device information of the target computing device to be called and the status information of the second random number generator of the target computing device are stored in a local device status information array; if not, storing the device information of the target computing device and the status information of the second random number generator into the device status information array.
[0057] In an embodiment of the present invention, the device information of the computing device and the state information of the second random number generator of the computing device may be maintained in array form, recorded as a device state information array, and the device state information array may be stored in the above-mentioned associated container.
[0058] Therefore, when the random number generator management module is called, the random number generator management module will store the device information and the status information of the second random number generator in the associated container in the form of a key-value pair. Each time the status information of the second random number generator of the target computing device is obtained, it will be queried whether the device information corresponding to the status information of the second random number generator exists in the associated container. If not, the device information and the status information of the second random number generator will be converted into a key-value pair and added to the associated container to avoid the situation of wrong transmission or missing transmission when transmitting information to the target computing device.
[0059] The random number generation control method provided by an embodiment of the present invention may also include: when receiving a resource deletion command, determining the device information of the target device to be deleted; deleting the corresponding device information and the corresponding status information of the second random number generator in the local device status information array according to the device information of the target device to be deleted.
[0060] That is to say, when releasing resources at the end of the program, it is only necessary to find the device information in the associated container and the status information of the second random number generator to ensure the correct release of the resources.
[0061] In an embodiment of the present invention, a communication method between a main processor and a computing device is further described.
[0062] In the random number generation control method provided by an embodiment of the present invention, determining the target computing device to be called in response to a random number generator call command of a model computing framework in S101 may include: determining the target computing device in response to a random number generator call command of a random number management module.
[0063] In S102, the seed variable of the first random number generator in the model calculation framework and the temporary offset of the first random number generator are sent to the target computing device, which may include: obtaining the seed variable of the first random number generator at the current moment and the temporary offset of the first random number generator at the current moment based on the random number management module; encapsulating the seed variable and the temporary offset into a first data packet; calling the communication bus between the main processor and the target computing device to send the first data packet to the target computing device.
[0064] In S102, the target computing device calls the local second random number generator to generate a random number according to the seed variable and the temporary offset and performs a random generation task according to the random number, which may include: the target computing device parses the first data packet to obtain the seed variable and the temporary offset; the target computing device calls the local second random number generator to generate a random number according to the seed variable and the temporary offset; the target computing device performs the random generation task according to the random number; the target computing device generates a second data packet with the status information of the second random number generator after generating the random number, and calls the communication bus to send the second data packet to the main processor.
[0065] Receiving the status information of the second random number generator returned by the target computing device after generating the random number in S103 may include: receiving a second data packet sent by the target computing device, and parsing the second data packet to obtain the status information of the second random number generator.
[0066] In the random number generation control method provided in an embodiment of the present invention, the seed variable of the first random number generator in the model calculation framework and the temporary offset of the first random number generator are sent to the target computing device in S102, and may also include: encrypting the seed variable and the temporary offset; and sending the encrypted seed variable and the encrypted temporary offset to the target computing device.
[0067] Receiving the state information of the second random number generator returned by the target computing device after generating the random number in S103 may also include: receiving the encrypted state information of the second random number generator returned by the target computing device after generating the random number.
[0068] When applied to a distributed system, the random number generation process may be vulnerable to external attacks. To improve the reliability of the random number generation task, in an embodiment of the present invention, the random number related information transmitted between the main processor and the target computing device is encrypted to ensure the security of the random number generation.
[0069] The embodiment of the present invention also provides a random number generation control method applied to a computing device, which may include: Receive a seed variable of a first random number generator and a temporary offset of the first random number generator in a model calculation framework of the main processor sent by the main processor; Call the local second random number generator to generate a random number according to the seed variable and the temporary offset; Perform random generation tasks based on random numbers; The state information of the second random number generator after generating the random number is sent to the main processor, so that the main processor updates the temporary offset of the first random number generator according to the state information of the second random number generator.
[0070] The specific implementation of the embodiment of the present invention may refer to the description of the random number generation control method applied to the main processor.
[0071] It should be noted that in the embodiments of the random number generation control method of the present invention, some of the steps or features can be ignored or not executed. The hardware or software functional modules divided for the convenience of description are not the only implementation form of the random number generation control method provided in the embodiments of the present invention.
[0072] The above describes in detail various embodiments corresponding to the random number generation control method. On this basis, the present invention also discloses a distributed computing system, a random number generation control device, a device, a non-volatile storage medium and a computer program product corresponding to the above method.
[0073] The distributed computing system provided by the embodiment of the present invention may include a main processor and a computing device.
[0074] Among them, the main processor is used to respond to the random number generator call command of the model computing framework, determine the target computing device to be called; send the seed variable of the first random number generator in the model computing framework and the temporary offset of the first random number generator to the target computing device; receive the status information of the second random number generator returned by the target computing device after generating the random number; and update the temporary offset of the first random number generator according to the status information of the second random number generator.
[0075] The target computing device is used to call a local second random number generator to generate a random number according to a seed variable and a temporary offset and to perform a random generation task according to the random number.
[0076] The distributed computing system provided by the embodiment of the present invention can be a distributed computing system composed of a main processor and computing devices in a single server, or a distributed computing system composed of a main processor and other computing nodes in a centralized management server in a distributed system with multiple servers.
[0077] Since the embodiments of the distributed computing system part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the distributed computing system part, which will not be repeated here.
[0078] Applied to a main processor, the random number generation control device provided by an embodiment of the present invention may include: A determination unit, configured to determine a target computing device to be called in response to a random number generator call command of the model computing framework; A first sending unit is used to send the seed variable of the first random number generator in the model calculation framework and the temporary offset of the first random number generator to the target computing device, so that the target computing device calls the local second random number generator to generate a random number according to the seed variable and the temporary offset and performs a random generation task according to the random number; A first receiving unit, configured to receive state information of a second random number generator returned by a target computing device after generating a random number; An updating unit is used to update the temporary offset of the first random number generator according to the state information of the second random number generator.
[0079] Applied to a computing device, the random number generation control device provided by an embodiment of the present invention may include: A second receiving unit is used to receive a seed variable of a first random number generator and a temporary offset of the first random number generator in a model calculation framework of a main processor sent by the main processor; A generation control unit, used for calling a local second random number generator to generate a random number according to a seed variable and a temporary offset; An execution unit, used for executing a random generation task according to a random number; The second sending unit is used to send the state information of the second random number generator after generating the random number to the main processor, so that the main processor updates the temporary offset of the first random number generator according to the state information of the second random number generator.
[0080] It should be noted that in each implementation of the random number generation control device provided by the embodiment of the present invention, the division of the unit is only a logical functional division, and other division methods can be adopted. The connection method between different units can be electrical, mechanical or other connection methods. The separated units can be located in the same physical location or distributed on multiple network nodes. Each unit can be implemented in the form of hardware or in the form of a software functional unit. That is, part or all of the units provided by the embodiment of the present invention can be selected according to actual needs and the corresponding connection method or integration method can be adopted to achieve the purpose of the embodiment of the present invention.
[0081] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.
[0082] Figure 3 A schematic diagram of the structure of a random number generation control device provided by an embodiment of the present invention.
[0083] like Figure 3 As shown, the random number generation control device provided by an embodiment of the present invention includes: a memory 310, used to store a computer program 311; a processor 320, used to execute the computer program 311, and when the computer program 311 is executed by the processor 320, the steps of the random number generation control method provided in any one of the above embodiments are implemented.
[0084] Among them, the processor 320 may include one or more processing cores, such as a 3-core processor, an 8-core processor, etc. The processor 320 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array. The processor 320 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 320 may be integrated with a graphics processing unit (GPU), and the image processor is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 320 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0085] The memory 310 may include one or more non-volatile storage media, which may be non-transitory. The memory 310 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 310 is at least used to store the following computer program 311, wherein the computer program 311, after being loaded and executed by the processor 320, can implement the relevant steps in the random number generation control method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 310 may also include an operating system 312 and data 313, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 312 may be Windows or other types of operating systems. Data 313 may include, but is not limited to, the data involved in the above method.
[0086] In some embodiments, the random number generation control device may further include a display screen 330 , a power supply 340 , a communication interface 350 , an input / output interface 360 , a sensor 370 , and a communication bus 380 .
[0087] Those skilled in the art will understand that Figure 3 The structure shown in the figure does not constitute a limitation on the random number generation control device, and may include more or fewer components than those shown in the figure.
[0088] The random number generation control device provided in an embodiment of the present invention includes a memory and a processor. When the processor executes the program stored in the memory, it can implement the steps of the random number generation control method provided in the above embodiment, and the effect is the same as above.
[0089] An embodiment of the present invention provides a non-volatile storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the random number generation control method provided in any one of the above embodiments can be implemented.
[0090] The non-volatile storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0091] For the introduction of the non-volatile storage medium provided in the embodiment of the present invention, please refer to the above method embodiment, and the effect thereof is the same as the random number generation control method provided in the embodiment of the present invention, and the present invention will not elaborate on it here.
[0092] An embodiment of the present invention provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the random number generation control method provided in any one of the above embodiments.
[0093] For an introduction to the computer program product provided by the embodiment of the present invention, please refer to the above method embodiment, and the effect thereof is the same as the random number generation control method provided by the embodiment of the present invention, and the present invention will not elaborate on it here.
[0094] The above is a detailed introduction to a random number generation control method, device, equipment and non-volatile storage medium provided by the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can be referenced to each other. For the devices, equipment, non-volatile storage media and computer program products disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, the present invention can also be improved and modified in a number of ways, and these improvements and modifications also fall within the scope of protection of the present invention.
[0095] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants 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 statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. A random number generation control method, characterized in that: Applicable to main processors, including: In response to a random number generator call command of the model computing framework, determining a target computing device to be called; Sending a seed variable of a first random number generator in the model computing framework and a temporary offset of the first random number generator to the target computing device, so that the target computing device calls a local second random number generator to generate a random number according to the seed variable and the temporary offset and performs a random generation task according to the random number; receiving status information of the second random number generator returned by the target computing device after generating the random number; The temporary offset of the first random number generator is updated according to the state information of the second random number generator.
2. The random number generation control method according to claim 1, characterized in that: Also includes: Determine whether the device information of the target computing device to be called and the state information of the second random number generator of the target computing device are stored in a local device state information array; If not, the device information of the target computing device and the state information of the second random number generator are stored in the device state information array.
3. The random number generation control method according to claim 1, characterized in that: Receiving state information of the second random number generator returned by the target computing device after generating the random number, comprising: receiving a state information pointer of the second random number generator fed back by the target computing device after generating the random number; The state information pointer is updated to a position corresponding to the target computing device in the local device state information array.
4. The random number generation control method according to claim 1, characterized in that: Updating the temporary offset of the first random number generator according to the state information of the second random number generator includes: The device information of the target computing device, the seed variable and the state information of the second random number generator are encapsulated into a class function corresponding to the model computing framework to update the temporary offset of the first random number generator.
5. The random number generation control method according to claim 1, characterized in that: Also includes: Upon receiving a resource deletion command, determining device information of a target device to be deleted; According to the device information of the target device to be deleted, the corresponding device information and the corresponding status information of the second random number generator are deleted in the local device status information array.
6. The random number generation control method according to claim 1, characterized in that: In response to a random number generator call command of the model computing framework, determining a target computing device to be called includes: In response to the random number generator call command to the random number management module, determining the target computing device; Wherein, the random number management module is created as a singleton mode.
7. The random number generation control method according to claim 1, characterized in that: In response to a random number generator call command of the model computing framework, determining a target computing device to be called includes: In response to the random number generator call command to the random number management module, determining the target computing device; Sending a seed variable of a first random number generator in the model computing framework and a temporary offset of the first random number generator to the target computing device includes: Acquire the seed variable of the first random number generator at the current moment and the temporary offset of the first random number generator at the current moment based on the random number management module; Encapsulating the seed variable and the temporary offset into a first data packet; Invoke a communication bus between the main processor and the target computing device to send the first data packet to the target computing device; The target computing device calls a local second random number generator to generate a random number according to the seed variable and the temporary offset and performs a random generation task according to the random number, including: The target computing device parses the first data packet to obtain the seed variable and the temporary offset; The target computing device calls the local second random number generator to generate the random number according to the seed variable and the temporary offset; The target computing device performs the random generation task according to the random number; The target computing device generates a second data packet using the state information of the second random number generator after generating the random number, and calls the communication bus to send the second data packet to the main processor; Receiving state information of the second random number generator returned by the target computing device after generating the random number, comprising: Receive the second data packet sent by the target computing device, and parse the second data packet to obtain status information of the second random number generator.
8. A random number generation control method, characterized in that: Applied to computing devices, including: Receiving a seed variable of a first random number generator and a temporary offset of the first random number generator in a model calculation framework of the main processor sent by a main processor; Calling a local second random number generator to generate a random number according to the seed variable and the temporary offset; Execute a random generation task according to the random number; The state information of the second random number generator after generating the random number is sent to the main processor, so that the main processor updates the temporary offset of the first random number generator according to the state information of the second random number generator.
9. A distributed computing system, characterized in that: including a main processor and a computing device; The main processor is used to determine the target computing device to be called in response to the random number generator call command of the model computing framework; send the seed variable of the first random number generator in the model computing framework and the temporary offset of the first random number generator to the target computing device; receive the status information of the second random number generator returned by the target computing device after generating the random number; and update the temporary offset of the first random number generator according to the status information of the second random number generator; The target computing device is used to call the local second random number generator to generate the random number according to the seed variable and the temporary offset and perform a random generation task according to the random number.
10. A random number generation control device, characterized in that: include: Memory for storing computer programs; A processor is used to execute the computer program, and when the computer program is executed by the processor, the steps of the random number generation control method as claimed in any one of claims 1 to 8 are implemented.
11. A non-volatile storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the random number generation control method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Hardware fingerprint information generation method and system based on national cryptographic algorithm
CN111709044A
Smart contract pseudo-random number security check method and system, medium and device
CN112131587A
Low-memory-occupancy implementation technology based on post quantum cryptography Saber algorithm
CN113472525A
Random number generation method and device, electronic equipment and medium
CN116301721A
Generating gaussian random numbers using inverse sampling and recurrence relationship
US20170220322A1
Cited By
Cross-chip random number generation method and device
CN121209836A