"Python SDK library for using the Modalic Federated Learning Operations Platform."
Project description
Python SDK
Python SDK library for using the Modalic Federated Learning Operations Platform.
The SDK library serves as convenient interface for performing Federated Learning with the most common Machine Learning frameworks like Pytorch or Tensorflow written in the Python programming language. As an additional software layer within a Machine Learning pipeline, the SKD enables an individual client application to take part within a Federated Learning setup. The coordination of a distributed Machine Learning process solving a particular problem, is done by a central server or service provider which can be started via Python script using the SDK.
As the main entrypoint to a production ready FLOps Platform, this software package aims for all developers and ML practitioners that want to run ML use cases in distributed fashion.
Usage
In order to run a Federated Learning procedure two main entities have to instantiated. The client logic and the aggregation server application. Both can be started via the SDK. Currently Pytorch & Tensorflow are supported as framework to construct the ML architecture.
Run the Aggregation Server
# (1) Run the aggregation server with configuration using .toml
cfg = toml.load("${configPATH}.toml")
modalic.run_server(cfg)
The .toml file can be used to control hyperparameters for the aggregation server.
# -c configs/config.toml
# REST API settings.
[api]
# The address to which the REST API of the server
# will be bound. All requests should be sent to this address.
server_address = "127.0.0.1:8080"
# Hyperparameter controlling the Federated Learning training process.
[protocol]
# Defines the number of training rounds (global epochs)
# that will be performed.
training_rounds = 10
# Sets the number of participants & local models
# one global epoch should at least contain.
participants = 2
For implementing the client logic a framework of choice can be used.
Pytorch
# (2) Construct the client logic.
import modalic
# Define a FLClient object that implements all the ML logic and will
# used as an input to an internal modalic client which enables the
# program to connect to the server an perform training in distributed fashion.
class FLClient(modalic.Client):
def __init__(self, dataset, ...):
self.model = Net()
self.dataset = torch.utils.data.DataLoader(dataset, batch_size=32)
...
def train(self):
for epoch in range(0, self.epochs):
for images, labels in self.trainloader:
...
return self.model
def serialize_local_model(self, model):
return modalic.serialize_torch_model(model)
def deserialize_global_model(self, global_model):
self.model = modalic.deserialize_torch_model(
self.model, global_model, self._get_model_shape()
)
def get_model_shape(self):
return modalic.get_torch_model_shape(self.model)
def get_model_dtype(self):
...
# Construct the client layer..
client = FLClient(...)
# (3) Run training for single client.
modalic.run_client(client)
Tensorflow
# (2) Construct the client logic.
class FLClient(modalic.Client):
def __init__(self, dataset, ...):
# Initialize & compile the MobileNetV2 model.
self.model = tf.keras.applications.MobileNetV2((32, 32, 3), classes=10, weights=None)
# Load the CIFAR-10 dataset using tf.keras.
(self.x_train, self.y_train), (_, _) = tf.keras.datasets.cifar10.load_data()
...
def train(self):
...
self.model.fit(self.x_train, self.y_train, batch_size=self.batch_size, epochs=self.epochs)
...
return self.model
def serialize_local_model(self, model):
return modalic.serialize_tf_keras_model(model)
def deserialize_global_model(self, global_model):
self.model = modalic.deserialize_tf_keras_model(
self.model, global_model, self._get_model_shape()
)
def get_model_shape(self):
return modalic.get_tf_keras_model_shape(self.model)
def get_model_dtype(self):
...
# Construct the client layer..
client = FLClient(...)
# (3) Run training for single client.
modalic.run_client(client)
Please keep in mind that this code snippet shows only the logic and the general idea. For more details, check out the /examples folder that contains more in-depth and complete instruction sets and examples that are actually actionable.
Installation
The latest release of Modalic Python SDK can be installed via pip:
pip install modalic
Documentation
See the Python SDK docs for more information. Additionally, some examples for starting with Modalic are provided in this repository under the examples folder. Any Questions? Reach out to us on modalic.ai.
Development
Find more information on contributing to the open source stack and the development process in general here.
License
The Modalic Python SDK is distributed under the terms of the Apache License Version 2.0. A complete version of the license is available in LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file modalic-0.2.0-cp310-cp310-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: modalic-0.2.0-cp310-cp310-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 8.9 MB
- Tags: CPython 3.10, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecb6717198d4b424d6b6f9bec98bbbb54b1f24844263dda39aafe2f76ca3f360 |
|
MD5 | 05976cb4a6b558e1573552af0cb3e7e0 |
|
BLAKE2b-256 | ad85f2cac7d2cee9211581e8fd7da7e54d33d9fe6ee1b03d8c1c622a118ace54 |
File details
Details for the file modalic-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: modalic-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 8.8 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76c777e921fde7de6d8f91c73fac0f52791ab083a58cc28f0b233e0224e8baa4 |
|
MD5 | ccef34bc12d527f8d5eba949d5448422 |
|
BLAKE2b-256 | b0f078fe5447034eb8dc8ea4dee873b1d4332a16def5519a8565f829c617c05c |
File details
Details for the file modalic-0.2.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: modalic-0.2.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 9.1 MB
- Tags: CPython 3.10, manylinux: glibc 2.12+ i686, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ff61c15ffd5bb3183682e4db81d78470d87934b79232df300e0db54bdfca2fd |
|
MD5 | 512b1f583e9c07b3e27035928ce4412c |
|
BLAKE2b-256 | f55f3a0ed0b6eb213e4a4e6d65810d1ae13a973eea495901cab2cbf5734385c5 |
File details
Details for the file modalic-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: modalic-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35631fff3b9c568a2fd211368505e25eda2f113bbb7cc659ab18a215bdff606d |
|
MD5 | 552344f3cc8f9ec2ffbb857104a9501d |
|
BLAKE2b-256 | 1e02e829117f5222b4e65b4fc17c929ea48d74826b969ccc90cd73405b270ab7 |
File details
Details for the file modalic-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: modalic-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 6.0 MB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36c9fad7d34a2508bdc857e0d12c6d696d614f7a97c38ef2a8550b04fe6b881a |
|
MD5 | c3a0ae9ff4243ec0a57b67613b127736 |
|
BLAKE2b-256 | a6ebf90679b2be66b0d1aca2eb7a9ecc8136ac6faae3aed40c0a803d27c93492 |
File details
Details for the file modalic-0.2.0-cp39-cp39-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: modalic-0.2.0-cp39-cp39-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 8.9 MB
- Tags: CPython 3.9, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd4b11073c5329746d110c0db8f3872b730afb3de778168b9812ef896457edb7 |
|
MD5 | 7f01bf5e064d045b4b98f413ec8878a2 |
|
BLAKE2b-256 | e2075bafc7bf384cd35e38d406e3f1e7fb6f5593f4821107d50f6ef4da3e39b5 |
File details
Details for the file modalic-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: modalic-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 8.8 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f55b6be3e4674c856c77aedb0c8d4e74e61a414724ae584e0379a2a237be4fd9 |
|
MD5 | b9a98f0ee9c285a7cbc117586377818b |
|
BLAKE2b-256 | ea1a6df7f09f6d2f9bda74210e82a75ec8c880cc43b6761504c217865e5d5a93 |
File details
Details for the file modalic-0.2.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: modalic-0.2.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 9.1 MB
- Tags: CPython 3.9, manylinux: glibc 2.12+ i686, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | da627589ff4206305bbc872598224984202903ea7ee48b2fd2355df99dc4d186 |
|
MD5 | b250856399530d91d6ed622d14d2ffbc |
|
BLAKE2b-256 | 3efd337d7a3e857d11ac68000b971e01138d4ac644a46c9d0b32f8ee90cadbfe |
File details
Details for the file modalic-0.2.0-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: modalic-0.2.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1973a6ff4c05ff5d96025e6a97c0c6d6edaa203b306b15ef2105df86d131564 |
|
MD5 | 859612f772b1416e908ff0cb92f3b9e1 |
|
BLAKE2b-256 | 1401807f9422011155bd1387a1a82126b02df90a9cbbd2d2b0843ecce877302f |
File details
Details for the file modalic-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: modalic-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 6.0 MB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0423555efbd8c2396052f09b9950fec7b55c0463f88f49165d403b4b2f79e7df |
|
MD5 | 42930c7bde5c397493baa8431f4e4c20 |
|
BLAKE2b-256 | e2b4d7ce58d3173b56821ef3ca133c78b4fd4208fdd1c543fae6520adadb7e63 |
File details
Details for the file modalic-0.2.0-cp38-cp38-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: modalic-0.2.0-cp38-cp38-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 8.9 MB
- Tags: CPython 3.8, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8efb986e71abce530f763702b918f77c080f6bc6bf462e2820d0873fdc38dc3 |
|
MD5 | 4d642d2f34a9f1bd3b3da0d8a8825913 |
|
BLAKE2b-256 | 0a44c68e28455a85efd0b826a8c5fadda367a79625d14754eb6cd34503747334 |
File details
Details for the file modalic-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: modalic-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 8.8 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90177b99dd28402d1d7ba2008cf1cf5d5911c6e4a2e2f905f25e19b586136b79 |
|
MD5 | 5ab3b483b1f0a5e046568874c3f90b70 |
|
BLAKE2b-256 | 805ed97e908a0e025e4168cf03f6df302b43f0414ba848228031b1d8ae6bbc30 |
File details
Details for the file modalic-0.2.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: modalic-0.2.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 9.1 MB
- Tags: CPython 3.8, manylinux: glibc 2.12+ i686, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9abe862ddec87d34f7597b6a8aceba173f6516bc3fe757f1ffb728268b6d06cf |
|
MD5 | 4592a9e67f59aa9d228fc2dbed54ba24 |
|
BLAKE2b-256 | 7ee3ce181d6ba3dbe87c7bf0ffedf1c79154e957ec510aa40f40a7dd141948cd |
File details
Details for the file modalic-0.2.0-cp38-cp38-macosx_11_0_arm64.whl
.
File metadata
- Download URL: modalic-0.2.0-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e3b72593b393d81e4c39e2709807b0b171828cb3a1b8195fe39802d069c5d5c |
|
MD5 | 4e6b50762e6c88b3f75aaed061e584c8 |
|
BLAKE2b-256 | 33bceb9e07957f2f0c5857d6f0366345ac7f50fc5472ac80e195f02725434d0a |
File details
Details for the file modalic-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: modalic-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 6.0 MB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 469db2563307cc506869d6181a4c356c83c7edd8f4ad56a3deb1d6f6d176e79b |
|
MD5 | 86229f1e00b5de43119ce7e80de01adc |
|
BLAKE2b-256 | a0668db9879cd467d4aa385e9467601c0087f3937ec691169e712d84bbb0a7d9 |