configurations.md

October 20, 2022 · View on GitHub

Component Launch Configuration

Some components of the federated framework need launch configurations. This doc will detail the configuration of each component. There are three types of configuration:

  • Command Line: When starting the program, specify some parameters following the command line, usually some simple and basic parameters.
  • Config file: When starting the program, specify the corresponding configuration file by '-f', usually is a json format file. Configuration file supports more parameter settings. (Command Line generally is a subset of Config file.)
  • ENV: By means of environment variables, usually some external service configuration.

Each component's configuration will be described in detail below.

Table of Contents

Component Launch Configuration

Component Launch Configuration

Coordinator

The Configuration can be passed in through the command line with args or configuration file. However, the command line only support some basic configurations to startup, if you need a complete configuration, you should use a config file. The detailed description is as follows.

Command Line

args nametyperequireddescription
job_namestringyesjob name, the federated job name.
descriptionstringnosome detailed information for this job.
outputstringnojob result output directory, such as the checkpoints, final model etc, will be saved in this directory.
Default is under current work dir.
hoststringnoIP address to serve for gRPC service.
Default is localhost
portintnoport to listen on for gRPC API, the range is 1024~65535.
Default port is 55051.
clientsstringyesConfig clients to participate in this job. Using ip:port to represent one client service address, split by ","
For example: 1 client "127.0.0.1:8888"
2 clients "127.0.0.1:8888, 192.0.0.1:7777"
task_entrystringyesClient task entrypoint, used to specify task name to client. Typically is the script entrypoint name of the training task.
model_pathstringyesLocal path of model, Which is the initial global model to broadcast to client for training.
runtimestringyesModel runtime used for loading and training model, allowed model runtime: (tensorflow, pytorch).
More runtimes will be supported in future versions.
log_levelstringnoLog level, support [DEBUG, INFO, WARNING, ERROR].
Default is INFO
sslstringnossl path, If use gRPCs, you must set the ssl path. the path should have certificate files. here is how to create certificate files and using gRPCs.
config_filestringnoPath to the configuration file. More detailed configuration can be configured in the configuration file, such as hyper parameters, algorithms etc. If used, configured args above will be replaced if the configuration file contains the same args.

Config File

In addition to supporting the above command line parameters, the file also supports following configurations. Config file fomat is json.

Note: The command line args is a sub-set of config file. If you set same args both in command line and config file, the command line will be ignored.
we highly recommand to use the configuration file.
args nametyperequireddescription
hyper_parametersHyperParametersnoThe hyper parameters of federated training. If not configured, will be filled with default training parameters
parametersParametersnoThe parameters that need to be passed to all training clients, need to be customized by the user
datasetsstringnoThe dataset to use for the job, when there are multiple datasets, seperated by ',', for example: "dataset1, dataset2"
resourceResourcenoThe required client resource to running the federated training
extenderExtendersnoThe extender interface configuration, through this interface, the custom extended interface scripts and functions can be injected into the federation process
secure_algorithmSecureAlgorithmnoFederated security algorithm configuration. If configured, the training process will protect the intermediate data of the job under the corresponding secure computing method.
scriptsScriptConfignoThe training scripts to broadcast to all the clients. This configuration is suitable for the scene that clients has no scripts in local
optimizerOptimizernoOptimizer cofiguration, currently for non iid datasets, you can use fedprox, scaffold two optimizers
lossLossnoLoss cofiguration, currently you can use feddc loss for non iid datasets.

ENVS

Note: Environment variables are usually configured before startup. Usually, some service addresses, constants, etc. are configured in the environment variables. If a container environment is used, it can be set when the container starts.
ENVDefaultDescription
REPORT_PERIOD10The time interval for the client to report its own status information, unit is second. Typically, the more stable the client can set the larger value
JOB_SCHEDULER_ADDRESSNoneIf the Job Scheduler component exists, set the service address(ip:port). If you set this address, then federated job process will be reported regularly
SELECTOR_ADDRESSNoneThe selector component address, if set this address, the coordinator will choose clients for federated job from the selector's interface
CKPT_ROOT_PATHcheckpointsDefault directory name to save the checkpoint during the federated training process.
DEPLOYMENT_WAYcloudThe deployment method of the coordinator, support cloud or local. If cloud, the should set the COORDINATOR_WORKSPACE_PATH, which is the root work directory of federated job.
COORDINATOR_WORKSPACE_PATH/flThe mounted root directory of federated job in the cloud storage.
K8S_IMAGE_PULL_SECRETSNoneSet imagePullSecrets in k8s pod or deployment to pull image If need

Client

The Configuration can be passed in through the command line with args or configuration file. However, the command line only support some basic configurations to startup, if you need a complete configuration, you should use a config file. The detailed description is as follows.

Note: we highly recommand to use the configuration file.

Command Line

args nametyperequireddescription
hoststringnoClient listen host, default is '0.0.0.0'
portintnoClient listen port, default is 22000
serverstringyesThe address of server, format is ip:port, where to report the the train or evaluate result.
For example: 192.0.0.1:9000
workspacestringyesClient's workspace path, where used to save some temporary files. These temporary files are generated during the task running, such as checkpoints, task result, etc.
platformstringnoClient's platform, support [k8s, linux], default is linux
task_config_entrystringyesThis is a path to store task_config.json. The task_config.json indicate the path of the entrypoint scripts that the task need to run
storage_quotaintnoThe storage quota of client (unit is MB), which limit the size of workspace. When storage_quota is exceeded, the long-standing temporary files in workspace will be deleted
log_levelstringnoLog level, support [DEBUG, INFO, WARNING, ERROR]
default is INFO
sslstringnossl path, If use gRPCs, you must set the ssl path. the path should have certificate files. here is how to create certificate files and using gRPCs.
datasetsstringyesA path to store a JSON file, in which describes the mapping relationship between dataset name and dataset path. This file indicates the dataset supported by the client for federated job
config_filestringnoPath to the configuration file. More detailed configuration can be configured in the configuration file. Configured args above will be replaced if the configuration file contains the same args.

Config file

In addition to supporting the above command line parameters, the file also supports following configurations. Config file fomat is json.

Note: The command line args is a sub-set of config file. If you set same args both in command line and config file, the command line will be ignored.
args nametyperequireddescription
client_idstringnoThe unique identifier of the client
external_addressstringnoThe IP address and port of the client's external service, Default is host:port
registrationboolnoWhether the client is registered to the selector component. Default is true
labelstringnoClient's label, which can be used to classify and filter devices
runtimestringnoClient supported runtimes, which can be used to classify and filter devices
task_saving_strategystringnoThe task storage strategy supports two strategies of mongo/postgreSQL. if not set, The client will not save task history information. If set mongo/postgreSQL, this refers to saving task history information to the mongo/postgreSQL database.
max_task_parallelismintnoThe maximum number of concurrent federated job on the client
usernamestringnoClient's username, used to authentication. Only used when registration is true.
passwordstringnoClient's password, used to authentication. Only used when registration is true.
public_keystringnoThe path to store the public key, see here how to generate public keys.
private_keystringnoThe path to store the private key, see here how to generate private keys.
certificatestringnoThe path to store the certificate, see here how to generate and load certificate.

ENVS

Note: Environment variables are usually configured before startup. If a container environment is used, it can be set when the container starts.
ENVDefaultDescription
WORKSPACE/worksapceThe workspace of this component
CONTAINER_EXECUTOR_IMAGENoneIf the client's task execution environment is kubernetes, then should specify the image address
WORKER_PORT8050Service port when the task is executed
WAIT_WORKER_FINISHED_TIMEOUT300Maximum time to wait for a task to complete, if not, the task will be stopped forcely
WORKER_HTTP_PROXYNoneSet up pod environment of http proxy if need
WORKER_HTTPS_PROXYNoneSet up pod environment of https proxy if need
K8S_IMAGE_PULL_SECRETSNoneSet imagePullSecrets in k8s pod or deployment to pull image If need
DB_TYPEmongoThe type of database, support ["mongo", "postgreSQL"]
DB_ADDRESSNoneThe service address of database
DB_USERNAMENoneThe username to login the database
DB_PASSWORDNoneThe password to login the database
DB_NAMENoneThe used database name
COLLECTION_NAMENoneThe used db collection name
STORAGE_TYPEposixThe storage protocol used by the backend storage
S3_ENDPOINTNoneIf protocol type of distributed storage is s3, configure the endpoint of DFS
S3_ACCESS_KEYNoneIf protocol type of distributed storage is s3, configure the access key of DFS
S3_SECRET_KEYNoneIf protocol type of distributed storage is s3, configure the secret key of DFS
WORKSPACE_BUCKETNoneIf protocol type of distributed storage is s3, configure the bucket used
WORKSPACE_PVCNoneIf protocol type of distributed storage is POSIX, configure the pvc used
K8S_ADDRESSNoneThe service address of Kubernetes
K8S_API_PROTOCOLhttpThe protocol used to access the k8s api server
K8S_API_TOKENNoneIf the K8S api server requires token authentication, a valid token value needs to be configured
K8S_IMAGE_PULL_SECRETSNoneIf the docker repository requires authentication, you need to configure the corresponding secret
GPU_RS_KEYnvidia.com/gpuIf the cluster has GPU resources, set the resource key value of GPU resources of k8s
K8S_NAMESPACEdefaultWhich namespace of k8s the related components deploy in

Selector

The selector component is mainly used to select the suitable clients for the federated job. The detailed configuration instructions are as follows:

Note: The selector component is not mandatory. you can also directly configure the client's service address to join the federated job. However, when you don't know the client, and there are a large number of clients, especially in the cross-device scenarios, such as mobile phone, sensors.

Command Line

args nametyperequireddescription
hoststringnoIP address to serve for gRPC API., default is '0.0.0.0'
portintnoPort to listen on for gRPC API, the range is 1024~65535. Default port is 50055.
log_levelstringnoLog level, support [DEBUG, INFO, WARNING, ERROR].
Default is INFO
auth_clientstringnoVerify the legitimacy of the client. If True, the client should send its certificate or public key. Only the clients pass the authentication can join the federaed job. Default is False.
root_certstringnoThe root certificate path, root certificate is used to verify the legitimacy of client, see here how to generate and load certificate.
sslstringnossl path, If use gRPCs, you must set the ssl path. the path should have certificate files. here is how to create certificate files and using gRPCs.
optimal_selectboolnoWhether the client will be selected by optimal strategy. If set False, the selector will random select client after filter. If set True, you can config the strategy in config file, or using the default strategy.
config_filestringnoPath to the configuration file. More detailed configuration can be configured in the configuration file. Configured args above will be replaced if the configuration file contains the same args.

Config file

Note: The command line args is a sub-set of config file. If you set same args both in command line and config file, the command line will be ignored.
You can config the strategies and extensions for evaluating and filtering clients.
args nametyperequireddescription
strategydictnoStrategy is used to score the clients, prioritize clients for federated job.
Strategy is composed with a few evaluators, with dict format, such as:
Key: evaluator_name Value: weight_value
{
"resource": 1,
"data": 1
}
The Strategy will use every evaluator in the config to score the client, then add up all the scores, which as the final score of client.
extendersdictnoExtender is used to extend the process client selection, it will be called after the strategy execution. Support extenders = ["filter", "score"]. For example:
{
"filter": ExtenderConfig,
"score": ExtenderConfig
}
ExtenderConfig
nametyperequireddescription
modestringyesThe form of extender, current support ["file"]
pathstringyesThe absolute path of extension script
method_namestringyesThe name of the extension function

ENVS

ENVDefaultDescription
SINGLE_HEART300The time interval at which the selector requires the client to report, if the client is a single device
CLUSTER_HEART600The time interval at which the selector requires the client to report, if the client is a cluster, which means more stable
STORAGE_TYPEposixThe storage protocol used by the backend storage
S3_ENDPOINTNoneIf protocol type of distributed storage is s3, configure the endpoint of DFS
S3_ACCESS_KEYNoneIf protocol type of distributed storage is s3, configure the access key of DFS
S3_SECRET_KEYNoneIf protocol type of distributed storage is s3, configure the secret key of DFS
WORKSPACE_BUCKETNoneIf protocol type of distributed storage is s3, configure the bucket used

Job Scheduler

Note: Job Scheduler is mainly responsible for scheduling tasks and interacting with multiple modules. There are no startup parameters, mainly some environment variable configurations.

ENVS

ENVDefaultDescription
HTTP_PORTNoneThe service port on which this job scheduler component runs
DB_TYPEmongoThe type of database, support ["mongo", "postgreSQL"]
DB_ADDRESSNoneThe service address of database
DB_USERNAMENoneThe username to login the database
DB_PASSWORDNoneThe password to login the database
DB_NAMENoneThe used database name
COLLECTION_NAMENoneThe used db collection name
WORKSPACE/worksapceThe workspace of this component
TEMP_DIR/coordinator_configsThe relative path of the coordinator configs directory which store dynamically generated coordinator startup configuration files
STORAGE_TYPEposixThe storage protocol used by the backend storage
S3_ENDPOINTNoneIf protocol type of distributed storage is s3, configure the endpoint of DFS
S3_ACCESS_KEYNoneIf protocol type of distributed storage is s3, configure the access key of DFS
S3_SECRET_KEYNoneIf protocol type of distributed storage is s3, configure the secret key of DFS
WORKSPACE_BUCKETNoneIf protocol type of distributed storage is s3, configure the bucket used
WORKSPACE_PVCNoneIf protocol type of distributed storage is POSIX, configure the pvc used
COORDINATOR_IMAGENoneThe docker image address of Coordinator component
COORDINATOR_WORKSPACE_PATHNoneThe workspace of coordinator
COORDINATOR_PORT50051The service port of coordinator
CLOUD_OSk8sThe system operating environment of each component
DEPLOYMENT_WAYcloudThe deployment method of component, default is in kubernetes
K8S_ADDRESSNoneThe service address of Kubernetes
K8S_API_PROTOCOLhttpThe protocol used to access the k8s api server
K8S_API_TOKENNoneIf the K8S api server requires token authentication, a valid token value needs to be configured
K8S_IMAGE_PULL_SECRETSNoneIf the docker repository requires authentication, you need to configure the corresponding secret
GPU_RS_KEYnvidia.com/gpuIf the cluster has GPU resources, set the resource key value of GPU resources of k8s
K8S_NAMESPACEdefaultWhich namespace of k8s the related components deploy in
MODEL_MANAGER_ADDRESSNoneThe service address of Model Manager component
PROXY_ADDRESSNoneThe service address of Proxy Component
JOB_SCHEDULER_ADDRESSNoneThe service address of Job Scheduler component
SELECTOR_ADDRESSNoneThe service address of Selector Component
REPORT_PERIOD10The report time interval of coordinator
COORDINATOR_HEARTBEAT_TIMEOUT20The maximum time interval reported by the coordinator, if timeout, the coordinator will be deleted, the jod will set to failed
MAX_RETRY_TIMES30Maximum number of attempts to connect
COORDINATOR_QUERY_INTERVAL1The retry time interval after schedule the coordinator

Model Manager

ENVS

ENVDefaultDescription
PORT50057The service port of this component
LOG_LEVELINFOThe log level, support [DEBUG, INFO, WARNING, ERROR]
DB_TYPEmongoThe type of database, support ["mongo", "postgreSQL"]
DB_ADDRESSNoneThe service address of database
DB_USERNAMENoneThe username to login the database
DB_PASSWORDNoneThe password to login the database
DB_NAMENoneThe used database name
DB_COLLECTION_NAMENoneThe used db collection name
WORKSPACE/worksapceThe workspace of this component
MODELS_DIRmodelsThe relative path where all models are stored in the workspace
STORAGE_TYPEposixThe storage protocol used by the backend storage
S3_ENDPOINTNoneIf protocol type of distributed storage is s3, configure the endpoint of DFS
S3_ACCESS_KEYNoneIf protocol type of distributed storage is s3, configure the access key of DFS
S3_SECRET_KEYNoneIf protocol type of distributed storage is s3, configure the secret key of DFS
WORKSPACE_BUCKETNoneIf protocol type of distributed storage is s3, configure the bucket used

Data Server

ENVS

ENVDefaultDescription
SERVER_ADDRESS0.0.0.0The service address of this component
PORT30088The service port of this component
LOG_LEVELINFOThe log level, support [DEBUG, INFO, WARNING, ERROR]
WORKSPACE/worksapceThe workspace of this component
STORAGE_TYPEposixThe storage protocol used by the backend storage
ACCESS_USERNoneUser name for data server authentication
ACCESS_PASSWORDNonePassword for data server authentication
S3_ENDPOINTNoneIf protocol type of distributed storage is s3, configure the endpoint of DFS
S3_ACCESS_KEYNoneIf protocol type of distributed storage is s3, configure the access key of DFS
S3_SECRET_KEYNoneIf protocol type of distributed storage is s3, configure the secret key of DFS
WORKSPACE_BUCKETNoneIf protocol type of distributed storage is s3, configure the bucket used