Vertical Federated Learning Communicator
- class mindspore_federated.VerticalFederatedCommunicator(http_server_config, remote_server_config, enable_ssl=False, ssl_config=None, compress_configs=None)[source]
Define the vertical federated communicator.
- Parameters
http_server_config (ServerConfig) – Configuration of local http server.
remote_server_config (ServerConfig) – Configuration of remote http server.
enable_ssl (bool, optional) – whether to enable ssl communication. Default: False.
ssl_config (SSLConfig, optional) – Configuration of ssl encryption. Default: None.
compress_configs (dict, optional) – Configuration of communication compression. Default: None.
Examples
>>> from mindspore_federated import VerticalFederatedCommunicator, ServerConfig >>> http_server_config = ServerConfig(server_name='server', server_address="127.0.0.1:1086") >>> remote_server_config = ServerConfig(server_name='client', server_address="127.0.0.1:1087") >>> vertical_communicator = VerticalFederatedCommunicator(http_server_config=http_server_config, ... remote_server_config=remote_server_config) >>> vertical_communicator.launch() >>> vertical_communicator.data_join_wait_for_start()
- data_join_wait_for_start()[source]
Block and wait for the registration information of the client worker.
- receive(target_server_name: str)[source]
Get the sensor data sent by the remote server.
- Parameters
target_server_name (str) – Specifies the name of the remote server.
- send_tensors(target_server_name, tensor_dict)[source]
Send distributed training sensor data.
- Parameters
target_server_name (str) – Specifies the name of the remote server.
tensor_dict (OrderedDict) – The dict of Tensors to be sent.
Examples
>>> from mindspore import Tensor >>> backbone_out = OrderedDict() >>> backbone_out["hidden_states"] = Tensor(np.random.random(size=(2, 2048, 1280)).astype(np.float16)) >>> vertical_communicator.send_tensors("leader", backbone_out)
- class mindspore_federated.ServerConfig(server_name, server_address)[source]
Define the vertical server configuration.
- class mindspore_federated.SSLConfig(server_password, client_password, server_cert_path=None, client_cert_path=None, ca_cert_path=None, crl_path=None, cipher_list=default_cipher_list, cert_expire_warning_time_in_day=90)[source]
Define the ssl certificate config. If you want to start SSL, you need to configure the following parameters. The return value is used for the third input of mindspore_federated.VerticalFederatedCommunicator .
- Parameters
server_password (str) – The password of the server certificate. Default: None.
client_password (str) – The password of the client certificate. Default: None.
server_cert_path (str) – The absolute path of the server certificate on the server. Default: None.
client_cert_path (str) – The absolute path of the client certificate on the server. Default: None.
ca_cert_path (str) – The absolute path of the root certificate on the server. Default: None.
crl_path (str) – The absolute path of the CRL certificate on the server. Default: None.
cipher_list (str) – The server supports the default encryption suite for ssl communication. Default: default_cipher_list.
cert_expire_warning_time_in_day (int) – How many days before the certificate expires to start printing warning messages. Default: 90.