Simple way to physically separate client and server for FHE Spaces demo

I need a little help to create a demo of the health prediction use case (and others) on physically separate client and server machines, e.g. my laptop and a cloud instance/container or other bare metal server. I’ve found the deployment code repo that explains how to do it with the breast cancer model, but I need some guidance on how to divide up the encrypted_health_prediction code that is running in Spaces to run in a similar fashion, so that I can run the client app and UI on my laptop and the model in AWS or docker. Suggestions? Thanks!

Hi @gotero,

You can check in the files of the hugginface demo → zama-fhe/encrypted_health_prediction at main.

The demo is done on a single machine but it implements the client and server

You will see that in app.py we launch the server before doing anything and then we use the requests library to query the server with encrypted data.

You should be able to do what you want very easily by taking the server.py along with some of the utils functions and the server.zip to aws.

You can keep the rest locally and set the SERVER_URL variable within utils.py to the aws machine one.

Let me know if anything is unclear.

Thanks for the help. It seems I got ahead of myself. I installed concrete-ML into a conda env on my Intel Mac running Ventura 13.2.1 and tried to run the simple logistic regression example and got this error:

NO target: Unable to find target for this triple (no targets are registered)
Traceback (most recent call last):
File “/Users/gotero/concrete/logistic_regression.py”, line 21, in
model.compile(X_train)
File “/Users/gotero/anaconda3/envs/concrete/lib/python3.10/site-packages/concrete/ml/sklearn/base.py”, line 575, in compile
self.fhe_circuit_ = module_to_compile.compile(
File “/Users/gotero/anaconda3/envs/concrete/lib/python3.10/site-packages/concrete/fhe/compilation/compiler.py”, line 606, in compile
circuit = Circuit(
File “/Users/gotero/anaconda3/envs/concrete/lib/python3.10/site-packages/concrete/fhe/compilation/circuit.py”, line 67, in init
self.enable_fhe_execution()
File “/Users/gotero/anaconda3/envs/concrete/lib/python3.10/site-packages/concrete/fhe/compilation/circuit.py”, line 134, in enable_fhe_execution
self.server = Server.create(
File “/Users/gotero/anaconda3/envs/concrete/lib/python3.10/site-packages/concrete/fhe/compilation/server.py”, line 220, in create
compilation_result = support.compile(mlir, options, compilation_context)
File “/Users/gotero/anaconda3/envs/concrete/lib/python3.10/site-packages/concrete/compiler/library_support.py”, line 172, in compile
self.cpp().compile(
RuntimeError: No default target machine for object generation

Xcode version 14.3.1

This is my gcc info:

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Suggestions?

Hello @gotero ,
This looks like a bug that we’ve recently fixed in Concrete but that has not been included in a public release yet. Could you try to install one of Concrete Python’s latest nightly bu running the following command in your environment ? :

pip install --extra-index-url https://pypi.zama.ai/cpu 2.7.0.dev20240709

Be aware that this is not a stable version and that might create other issues with Concrete or Concrete ML. We will try to release a public version with the fix as soon as we can.

Hop that helps !

Thanks for the help. I get this error when trying to install the nightly build:

ERROR: Could not find a version that satisfies the requirement 2.7.0.dev20240709 (from versions: none)
ERROR: No matching distribution found for 2.7.0.dev20240709