A hierarchical federated learning method based on blockchain

By introducing blockchain technology and sidechain storage into federated learning, optimizing user association and resource allocation, the problem of model accuracy and system performance degradation caused by Non-IID data is solved, and efficient hierarchical federated learning is achieved.

CN115378961BActive Publication Date: 2025-02-18KELIAN CLOUD (XIAMEN) TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210980496.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-16
Publication Date
2025-02-18
Estimated Expiration
2042-08-16

AI Technical Summary

Technical Problem

In federated learning, the non-independent homogeneous distribution of user data (Non-IID) leads to large differences in model parameters, reducing model accuracy. At the same time, the traditional centralized learning model increases the burden on the cloud and network delay.

Method used

Adopting a hierarchical federated learning method based on blockchain, through the decentralized characteristics and side chain technology of blockchain, optimize user association and resource allocation, reduce consensus delay, and use side chain storage edge model in the aggregation stage to improve Model accuracy and system performance.

Benefits of technology

On the premise of ensuring model accuracy, the system delay and power consumption are effectively reduced, and the model accuracy and system performance degradation caused by Non-IID data are solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115378961B_ABST
    Figure CN115378961B_ABST
Patent Text Reader

Abstract

The present invention relates to a hierarchical federated learning method based on blockchain, and belongs to the field of mobile communication technology. Users are grouped based on the Non-IID degree of user data to improve the accuracy of federated learning and reduce the total network cost. First, the edge server is associated according to the Non-IID degree of user data to improve the accuracy of the edge model; secondly, by optimizing the user computing power and communication resource allocation, the task processing delay and energy consumption are reduced; then, a user association and resource allocation joint optimization algorithm ARO is proposed; finally, in the aggregation stage, the side chain technology is used to store the edge model of federated learning in the side chain block, thereby reducing the consensus delay. This solution effectively reduces system delay and power consumption while ensuring the accuracy of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of mobile communications and relates to a hierarchical federated learning method based on blockchain. Background Art

[0002] With the rapid development of communication and information technology, Internet of Things (IoT) applications have penetrated into every aspect of our daily lives. As the massive data of IoT grows, the demand for intelligence is gradually raised. Artificial Intelligence (AI) is considered to be a key technology for the future sixth generation of mobile communications (6G). By adopting artificial intelligence network management and operation solutions, the communication, computing and storage capabilities of the network can be effectively and fully integrated. The existing training model method is mainly based on a centralized learning mode, requiring network edge devices to transmit the collected data to a centralized server through a wireless channel. Wireless data transmission has a large traffic load and high privacy risks. At the same time, the centralized learning mode increases the burden on the cloud. The distributed learning mode is an effective way to solve this problem.

[0003] Federated Learning is a distributed learning model that trains high-quality models by exchanging model parameters instead of raw data, thereby ensuring low-traffic data transmission and user privacy data. Since learning is based on a single cloud server connection, which is limited, mobile edge computing needs to be introduced to carry the hierarchical federated learning model. Edge computing can distribute computing, communication, and storage resources to base stations close to users, thereby extending cloud computing to the edge of the network. Compared with traditional cloud computing, edge computing has the advantages of low latency, low energy consumption, and high quality. However, federated global aggregation depends on a central node, usually a cloud server. In edge computing networks, in order to reduce latency and cloud task load, it is a major challenge to not rely on cloud server aggregation.

[0004] Blockchain is considered to be an effective way to solve this problem. In recent years, blockchain technology has been widely studied in academia and industry. As the research on blockchain technology continues to deepen, people have found that it is very suitable for edge computing systems. In the process of hierarchical federated learning, the original data of the user cannot be known, so it is impossible to determine whether the data between users obeys independent and identical distribution (IID). Training the model when the user data is non-independent and identically distributed (Non-IID) leads to large differences in model parameters, which leads to the problem of reduced model accuracy. The more users participate in federated learning, the wider the applicability of the model. Therefore, it is particularly important to formulate an edge aggregation method to ensure model accuracy without excluding users with large differences from the global model. Users have limited computing and communication resources. How to allocate resources to reduce the latency and energy consumption of the communication network is a problem worth optimizing.

[0005] Based on the above problems, the present invention designs a cloud-edge network architecture diagram based on blockchain. Under this architecture, the resource allocation scheme will determine the connection relationship between the user and the edge server, the computing frequency and the transmission power. In addition, the sidechain technology stores a large number of edge model update transactions in the sidechain block to increase the throughput of the blockchain network. Summary of the invention

[0006] In view of this, the purpose of the present invention is to provide a hierarchical federated learning method based on blockchain to solve the problems of reduced model accuracy and system performance caused by Non-IID data.

[0007] In order to achieve the above object, the present invention provides the following technical solutions:

[0008] A hierarchical federated learning method based on blockchain, the method comprising the following steps:

[0009] S1: Hierarchical federated learning based on blockchain;

[0010] S2: Non-IID degree estimation of user data;

[0011] S3: Optimize user association and resource allocation;

[0012] S4: Reduce consensus latency based on blockchain sidechain.

[0013] Optionally, in S1, a three-layer network model based on blockchain is established:

[0014] 1) User layer, including smartphones, wearable devices, personal computers and smart terminals;

[0015] 2) Edge service layer, including distributed edge servers;

[0016] 3) Central cloud layer, including cloud servers and enterprises and institutions that initiate task requests;

[0017] Edge servers are deployed at base stations to provide computing services to users;

[0018] The user layer consists of terminal smart devices with local training data;

[0019] The terminal equipment has computing power and communication capabilities, and reduces the total system latency and energy consumption by optimizing computing power and power allocation;

[0020] The cloud server has the computing power to coordinate and allocate tasks; the edge cloud collaborative network jointly maintains the blockchain;

[0021] The cloud server publishes smart contracts related to task information, and the edge server executes the smart contracts.

[0022] Optionally, in S2, for users n, d n,l is the number of samples of category l in the user data, D n is the total number of samples in the user's local data set; q n (l) = d n,l / D n It represents the proportion of the number of samples of task category l in the total number of samples. When the data is IID, q(l) = 1 / L, that is, the data set has all task categories and the number of samples is equal. The degree of Non-IID of user n's data is expressed as:

[0023]

[0024] Optionally, in S3, the Non-IID degree of users in the same set, task processing delay and task processing energy consumption are minimized. For user n, the calculation delay is Upload delay is Calculate the energy consumption as The energy consumption for uploading is The optimization goal is to minimize the total network cost, as shown below:

[0025]

[0026] Where N is the set of all users, N m is the set of users within the coverage area of ​​edge server m, x n,m Represents the connection relationship between user n and edge server m; α1, α2, and α3 are weights, which are set based on the specific needs of different application scenarios.

[0027] Optionally, in S4, the main chain block is used to store the global model and the operation process related to the aggregated global model, and the side chain block is used to store the edge model.

[0028] The beneficial effect of the present invention is that the mode of federated learning without interacting with original data overcomes the problems of large wireless transmission load and high privacy risk brought by centralized learning. However, traditional federated learning relies on a single central server, which increases the computing load for the cloud and increases the network latency. Hierarchical federated learning implemented through mobile edge computing can achieve distributed aggregation and reduce network latency. Blockchain can be deeply integrated with hierarchical federated learning due to its tamper-proof and decentralized characteristics, and the high latency problem brought about by the consensus process follows. At the same time, due to the non-independent identically distributed (Non-IID) of user data, the accuracy of the global model of federated learning will decrease. In order to solve the above problems, the present invention groups users based on the degree of Non-IID of user data to improve the accuracy of federated learning and reduce the total network cost. First, the edge server is associated according to the Non-IID degree of user data to improve the accuracy of the edge model; secondly, the task processing delay and energy consumption are reduced by optimizing the user computing power and communication resource allocation; then, a user association and resource allocation joint optimization algorithm (ARO) is proposed; finally, in the aggregation stage, the side chain technology is used to store the edge model of federated learning in the side chain block, thereby reducing the consensus delay. This solution effectively reduces system delay and power consumption while ensuring the accuracy of the model.

[0029] Other advantages, objectives and features of the present invention will be described in the following description to some extent, and to some extent, will be obvious to those skilled in the art based on the following examination and study, or can be taught from the practice of the present invention. The objectives and other advantages of the present invention can be realized and obtained through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention will be described in detail below in conjunction with the accompanying drawings, wherein:

[0031] Figure 1 This is a diagram of the cloud-edge network architecture based on blockchain;

[0032] Figure 2 Edge model update and global aggregation process for federated learning;

[0033] Figure 3 It is a schematic diagram of the ARO algorithm;

[0034] Figure 4 Execute the flowchart for the ARO algorithm for hierarchical federated learning based on blockchain. DETAILED DESCRIPTION

[0035] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the illustrations provided in the following embodiments only illustrate the basic concept of the present invention in a schematic manner, and the following embodiments and features in the embodiments can be combined with each other without conflict.

[0036] Among them, the drawings are only used for illustrative explanations, and they only represent schematic diagrams rather than actual pictures, and should not be understood as limitations on the present invention. In order to better illustrate the embodiments of the present invention, some parts of the drawings may be omitted, enlarged or reduced, and do not represent the size of actual products. For those skilled in the art, it is understandable that some well-known structures and their descriptions in the drawings may be omitted.

[0037] The same or similar numbers in the drawings of the embodiments of the present invention correspond to the same or similar parts; in the description of the present invention, it should be understood that if the terms "upper", "lower", "left", "right", "front", "rear", etc. indicate the orientation or position relationship, they are based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation. Therefore, the terms describing the position relationship in the drawings are only used for illustrative purposes and cannot be understood as limiting the present invention. For ordinary technicians in this field, the specific meanings of the above terms can be understood according to specific circumstances.

[0038] Figure 1 FIG. 1 shows a possible structural diagram of a communication system involved in an embodiment of the present invention. Figure 1 As shown in the figure, the network considers four layers of networks, including the central cloud layer, the intelligent consensus layer, the edge layer, and the user layer. The central cloud layer includes cloud servers and task requesters from different industries, such as enterprises and institutions. The cloud server provides the requester with an API for publishing tasks, and then generates a smart contract for the corresponding task and publishes it on the blockchain. The intelligent consensus layer is a blockchain composed of the main chain and the side chain, which is jointly maintained by the edge server and the cloud server to verify and record model updates. The edge layer is composed of edge servers that are close to users and have strong computing power. The user layer is composed of smart devices that mostly hold Non-IID data and communicate with the edge server through wireless links.

[0039] 1. Federated Learning Process

[0040] Federated learning is accomplished through cloud-edge-device collaboration and is divided into the following steps:

[0041] (1) Initialization model: After the requester publishes a task to the cloud server through the API, the cloud server generates a smart contract based on the task requirements and publishes it to the blockchain. The smart contract contains information such as the initial model, aggregation rules, and stop conditions.

[0042] (2) Local model update: The edge server obtains the global model from the blockchain ledger and broadcasts it to users within the coverage area. Users update the local model parameters based on local data using the gradient descent method:

[0043]

[0044] in, is the local model parameter of user n in the kth local iteration in the Tth global iteration. is the mean square error loss function of category l, q n (l) is the category proportion. X is the training input data sample, and Y is the true label sample.

[0045] (3) Edge model aggregation: The edge server aggregates the edge model based on the collected local model parameters:

[0046]

[0047] Among them, x n,m Indicates that the nth user is connected to the mth edge server, represents the set of users connected to edge server m, Indicates the number of the set,edges after aggregation and uploads the updated edge model to the blockchain.

[0048] (4) Global model aggregation: The elected leader is responsible for global aggregation, which aggregates the global model based on the updated edge model in the blockchain ledger:

[0049]

[0050] (5) Stop iteration: When the convergence conditions of the federated learning task are not met, it will return to step (2) and continue iterating training. Otherwise, the cloud server obtains the final model and submits it to the task requester.

[0051] 2. Blockchain structure

[0052] The intelligent consensus layer is divided into the main chain and the side chain, where the main chain uses the Raft consensus algorithm and the side chain uses the HotStuff consensus algorithm. The main chain block mainly stores the global model and the operation process related to it. In the global aggregation process of traditional federated learning, all models need to be collected by the central server to aggregate the global model. In the present invention, before the next round of model training, all edge nodes elect a Leader based on the Raft consensus, and then the Leader locks the assets on the main chain after passing the Simple Payment Verification (SPV) proof, and all subsequent transactions will be written into the side chain block. The side chain block mainly stores the edge model, using the pipelined HotStuff algorithm, which mainly includes four stages: prepare, pre-commit, commit, and decide. The edge node initiates an update consensus request according to the edge model time. All edge nodes can process the four stages in the HotStuff algorithm in parallel. After the consensus is successful, the edge node packages the edge model into blocks and writes it to the blockchain. After all edge models are written into the blockchain, the Leader extracts the model into the cache memory, and locks the assets on the side chain again through SPV proof, and aggregates the global model and writes it into the main chain block. This process is repeated. The edge model update and global aggregation consensus process is as follows: Figure 2 shown.

[0053] 3. User association strategy

[0054] Before allocating user resources, the connection relationship between the user and the edge server needs to be determined. In order to reduce the impact of Non-IID data, the edge server needs to optimize the selection of associated users to minimize the degree of Non-IID. The model is as follows:

[0055]

[0056] st

[0057] x n,m ∈{0, 1}

[0058] This problem can be expressed as an assignment problem in a nonstandard form. After being converted into a standard form, a polynomial solution to the problem can be obtained based on the Kuhn-Munkres (KM) algorithm.

[0059] 4. User computing power and transmission power allocation

[0060] The calculation delay of the local task of user n can be obtained as follows:

[0061]

[0062] The number of local calculations required to achieve model accuracy ∈. C n The number of CPU cycles required to train a sample for user n, D n is the total number of local samples of user n, f n Calculates the CPU frequency for user n.

[0063] The computational energy consumption of local model training for user n can be obtained as follows:

[0064]

[0065] Where γ is the processing D n The effective switching capacitance.

[0066] Based on Shannon's formula, the latency and energy consumption of user n uploading the local model are as follows:

[0067]

[0068] M is the model size, p n is the transmission power of user n, g n is the channel gain of user n, N0 is the noise power, and B is the transmission bandwidth.

[0069] During the local model training process, due to the different computing power and transmission power of smart devices, the total time to complete model training and uploading is also different. The edge server needs to wait for all users to upload the model before aggregating the edge model, so user n can dynamically adjust f n and p n , so that the task processing delay and energy consumption are minimized. To minimize the processing delay and total energy consumption of all tasks, the objective function can be expressed as:

[0070]

[0071] The computing power allocated by user n cannot exceed the maximum computing power that the CPU can provide, so constraint C1 is:

[0072]

[0073] The transmission power of user n cannot exceed its maximum transmission power, so constraint C2 is:

[0074]

[0075] The received signal that the edge server can demodulate must meet the signal-to-noise ratio threshold s, so constraint C3 is:

[0076]

[0077] Since Q2(f n , pn ) is a positive definite matrix, and the optimization problem is a convex optimization problem, which can be transformed into an unconstrained optimization problem according to the Lagrange multiplier method and the optimal solution can be obtained based on the KKT condition. The present invention combines user association and proposes an ARO algorithm, such as Figure 3 shown.

[0078] 5. System Process

[0079] Figure 4 The following is a flowchart of the ARO algorithm execution based on blockchain-based hierarchical federated learning. The specific steps are as follows:

[0080] Step 501: Algorithm initialization;

[0081] Step 502: The requester publishes the task to the cloud server;

[0082] Step 503: The edge and cloud register as blockchain nodes;

[0083] Step 504: Generate a genesis block;

[0084] Step 505: The cloud server publishes the smart contract and initializes the global model;

[0085] Step 506: The edge server obtains the global model and sends it to the user;

[0086] Steps 507-509: User association;

[0087] Step 507: construct matching weights between users and edges;

[0088] Step 508: Execute KM algorithm;

[0089] Step 509: If the optimal match is achieved, execute step 510, otherwise repeat step 507;

[0090] Steps 510-512: User computing and communication resource allocation;

[0091] Step 510: The user allocates computing and communication resources for training and uploading models;

[0092] Step 511: local training;

[0093] Step 512: If the specified number of training rounds t is met, execute step 513, otherwise repeat step 510;

[0094] Step 513: Upload the model to the edge server;

[0095] Step 514: All edge servers aggregate edge models;

[0096] Steps 515-518: Elect Leader;

[0097] Step 515: The candidate willing to become the leader triggers the leader election through heartbeat;

[0098] Step 516: All Followers receive the Candidate's voting request;

[0099] Step 517: If the number of consensus nodes that agree that the candidate should become the leader exceeds half, then execute step 518, otherwise repeat step 515;

[0100] Step 518: The candidate becomes a leader and locks assets through the main chain SPV certificate;

[0101] Steps 519-522: edge model update verification;

[0102] Step 519: The edge nodes initiate update verification transactions in sequence;

[0103] Step 520: HotStuff consensus;

[0104] Step 521: If all edge models pass the verification, execute step 522, otherwise repeat step 519;

[0105] Step 522: Leader extracts all edge models;

[0106] Step 523: Leader passes the sidechain SPV proof;

[0107] Step 524: Leader aggregates the global model and packages it into the main chain block;

[0108] Step 525: If the global model accuracy meets the requirement, execute step 526, otherwise repeat step 506;

[0109] Step 526: The cloud server obtains the global model;

[0110] Step 527: Submit the model to the requester;

[0111] Step 528: The algorithm ends.

[0112] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution, which should be included in the scope of the claims of the present invention.

Claims

1. A hierarchical federated learning method based on blockchain, characterized by: The method comprises the following steps: S1: Hierarchical federated learning based on blockchain; In S1, a three-layer network model based on blockchain is established: 1) User layer, including smartphones, wearable devices, personal computers and smart terminals; 2) Edge service layer, including distributed edge servers; 3) Central cloud layer, including cloud servers and enterprises and institutions that initiate task requests; Edge servers are deployed at base stations to provide computing services to users; The user layer consists of terminal smart devices with local training data; The terminal equipment has computing power and communication capabilities, and reduces the total system latency and energy consumption by optimizing computing power and power allocation; The cloud server has the computing power to coordinate and allocate tasks; the edge cloud collaborative network jointly maintains the blockchain; The cloud server publishes smart contracts related to task information, and the edge server executes the smart contracts; S2: Non-IID degree estimation of user data; In S2, for user n, d n,l is the number of samples of category 1 in the user data, D n is the total number of samples in the user's local data set; q n (l) = d n,l / D n It indicates the proportion of samples of task category 1 in the total number of samples. When the data is IID, q(l) = 1 / L, that is, the data set has all task categories and the number of samples is equal. The degree of Non-IID of user n's data is expressed as: S3: Optimize user association and resource allocation; In S3, the connection relationship between the user and the edge server is determined before user resource allocation. The edge server optimizes the selection of associated users to minimize their Non-IID degree. To optimize user association, the user allocates computing power and transmission power through an optimization algorithm. The goal of the optimization algorithm is to minimize the total network cost, including the Non-IID degree of users in the same set, task processing delay, and task processing energy consumption. For user n, the calculation delay is Upload delay is Calculate the energy consumption as The energy consumption for uploading is The optimization objectives are as follows: in For all users, is the set of users within the coverage area of ​​edge server m, x n,m represents the connection relationship between user n and edge server m; α1, α2, α3 are weights, which are set based on the specific needs of different application scenarios; S4: Reduce consensus latency based on blockchain sidechain; In S4, the main chain block is used to store the global model and the operation process related to the aggregated global model, and the side chain block is used to store the edge model.

Citation Information

Patent Citations

  • Method for accelerating federated learning for data and equipment heterogeneity under edge computing

    CN113206887A

  • Federal learning method based on fog calculation

    CN113379066A