Warning: This project is work in progress and should not be used in production. The current implementation is a prototype.
The dpsa4fl project aims at providing a mechanism for secure and differentially private aggregation of gradients in federated machine learning. For more information see the project overview.
This package provides python bindings for the dpsa4fl library. The following functionality is provided:
- Controller api: start a training session on the janus server, and collect aggregated gradients.
- Client api: securely submit gradients to the janus server.
A modified janus server setup is required, see the example project for step-by-step instructions.
controller_api_new_state(gradient_len, privacy_parameter, fixed_bitsize, external_leader_tasks, external_helper_tasks)
Create new controller state.
gradient_len: intSize of the gradients to be submitted.privacy_parameter: floatused by the aggregators to determine the amount of noise added. Each aggregation result will be1/2 * privacy_parameter^2zero-concentrated differentially private.fixed_bitsize: intThe resolution of the fixed-point encoding used for secure aggregation A larger value will result in a less lossy representation and more communication and computation overhead. Currently, 16, 32 and 64 bit are supported.external_leader_tasks: strLocation of the leader aggregator server in URL format including the port. For example, for a server running locally: "http://127.0.0.1:9991"external_helper_tasks: strLocation of the helper aggregator server in URL format including the port. For example, for a server running locally: "http://127.0.0.1:9992"
state: PyControllerStateA controller state object containing the input.
Create a new training session.
controller_state: PyControllerStateA controller state object identifying the aggregator servers on which the session is supposed to run.
session_id: intThe ID of the newly created training session.
End the current training session.
controller_state: PyControllerStateA controller state object identifying the aggregator servers on which the session is running.
Start a new training round.
controller_state: PyControllerStateA controller state object identifying the aggregator servers on which the training round is supposed to run.
task_id: strThe ID of the newly started task, as a string.
Collect resulting aggregated gradient vector from janus.
controller_state: PyControllerStateA controller state object identifying the aggregator servers from which to collect.
aggregate: numpy.ndarrayThe aggregated and noised gradient vector. (1,)-shaped (flat).
State object for dpsa4fl servers. Stores gradient length, privacy parameter, fixedpoint resolution and aggregator locations. Also contains current task and training session IDs, accessible with the mstate: PyControllerStateMut attribute.
State object for dpsa4fl servers containing the current training session and taks IDs.
Create new client state, containing the aggregator locations.
external_leader_tasks: strLocation of the leader aggregator server in URL format including the port. For example, for a server running locally: "http://127.0.0.1:9991"external_helper_tasks: strLocation of the helper aggregator server in URL format including the port. For example, for a server running locally: "http://127.0.0.1:9992"
state: PyClientStateA client state object containing the input locations.
Request the privacy parameter used by the aggregator to determine the amount
of noise added. If this function returns eps, the aggregation result of
this task will be 1/2 * eps^2 zero-concentrated differentially private.
client_state: PyClientStateA client state object containing the aggregator locations.task_id: strID of the task whose privacy parameter we want to know.
privacy: floatThe zCDP parameter of this aggregation task.i
Submit a gradient vector to a janus server.
client_state: PyClientStateA client state object containing the aggregator locations.task_id: strID to identify the janus task to which this gradient corresponds.data: numpy.ndarrayThe gradient to be submitted. Expected to be (1,)-shaped (flat).
State object for dpsa4fl clients. Stores aggregator locations.
To release a new version of this package, you have to:
- Increment the version number in
Cargo.toml. - Push the current state to the
releasebranch. Then github actions will do the rest. Alternatively, you can use act to run github actions locally.
Use maturin to build the python package. To do so using the poetry python package manager, do the following in the dpsa4fl-bindings folder:
poetry shell
maturin develop
This project is funded through the NGI Assure Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet program. Learn more on the NLnet project page.
