Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ios sdk and example with CoreML #1289

Merged
merged 9 commits into from
Aug 6, 2022
Merged

Conversation

danielnugraha
Copy link
Contributor

Reference Issues/PRs

What does this implement/fix? Explain your changes.

Added a Flower iOS SDK (as a Swift package) for Flower client and a working example with CoreML.
Transport.proto is compiled using Swift protobuf compiler plug-in provided by grpc-swift and produces 2 files, 1 for the messages and 1 for the services.
The Flower client in iOS is translated from python and uses the same structure as python Flower client.

The only exception is the Parameter file. Right now to be able to use the python server out of the box and its built in strategies the model parameters from the client will be converted into numpy array using Python-iOS and sent as bytes to the server as a message in FitRes or getParameters.
Model parameters from the server will also be converted to swift array (in this case MLMultiArray).

The example uses a Digit Recognition CoreML Model and MNIST Dataset as csv (there are no official dataset for swift so I use the dataset provided in https://github.com/JacopoMangiavacchi/MNIST-CoreML-Training).

How to test:

  1. Open the project in xcode
  2. Build and run the Flower client with Target Simulator iPhone 13
  3. Start the server included in the ios folder
  4. Prepare the dataset in the client and click start federated learning

@danieljanes
Copy link
Member

Thanks for the PR @danielnugraha, very cool! Could you move the code into examples/ios?

Copy link
Member

@danieljanes danieljanes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finished a first high-level review of this PR and left a few comments (mainly updating the README and potentially shortening server.py). I look forward to merging it soon to make it available to the community, we can then continue to iterate on the iOS example/SDK in follow-up PRs.

The biggest update we'll have to do in a follow-up PR is to make it compatible with Flower 1.0 (which changes transport.proto to handle optional client methods).

Again, thanks for the PR, great work!

examples/ios/server.py Show resolved Hide resolved
examples/ios/server.py Show resolved Hide resolved
examples/ios/server.py Outdated Show resolved Hide resolved
examples/ios/README.md Outdated Show resolved Hide resolved
examples/ios/Flower/Sources/Flower/GRPC/Start.swift Outdated Show resolved Hide resolved
examples/ios/Flower/Sources/Flower/GRPC/Start.swift Outdated Show resolved Hide resolved
Copy link
Member

@danieljanes danieljanes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @danielnugraha, just one comment about the strategy left, apart from that it looks good!

examples/ios/server.py Outdated Show resolved Hide resolved
@danieljanes danieljanes enabled auto-merge (squash) August 6, 2022 11:11
@danieljanes danieljanes merged commit a1ea6c4 into adap:main Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants