Model weight file distribution method and apparatus, computer program product, host, and storage medium
By monitoring and automatically distributing model weight files in a container environment, the time-consuming and unstable distribution of model weight files is solved, and efficient deployment and security of container images are achieved.
Patent Information
- Application Number
- CN202510829153.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2045-06-20
AI Technical Summary
In a container environment, the distribution of model weight files is time-consuming and unstable, leading to difficulties in model deployment and security risks.
By monitoring the working status of the container, it is allowed to automatically load the model weight file in the host directory, and use the weight file registry and warehouse to query and pull, so as to realize the container's access to the host directory and the automatic distribution of file addresses.
It realizes the automatic distribution of model weight files, reduces deployment time and workload, improves security, and avoids the duplication of container images in occupying disk space.
Smart Images

Figure CN120336272B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software technology, and in particular to a method, device, computer program product, host, and storage medium for distributing a model weight file. Background Art
[0002] The model weight file is used to store model weight parameters. Before the model runs, the model weight parameters need to be filled in its framework to be used for subsequent model inference. In a container environment, there are generally two ways to distribute model weight files:
[0003] The first solution involves binding the model weight file to the container image. This requires that the model weight file be packaged into the image file when creating the container image. However, due to the large amount of data in the model weight file, pushing the image file to the image repository and pulling the image file from the image repository during container deployment are time-consuming, making model deployment difficult. Furthermore, due to the container image's caching mechanism, even the slightest change to the image content invalidates the cache of the image file, causing the same content to repeatedly occupy the host's disk space.
[0004] To address the issue of binding model weight files to container images, a second solution was developed: storing the model weight files in a host directory. This required users to manually transfer the model weight files, which was a significant workload when deploying across multiple hosts. Furthermore, this manual operation made container deployment unstable, posing a security risk to the process of running the model in the container. Summary of the Invention
[0005] In view of the above problems, this application provides a method, device, computer program product, host and storage medium for distributing model weight files to achieve the purpose of automatically distributing model weight files in the host directory. The specific solution is as follows:
[0006] A first aspect of the present application provides a method for distributing a model weight file, the method being applied to a host, and comprising:
[0007] Monitoring a working state of a target container for executing a model running task, wherein the working state includes a startup state, and the target container can access a host directory of the host in the startup state;
[0008] In response to a first query request for a target model weight file sent by the target container in the startup state, query a target file address of the target model weight file in the host directory;
[0009] The target file address is returned to the target container, so that the target container loads the target model weight file in the host directory based on the target file address.
[0010] In a possible implementation, the first query request includes a target file identifier, where the target file identifier is used to uniquely identify the target model weight file. Querying the target file address of the target model weight file in the host directory includes:
[0011] Retrieve a weight file registry, wherein the weight file registry records registration information of the downloaded model weight file, wherein the registration information at least includes a file identifier of the model weight file and a file address thereof in the host directory;
[0012] Querying the weight file registry based on the target file identifier;
[0013] If the target file identifier is found in the weight file registry, the file address corresponding to the target file identifier is used as the target file address.
[0014] In a possible implementation, querying the target file address of the target model weight file in the host directory further includes:
[0015] If the target file identifier is not found in the weight file registry, the target model weight file is pulled from the weight file warehouse based on the target file identifier;
[0016] The target model weight file is stored in the host directory, and the file address of the target model weight file in the host directory is used as the target file address;
[0017] The target file identifier and the target file address are recorded in the weight file registration table as registration information of the target model weight file.
[0018] In a possible implementation, the registration information further includes a file check value of the model weight file, and the file check value corresponds one-to-one to the file identifier of the model weight file;
[0019] Pulling the target model weight file from the weight file warehouse based on the target file identifier includes:
[0020] Sending a second query request including the target file identifier to the weight file repository, so that the weight file repository returns a candidate model weight file and its corresponding candidate file check value in response to the second query request;
[0021] determining a target file identification corresponding to the target file address, and determining a target file check value corresponding to the target file identification;
[0022] if the target file check value is identical to the candidate file check value, taking the candidate model weight file as the target model weight file;
[0023] Correspondingly, the registration information of the target file identification and the target file address to the target model weight file is recorded into the weight file registry, including:
[0024] The target file identification, the target file address and the target file check value are recorded as the registration information of the target model weight file into the weight file registry.
[0025] In a possible implementation, the working state further contains an offline state, the registration information further contains a loading number of the model weight file, and the distribution method of the model weight file further includes:
[0026] After the target file address is returned to the target container, a target loading number of the target model weight file in the weight file registry is queried, and the target loading number is increased by 1;
[0027] In response to a release request for the target model weight file sent by the target container in the offline state, the target loading number is decreased by 1.
[0028] In a possible implementation, the distribution method of the model weight file further includes:
[0029] In the case that the target loading number meets a corresponding deletion condition, the target model weight file is deleted under the host directory.
[0030] The second aspect of the present application provides a model weight file distribution device, the model weight file distribution device is applied to a host, and the model weight file distribution device includes:
[0031] A container monitoring module is configured to monitor a working state of a target container performing a model running task, wherein the working state contains a start state, and the target container can access a host directory of the host in the start state.
[0032] The file distribution module is configured to, in response to a first query request for a target model weight file sent by the target container in the starting state, query a target file address of the target model weight file in the host directory, and return the target file address to the target container, so that the target container loads the target model weight file in the host directory based on the target file address.
[0033] The third aspect of the present application provides a computer program product comprising computer readable instructions which, when executed on a host, cause the host to implement the model weight file distribution method of the first aspect or any implementation manner of the first aspect.
[0034] The fourth aspect of the present application provides a host comprising at least one processor and a memory connected to the processor, wherein:
[0035] The memory is configured to store a computer program;
[0036] The processor is configured to execute the computer program to enable the host to implement the model weight file distribution method of the first aspect or any implementation manner of the first aspect.
[0037] The fifth aspect of the present application provides a computer storage medium carrying one or more computer programs, which, when executed by a host, enable the host to implement the model weight file distribution method of the first aspect or any implementation manner of the first aspect.
[0038] By the above technical solution, the model weight file distribution method, device, computer program product, host and storage medium provided by the present application are applied to a host, monitor the working state of a target container executing a model running task, the working state includes a starting state, and the target container can access a host directory of the host in the starting state; in response to a first query request for a target model weight file sent by the target container in the starting state, the target file address of the target model weight file in the host directory is queried; the target file address is returned to the target container, so that the target container loads the target model weight file in the host directory based on the target file address. In the present application, the container can access the host directory when starting, and then query the host for the file address of the model weight file required by the container in the host directory, and finally load the model weight file based on the file address. Multiple containers can share the same physical storage of the model weight file, which not only can release the binding of the model weight file and the container image, and the disk occupation when multiple containers deploy the same model, but also can realize the automatic loading of the model weight file in the host directory by the container, reduce the workload when deploying multiple hosts, and improve the security. BRIEF DESCRIPTION OF DRAWINGS
[0039] The above and other features, advantages, and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale.
[0040] Figure 1 A flow chart of a method for distributing model weight files provided in an embodiment of the present application;
[0041] Figure 2 A partial flow chart of a method for distributing model weight files provided in an embodiment of the present application;
[0042] Figure 3 A schematic diagram of another part of the flow chart of a method for distributing model weight files provided in an embodiment of the present application;
[0043] Figure 4 A schematic diagram of another part of the flow chart of a method for distributing model weight files provided in an embodiment of the present application;
[0044] Figure 5 A schematic diagram of the structure of a distribution device for a model weight file provided in an embodiment of the present application;
[0045] Figure 6 A schematic diagram of the structure of a host provided in an embodiment of the present application. DETAILED DESCRIPTION
[0046] The following describes the embodiments of the present application in conjunction with the accompanying drawings. The terms used in the implementation methods of the present application are only used to explain the specific embodiments of the present application and are not intended to limit the present application.
[0047] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0048] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, and this is merely a way of distinguishing the objects of the same attributes when describing them in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0049] Referring to Figure 1 , Figure 1 A flowchart of a model weight file distribution method provided by an embodiment of the present application. As shown in Figure 1 , the model weight file distribution method provided by an embodiment of the present application, applied to a host, can include steps S101-S103, which are described in detail as follows.
[0050] S101, monitoring the working state of a target container performing a model running task, the working state including a startup state, the target container being able to access a host directory of the host in the startup state.
[0051] In the embodiment of the present application, a container is a process isolation environment implemented by an operating system level virtualization technology, which can share a host kernel but has an independent file system view. Based on the container, file access permission isolation can be implemented, and the isolation mechanism of the container is based on Linux namespace isolation, supporting read-write permission control of a file directory. For a target container performing a model running task, the host can monitor its working state, such as a creation state, a startup state, a running state, and an offline state. Before the target container is created, the host directory of the host can be mounted. After the target container is created, an image file is first pulled from an image repository. Since the image file is not bound with a model weight file, the target container needs to load the target model weight file required by the target container, which requires the target container to be able to access the host directory in the startup state to load the target model weight file in the host directory.
[0052] In the embodiment of the present application, in order to facilitate sharing of a disk among containers running on the same host, the container is allowed to mount one or more host directories before being created. Multiple containers can mount the same host directory, and the host directory is persistent, that is, the host directory will not change when the container is destroyed or restarted. In the embodiment of the present application, the permission of the container to the host directory is read-only.
[0053] S102, in response to a first query request for a target model weight file sent by the target container in the startup state, querying a target file address of the target model weight file in the host directory.
[0054] In the embodiment of the present application, the target container in the startup state can send a query request (i.e., the first query request) for the target model weight file to the host. The host responds to the first query request and queries the file address (i.e., the target file address) of the target model file in the host directory.
[0055] It should be noted that the target container can query the target file address corresponding to the target model weight file from the host through IPC (Inter Process Communication). When the target container and the host interact through IPC, a semaphore, a message queue, an HTTP (HyperText Transfer Protocol) and the like can be used. Taking the HTTP as an example, the host can start an HTTP listener at a fixed port, and the container communicates with the host through the HTTP protocol.
[0056] In a possible implementation, the host can perform shared storage management on the model weight file through a unique file identifier. Referring to Figure 2 , Figure 2 Part of a flowchart of a model weight file distribution method provided by an embodiment of the present application. As shown in Figure 2 The model weight file distribution method provided by an embodiment of the present application, wherein the target file identifier in the first query request is used to uniquely identify the target model weight file. In this regard, the step S102 of "querying the target file address of the target model weight file in the host directory" can include steps S201 to S203, which will be described in detail below.
[0057] S201, invoke the weight file registry, the weight file registry records the registration information of the downloaded model weight file, and the registration information at least includes the file identifier of the model weight file and the file address in the host directory.
[0058] S202, query the weight file registry based on the target file identifier.
[0059] S203, if the target file identifier is queried in the weight file registry, the file address corresponding to the target file identifier is taken as the target file address.
[0060] In the embodiment of the present application, the host is configured with a weight file registry, and the weight file registry records the registration information of the model weight file downloaded by the host. The registration information at least includes the file identifier of the model weight file and the file address of the model weight file in the host directory. The file identifier corresponds to the model weight file one by one, and is used to uniquely identify the model weight file. For example, the file identifier corresponding to the model weight file can be generated in the form of UUID (Universally Unique Identifier), and the uniqueness is ensured through file SHA verification.
[0061] The host queries the file identifier in the weight file registry based on the target file identifier. If the target file identifier hits the file identifier in the weight file registry, it means that the target file identifier is queried in the weight file registry, and the file address corresponding to the target file identifier is used as the target file address, that is, the file address in the weight file registry that belongs to the same model weight file as the target file identifier is used as the target file address.
[0062] In a possible implementation, when the target model weight file is missing in the host directory, the host can pull the target model weight file from the weight file repository and update the weight file registry. Figure 3 , Figure 3 This is another partial flow chart of a method for distributing model weight files provided in an embodiment of the present application. Figure 3 As shown, an embodiment of the present application provides a method for distributing model weight files, wherein "querying the target file address of the target model weight file in the host directory" in step S102 can also include steps S301 to S303, and these steps are described in detail below.
[0063] S301: If the target file identifier is not found in the weight file registry, the target model weight file is pulled from the weight file warehouse based on the target file identifier.
[0064] S302, storing the target model weight file in the host directory, and using the file address of the target model weight file in the host directory as the target file address.
[0065] S303, recording the target file identifier and the target file address as registration information of the target model weight file into the weight file registration table.
[0066] In an embodiment of the present application, if the target file identifier does not hit the file identifier in the weight file registry, it means that the target file identifier is not found in the weight file registry, and the host pulls the target model weight file from the weight file warehouse based on the target file identifier. It should be noted that the model weight file in the weight file warehouse is verified content and is credible.
[0067] The host stores the target model weight file in the host directory, uses the file address of the target model file in the host directory as the target file address, and records the target file identifier and target file address as the registration information of the target model weight file in the weight file registry.
[0068] In a possible implementation, the host can perform security verification on the model weight file fed back by the weight file warehouse. In this regard, the registration information further contains a file check value of the model weight file, and the file check value corresponds to the file identifier of the model weight file in a one-to-one manner. See Figure 4 Figure 4 Another part of the flowchart of the model weight file distribution method provided by the embodiment of the present application is shown in FIG. 4. As shown in FIG. 4, the model weight file distribution method provided by the embodiment of the present application can include steps S401 to S403. Figure 4
[0069] S401, sending a second query request containing the target file identifier to the weight file warehouse, so that the weight file warehouse returns a candidate model weight file and a corresponding candidate file check value in response to the second query request.
[0070] S402, determining a target file check value corresponding to the target file identifier, and comparing the target file check value with the candidate file check value.
[0071] S403, if the target file check value is the same as the candidate file check value, regarding the candidate model weight file as the target model weight file.
[0072] Correspondingly, the step S303 of recording the target file identifier and the target file address as the registration information of the target model weight file in the weight file registration table includes:
[0073] S303, recording the target file identifier, the target file address and the target file check value as the registration information of the target model weight file in the weight file registration table.
[0074] In the embodiment of the present application, the host sends a query request (i.e., the second query request) containing the target file identifier to the weight file warehouse. The weight file warehouse queries the model weight file in the weight file warehouse based on the target file identifier in response to the second query request, and returns the queried model weight file (i.e., the candidate model weight file). At the same time, the weight file warehouse returns the corresponding file check value (i.e., the candidate file check value) along with the candidate model weight file.
[0075] The host determines the corresponding file checksum (i.e., the target file checksum) based on the target file identifier. For example, the model file repository and the host can simultaneously generate file checksums (including candidate file checksums and target file checksums) using MD5. To this end, the host can compare the target file checksum with the candidate file checksum. If the two are the same, it means that the candidate file checksum has passed the MD5-based file integrity verification. In this case, the candidate model weight file can be used as the target model weight file. Conversely, if the target file checksum is different from the candidate file checksum, it means that the candidate file checksum has not passed the MD5-based file integrity verification. In this case, the candidate model weight file can be discarded and the target model weight file can be obtained from other channels.
[0076] In one possible implementation, a counting mechanism can be introduced to manage the life cycle of the model weight file. To this end, the working status of the target container also includes the offline status, and the registration information of the model weight file in the weight file registry also includes the number of times the model weight file has been loaded. To this end, a distribution method for a model weight file provided in an embodiment of the present application also includes the following steps:
[0077] After returning the target file address to the target container, query the target load count of the target model weight file in the weight file registry, and add 1 to the target load count; respond to the release request for the target model weight file sent by the target container in the offline state, and reduce the target load count by 1.
[0078] In an embodiment of the present application, after returning the target file address to the target container, the host can query the number of times the target model weight file has been loaded in the weight file registry (i.e., the target load count), and add 1 to the target load count, which means that the number of times the target model weight file is being loaded by the container has increased by 1. After the target container loads the target weight file, it can enter the running state to execute the model running task until the model running task is completed and enters the offline state.
[0079] The host responds to the release request for the target model weight file sent by the target container in the offline state. At this time, the host can reduce the target load count by 1, which means that the number of times the target model weight file is being loaded by the container is reduced by 1.
[0080] In this way, the number of times the target model weight file is loaded by the container at different times can be tracked, thereby determining the life cycle of the target model file, such as whether it has not been loaded or how many containers are loading it at the same time.
[0081] On this basis, the target model weight file can be regularly cleaned up according to the target number of loads to free up disk space. In this regard, the distribution method of a model weight file provided in an embodiment of the present application further includes the following steps:
[0082] When the target load times meet the corresponding deletion conditions, the target model weight file is deleted in the host directory.
[0083] In an embodiment of the present application, if the target loading times are equal to 0, or the duration when the target loading times are equal to 0 reaches the upper limit, it can be determined that the deletion condition is met, and the target model weight file is deleted in the host directory.
[0084] S103: Return the target file address to the target container, so that the target container loads the target model weight file in the host directory based on the target file address.
[0085] In an embodiment of the present application, the host returns the target file address to the target container. The target container can load the target model weight file in the host directory based on the target file address and enter the running state to execute the model running task.
[0086] Through the above description, the embodiment of the present application provides a method for distributing model weight files, in which the container on the host can mount the same host directory, and the loading of the model weight file in the host directory is realized by querying the file address from the host. The same model weight file is only stored in one copy in the host, so that multiple containers can share the physical storage of the same model weight file. In addition, since the model weight file is stored on the host's disk, it can be reused without the need for secondary pulling, which can shorten the container startup time. The container time will be extended only when and only when the model weight file is pulled by the host for the first time. Since the container image is not bound to the model weight file, the host pulling the container image is the same as the ordinary image. In addition, the host can also introduce a counting mechanism to track the life cycle of the model weight file and automatically clean up expired files to free up disk space.
[0087] The above introduces a method for distributing model weight files provided in an embodiment of the present application. The following will introduce a device for executing the above-mentioned method for distributing model weight files.
[0088] See also Figure 5 , Figure 5 This is a schematic diagram of the structure of a distribution device for a model weight file provided in an embodiment of the present application. Figure 5 As shown, an embodiment of the present application provides a distribution device for a model weight file, comprising:
[0089] The container monitoring module 501 is used to monitor the working status of the target container that executes the model running task. The working status includes the startup state. When the target container is in the startup state, it can access the host directory of the host.
[0090] The file distribution module 502 is used to respond to the first query request for the target model weight file sent by the target container in the startup state, query the target file address of the target model weight file in the host directory; return the target file address to the target container, so that the target container loads the target model weight file in the host directory based on the target file address.
[0091] In one possible implementation, the first query request includes a target file identifier, which is used to uniquely identify the target model weight file. The file distribution module 502 for querying the target file address of the target model weight file in the host directory is specifically used to:
[0092] Retrieve the weight file registry, which records the registration information of the downloaded model weight file. The registration information at least includes the file identifier of the model weight file and its file address in the host directory; query the weight file registry based on the target file identifier; if the target file identifier is found in the weight file registry, use the file address corresponding to the target file identifier as the target file address.
[0093] In one possible implementation, the file distribution module 502 for querying the target file address of the target model weight file in the host directory is further configured to:
[0094] If the target file identifier is not found in the weight file registry, the target model weight file is pulled from the weight file warehouse based on the target file identifier; the target model weight file is stored in the host directory, and the file address of the target model weight file in the host directory is used as the target file address; the target file identifier and target file address are recorded as the registration information of the target model weight file in the weight file registry.
[0095] In a possible implementation, the registration information further includes a file checksum of the model weight file, and the file checksum corresponds one-to-one with the file identifier of the model weight file;
[0096] The file distribution module 502 is used to pull the target model weight file from the weight file warehouse based on the target file identifier, specifically for:
[0097] Sending a second query request including a target file identifier to the weight file repository, so that the weight file repository returns a candidate model weight file and its corresponding candidate file check value in response to the second query request; determining a target file check value corresponding to the target file identifier, and comparing the target file check value with the candidate file check value; if the target file check value is the same as the candidate file check value, using the candidate model weight file as the target model weight file;
[0098] Accordingly, the file distribution module 502 for recording the target file identifier and the target file address as registration information of the target model weight file in the weight file registration table is specifically used to:
[0099] The target file identifier, target file address and target file check value are recorded in the weight file registry as registration information of the target model weight file.
[0100] In a possible implementation, the working status further includes the offline status, the registration information further includes the number of times the model weight file has been loaded, and the file distribution module 502 is further used to:
[0101] After returning the target file address to the target container, query the target load count of the target model weight file in the weight file registry, and add 1 to the target load count; respond to the release request for the target model weight file sent by the target container in the offline state, and reduce the target load count by 1.
[0102] In a possible implementation, the file distribution module 502 is further configured to:
[0103] When the target load times meet the corresponding deletion conditions, the target model weight file is deleted in the host directory.
[0104] It should be noted that the detailed functions of each module in the embodiment of the present application can be found in the corresponding public part of the above-mentioned model weight file distribution method embodiment, and will not be repeated here.
[0105] The present application also provides a host. Figure 6 , Figure 6 A schematic diagram of the structure of a host provided in an embodiment of the present application. The host in the embodiment of the present application may include, but is not limited to, fixed terminals such as mobile phones, laptops, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Figure 6 The host shown is merely an example and should not limit the functions and scope of use of the embodiments of the present application.
[0106] like Figure 6 As shown, the host computer may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes based on programs stored in a read-only memory (ROM) 602 or programs loaded from a storage device 608 into a random access memory (RAM) 603. When the host computer is powered on, the RAM 603 also stores various programs and data required for host operation. The processing device 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0107] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a memory card, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the host to communicate with other devices wirelessly or by wire to exchange data. Figure 6 A host having various devices is shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have instead.
[0108] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on a host, the host implements any one of the model weight file distribution methods provided in the embodiments of the present application.
[0109] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by a host, the host can implement any model weight file distribution method provided in an embodiment of the present application.
[0110] It should also be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, in the drawings of the device embodiments provided in this application, the connection relationship between the modules indicates that there is a communication connection between them, which can be specifically implemented as one or more communication buses or signal lines.
[0111] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course can also be implemented by special hardware including application-specific integrated circuits, special CPUs, special memories, special components, etc. In general, all functions performed by computer programs can be easily implemented with corresponding hardware, and the specific hardware structures used to implement the same function can also be diverse, such as analog circuits, digital circuits or special circuits, etc. However, for the present application, software program implementation is a better implementation method in most cases. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer's floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., and includes a number of instructions to enable a computer device (which can be a personal computer, training equipment, or network equipment, etc.) to execute the methods described in each embodiment of the present application.
[0112] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0113] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, a computer, a training device or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website, a computer, a training device or a data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
Claims
1. A method for distributing a model weight file, characterized in that: The method for distributing the model weight file is applied to a host, on which a target container implemented by operating system-level virtualization technology and used to execute a model running task is run. The method for distributing the model weight file includes: Monitor the working status of the target container of the execution model running task, where the working status includes a startup state and an offline state, and the target container can access the host directory of the host in the startup state; Responding to a first query request for a target model weight file sent by the target container in the startup state, the first query request includes a target file identifier, the target file identifier is used to uniquely identify the target model weight file, and retrieving a weight file registry, the weight file registry records registration information of the downloaded model weight file, the registration information at least including a file identifier of the model weight file and its file address in the host directory, and the number of times the model weight file is loaded; Querying the weight file registry based on the target file identifier; If the target file identifier is found in the weight file registry, the file address corresponding to the target file identifier is used as the target file address; Returning the target file address to the target container, so that the target container loads the target model weight file in the host directory based on the target file address; After returning the target file address to the target container, querying the target load count of the target model weight file in the weight file registry, and adding 1 to the target load count; In response to a release request for the target model weight file sent by the target container in the offline state, the target loading count is reduced by 1.
2. The method for distributing model weight files according to claim 1, characterized in that: The querying of the target file address of the target model weight file in the host directory further includes: If the target file identifier is not found in the weight file registry, the target model weight file is pulled from the weight file warehouse based on the target file identifier; The target model weight file is stored in the host directory, and the file address of the target model weight file in the host directory is used as the target file address; The target file identifier and the target file address are recorded in the weight file registration table as registration information of the target model weight file.
3. The method for distributing model weight files according to claim 2, characterized in that: The registration information also includes a file check value of the model weight file, and the file check value corresponds one-to-one with the file identifier of the model weight file; Pulling the target model weight file from the weight file warehouse based on the target file identifier includes: Sending a second query request including the target file identifier to the weight file repository, so that the weight file repository returns a candidate model weight file and its corresponding candidate file check value in response to the second query request; Determine a target file check value corresponding to the target file identifier, and compare the target file check value with the candidate file check value; If the target file check value is the same as the candidate file check value, using the candidate model weight file as the target model weight file; Accordingly, recording the target file identifier and the target file address as registration information of the target model weight file in the weight file registration table includes: The target file identifier, the target file address and the target file check value are recorded in the weight file registration table as registration information of the target model weight file.
4. The method for distributing model weight files according to claim 1, wherein: The distribution method of the model weight file also includes: When the target loading times meets the corresponding deletion condition, the target model weight file is deleted in the host directory.
5. A distribution device for a model weight file, characterized in that: The distribution device of the model weight file is applied to a host, on which a target container implemented by operating system-level virtualization technology and used to execute the model running task is run, and the distribution device of the model weight file includes: A container monitoring module is used to monitor the working status and offline status of the target container that executes the model running task, wherein the working status includes a startup state, and the target container can access the host directory of the host in the startup state; A file distribution module is used to respond to a first query request for a target model weight file sent by the target container in the startup state, the first query request includes a target file identifier, the target file identifier is used to uniquely identify the target model weight file, retrieve a weight file registry, the weight file registry records registration information of the downloaded model weight file, the registration information at least includes the file identifier of the model weight file and its file address in the host directory, and the number of loads of the model weight file; query the weight file registry based on the target file identifier; if the target file identifier is queried in the weight file registry, use the file address corresponding to the target file identifier as the target file address; return the target file address to the target container, so that the target container loads the target model weight file in the host directory based on the target file address; after returning the target file address to the target container, query the target load count of the target model weight file in the weight file registry, and add 1 to the target load count; respond to a release request for the target model weight file sent by the target container in the offline state, and subtract 1 from the target load count.
6. A computer program product, characterized in that The method comprises computer-readable instructions, which, when executed on a host, enable the host to implement the method for distributing the model weight file according to any one of claims 1 to 4.
7. A host, characterized in that: comprising at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is configured to execute the computer program so that the host can implement the method for distributing the model weight file according to any one of claims 1 to 4.
8. A computer storage medium, characterized in that The storage medium carries one or more computer programs, and when the one or more computer programs are executed by a host, the host can implement the distribution method of the model weight file as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Model file calling system and method
CN110795398A
Model file loading method and device
CN111562949A
Model file management method and device, wearable equipment and storage medium
CN115756508A