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

Hello again @gotero,
Indeed, I made a small mistake in the above command, here’s what you should run :

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

I got this error when running the command:

ERROR: Could not find a version that satisfies the requirement concrete-python==2.7.0.dev2 (from versions: none)
ERROR: No matching distribution found for concrete-python==2.7.0.dev2

I started over by creating a conda environment with python 3.9 instead of 3.10 and the default installation worked.

You need to copy paste the full version, so 2.7.0.dev20240709, not 2.7.0.dev2 :wink:

But then are you saying that using python 3.9 instead of 3.10 does not raise your initial NO target: Unable to find target for this triple (no targets are registered) error ?

Yep. Python 3.9 didn’t give me the initial No target error. I tried installing with the full URL with python 3.10 and still got the same error:

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

This is very weird, we’ll try to see if we can reproduce this in our side, thanks for the report ! Anyway, great to know that you can work with python 3.9 then :tada:

Hello again @gotero , you might want to try to run pip install --upgrade pip as well as pip install -U pip wheel setuptools before installing everything in your ptyhon 3.10 env !

Hope that fixes your issue :wink:

To add on this:

  • I have tested it myself on Mac Intel with python3.9 and 3.10, and I was able to install it
  • don’t forget to use a virtual env: python3.9 -m venv .venv; source .venv/bin/activate before doing all of this

Cheers

1 Like

That fixed my issue with python 3.9. Thanks!

1 Like