Skip to main content

"Python SDK library for using the Modalic Federated Learning Operations Platform."

Project description

Modalic Logo


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 written in the Python programming language. As an API layer it 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 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(".toml")
modalic.run_server(cfg)

  # .toml
  #
  # [api]
  # server_address = "[::]:8080"
  #
  # [model]
  # data_type = "F32"
  #
  # [process]
  # training_rounds = 10
  # participants = 3
  # strategy = "FedAvg"

Construct the client logic using a framework of choice. The Pytorch approach uses an object-oriented paradigm while the Tensorflow examples applies a functional one. Both paradigm are available in both frameworks vice versa.

Pytorch

# (2) Construct the client logic.

# Define a Trainer object that contains all the ML logic.
class Trainer():

  def __init__():
    self.model = Net()
    self.dataset = torch.utils.data.DataLoader(dataset, batch_size=32)
    ...

  def train():
    ...

# Put the Modalic client layer on top of the ML logic.
client = modalic.PytorchClient(Trainer())

# (3) Run training for single client.
client.run()

Tensorflow

# (2) Construct the client logic.

# Wrap the custom defined train function with modalic.tf_train.
@modalic.tf_train(...)
def train(model, x_train, y_train):
    model.fit(x_train, y_train, batch_size=32, epochs=1)
    return model
    ...

# Define the model & data
model = tf.keras.Model(...)
...

# (3) Run training for single client simply via.
train(model, x_train, y_train)

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

Binaries

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

modalic-0.1.0-cp310-cp310-musllinux_1_1_x86_64.whl (7.4 MB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

modalic-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.0 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

modalic-0.1.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (8.0 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686

modalic-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (4.1 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

modalic-0.1.0-cp39-cp39-musllinux_1_1_x86_64.whl (7.4 MB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

modalic-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.0 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

modalic-0.1.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (8.0 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686

modalic-0.1.0-cp39-cp39-macosx_11_0_arm64.whl (4.1 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

modalic-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl (4.5 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

modalic-0.1.0-cp38-cp38-musllinux_1_1_x86_64.whl (7.4 MB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

modalic-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.0 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

modalic-0.1.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl (8.0 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686

modalic-0.1.0-cp38-cp38-macosx_11_0_arm64.whl (4.1 MB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

modalic-0.1.0-cp38-cp38-macosx_10_9_x86_64.whl (4.5 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page