Federal learning optimization method of non-main-chain fragment architecture based on clustering
By adopting a cluster-based main chain-free sharding architecture and federated learning state tree in federated learning, the problem of combining blockchain with federated learning is solved, and a more efficient and decentralized federated learning system is achieved.
Patent Information
- Application Number
- CN202411893184.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-11
Smart Images

Figure CN119808894A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of federated learning technology, and in particular to a federated learning optimization method based on a clustering-based mainchain-free sharding architecture. Background Art
[0002] Federated Learning (FL) is a distributed machine learning technology that aims to meet privacy requirements by optimizing models rather than collecting raw data from decentralized clients. In addition, many studies have integrated blockchain technology into federated learning, allowing local models to be part of blockchain transactions. With the incentive and reliability characteristics of blockchain, federated learning can overcome the two main challenges faced by traditional federated learning: single point failure and incentive issues for client participation.
[0003] However, combining blockchain with federated learning also introduces new problems, namely low throughput and high latency, which have a negative impact on the stability and efficiency of the system. Existing methods are mainly divided into two types: traditional single-chain structure and sharding structure. Based on the traditional single-chain structure, Miao et al. designed a privacy-preserving Byzantine fault-tolerant federated learning scheme based on blockchain, which mitigates the influence of central servers and malicious clients. Wang et al. designed an incentive mechanism to help model owners allocate appropriate rewards to each client for training and mining, thereby determining the allocation of computing power. Shayan et al. proposed Biscotti, a fully decentralized peer-to-peer (P2P) multi-party machine learning (ML) method. This method uses blockchain technology and cryptographic technology to promote the privacy-preserving machine learning process between participating clients. Feng et al. proposed a blockchain-based asynchronous federated learning (BAFL) framework to ensure the security and efficiency required for federated learning. However, in the above technical methods, the blockchain must wait for all models to complete transmission and then aggregate them into a new global model. The process of waiting for model transmission and aggregation becomes a performance bottleneck. To solve these problems, existing technologies have introduced sharding technology. Blockchain sharding is a method to improve the scalability of blockchain networks by supporting concurrent transaction processing. Elastico is considered to be the first sharded blockchain system, in which transactions are assigned to different shards for parallel processing. Despite this, each shard still maintains the entire state ledger. In order to optimize storage, OmniLedger proposed state sharding, assigning each shard to be responsible for storing and processing part of the ledger data. Monoxide] implemented a sharded blockchain based on account balances, in which a novel relay transaction mechanism was used to process transactions across shards. Other advanced state sharding protocols, such as Pyramid and BrokerChain, have also been developed. However, previous studies have focused on the throughput of transaction transfers and are not applicable to federated learning scenarios.
[0004] Existing studies have proposed a two-layer architecture consisting of a main chain and multiple shards. Yuan et al. proposed a two-layer blockchain-driven federated learning (FL) framework called ChainsFL. The framework consists of multiple shard networks (first layer) and a main chain (second layer). In the first layer, the size of each shard is limited to facilitate small-scale information exchange. In the second layer, each shard can update and share models in parallel and asynchronously. Similarly, Feng et al. proposed a two-layer architecture consisting of two blockchains: a local model update chain and a global model update chain. Lin et al. proposed an adaptive sharding mechanism using deep reinforcement learning, which automatically selects sharding parameters based on a two-layer blockchain. In this type of technical approach, shards are responsible for collecting local models from clients and aggregating them into shard models. The main chain then collects these shard models to generate a new global model. The use of shards enables blockchains to process transactions in parallel, thereby increasing throughput and reducing latency. However, this approach introduces new communication bottlenecks due to the interaction required for model transmission between the main chain and the shards. The client must wait for the main chain to complete the model transfer and generate a new global model, which inevitably increases the client's waiting time. Summary of the invention
[0005] The purpose of the present invention is to provide a federated learning optimization method for a clustering-based main chain-free sharding architecture. A clustering algorithm is used to allocate clients to different shards so that each shard generates a global model independently. At the same time, in order to solve the client state management problem in the absence of a main chain, a federated learning state tree (FLS-Tree) is proposed to record the client state.
[0006] The purpose of the present invention can be achieved by the following technical solutions:
[0007] A clustering-based federated learning optimization method for a mainchain-free sharding architecture. The method uses a clustering algorithm to assign clients to different shards, so that each shard independently generates a global model, and uses a federated learning state tree to record client states, wherein the federated learning tree uses blocks for data recording and retrieval.
[0008] The method comprises the following steps:
[0009] Sharding phase: Collect the models of clients participating in the federated learning task and cluster them. Create shards based on the clusters. Each shard is responsible for interacting with clients in a cluster. A federated learning tree is created for each shard to manage the client status within the shard.
[0010] Client training phase: In each shard, each client obtains the global model from the committee node, updates the local model using local data, and sends the updated local model parameters to the committee node;
[0011] Global model generation phase: In each shard, the committee node verifies the received local model parameters and generates a new global model for the next round of client training.
[0012] The sharding phase includes the following steps:
[0013] Gradient reception and clustering: After each federated learning task is released, the federated learning models of the clients participating in the task are collected, and the model parameters are clustered using a clustering algorithm to obtain multiple different clusters; based on the clusters, corresponding shards are created;
[0014] Federated learning tree creation: When a cluster is generated, a corresponding federated learning tree is created to assist in managing the status of clients within the cluster, and the committee node of the shard to which the cluster belongs is responsible for maintaining and updating the federated learning tree.
[0015] The client training phase includes the following steps:
[0016] Initial model request: At the beginning of each training round, client i sends a request to the committee node to obtain the latest global model w t , the global model w t Updated from the global model generation phase of the previous round, where i = 1, 2, ... N, and N is the number of clients in the corresponding shard;
[0017] Local model update: Client i receives the global model w t After that, the model is optimized using its local data to generate a new local model. And get model parameter information
[0018] Gradient upload: Client i uploads the updated model parameter information Sent to the committee node of the corresponding shard in the form of a transaction, waiting for the next round of global model w t+1 to continue training.
[0019] The local model updating process adopts the gradient descent method, and the model parameter information obtained is the gradient information.
[0020] The global model generation stage includes the following steps:
[0021] Gradient collection and verification: In each block cycle, the committee node collects all received model parameter information and verifies its legitimacy. The verified model parameter information is stored in the transaction pool for further processing.
[0022] Global model generation and synchronization: The committee node selects model parameter information from the transaction pool and uses the model parameter information to generate a new global model. The generated new global model and model parameter information are packaged into candidate blocks, and PBFT is applied to synchronize the training results of this round. After the synchronization is completed, the committee node broadcasts the latest block information to the client that needs to update the model.
[0023] The FedAvg algorithm is used to generate a new global model using the model parameter information.
[0024] The block includes a block header and a block body, wherein the block header is the metadata part of the block, which contains key information describing the block characteristics and linking the previous and next blocks, and is used to ensure the integrity and consistency of the blockchain; the block body stores actual transactions and model update information.
[0025] The block header includes:
[0026] Federated learning state tree root: The federated learning state tree root is the root hash value of the federated learning state tree in the entire block, which records the state information of all clients in the block; when the state is updated or queried, the root hash value is used to verify the integrity of the data;
[0027] State root: The state root is a root hash value stored in the federated learning state tree node in the MPT data structure, which is used to record and verify the state information of all shards in the current block;
[0028] Federated learning Merkle root: The federated learning Merkle root records the Merkle tree root hash values of all local model transactions during the federated learning process, and is used to verify the integrity and consistency of client transactions;
[0029] The block body comprises:
[0030] Local model transactions: The local model transactions are model parameter information uploaded by the client, which records the update results of each client on its local model in a specific training round. The local model transactions are packaged into blocks and become the basic data for global model generation;
[0031] Global model: The global model stores a new global model generated by aggregating each shard.
[0032] The node of the federated learning state tree stores a shard ID, a state root, and a global model, wherein the shard ID is a field used to identify the shard position to which the node of the federated learning state tree belongs.
[0033] Compared with the prior art, the present invention has the following beneficial effects:
[0034] 1. Propose a blockchain sharding architecture without a main chain:
[0035] Communication burden without dynamic sharding: Traditional blockchain sharding architecture relies on the main chain to complete the aggregation of the global model. This design introduces additional communication overhead, especially when cross-shard communication is required, which will lead to higher latency and bottlenecks. In the present invention, since the sharding structure is fixed after the initial clustering, frequent cross-shard communication and state migration are avoided. Traditional sharding architecture requires frequent cross-shard communication to synchronize client status, which increases bandwidth consumption and system latency. The present invention eliminates this communication bottleneck by fixing the sharding structure, thereby significantly reducing the system's network overhead.
[0036] Parallel processing: Each shard independently generates and manages the global model within a fixed set of clients. This parallel processing capability greatly improves the throughput of the system. Compared with the traditional dynamic sharding structure, the client does not have to wait for shard adjustment and migration, thus completing local training faster and participating in the update of the global model.
[0037] Reduce model synchronization waiting time: Since the clients within a shard are relatively stable, the present invention avoids frequent cross-shard model synchronization during each iteration. This reduces the delay of model updates and further improves the efficiency and throughput of the system.
[0038] Decentralization enhancement: Since the sharding structure no longer relies on centralized main chain coordination, by removing the main chain, the present invention achieves complete decentralization, and each shard can independently manage and process its own model updates, reducing the risk of the main chain becoming a performance bottleneck or single point of failure in the traditional architecture. Each shard runs independently and implements global model updates without relying on centralized coordination, which makes the entire system more flexible and robust.
[0039] 2. Introduce clustering-based sharding mechanism:
[0040] Sharding optimization: The present invention adopts a clustering algorithm to perform clustering according to the model gradient of the client and initialize the sharding system. In this way, it is possible to adapt to the data distribution of different clients and ensure that clients in the same shard have similar data characteristics. This makes the global model generated in the shard more consistent with the respective data characteristics, thereby improving the performance of the model on non-IID (non-independent and identically distributed) data. This sharding mechanism not only improves the efficiency of model training, but also enhances the adaptability and generalization ability of the system in heterogeneous data environments. Compared with the traditional single global model, the global model independently generated in multiple shards has higher accuracy in a data heterogeneous environment.
[0041] 3. Design of Federated Learning State Tree (FLS-Tree):
[0042] Efficient client state management: FLS-Tree is a new data structure used to record and manage client states, including model gradients and sharding information. By leveraging the characteristics of Merkle Patricia Tree (MPT), FLS-Tree can efficiently store and retrieve client states. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 is a flow chart of the method of the present invention;
[0044] Figure 2 Schematic diagram of the federated learning state tree structure of the present invention. DETAILED DESCRIPTION
[0045] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0046] This embodiment provides a federated learning optimization method for a clustering-based mainchain-free sharding architecture. The method uses a clustering algorithm to distribute clients to different shards, so that each shard independently generates a global model, and uses a federated learning state tree to record client status.
[0047] like Figure 1 As shown, the method comprises the following steps:
[0048] (1) Sharding stage: The models of the clients participating in the federated learning task are collected and clustered, and shards are created based on the clusters. Each shard is responsible for interacting with the clients within a cluster, and a federated learning tree is created for each shard to manage the client status within the shard.
[0049] The sharding phase includes the following steps:
[0050] (11) Gradient reception and clustering: After each federated learning task is released, the federated learning models of the clients participating in the task are collected, and the model parameters are clustered using a clustering algorithm to obtain multiple different clusters; based on the clusters, corresponding shards are created;
[0051] (12) Federated learning tree creation: When a cluster is generated, a corresponding federated learning tree is created to assist in managing the status of clients within the cluster, and the committee node of the shard to which the cluster belongs is responsible for maintaining and updating the federated learning tree.
[0052] The structure of the federated learning state tree is as follows Figure 2 As shown, the node stores the shard ID, state root and global model, and uses blocks to record and retrieve data. The block includes a block header and a block body.
[0053] 1.Shard ID
[0054] Definition: Shard ID is a field used to identify the shard location to which an FLS-Tree node belongs.
[0055] Function: This field indicates the shard that the FLS-Tree node is located in when it is created. Through the Shard ID, you can clearly know which shard a certain status information belongs to.
[0056] 2. State Root
[0057] Definition: State Root is the Merkle Patricia Tree (MPT) root hash value stored in the FLS-Tree node.
[0058] Function: State Root is used to maintain the hash value of the state information of all clients in the current shard. During the state management process, State Root can be used to quickly verify the integrity and consistency of the client state.
[0059] 3.Global Model
[0060] Definition: Global Model is used to record the latest global model.
[0061] Function: This field records the latest global model information of the client within a specific block period.
[0062] 4.Block Header
[0063] Definition: Block Header is the metadata part of a block, which contains key information describing the characteristics of the block and linking the previous and next blocks.
[0064] Function: Block Header is mainly used to ensure the integrity and consistency of the blockchain, and usually includes the following sub-items:
[0065] 41. FLS-Tree Root (Federated Learning State Tree Root): This is the root hash value of the FLS-Tree in the entire block, which records the state information of all clients in the block. When updating or querying the state, this root hash value can be used to verify the integrity of the data.
[0066] 42.State Root: This is the root hash value of a Merkle Patricia Tree (MPT), which is used to record and verify the status information of all shards in the current block. It ensures that the status of each shard at the time of block generation can be tracked and verified securely and efficiently.
[0067] 43.FL Merkle Root (Federated Learning Merkle Root): This field records the Merkle tree root hash value of all local model transactions in the federated learning process, which is used to verify the integrity and consistency of client transactions.
[0068] 5. Block Body
[0069] Definition: Block Body is the part of the block that stores actual transactions and model update information.
[0070] Function: Block Body contains all local model transactions (Local Model TXs) and the generated global model (Global Model) in the block. This information is generated by the client model data collected and aggregated by each shard. It includes:
[0071] 51. Local Model TXs: These are model gradient information uploaded by the client, recording the update results of each client on its local model in a specific training round. These transactions are packaged into blocks and become the basic data for global model generation.
[0072] 52. Global Model: This field stores the new global model generated by shard aggregation. These global models are generated by collecting and aggregating the model updates of all clients by each shard node within a specific block cycle, representing the latest model status of the current federated learning task.
[0073] 6. Merkle Patricia Tree (MPT)
[0074] Definition: Merkle Patricia Tree is a data structure for efficiently recording and retrieving state information.
[0075] Function: MPT is used to store and verify the hash value of client status and model transactions in the block. Through this tree structure, the status of a specific client or transaction can be quickly located and verified, thereby ensuring the integrity and security of the data recorded in the block.
[0076] In FLS-Tree, SHA-256 is used to calculate the hash value of each node to generate and maintain the structure of the entire tree. Through SHA-256, it is possible to verify whether the client's state is correctly stored and updated at any time, and ensure data consistency during the state migration process between shards.
[0077] (2) Client training phase: In each shard, each client obtains the global model from the committee node, updates the local model using local data, and sends the updated local model parameters to the committee node.
[0078] The client training phase includes the following steps:
[0079] (21) Initial model request: At the beginning of each training round, client i sends a request to the committee node to obtain the latest global model w t , the global model w t Updated from the global model generation phase of the previous round, where i = 1, 2, ... N, and N is the number of clients in the corresponding shard;
[0080] (22) Local model update: Client i receives the global model w t After that, the model is optimized using its local data to generate a new local model. And get model parameter information
[0081] (23) Gradient upload: Client i uploads the updated model parameter information Sent to the committee node of the corresponding shard in the form of a transaction, waiting for the next round of global model w t+1 to continue training.
[0082] In this embodiment, the local model updating process adopts the gradient descent method, and the obtained model parameter information is the gradient information.
[0083] (3) Global model generation phase: In each shard, the committee node verifies the received local model parameters and generates a new global model for the next round of client training.
[0084] The global model generation phase includes the following steps:
[0085] (31) Gradient collection and verification: In each block cycle, the committee node collects all received model parameter information and verifies its legitimacy to prevent possible malicious attacks (such as poisoning attacks). The verified model parameter information is stored in the transaction pool and awaits further processing.
[0086] (32) Global model generation and synchronization: The committee node selects model parameter information from the transaction pool and uses the model parameter information to generate a new global model (such as using the FedAvg algorithm). The generated new global model and model parameter information are packaged into candidate blocks, and PBFT (Practical Byzantine Fault Tolerance) is used to synchronize the training results of this round. After the synchronization is completed, the committee node broadcasts the latest block information to the clients that need to update the model.
[0087] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning, or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. A clustering-based federated learning optimization method for a mainchain-free sharding architecture, characterized in that: This method uses a clustering algorithm to distribute clients to different shards, so that each shard generates a global model independently, and uses a federated learning state tree to record client status, where the federated learning tree uses blocks to record and retrieve data.
2. According to claim 1, a clustering-based federated learning optimization method for a mainchain-free sharding architecture, characterized in that: The method comprises the following steps: Sharding phase: Collect the models of clients participating in the federated learning task and cluster them. Create shards based on the clusters. Each shard is responsible for interacting with clients in a cluster. A federated learning tree is created for each shard to manage the client status within the shard. Client training phase: In each shard, each client obtains the global model from the committee node, updates the local model using local data, and sends the updated local model parameters to the committee node; Global model generation phase: In each shard, the committee node verifies the received local model parameters and generates a new global model for the next round of client training.
3. According to claim 2, a clustering-based federated learning optimization method for a mainchain-free sharding architecture is characterized in that: The sharding phase includes the following steps: Gradient reception and clustering: After each federated learning task is released, the federated learning models of the clients participating in the task are collected, and the model parameters are clustered using a clustering algorithm to obtain multiple different clusters; based on the clusters, corresponding shards are created; Federated learning tree creation: When a cluster is generated, a corresponding federated learning tree is created to assist in managing the status of clients within the cluster, and the committee node of the shard to which the cluster belongs is responsible for maintaining and updating the federated learning tree.
4. According to claim 2, a clustering-based federated learning optimization method for a main chain-free sharding architecture is characterized in that: The client training phase includes the following steps: Initial model request: At the beginning of each training round, client i sends a request to the committee node to obtain the latest global model w t , the global model w t Updated from the global model generation phase of the previous round, where i = 1, 2, ... N, and N is the number of clients in the corresponding shard; Local model update: Client i receives the global model w t After that, the model is optimized using its local data to generate a new local model. And get model parameter information Gradient upload: Client i uploads the updated model parameter information Sent to the committee node of the corresponding shard in the form of a transaction, waiting for the next round of global model w t+1 to continue training.
5. According to claim 4, a clustering-based mainchain-free sharding architecture federated learning optimization method is characterized in that: The local model updating process adopts the gradient descent method, and the model parameter information obtained is the gradient information.
6. According to claim 2, a clustering-based federated learning optimization method for a main chain-free sharding architecture is characterized in that: The global model generation stage includes the following steps: Gradient collection and verification: In each block cycle, the committee node collects all received model parameter information and verifies its legitimacy. The verified model parameter information is stored in the transaction pool for further processing. Global model generation and synchronization: The committee node selects model parameter information from the transaction pool and uses the model parameter information to generate a new global model. The generated new global model and model parameter information are packaged into candidate blocks, and PBFT is applied to synchronize the training results of this round. After the synchronization is completed, the committee node broadcasts the latest block information to the client that needs to update the model.
7. The method for optimizing federated learning based on clustering-based mainchain-free sharding architecture according to claim 6, characterized in that: The FedAvg algorithm is used to generate a new global model using the model parameter information.
8. According to claim 1, a clustering-based federated learning optimization method for a mainchain-free sharding architecture, characterized in that: The block includes a block header and a block body, wherein the block header is the metadata part of the block, which contains key information describing the block characteristics and linking the previous and next blocks, and is used to ensure the integrity and consistency of the blockchain; the block body stores actual transactions and model update information.
9. The method for optimizing federated learning based on clustering-based mainchain-free sharding architecture according to claim 8, characterized in that: The block header includes: Federated learning state tree root: The federated learning state tree root is the root hash value of the federated learning state tree in the entire block, which records the state information of all clients in the block; when the state is updated or queried, the root hash value is used to verify the integrity of the data; State root: The state root is a root hash value stored in the federated learning state tree node in the MPT data structure, which is used to record and verify the state information of all shards in the current block; Federated learning Merkle root: The federated learning Merkle root records the Merkle tree root hash values of all local model transactions during the federated learning process, and is used to verify the integrity and consistency of client transactions; The block body comprises: Local model transactions: The local model transactions are model parameter information uploaded by the client, which records the update results of each client on its local model in a specific training round. The local model transactions are packaged into blocks and become the basic data for global model generation; Global model: The global model stores a new global model generated by aggregating each shard.
10. The method for optimizing federated learning based on clustering-based mainchain-free sharding architecture according to claim 9, characterized in that: The node of the federated learning state tree stores a shard ID, a state root, and a global model, wherein the shard ID is a field used to identify the shard position to which the node of the federated learning state tree belongs.