diff --git a/.github/workflows/refresh-one-notebook.yaml b/.github/workflows/refresh-one-notebook.yaml index 6f502f153..a77872d71 100644 --- a/.github/workflows/refresh-one-notebook.yaml +++ b/.github/workflows/refresh-one-notebook.yaml @@ -15,7 +15,6 @@ on: - CreditScoring \n - DecisionTreeClassifier \n - DecisionTreeRegressor \n - - Deployment \n - EncryptedPandas \n - ExperimentPrivacyTreePaper \n - FromImageNetToCifar \n @@ -60,7 +59,6 @@ env: CreditScoring: "use_case_examples/credit_scoring/CreditScoring.ipynb" DecisionTreeClassifier: "docs/advanced_examples/DecisionTreeClassifier.ipynb" DecisionTreeRegressor: "docs/advanced_examples/DecisionTreeRegressor.ipynb" - Deployment: "docs/advanced_examples/Deployment.ipynb" EncryptedPandas: "docs/advanced_examples/EncryptedPandas.ipynb" ExperimentPrivacyTreePaper: "docs/advanced_examples/ExperimentPrivacyTreePaper.ipynb" FromImageNetToCifar: "use_case_examples/cifar/cifar_brevitas_finetuning/FromImageNetToCifar.ipynb" diff --git a/.github/workflows/run_one_use_cases_example.yaml b/.github/workflows/run_one_use_cases_example.yaml index 3b3e399ec..0d3989164 100644 --- a/.github/workflows/run_one_use_cases_example.yaml +++ b/.github/workflows/run_one_use_cases_example.yaml @@ -12,7 +12,7 @@ on: - cifar/cifar_brevitas_finetuning - cifar/cifar_brevitas_training - credit_scoring - - deployment/breast_cancer_builtin + - deployment/breast_cancer - deployment/cifar - deployment/sentiment_analysis - disease_prediction diff --git a/deps_licenses/licenses_linux_user.txt b/deps_licenses/licenses_linux_user.txt index 467fcc459..39ebd0a68 100644 --- a/deps_licenses/licenses_linux_user.txt +++ b/deps_licenses/licenses_linux_user.txt @@ -1,80 +1,54 @@ Name, Version, License -GitPython, 3.1.41, BSD License PyYAML, 6.0.1, MIT License -anyio, 3.7.1, MIT License -boto3, 1.34.88, Apache Software License -botocore, 1.34.88, Apache Software License brevitas, 0.8.0, UNKNOWN -certifi, 2023.7.22, Mozilla Public License 2.0 (MPL 2.0) +certifi, 2024.2.2, Mozilla Public License 2.0 (MPL 2.0) charset-normalizer, 3.3.2, MIT License -click, 8.1.7, BSD License coloredlogs, 15.0.1, MIT License concrete-python, 2024.4.19, BSD-3-Clause dependencies, 2.0.1, BSD License dill, 0.3.8, BSD License -exceptiongroup, 1.2.1, MIT License -fastapi, 0.103.2, MIT License -filelock, 3.13.4, The Unlicense (Unlicense) +filelock, 3.14.0, The Unlicense (Unlicense) flatbuffers, 24.3.25, Apache Software License fsspec, 2024.3.1, BSD License -gitdb, 4.0.11, BSD License -h11, 0.14.0, MIT License huggingface-hub, 0.22.2, Apache Software License humanfriendly, 10.0, MIT License -hummingbird-ml, 0.4.8, MIT License +hummingbird-ml, 0.4.11, MIT License idna, 3.7, BSD License importlib_resources, 6.4.0, Apache Software License -iniconfig, 2.0.0, MIT License -jmespath, 1.0.1, MIT License joblib, 1.4.0, BSD License jsonpickle, 3.0.4, BSD License mpmath, 1.3.0, BSD License networkx, 3.1, BSD License -numpy, 1.23.5, BSD License +numpy, 1.24.3, BSD License nvidia-cublas-cu11, 11.10.3.66, Other/Proprietary License nvidia-cuda-nvrtc-cu11, 11.7.99, Other/Proprietary License nvidia-cuda-runtime-cu11, 11.7.99, Other/Proprietary License nvidia-cudnn-cu11, 8.5.0.96, Other/Proprietary License -onnx, 1.15.0, Apache License v2.0 +onnx, 1.16.0, Apache License v2.0 onnxconverter-common, 1.13.0, MIT License -onnxmltools, 1.11.0, Apache Software License +onnxmltools, 1.12.0, Apache Software License onnxoptimizer, 0.3.13, Apache License v2.0 onnxruntime, 1.17.3, MIT License packaging, 24.0, Apache Software License; BSD License pandas, 2.0.3, BSD License -pluggy, 1.5.0, MIT License protobuf, 3.20.3, BSD-3-Clause psutil, 5.9.8, BSD License -pydantic, 1.10.15, MIT License -pytest, 7.4.1, MIT License -pytest-json-report, 1.5.0, MIT -pytest-metadata, 3.1.1, Mozilla Public License 2.0 (MPL 2.0) python-dateutil, 2.9.0.post0, Apache Software License; BSD License pytz, 2024.1, MIT License -regex, 2024.4.16, Apache Software License requests, 2.31.0, Apache Software License -s3transfer, 0.10.1, Apache Software License -safetensors, 0.4.3, Apache Software License -scikit-learn, 1.1.3, BSD License +scikit-learn, 1.3.2, BSD License scipy, 1.10.1, BSD License six, 1.16.0, MIT License -skl2onnx, 1.12, Apache Software License +skl2onnx, 1.16.0, Apache Software License skops, 0.5.0, MIT skorch, 0.11.0, new BSD 3-Clause -smmap, 5.0.1, BSD License -sniffio, 1.3.1, Apache Software License; MIT License -starlette, 0.27.0, BSD License sympy, 1.12, BSD License tabulate, 0.8.10, MIT License -threadpoolctl, 3.4.0, BSD License -tokenizers, 0.19.1, Apache Software License -tomli, 2.0.1, MIT License +threadpoolctl, 3.5.0, BSD License torch, 1.13.1, BSD License tqdm, 4.66.2, MIT License; Mozilla Public License 2.0 (MPL 2.0) -transformers, 4.40.0, Apache Software License typing_extensions, 4.5.0, Python Software Foundation License tzdata, 2024.1, Apache Software License urllib3, 2.2.1, MIT License -uvicorn, 0.21.1, BSD License -xgboost, 1.6.2, Apache Software License +xgboost, 1.7.6, Apache Software License z3-solver, 4.13.0.0, MIT License diff --git a/deps_licenses/licenses_linux_user.txt.md5 b/deps_licenses/licenses_linux_user.txt.md5 index 52bb282cc..8b9371fc0 100644 --- a/deps_licenses/licenses_linux_user.txt.md5 +++ b/deps_licenses/licenses_linux_user.txt.md5 @@ -1 +1 @@ -ae40a75edf0bfc21ffa11c3d59deaf7c +04e7118e6e1ab280b1e727c7911f66a7 diff --git a/deps_licenses/licenses_mac_intel_user.txt b/deps_licenses/licenses_mac_intel_user.txt index 039425cab..db194acd7 100644 --- a/deps_licenses/licenses_mac_intel_user.txt +++ b/deps_licenses/licenses_mac_intel_user.txt @@ -1,76 +1,50 @@ Name, Version, License -GitPython, 3.1.41, BSD License PyYAML, 6.0.1, MIT License -anyio, 3.7.1, MIT License -boto3, 1.34.88, Apache Software License -botocore, 1.34.88, Apache Software License brevitas, 0.8.0, UNKNOWN -certifi, 2023.7.22, Mozilla Public License 2.0 (MPL 2.0) +certifi, 2024.2.2, Mozilla Public License 2.0 (MPL 2.0) charset-normalizer, 3.3.2, MIT License -click, 8.1.7, BSD License coloredlogs, 15.0.1, MIT License concrete-python, 2024.4.19, BSD-3-Clause dependencies, 2.0.1, BSD License dill, 0.3.8, BSD License -exceptiongroup, 1.2.1, MIT License -fastapi, 0.103.2, MIT License -filelock, 3.13.4, The Unlicense (Unlicense) +filelock, 3.14.0, The Unlicense (Unlicense) flatbuffers, 24.3.25, Apache Software License fsspec, 2024.3.1, BSD License -gitdb, 4.0.11, BSD License -h11, 0.14.0, MIT License huggingface-hub, 0.22.2, Apache Software License humanfriendly, 10.0, MIT License -hummingbird-ml, 0.4.8, MIT License +hummingbird-ml, 0.4.11, MIT License idna, 3.7, BSD License importlib_resources, 6.4.0, Apache Software License -iniconfig, 2.0.0, MIT License -jmespath, 1.0.1, MIT License joblib, 1.4.0, BSD License jsonpickle, 3.0.4, BSD License mpmath, 1.3.0, BSD License networkx, 3.1, BSD License -numpy, 1.23.5, BSD License -onnx, 1.15.0, Apache License v2.0 +numpy, 1.24.3, BSD License +onnx, 1.16.0, Apache License v2.0 onnxconverter-common, 1.13.0, MIT License -onnxmltools, 1.11.0, Apache Software License +onnxmltools, 1.12.0, Apache Software License onnxoptimizer, 0.3.13, Apache License v2.0 onnxruntime, 1.17.3, MIT License packaging, 24.0, Apache Software License; BSD License pandas, 2.0.3, BSD License -pluggy, 1.5.0, MIT License protobuf, 3.20.3, BSD-3-Clause psutil, 5.9.8, BSD License -pydantic, 1.10.15, MIT License -pytest, 7.4.1, MIT License -pytest-json-report, 1.5.0, MIT -pytest-metadata, 3.1.1, Mozilla Public License 2.0 (MPL 2.0) python-dateutil, 2.9.0.post0, Apache Software License; BSD License pytz, 2024.1, MIT License -regex, 2024.4.16, Apache Software License requests, 2.31.0, Apache Software License -s3transfer, 0.10.1, Apache Software License -safetensors, 0.4.3, Apache Software License -scikit-learn, 1.1.3, BSD License +scikit-learn, 1.3.2, BSD License scipy, 1.10.1, BSD License six, 1.16.0, MIT License -skl2onnx, 1.12, Apache Software License +skl2onnx, 1.16.0, Apache Software License skops, 0.5.0, MIT skorch, 0.11.0, new BSD 3-Clause -smmap, 5.0.1, BSD License -sniffio, 1.3.1, Apache Software License; MIT License -starlette, 0.27.0, BSD License sympy, 1.12, BSD License tabulate, 0.8.10, MIT License -threadpoolctl, 3.4.0, BSD License -tokenizers, 0.19.1, Apache Software License -tomli, 2.0.1, MIT License +threadpoolctl, 3.5.0, BSD License torch, 1.13.1, BSD License tqdm, 4.66.2, MIT License; Mozilla Public License 2.0 (MPL 2.0) -transformers, 4.40.0, Apache Software License typing_extensions, 4.5.0, Python Software Foundation License tzdata, 2024.1, Apache Software License urllib3, 2.2.1, MIT License -uvicorn, 0.21.1, BSD License -xgboost, 1.6.2, Apache Software License +xgboost, 1.7.6, Apache Software License z3-solver, 4.13.0.0, MIT License diff --git a/deps_licenses/licenses_mac_intel_user.txt.md5 b/deps_licenses/licenses_mac_intel_user.txt.md5 index 52bb282cc..0aa27f999 100644 --- a/deps_licenses/licenses_mac_intel_user.txt.md5 +++ b/deps_licenses/licenses_mac_intel_user.txt.md5 @@ -1 +1 @@ -ae40a75edf0bfc21ffa11c3d59deaf7c +7be80ba54850fbc203015560c8acb9a8 diff --git a/deps_licenses/licenses_mac_silicon_user.txt b/deps_licenses/licenses_mac_silicon_user.txt index 039425cab..db194acd7 100644 --- a/deps_licenses/licenses_mac_silicon_user.txt +++ b/deps_licenses/licenses_mac_silicon_user.txt @@ -1,76 +1,50 @@ Name, Version, License -GitPython, 3.1.41, BSD License PyYAML, 6.0.1, MIT License -anyio, 3.7.1, MIT License -boto3, 1.34.88, Apache Software License -botocore, 1.34.88, Apache Software License brevitas, 0.8.0, UNKNOWN -certifi, 2023.7.22, Mozilla Public License 2.0 (MPL 2.0) +certifi, 2024.2.2, Mozilla Public License 2.0 (MPL 2.0) charset-normalizer, 3.3.2, MIT License -click, 8.1.7, BSD License coloredlogs, 15.0.1, MIT License concrete-python, 2024.4.19, BSD-3-Clause dependencies, 2.0.1, BSD License dill, 0.3.8, BSD License -exceptiongroup, 1.2.1, MIT License -fastapi, 0.103.2, MIT License -filelock, 3.13.4, The Unlicense (Unlicense) +filelock, 3.14.0, The Unlicense (Unlicense) flatbuffers, 24.3.25, Apache Software License fsspec, 2024.3.1, BSD License -gitdb, 4.0.11, BSD License -h11, 0.14.0, MIT License huggingface-hub, 0.22.2, Apache Software License humanfriendly, 10.0, MIT License -hummingbird-ml, 0.4.8, MIT License +hummingbird-ml, 0.4.11, MIT License idna, 3.7, BSD License importlib_resources, 6.4.0, Apache Software License -iniconfig, 2.0.0, MIT License -jmespath, 1.0.1, MIT License joblib, 1.4.0, BSD License jsonpickle, 3.0.4, BSD License mpmath, 1.3.0, BSD License networkx, 3.1, BSD License -numpy, 1.23.5, BSD License -onnx, 1.15.0, Apache License v2.0 +numpy, 1.24.3, BSD License +onnx, 1.16.0, Apache License v2.0 onnxconverter-common, 1.13.0, MIT License -onnxmltools, 1.11.0, Apache Software License +onnxmltools, 1.12.0, Apache Software License onnxoptimizer, 0.3.13, Apache License v2.0 onnxruntime, 1.17.3, MIT License packaging, 24.0, Apache Software License; BSD License pandas, 2.0.3, BSD License -pluggy, 1.5.0, MIT License protobuf, 3.20.3, BSD-3-Clause psutil, 5.9.8, BSD License -pydantic, 1.10.15, MIT License -pytest, 7.4.1, MIT License -pytest-json-report, 1.5.0, MIT -pytest-metadata, 3.1.1, Mozilla Public License 2.0 (MPL 2.0) python-dateutil, 2.9.0.post0, Apache Software License; BSD License pytz, 2024.1, MIT License -regex, 2024.4.16, Apache Software License requests, 2.31.0, Apache Software License -s3transfer, 0.10.1, Apache Software License -safetensors, 0.4.3, Apache Software License -scikit-learn, 1.1.3, BSD License +scikit-learn, 1.3.2, BSD License scipy, 1.10.1, BSD License six, 1.16.0, MIT License -skl2onnx, 1.12, Apache Software License +skl2onnx, 1.16.0, Apache Software License skops, 0.5.0, MIT skorch, 0.11.0, new BSD 3-Clause -smmap, 5.0.1, BSD License -sniffio, 1.3.1, Apache Software License; MIT License -starlette, 0.27.0, BSD License sympy, 1.12, BSD License tabulate, 0.8.10, MIT License -threadpoolctl, 3.4.0, BSD License -tokenizers, 0.19.1, Apache Software License -tomli, 2.0.1, MIT License +threadpoolctl, 3.5.0, BSD License torch, 1.13.1, BSD License tqdm, 4.66.2, MIT License; Mozilla Public License 2.0 (MPL 2.0) -transformers, 4.40.0, Apache Software License typing_extensions, 4.5.0, Python Software Foundation License tzdata, 2024.1, Apache Software License urllib3, 2.2.1, MIT License -uvicorn, 0.21.1, BSD License -xgboost, 1.6.2, Apache Software License +xgboost, 1.7.6, Apache Software License z3-solver, 4.13.0.0, MIT License diff --git a/deps_licenses/licenses_mac_silicon_user.txt.md5 b/deps_licenses/licenses_mac_silicon_user.txt.md5 index 52bb282cc..0aa27f999 100644 --- a/deps_licenses/licenses_mac_silicon_user.txt.md5 +++ b/deps_licenses/licenses_mac_silicon_user.txt.md5 @@ -1 +1 @@ -ae40a75edf0bfc21ffa11c3d59deaf7c +7be80ba54850fbc203015560c8acb9a8 diff --git a/docs/advanced_examples/Deployment.ipynb b/docs/advanced_examples/Deployment.ipynb deleted file mode 100644 index 7b9a99a42..000000000 --- a/docs/advanced_examples/Deployment.ipynb +++ /dev/null @@ -1,1065 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "e8019f56", - "metadata": {}, - "source": [ - "# Deployment\n", - "\n", - "In this notebook we display how to serve a model in FHE through AWS using python.\n", - "\n", - "In the first block of code we train, compile and serialize our model." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "dff1ab8e", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'\n" - ] - } - ], - "source": [ - "import io\n", - "import shutil\n", - "from pathlib import Path\n", - "\n", - "import numpy\n", - "import requests\n", - "from sklearn.datasets import load_breast_cancer\n", - "from tqdm import tqdm\n", - "\n", - "from concrete.ml.deployment import FHEModelClient, FHEModelDev\n", - "from concrete.ml.deployment.deploy_to_aws import AWSInstance, deploy_to_aws\n", - "from concrete.ml.sklearn import XGBClassifier\n", - "\n", - "# Let's first get some data and train a model.\n", - "X, y = load_breast_cancer(return_X_y=True)\n", - "\n", - "assert isinstance(X, numpy.ndarray)\n", - "assert isinstance(y, numpy.ndarray)\n", - "\n", - "# Split X into X_model_owner and X_client\n", - "X_train = X[:-10]\n", - "y_train = y[:-10]\n", - "\n", - "X_test = X[-10:]\n", - "y_test = y[-10:]\n", - "\n", - "# Train the model and compile it\n", - "model = XGBClassifier(n_bits=2, n_estimators=8, max_depth=3)\n", - "model.fit(X_train, y_train)\n", - "\n", - "\n", - "path_to_model = Path(\"./serialized_model\").resolve()\n", - "if path_to_model.exists():\n", - " shutil.rmtree(path_to_model)\n", - "model.compile(X_train)\n", - "dev = FHEModelDev(path_to_model, model)\n", - "dev.save(via_mlir=True) # Needed for cross-platform deployment" - ] - }, - { - "cell_type": "markdown", - "id": "55d13d30", - "metadata": {}, - "source": [ - "In Concrete ML we expose a context manager called `AWSDeploy` that deploys the model to a AWS EC2 instance.\n", - "\n", - "Using a context manager allows for proper termination of the instance once the computation is finished.\n", - "\n", - "For persisting the instance/server consider using the `deploy_to_aws` method instead." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "506a0e28", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Security Group Created sg-07f05840eb7ade459 in vpc vpc-0677a14476c51231f.\n", - "Instance took 15.56025743484497 seconds to start running\n", - "Waiting for SSH connexion to be available...\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "9it [00:15, 1.78s/it]\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "SSH connexion available.\n", - "upload files...\n", - "upload finished.\n", - "ssh -i /home/luis/Documents/3068-can-we-call-your-deployment-script-directly-from-py-notebooks/src/concrete/ml/deployment/ssh_keys/cml_notebook_demo-2023_03_21_10_41_02-keypair.pem -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -o RequestTTY=yes ubuntu@13.37.225.25 \"tmux new-session -d -s cml_notebook_demo-2023_03_21_10_41_02 sudo chmod -R 777 /home/ubuntu/venv && sudo apt install -y python3.8 && sudo apt install -y python3.8-distutils && virtualenv deployment_venv --python=python3.8 && source deployment_venv/bin/activate && python -m pip install -r server_requirements.txt && python -m pip install concrete-ml==0.6.1 && python -m pip install concrete-compiler==0.24.0rc5 && PORT=5000 PATH_TO_MODEL=\"./serialized_model\" python ./server.py\"\n", - "Pseudo-terminal will not be allocated because stdin is not a terminal.\n", - "\n", - "\n", - "\n", - "WARNING: apt does not have a stable CLI interface. Use with caution in scripts.\n", - "\n", - "\n", - "\n", - "Reading package lists...\n", - "\n", - "Building dependency tree...\n", - "\n", - "Reading state information...\n", - "\n", - "The following additional packages will be installed:\n", - "\n", - " libpython3.8-minimal libpython3.8-stdlib python3.8-minimal\n", - "\n", - "Suggested packages:\n", - "\n", - " python3.8-venv binfmt-support\n", - "\n", - "The following NEW packages will be installed:\n", - "\n", - " libpython3.8-minimal libpython3.8-stdlib python3.8 python3.8-minimal\n", - "\n", - "0 upgraded, 4 newly installed, 0 to remove and 2 not upgraded.\n", - "\n", - "Need to get 5067 kB of archives.\n", - "\n", - "After this operation, 18.8 MB of additional disk space will be used.\n", - "\n", - "Get:1 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy/main amd64 libpython3.8-minimal amd64 3.8.16-1+jammy1 [792 kB]\n", - "\n", - "Get:2 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy/main amd64 python3.8-minimal amd64 3.8.16-1+jammy1 [2023 kB]\n", - "\n", - "Get:3 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy/main amd64 libpython3.8-stdlib amd64 3.8.16-1+jammy1 [1815 kB]\n", - "\n", - "Get:4 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy/main amd64 python3.8 amd64 3.8.16-1+jammy1 [437 kB]\n", - "\n", - "perl: warning: Setting locale failed.\n", - "\n", - "perl: warning: Please check that your locale settings:\n", - "\n", - "\tLANGUAGE = (unset),\n", - "\n", - "\tLC_ALL = (unset),\n", - "\n", - "\tLC_TIME = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_MONETARY = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_ADDRESS = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_TELEPHONE = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_NAME = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_MEASUREMENT = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_IDENTIFICATION = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_NUMERIC = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_PAPER = \"fr_FR.UTF-8\",\n", - "\n", - "\tLANG = \"C.UTF-8\"\n", - "\n", - " are supported and installed on your system.\n", - "\n", - "perl: warning: Falling back to a fallback locale (\"C.UTF-8\").\n", - "\n", - "locale: Cannot set LC_ALL to default locale: No such file or directory\n", - "\n", - "debconf: unable to initialize frontend: Dialog\n", - "\n", - "debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)\n", - "\n", - "debconf: falling back to frontend: Readline\n", - "\n", - "Fetched 5067 kB in 1s (8720 kB/s)\n", - "\n", - "debconf: unable to initialize frontend: Readline\n", - "\n", - "debconf: (This frontend requires a controlling tty.)\n", - "\n", - "debconf: falling back to frontend: Teletype\n", - "\n", - "dpkg-preconfigure: unable to re-open stdin: \n", - "\n", - "Selecting previously unselected package libpython3.8-minimal:amd64.\n", - "\n", - "(Reading database ... \n", - "\n", - "(Reading database ... 5%\n", - "\n", - "(Reading database ... 10%\n", - "\n", - "(Reading database ... 15%\n", - "\n", - "(Reading database ... 20%\n", - "\n", - "(Reading database ... 25%\n", - "\n", - "(Reading database ... 30%\n", - "\n", - "(Reading database ... 35%\n", - "\n", - "(Reading database ... 40%\n", - "\n", - "(Reading database ... 45%\n", - "\n", - "(Reading database ... 50%\n", - "\n", - "(Reading database ... 55%\n", - "\n", - "(Reading database ... 60%\n", - "\n", - "(Reading database ... 65%\n", - "\n", - "(Reading database ... 70%\n", - "\n", - "(Reading database ... 75%\n", - "\n", - "(Reading database ... 80%\n", - "\n", - "(Reading database ... 85%\n", - "\n", - "(Reading database ... 90%\n", - "\n", - "(Reading database ... 95%\n", - "\n", - "(Reading database ... 100%\n", - "\n", - "(Reading database ... 100502 files and directories currently installed.)\n", - "\n", - "Preparing to unpack .../libpython3.8-minimal_3.8.16-1+jammy1_amd64.deb ...\n", - "\n", - "Unpacking libpython3.8-minimal:amd64 (3.8.16-1+jammy1) ...\n", - "\n", - "Selecting previously unselected package python3.8-minimal.\n", - "\n", - "Preparing to unpack .../python3.8-minimal_3.8.16-1+jammy1_amd64.deb ...\n", - "\n", - "Unpacking python3.8-minimal (3.8.16-1+jammy1) ...\n", - "\n", - "Selecting previously unselected package libpython3.8-stdlib:amd64.\n", - "\n", - "Preparing to unpack .../libpython3.8-stdlib_3.8.16-1+jammy1_amd64.deb ...\n", - "\n", - "Unpacking libpython3.8-stdlib:amd64 (3.8.16-1+jammy1) ...\n", - "\n", - "Selecting previously unselected package python3.8.\n", - "\n", - "Preparing to unpack .../python3.8_3.8.16-1+jammy1_amd64.deb ...\n", - "\n", - "Unpacking python3.8 (3.8.16-1+jammy1) ...\n", - "\n", - "Setting up libpython3.8-minimal:amd64 (3.8.16-1+jammy1) ...\n", - "\n", - "Setting up python3.8-minimal (3.8.16-1+jammy1) ...\n", - "\n", - "Setting up libpython3.8-stdlib:amd64 (3.8.16-1+jammy1) ...\n", - "\n", - "Setting up python3.8 (3.8.16-1+jammy1) ...\n", - "\n", - "Processing triggers for man-db (2.10.2-1) ...\n", - "\n", - "Processing triggers for mailcap (3.70+nmu1ubuntu1) ...\n", - "\n", - "perl: warning: Setting locale failed.\n", - "\n", - "perl: warning: Please check that your locale settings:\n", - "\n", - "\tLANGUAGE = (unset),\n", - "\n", - "\tLC_ALL = (unset),\n", - "\n", - "\tLC_TIME = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_MONETARY = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_ADDRESS = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_TELEPHONE = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_NAME = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_MEASUREMENT = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_IDENTIFICATION = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_NUMERIC = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_PAPER = \"fr_FR.UTF-8\",\n", - "\n", - "\tLANG = \"C.UTF-8\"\n", - "\n", - " are supported and installed on your system.\n", - "\n", - "perl: warning: Falling back to a fallback locale (\"C.UTF-8\").\n", - "\n", - "\n", - "\n", - "Running kernel seems to be up-to-date.\n", - "\n", - "\n", - "\n", - "No services need to be restarted.\n", - "\n", - "\n", - "\n", - "No containers need to be restarted.\n", - "\n", - "\n", - "\n", - "No user sessions are running outdated binaries.\n", - "\n", - "\n", - "\n", - "No VM guests are running outdated hypervisor (qemu) binaries on this host.\n", - "\n", - "\n", - "\n", - "WARNING: apt does not have a stable CLI interface. Use with caution in scripts.\n", - "\n", - "Reading package lists...\n", - "\n", - "Building dependency tree...\n", - "\n", - "\n", - "\n", - "Reading state information...\n", - "\n", - "The following additional packages will be installed:\n", - "\n", - " python3.8-lib2to3\n", - "\n", - "The following NEW packages will be installed:\n", - "\n", - " python3.8-distutils python3.8-lib2to3\n", - "\n", - "0 upgraded, 2 newly installed, 0 to remove and 2 not upgraded.\n", - "\n", - "Need to get 319 kB of archives.\n", - "\n", - "After this operation, 1237 kB of additional disk space will be used.\n", - "\n", - "Get:1 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy/main amd64 python3.8-lib2to3 all 3.8.16-1+jammy1 [126 kB]\n", - "\n", - "Get:2 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy/main amd64 python3.8-distutils all 3.8.16-1+jammy1 [193 kB]\n", - "\n", - "perl: warning: Setting locale failed.\n", - "\n", - "perl: warning: Please check that your locale settings:\n", - "\n", - "\tLANGUAGE = (unset),\n", - "\n", - "\tLC_ALL = (unset),\n", - "\n", - "\tLC_TIME = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_MONETARY = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_ADDRESS = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_TELEPHONE = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_NAME = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_MEASUREMENT = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_IDENTIFICATION = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_NUMERIC = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_PAPER = \"fr_FR.UTF-8\",\n", - "\n", - "\tLANG = \"C.UTF-8\"\n", - "\n", - " are supported and installed on your system.\n", - "\n", - "perl: warning: Falling back to a fallback locale (\"C.UTF-8\").\n", - "\n", - "locale: Cannot set LC_ALL to default locale: No such file or directory\n", - "\n", - "debconf: unable to initialize frontend: Dialog\n", - "\n", - "debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)\n", - "\n", - "debconf: falling back to frontend: Readline\n", - "\n", - "debconf: unable to initialize frontend: Readline\n", - "\n", - "debconf: (This frontend requires a controlling tty.)\n", - "\n", - "debconf: falling back to frontend: Teletype\n", - "\n", - "dpkg-preconfigure: unable to re-open stdin: \n", - "\n", - "Fetched 319 kB in 0s (1698 kB/s)\n", - "\n", - "Selecting previously unselected package python3.8-lib2to3.\n", - "\n", - "(Reading database ... \n", - "\n", - "(Reading database ... 5%\n", - "\n", - "(Reading database ... 10%\n", - "\n", - "(Reading database ... 15%\n", - "\n", - "(Reading database ... 20%\n", - "\n", - "(Reading database ... 25%\n", - "\n", - "(Reading database ... 30%\n", - "\n", - "(Reading database ... 35%\n", - "\n", - "(Reading database ... 40%\n", - "\n", - "(Reading database ... 45%\n", - "\n", - "(Reading database ... 50%\n", - "\n", - "(Reading database ... 55%\n", - "\n", - "(Reading database ... 60%\n", - "\n", - "(Reading database ... 65%\n", - "\n", - "(Reading database ... 70%\n", - "\n", - "(Reading database ... 75%\n", - "\n", - "(Reading database ... 80%\n", - "\n", - "(Reading database ... 85%\n", - "\n", - "(Reading database ... 90%\n", - "\n", - "(Reading database ... 95%\n", - "\n", - "(Reading database ... 100%\n", - "\n", - "(Reading database ... 101128 files and directories currently installed.)\n", - "\n", - "Preparing to unpack .../python3.8-lib2to3_3.8.16-1+jammy1_all.deb ...\n", - "\n", - "Unpacking python3.8-lib2to3 (3.8.16-1+jammy1) ...\n", - "\n", - "Selecting previously unselected package python3.8-distutils.\n", - "\n", - "Preparing to unpack .../python3.8-distutils_3.8.16-1+jammy1_all.deb ...\n", - "\n", - "Unpacking python3.8-distutils (3.8.16-1+jammy1) ...\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Setting up python3.8-lib2to3 (3.8.16-1+jammy1) ...\n", - "\n", - "Setting up python3.8-distutils (3.8.16-1+jammy1) ...\n", - "\n", - "perl: warning: Setting locale failed.\n", - "\n", - "perl: warning: Please check that your locale settings:\n", - "\n", - "\tLANGUAGE = (unset),\n", - "\n", - "\tLC_ALL = (unset),\n", - "\n", - "\tLC_TIME = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_MONETARY = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_ADDRESS = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_TELEPHONE = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_NAME = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_MEASUREMENT = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_IDENTIFICATION = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_NUMERIC = \"fr_FR.UTF-8\",\n", - "\n", - "\tLC_PAPER = \"fr_FR.UTF-8\",\n", - "\n", - "\tLANG = \"C.UTF-8\"\n", - "\n", - " are supported and installed on your system.\n", - "\n", - "perl: warning: Falling back to a fallback locale (\"C.UTF-8\").\n", - "\n", - "\n", - "\n", - "Running kernel seems to be up-to-date.\n", - "\n", - "\n", - "\n", - "No services need to be restarted.\n", - "\n", - "\n", - "\n", - "No containers need to be restarted.\n", - "\n", - "\n", - "\n", - "No user sessions are running outdated binaries.\n", - "\n", - "\n", - "\n", - "No VM guests are running outdated hypervisor (qemu) binaries on this host.\n", - "\n", - "created virtual environment CPython3.8.16.final.0-64 in 1282ms\n", - "\n", - " creator CPython3Posix(dest=/home/ubuntu/deployment_venv, clear=False, no_vcs_ignore=False, global=False)\n", - "\n", - " seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/ubuntu/.local/share/virtualenv)\n", - "\n", - " added seed packages: pip==22.0.2, setuptools==59.6.0, wheel==0.37.1\n", - "\n", - " activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator\n", - "\n", - "Collecting fastapi\n", - "\n", - " Downloading fastapi-0.95.0-py3-none-any.whl (57 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.1/57.1 KB 2.6 MB/s eta 0:00:00\n", - "\n", - "Collecting uvicorn\n", - "\n", - " Downloading uvicorn-0.21.1-py3-none-any.whl (57 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.8/57.8 KB 6.4 MB/s eta 0:00:00\n", - "\n", - "Collecting python-multipart\n", - "\n", - " Downloading python_multipart-0.0.6-py3-none-any.whl (45 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 45.7/45.7 KB 9.2 MB/s eta 0:00:00\n", - "\n", - "Collecting starlette<0.27.0,>=0.26.1\n", - "\n", - " Downloading starlette-0.26.1-py3-none-any.whl (66 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 66.9/66.9 KB 12.3 MB/s eta 0:00:00\n", - "\n", - "Collecting pydantic!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0,>=1.6.2\n", - "\n", - " Downloading pydantic-1.10.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 87.2 MB/s eta 0:00:00\n", - "\n", - "Collecting click>=7.0\n", - "\n", - " Downloading click-8.1.3-py3-none-any.whl (96 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 96.6/96.6 KB 24.9 MB/s eta 0:00:00\n", - "\n", - "Collecting h11>=0.8\n", - "\n", - " Downloading h11-0.14.0-py3-none-any.whl (58 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.3/58.3 KB 15.6 MB/s eta 0:00:00\n", - "\n", - "Collecting typing-extensions>=4.2.0\n", - "\n", - " Downloading typing_extensions-4.5.0-py3-none-any.whl (27 kB)\n", - "\n", - "Collecting anyio<5,>=3.4.0\n", - "\n", - " Downloading anyio-3.6.2-py3-none-any.whl (80 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 80.6/80.6 KB 18.0 MB/s eta 0:00:00\n", - "\n", - "Collecting sniffio>=1.1\n", - "\n", - " Downloading sniffio-1.3.0-py3-none-any.whl (10 kB)\n", - "\n", - "Collecting idna>=2.8\n", - "\n", - " Downloading idna-3.4-py3-none-any.whl (61 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 KB 15.4 MB/s eta 0:00:00\n", - "\n", - "Installing collected packages: typing-extensions, sniffio, python-multipart, idna, h11, click, uvicorn, pydantic, anyio, starlette, fastapi\n", - "\n", - "Successfully installed anyio-3.6.2 click-8.1.3 fastapi-0.95.0 h11-0.14.0 idna-3.4 pydantic-1.10.6 python-multipart-0.0.6 sniffio-1.3.0 starlette-0.26.1 typing-extensions-4.5.0 uvicorn-0.21.1\n", - "\n", - "Collecting concrete-ml==0.6.1\n", - "\n", - " Downloading concrete_ml-0.6.1-py3-none-any.whl (119 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119.2/119.2 KB 3.7 MB/s eta 0:00:00\n", - "\n", - "Collecting numpy==1.21.6\n", - "\n", - " Downloading numpy-1.21.6-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.7 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.7/15.7 MB 94.4 MB/s eta 0:00:00\n", - "\n", - "Collecting concrete-numpy==0.9.0\n", - "\n", - " Downloading concrete_numpy-0.9.0-py3-none-any.whl (82 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 82.1/82.1 KB 1.3 MB/s eta 0:00:00\n", - "\n", - "Collecting scipy==1.7.3\n", - "\n", - " Downloading scipy-1.7.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (39.3 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 39.3/39.3 MB 51.4 MB/s eta 0:00:00\n", - "\n", - "Collecting protobuf==3.19.4\n", - "\n", - " Downloading protobuf-3.19.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 100.2 MB/s eta 0:00:00\n", - "\n", - "Collecting skorch==0.11.0\n", - "\n", - " Downloading skorch-0.11.0-py3-none-any.whl (155 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 155.1/155.1 KB 2.3 MB/s eta 0:00:00\n", - "\n", - "Collecting typing-extensions==4.4.0\n", - "\n", - " Downloading typing_extensions-4.4.0-py3-none-any.whl (26 kB)\n", - "\n", - "Collecting xgboost==1.6.2\n", - "\n", - " Downloading xgboost-1.6.2-py3-none-manylinux2014_x86_64.whl (255.9 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 255.9/255.9 MB 2.9 MB/s eta 0:00:00\n", - "\n", - "Collecting onnx==1.12.0\n", - "\n", - " Downloading onnx-1.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.1 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.1/13.1 MB 103.8 MB/s eta 0:00:00\n", - "\n", - "Collecting hummingbird-ml[onnx]==0.4.4\n", - "\n", - " Downloading hummingbird_ml-0.4.4-py2.py3-none-any.whl (181 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 181.5/181.5 KB 38.0 MB/s eta 0:00:00\n", - "\n", - "Collecting torch==1.12.1\n", - "\n", - " Downloading torch-1.12.1-cp38-cp38-manylinux1_x86_64.whl (776.3 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 776.3/776.3 MB 425.9 kB/s eta 0:00:00\n", - "\n", - "Collecting scikit-learn==1.0.2\n", - "\n", - " Downloading scikit_learn-1.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (26.7 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 26.7/26.7 MB 64.6 MB/s eta 0:00:00\n", - "\n", - "Collecting concrete-ml-extensions-brevitas==0.1.0\n", - "\n", - " Downloading concrete_ml_extensions_brevitas-0.1.0-py3-none-any.whl (414 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 414.4/414.4 KB 62.3 MB/s eta 0:00:00\n", - "\n", - "Collecting setuptools==65.6.3\n", - "\n", - " Downloading setuptools-65.6.3-py3-none-any.whl (1.2 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 97.5 MB/s eta 0:00:00\n", - "\n", - "Collecting onnxoptimizer==0.2.7\n", - "\n", - " Downloading onnxoptimizer-0.2.7-cp38-cp38-manylinux2014_x86_64.whl (499 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 499.4/499.4 KB 67.3 MB/s eta 0:00:00\n", - "\n", - "Collecting future-annotations\n", - "\n", - " Downloading future_annotations-1.0.0-py2.py3-none-any.whl (5.6 kB)\n", - "\n", - "Collecting packaging\n", - "\n", - " Downloading packaging-23.0-py3-none-any.whl (42 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.7/42.7 KB 11.2 MB/s eta 0:00:00\n", - "\n", - "Collecting dependencies==2.0.1\n", - "\n", - " Downloading dependencies-2.0.1-py2.py3-none-any.whl (15 kB)\n", - "\n", - "Collecting matplotlib<4.0.0,>=3.5.1\n", - "\n", - " Downloading matplotlib-3.7.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (9.2 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9.2/9.2 MB 121.1 MB/s eta 0:00:00\n", - "\n", - "Collecting Pillow<10.0.0,>=9.0.0\n", - "\n", - " Downloading Pillow-9.4.0-cp38-cp38-manylinux_2_28_x86_64.whl (3.4 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.4/3.4 MB 39.9 MB/s eta 0:00:00\n", - "\n", - "Collecting networkx<3.0.0,>=2.6.3\n", - "\n", - " Downloading networkx-2.8.8-py3-none-any.whl (2.0 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.0/2.0 MB 117.2 MB/s eta 0:00:00\n", - "\n", - "Collecting concrete-compiler<0.24.0,>=0.23.1\n", - "\n", - " Downloading concrete_compiler-0.23.4-cp38-cp38-manylinux_2_28_x86_64.whl (56.7 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 56.7/56.7 MB 38.7 MB/s eta 0:00:00\n", - "\n", - "Collecting onnxconverter-common>=1.6.0\n", - "\n", - " Downloading onnxconverter_common-1.13.0-py2.py3-none-any.whl (83 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 83.8/83.8 KB 1.0 MB/s eta 0:00:00\n", - "\n", - "Collecting psutil\n", - "\n", - " Downloading psutil-5.9.4-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (280 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 280.2/280.2 KB 43.6 MB/s eta 0:00:00\n", - "\n", - "Collecting dill\n", - "\n", - " Downloading dill-0.3.6-py3-none-any.whl (110 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 110.5/110.5 KB 28.3 MB/s eta 0:00:00\n", - "\n", - "Collecting onnxruntime>=1.0.0\n", - "\n", - " Downloading onnxruntime-1.14.1-cp38-cp38-manylinux_2_27_x86_64.whl (5.0 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.0/5.0 MB 64.9 MB/s eta 0:00:00\n", - "\n", - "Collecting skl2onnx>=1.7.0\n", - "\n", - " Downloading skl2onnx-1.14.0-py2.py3-none-any.whl (294 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 294.0/294.0 KB 50.7 MB/s eta 0:00:00\n", - "\n", - "Collecting onnxmltools>=1.6.0\n", - "\n", - " Downloading onnxmltools-1.11.2-py2.py3-none-any.whl (322 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 322.5/322.5 KB 52.3 MB/s eta 0:00:00\n", - "\n", - "Collecting joblib>=0.11\n", - "\n", - " Downloading joblib-1.2.0-py3-none-any.whl (297 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 298.0/298.0 KB 6.8 MB/s eta 0:00:00\n", - "\n", - "Collecting threadpoolctl>=2.0.0\n", - "\n", - " Downloading threadpoolctl-3.1.0-py3-none-any.whl (14 kB)\n", - "\n", - "Collecting tqdm>=4.14.0\n", - "\n", - " Downloading tqdm-4.65.0-py3-none-any.whl (77 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.1/77.1 KB 20.4 MB/s eta 0:00:00\n", - "\n", - "Collecting tabulate>=0.7.7\n", - "\n", - " Downloading tabulate-0.9.0-py3-none-any.whl (35 kB)\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Collecting PyYAML\n", - "\n", - " Downloading PyYAML-6.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (701 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 701.2/701.2 KB 82.1 MB/s eta 0:00:00\n", - "\n", - "Collecting fonttools>=4.22.0\n", - "\n", - " Downloading fonttools-4.39.2-py3-none-any.whl (1.0 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.0/1.0 MB 97.2 MB/s eta 0:00:00\n", - "\n", - "Collecting cycler>=0.10\n", - "\n", - " Downloading cycler-0.11.0-py3-none-any.whl (6.4 kB)\n", - "\n", - "Collecting pyparsing>=2.3.1\n", - "\n", - " Downloading pyparsing-3.0.9-py3-none-any.whl (98 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.3/98.3 KB 27.0 MB/s eta 0:00:00\n", - "\n", - "Collecting importlib-resources>=3.2.0\n", - "\n", - " Downloading importlib_resources-5.12.0-py3-none-any.whl (36 kB)\n", - "\n", - "Collecting kiwisolver>=1.0.1\n", - "\n", - " Downloading kiwisolver-1.4.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.2 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 99.0 MB/s eta 0:00:00\n", - "\n", - "Collecting contourpy>=1.0.1\n", - "\n", - " Downloading contourpy-1.0.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (300 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 300.0/300.0 KB 48.4 MB/s eta 0:00:00\n", - "\n", - "Collecting python-dateutil>=2.7\n", - "\n", - " Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 KB 49.8 MB/s eta 0:00:00\n", - "\n", - "Collecting sympy\n", - "\n", - " Downloading sympy-1.11.1-py3-none-any.whl (6.5 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.5/6.5 MB 120.7 MB/s eta 0:00:00\n", - "\n", - "Collecting coloredlogs\n", - "\n", - " Downloading coloredlogs-15.0.1-py2.py3-none-any.whl (46 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 46.0/46.0 KB 11.6 MB/s eta 0:00:00\n", - "\n", - "Collecting flatbuffers\n", - "\n", - " Downloading flatbuffers-23.3.3-py2.py3-none-any.whl (26 kB)\n", - "\n", - "Collecting tokenize-rt>=3\n", - "\n", - " Downloading tokenize_rt-5.0.0-py2.py3-none-any.whl (5.8 kB)\n", - "\n", - "Collecting zipp>=3.1.0\n", - "\n", - " Downloading zipp-3.15.0-py3-none-any.whl (6.8 kB)\n", - "\n", - "Collecting six>=1.5\n", - "\n", - " Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)\n", - "\n", - "Collecting humanfriendly>=9.1\n", - "\n", - " Downloading humanfriendly-10.0-py2.py3-none-any.whl (86 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 86.8/86.8 KB 22.1 MB/s eta 0:00:00\n", - "\n", - "Collecting mpmath>=0.19\n", - "\n", - " Downloading mpmath-1.3.0-py3-none-any.whl (536 kB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 536.2/536.2 KB 68.8 MB/s eta 0:00:00\n", - "\n", - "Installing collected packages: mpmath, flatbuffers, zipp, typing-extensions, tqdm, tokenize-rt, threadpoolctl, tabulate, sympy, six, setuptools, PyYAML, pyparsing, psutil, protobuf, Pillow, packaging, numpy, networkx, kiwisolver, joblib, humanfriendly, fonttools, dill, dependencies, cycler, torch, scipy, python-dateutil, onnx, importlib-resources, future-annotations, contourpy, concrete-compiler, coloredlogs, xgboost, scikit-learn, onnxruntime, onnxoptimizer, onnxconverter-common, matplotlib, concrete-ml-extensions-brevitas, skorch, skl2onnx, hummingbird-ml, concrete-numpy, onnxmltools, concrete-ml\n", - "\n", - " Attempting uninstall: typing-extensions\n", - "\n", - " Found existing installation: typing_extensions 4.5.0\n", - "\n", - " Uninstalling typing_extensions-4.5.0:\n", - "\n", - " Successfully uninstalled typing_extensions-4.5.0\n", - "\n", - " Attempting uninstall: setuptools\n", - "\n", - " Found existing installation: setuptools 59.6.0\n", - "\n", - " Uninstalling setuptools-59.6.0:\n", - "\n", - " Successfully uninstalled setuptools-59.6.0\n", - "\n", - "Successfully installed Pillow-9.4.0 PyYAML-6.0 coloredlogs-15.0.1 concrete-compiler-0.23.4 concrete-ml-0.6.1 concrete-ml-extensions-brevitas-0.1.0 concrete-numpy-0.9.0 contourpy-1.0.7 cycler-0.11.0 dependencies-2.0.1 dill-0.3.6 flatbuffers-23.3.3 fonttools-4.39.2 future-annotations-1.0.0 humanfriendly-10.0 hummingbird-ml-0.4.4 importlib-resources-5.12.0 joblib-1.2.0 kiwisolver-1.4.4 matplotlib-3.7.1 mpmath-1.3.0 networkx-2.8.8 numpy-1.21.6 onnx-1.12.0 onnxconverter-common-1.13.0 onnxmltools-1.11.2 onnxoptimizer-0.2.7 onnxruntime-1.14.1 packaging-23.0 protobuf-3.19.4 psutil-5.9.4 pyparsing-3.0.9 python-dateutil-2.8.2 scikit-learn-1.0.2 scipy-1.7.3 setuptools-65.6.3 six-1.16.0 skl2onnx-1.14.0 skorch-0.11.0 sympy-1.11.1 tabulate-0.9.0 threadpoolctl-3.1.0 tokenize-rt-5.0.0 torch-1.12.1 tqdm-4.65.0 typing-extensions-4.4.0 xgboost-1.6.2 zipp-3.15.0\n", - "\n", - "Collecting concrete-compiler==0.24.0rc5\n", - "\n", - " Downloading concrete_compiler-0.24.0rc5-cp38-cp38-manylinux_2_28_x86_64.whl (67.1 MB)\n", - "\n", - " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 67.1/67.1 MB 8.5 MB/s eta 0:00:00\n", - "\n", - "Requirement already satisfied: numpy in ./deployment_venv/lib/python3.8/site-packages (from concrete-compiler==0.24.0rc5) (1.21.6)\n", - "\n", - "Requirement already satisfied: PyYAML in ./deployment_venv/lib/python3.8/site-packages (from concrete-compiler==0.24.0rc5) (6.0)\n", - "\n", - "Requirement already satisfied: setuptools in ./deployment_venv/lib/python3.8/site-packages (from concrete-compiler==0.24.0rc5) (65.6.3)\n", - "\n", - "Installing collected packages: concrete-compiler\n", - "\n", - " Attempting uninstall: concrete-compiler\n", - "\n", - " Found existing installation: concrete-compiler 0.23.4\n", - "\n", - " Uninstalling concrete-compiler-0.23.4:\n", - "\n", - " Successfully uninstalled concrete-compiler-0.23.4\n", - "\n", - "Successfully installed concrete-compiler-0.24.0rc5\n", - "\n", - "ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n", - "\n", - "concrete-numpy 0.9.0 requires concrete-compiler<0.24.0,>=0.23.1, but you have concrete-compiler 0.24.0rc5 which is incompatible.\n", - "\n", - "INFO: Started server process [884]\n", - "\n", - "INFO: Waiting for application startup.\n", - "\n", - "INFO: Application startup complete.\n", - "\n", - "INFO: Uvicorn running on http://0.0.0.0\n", - "Evaluation keys size: 72.23 MB\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:16<00:00, 1.63s/it]\n" - ] - } - ], - "source": [ - "status_ok = 200\n", - "client_folder = Path(\"./client_folder\")\n", - "client_folder.mkdir(exist_ok=True)\n", - "\n", - "with AWSInstance(\n", - " instance_type=\"c5.large\",\n", - " verbose=True,\n", - " instance_name=\"cml_notebook_demo\",\n", - ") as instance_metadata:\n", - " deploy_to_aws(\n", - " path_to_model=path_to_model,\n", - " instance_metadata=instance_metadata,\n", - " verbose=True,\n", - " wait_bar=True,\n", - " )\n", - " url = instance_metadata[\"URL\"]\n", - "\n", - " zip_response = requests.get(f\"{url}/get_client\")\n", - " assert zip_response.status_code == status_ok\n", - " with open(client_folder / \"client.zip\", \"wb\") as file:\n", - " file.write(zip_response.content)\n", - "\n", - " # Let's create the client using what we got from the server\n", - " client = FHEModelClient(path_dir=client_folder, key_dir=client_folder / \"keys\")\n", - "\n", - " # The client first need to create the private and evaluation keys.\n", - " client.generate_private_and_evaluation_keys()\n", - "\n", - " # Get the serialized evaluation keys\n", - " serialized_evaluation_keys = client.get_serialized_evaluation_keys()\n", - " assert isinstance(serialized_evaluation_keys, bytes)\n", - "\n", - " # Evaluation keys can be quite large files but only have to be shared once with the server.\n", - "\n", - " # Check the size of the evaluation keys (in MB)\n", - " print(f\"Evaluation keys size: {len(serialized_evaluation_keys) / (10**6):.2f} MB\")\n", - "\n", - " # Let's send this evaluation key to the server (this has to be done only once)\n", - " # send_evaluation_key_to_server(serialized_evaluation_keys)\n", - "\n", - " # Now we have everything for the client to interact with the server\n", - "\n", - " # We create a loop to send the input to the server and receive the encrypted prediction\n", - " execution_time = []\n", - " encrypted_input = None\n", - " clear_input = None\n", - "\n", - " response = requests.post(\n", - " f\"{url}/add_key\", files={\"key\": io.BytesIO(initial_bytes=serialized_evaluation_keys)}\n", - " )\n", - " assert response.status_code == status_ok\n", - " uid = response.json()[\"uid\"]\n", - "\n", - " inferences = []\n", - " for i in tqdm(range(len(X_test))):\n", - " clear_input = X_test[[i], :]\n", - "\n", - " assert isinstance(clear_input, numpy.ndarray)\n", - " encrypted_input = client.quantize_encrypt_serialize(clear_input)\n", - " assert isinstance(encrypted_input, bytes)\n", - "\n", - " inferences.append(\n", - " requests.post(\n", - " f\"{url}/compute\",\n", - " files={\n", - " \"model_input\": io.BytesIO(encrypted_input),\n", - " },\n", - " data={\n", - " \"uid\": uid,\n", - " },\n", - " )\n", - " )\n", - "\n", - "# Unpack the results\n", - "decrypted_predictions = []\n", - "for result in inferences:\n", - " assert result.status_code == status_ok\n", - " encrypted_result = result.content\n", - " decrypted_prediction = client.deserialize_decrypt_dequantize(encrypted_result)[0]\n", - " decrypted_predictions.append(decrypted_prediction)" - ] - }, - { - "cell_type": "markdown", - "id": "4bcd9b24", - "metadata": {}, - "source": [ - "We can now check that the predictions from the server are actually the same as the model in clear." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "dbb5814d", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "(numpy.array(decrypted_predictions) == model.predict_proba(X_test)).all()" - ] - } - ], - "metadata": { - "execution": { - "timeout": 10800 - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/docs/guides/client_server.md b/docs/guides/client_server.md index f9373b27a..425bda231 100644 --- a/docs/guides/client_server.md +++ b/docs/guides/client_server.md @@ -32,19 +32,3 @@ The server-side implementation of a Concrete ML model follows the diagram above. ## Example notebook For a complete example, see [the client-server notebook](../advanced_examples/ClientServer.ipynb) or [the use-case examples](../../use_case_examples/deployment/). - -### AWS - -We provide scripts that leverage `boto3` to deploy any Concrete ML model to AWS. -The first required step is to properly set up AWS CLI on your system, which can be done by following the instructions in [AWS Documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html). -To create Access keys to configure AWS CLI, go to the [appropriate panel on AWS website](https://us-east-1.console.aws.amazon.com/iamv2/home?region=us-east-1#/security_credentials?section=IAM_credentials). - -Once this first setup is done you can launch `python src/concrete/ml/deployment/deploy_to_aws.py --path-to-model ` from the root of the repository to create an instance that runs a FastAPI server serving the model. - -### Docker - -Running Docker with the latest version of Concrete ML will require you to build a Docker image. To do this, run the following command: `poetry build && mkdir pkg && cp dist/* pkg/ && make release_docker`. You will need to have `make`, `poetry` and `docker` installed on your system. -To test locally there is a dedicated script: `python src/concrete/ml/deployment/deploy_to_docker.py --path-to-model ` whoch should be run from the root of the repository in order to create a Docker that runs a FastAPI server serving the model. - -No code is required to run the server but each client is specific to the use-case, even if the workflow stays the same. -To see how to create your client refer to our [examples](../../use_case_examples/deployment) or [this notebook](../advanced_examples/Deployment.ipynb). diff --git a/docs/references/api/README.md b/docs/references/api/README.md index 5a5392d8b..45b66d6fb 100644 --- a/docs/references/api/README.md +++ b/docs/references/api/README.md @@ -15,11 +15,7 @@ - [`concrete.ml.common.serialization.loaders`](./concrete.ml.common.serialization.loaders.md#module-concretemlcommonserializationloaders): Load functions for serialization. - [`concrete.ml.common.utils`](./concrete.ml.common.utils.md#module-concretemlcommonutils): Utils that can be re-used by other pieces of code in the module. - [`concrete.ml.deployment`](./concrete.ml.deployment.md#module-concretemldeployment): Module for deployment of the FHE model. -- [`concrete.ml.deployment.deploy_to_aws`](./concrete.ml.deployment.deploy_to_aws.md#module-concretemldeploymentdeploy_to_aws): Methods to deploy a client/server to AWS. -- [`concrete.ml.deployment.deploy_to_docker`](./concrete.ml.deployment.deploy_to_docker.md#module-concretemldeploymentdeploy_to_docker): Methods to deploy a server using Docker. - [`concrete.ml.deployment.fhe_client_server`](./concrete.ml.deployment.fhe_client_server.md#module-concretemldeploymentfhe_client_server): APIs for FHE deployment. -- [`concrete.ml.deployment.server`](./concrete.ml.deployment.server.md#module-concretemldeploymentserver): Deployment server. -- [`concrete.ml.deployment.utils`](./concrete.ml.deployment.utils.md#module-concretemldeploymentutils): Utils. - [`concrete.ml.onnx`](./concrete.ml.onnx.md#module-concretemlonnx): ONNX module. - [`concrete.ml.onnx.convert`](./concrete.ml.onnx.convert.md#module-concretemlonnxconvert): ONNX conversion related code. - [`concrete.ml.onnx.onnx_impl_utils`](./concrete.ml.onnx.onnx_impl_utils.md#module-concretemlonnxonnx_impl_utils): Utility functions for onnx operator implementations. @@ -64,7 +60,6 @@ - [`decoder.ConcreteDecoder`](./concrete.ml.common.serialization.decoder.md#class-concretedecoder): Custom json decoder to handle non-native types found in serialized Concrete ML objects. - [`encoder.ConcreteEncoder`](./concrete.ml.common.serialization.encoder.md#class-concreteencoder): Custom json encoder to handle non-native types found in serialized Concrete ML objects. - [`utils.FheMode`](./concrete.ml.common.utils.md#class-fhemode): Enum representing the execution mode. -- [`deploy_to_aws.AWSInstance`](./concrete.ml.deployment.deploy_to_aws.md#class-awsinstance): AWSInstance. - [`fhe_client_server.FHEModelClient`](./concrete.ml.deployment.fhe_client_server.md#class-fhemodelclient): Client API to encrypt and decrypt FHE data. - [`fhe_client_server.FHEModelDev`](./concrete.ml.deployment.fhe_client_server.md#class-fhemodeldev): Dev API to save the model and then load and run the FHE circuit. - [`fhe_client_server.FHEModelServer`](./concrete.ml.deployment.fhe_client_server.md#class-fhemodelserver): Server API to load and run the FHE circuit. @@ -262,20 +257,7 @@ - [`utils.process_rounding_threshold_bits`](./concrete.ml.common.utils.md#function-process_rounding_threshold_bits): Check and process the rounding_threshold_bits parameter. - [`utils.replace_invalid_arg_name_chars`](./concrete.ml.common.utils.md#function-replace_invalid_arg_name_chars): Sanitize arg_name, replacing invalid chars by \_. - [`utils.to_tuple`](./concrete.ml.common.utils.md#function-to_tuple): Make the input a tuple if it is not already the case. -- [`deploy_to_aws.create_instance`](./concrete.ml.deployment.deploy_to_aws.md#function-create_instance): Create a EC2 instance. -- [`deploy_to_aws.delete_security_group`](./concrete.ml.deployment.deploy_to_aws.md#function-delete_security_group): Terminate a AWS EC2 instance. -- [`deploy_to_aws.deploy_to_aws`](./concrete.ml.deployment.deploy_to_aws.md#function-deploy_to_aws): Deploy a model to a EC2 AWS instance. -- [`deploy_to_aws.main`](./concrete.ml.deployment.deploy_to_aws.md#function-main): Deploy a model. -- [`deploy_to_aws.terminate_instance`](./concrete.ml.deployment.deploy_to_aws.md#function-terminate_instance): Terminate a AWS EC2 instance. -- [`deploy_to_aws.wait_instance_termination`](./concrete.ml.deployment.deploy_to_aws.md#function-wait_instance_termination): Wait for AWS EC2 instance termination. -- [`deploy_to_docker.build_docker_image`](./concrete.ml.deployment.deploy_to_docker.md#function-build_docker_image): Build server Docker image. -- [`deploy_to_docker.delete_image`](./concrete.ml.deployment.deploy_to_docker.md#function-delete_image): Delete a Docker image. -- [`deploy_to_docker.main`](./concrete.ml.deployment.deploy_to_docker.md#function-main): Deploy function. -- [`deploy_to_docker.stop_container`](./concrete.ml.deployment.deploy_to_docker.md#function-stop_container): Kill all containers that use a given image. - [`fhe_client_server.check_concrete_versions`](./concrete.ml.deployment.fhe_client_server.md#function-check_concrete_versions): Check that current versions match the ones used in development. -- [`utils.filter_logs`](./concrete.ml.deployment.utils.md#function-filter_logs): Filter logs based on previous logs. -- [`utils.is_connection_available`](./concrete.ml.deployment.utils.md#function-is_connection_available): Check if ssh connection is available. -- [`utils.wait_for_connection_to_be_available`](./concrete.ml.deployment.utils.md#function-wait_for_connection_to_be_available): Wait for connection to be available. - [`convert.fuse_matmul_bias_to_gemm`](./concrete.ml.onnx.convert.md#function-fuse_matmul_bias_to_gemm): Fuse sequence of matmul -> add into a gemm node. - [`convert.get_equivalent_numpy_forward_from_onnx`](./concrete.ml.onnx.convert.md#function-get_equivalent_numpy_forward_from_onnx): Get the numpy equivalent forward of the provided ONNX model. - [`convert.get_equivalent_numpy_forward_from_onnx_tree`](./concrete.ml.onnx.convert.md#function-get_equivalent_numpy_forward_from_onnx_tree): Get the numpy equivalent forward of the provided ONNX model for tree-based models only. diff --git a/docs/references/api/concrete.ml.common.debugging.custom_assert.md b/docs/references/api/concrete.ml.common.debugging.custom_assert.md index c40d3bbbc..ba4380224 100644 --- a/docs/references/api/concrete.ml.common.debugging.custom_assert.md +++ b/docs/references/api/concrete.ml.common.debugging.custom_assert.md @@ -8,7 +8,7 @@ Provide some variants of assert. ______________________________________________________________________ - + ## function `assert_true` @@ -30,7 +30,7 @@ Provide a custom assert to check that the condition is True. ______________________________________________________________________ - + ## function `assert_false` @@ -52,7 +52,7 @@ Provide a custom assert to check that the condition is False. ______________________________________________________________________ - + ## function `assert_not_reached` diff --git a/docs/references/api/concrete.ml.common.serialization.decoder.md b/docs/references/api/concrete.ml.common.serialization.decoder.md index 15b94b5e2..5d1faba90 100644 --- a/docs/references/api/concrete.ml.common.serialization.decoder.md +++ b/docs/references/api/concrete.ml.common.serialization.decoder.md @@ -16,7 +16,7 @@ Custom decoder for serialization. ______________________________________________________________________ - + ## function `object_hook` @@ -42,13 +42,13 @@ If the input's type is non-native, then we expect it to have the following forma ______________________________________________________________________ - + ## class `ConcreteDecoder` Custom json decoder to handle non-native types found in serialized Concrete ML objects. - + ### method `__init__` diff --git a/docs/references/api/concrete.ml.common.serialization.dumpers.md b/docs/references/api/concrete.ml.common.serialization.dumpers.md index 466cfd244..dd98056d0 100644 --- a/docs/references/api/concrete.ml.common.serialization.dumpers.md +++ b/docs/references/api/concrete.ml.common.serialization.dumpers.md @@ -8,7 +8,7 @@ Dump functions for serialization. ______________________________________________________________________ - + ## function `dumps` @@ -28,7 +28,7 @@ Dump any object as a string. ______________________________________________________________________ - + ## function `dump` diff --git a/docs/references/api/concrete.ml.common.serialization.encoder.md b/docs/references/api/concrete.ml.common.serialization.encoder.md index 8a52cb17e..6f6033e3a 100644 --- a/docs/references/api/concrete.ml.common.serialization.encoder.md +++ b/docs/references/api/concrete.ml.common.serialization.encoder.md @@ -13,7 +13,7 @@ Custom encoder for serialization. ______________________________________________________________________ - + ## function `dump_name_and_value` @@ -35,7 +35,7 @@ Dump the value into a custom dict format. ______________________________________________________________________ - + ## class `ConcreteEncoder` @@ -49,7 +49,7 @@ The ConcreteEncoder is only meant to encode Concrete-ML's built-in models and th ______________________________________________________________________ - + ### method `default` @@ -73,7 +73,7 @@ Define a custom default method that enables dumping any supported serialized val ______________________________________________________________________ - + ### method `isinstance` @@ -96,7 +96,7 @@ Natively, among other types, the JSONENcoder handles integers, floating points a ______________________________________________________________________ - + ### method `iterencode` diff --git a/docs/references/api/concrete.ml.common.serialization.loaders.md b/docs/references/api/concrete.ml.common.serialization.loaders.md index 58c1589af..b1c53d0a5 100644 --- a/docs/references/api/concrete.ml.common.serialization.loaders.md +++ b/docs/references/api/concrete.ml.common.serialization.loaders.md @@ -8,7 +8,7 @@ Load functions for serialization. ______________________________________________________________________ - + ## function `loads` @@ -28,7 +28,7 @@ Load any Concrete ML object that provide a `dump_dict` method. ______________________________________________________________________ - + ## function `load` diff --git a/docs/references/api/concrete.ml.common.utils.md b/docs/references/api/concrete.ml.common.utils.md index 4fc2a84d7..e3ab5e60a 100644 --- a/docs/references/api/concrete.ml.common.utils.md +++ b/docs/references/api/concrete.ml.common.utils.md @@ -17,7 +17,7 @@ Utils that can be re-used by other pieces of code in the module. ______________________________________________________________________ - + ## function `replace_invalid_arg_name_chars` @@ -39,7 +39,7 @@ This does not check that the starting character of arg_name is valid. ______________________________________________________________________ - + ## function `generate_proxy_function` @@ -65,7 +65,7 @@ This returns a runtime compiled function with the sanitized argument names passe ______________________________________________________________________ - + ## function `get_onnx_opset_version` @@ -85,7 +85,7 @@ Return the ONNX opset_version. ______________________________________________________________________ - + ## function `manage_parameters_for_pbs_errors` @@ -122,7 +122,7 @@ Note that global_p_error is currently set to 0 in the FHE simulation mode. ______________________________________________________________________ - + ## function `check_there_is_no_p_error_options_in_configuration` @@ -140,7 +140,7 @@ It would be dangerous, since we set them in direct arguments in our calls to Con ______________________________________________________________________ - + ## function `get_model_class` @@ -159,7 +159,7 @@ The model's class. ______________________________________________________________________ - + ## function `is_model_class_in_a_list` @@ -179,7 +179,7 @@ If the model's class is in the list or not. ______________________________________________________________________ - + ## function `get_model_name` @@ -198,7 +198,7 @@ the model's name. ______________________________________________________________________ - + ## function `is_classifier_or_partial_classifier` @@ -218,7 +218,7 @@ Indicate if the model class represents a classifier. ______________________________________________________________________ - + ## function `is_regressor_or_partial_regressor` @@ -238,7 +238,7 @@ Indicate if the model class represents a regressor. ______________________________________________________________________ - + ## function `is_pandas_dataframe` @@ -260,7 +260,7 @@ This function is inspired from Scikit-Learn's test validation tools and avoids t ______________________________________________________________________ - + ## function `is_pandas_series` @@ -282,7 +282,7 @@ This function is inspired from Scikit-Learn's test validation tools and avoids t ______________________________________________________________________ - + ## function `is_pandas_type` @@ -302,7 +302,7 @@ Indicate if the input container is a Pandas DataFrame or Series. ______________________________________________________________________ - + ## function `check_dtype_and_cast` @@ -334,7 +334,7 @@ If values types don't match with any supported type or the expected dtype, raise ______________________________________________________________________ - + ## function `compute_bits_precision` @@ -354,7 +354,7 @@ Compute the number of bits required to represent x. ______________________________________________________________________ - + ## function `is_brevitas_model` @@ -374,7 +374,7 @@ Check if a model is a Brevitas type. ______________________________________________________________________ - + ## function `to_tuple` @@ -394,7 +394,7 @@ Make the input a tuple if it is not already the case. ______________________________________________________________________ - + ## function `all_values_are_integers` @@ -414,7 +414,7 @@ Indicate if all unpacked values are of a supported integer dtype. ______________________________________________________________________ - + ## function `all_values_are_floats` @@ -434,7 +434,7 @@ Indicate if all unpacked values are of a supported float dtype. ______________________________________________________________________ - + ## function `all_values_are_of_dtype` @@ -455,7 +455,7 @@ Indicate if all unpacked values are of the specified dtype(s). ______________________________________________________________________ - + ## function `array_allclose_and_same_shape` @@ -485,7 +485,7 @@ Check if two numpy arrays are equal within a tolerances and have the same shape. ______________________________________________________________________ - + ## function `process_rounding_threshold_bits` @@ -507,10 +507,11 @@ Check and process the rounding_threshold_bits parameter. - `NotImplementedError`: If 'auto' rounding is specified but not implemented. - `ValueError`: If an invalid type or value is provided for rounding_threshold_bits. +- `KeyError`: If the dict contains keys other than 'n_bits' and 'method'. ______________________________________________________________________ - + ## class `FheMode` diff --git a/docs/references/api/concrete.ml.deployment.deploy_to_aws.md b/docs/references/api/concrete.ml.deployment.deploy_to_aws.md deleted file mode 100644 index f6a8fa828..000000000 --- a/docs/references/api/concrete.ml.deployment.deploy_to_aws.md +++ /dev/null @@ -1,197 +0,0 @@ - - - - -# module `concrete.ml.deployment.deploy_to_aws` - -Methods to deploy a client/server to AWS. - -It takes as input a folder with: -\- client.zip -\- server.zip -\- processing.json - -It spawns a AWS EC2 instance with proper security groups. Then SSHs to it to rsync the files and update Python dependencies. It then launches the server. - -## **Global Variables** - -- **DATE_FORMAT** -- **DEFAULT_CML_AMI_ID** - -______________________________________________________________________ - - - -## function `create_instance` - -```python -create_instance( - instance_type: str = 'c5.large', - open_port=5000, - instance_name: Optional[str] = None, - verbose: bool = False, - region_name: Optional[str] = None, - ami_id='ami-0d7427e883fa00ff3' -) → Dict[str, Any] -``` - -Create a EC2 instance. - -**Arguments:** - -- `instance_type` (str): the type of AWS EC2 instance. -- `open_port` (int): the port to open. -- `instance_name` (Optional\[str\]): the name to use for AWS created objects -- `verbose` (bool): show logs or not -- `region_name` (Optional\[str\]): AWS region -- `ami_id` (str): AMI to use - -**Returns:** - -- `Dict[str, Any]`: some information about the newly created instance. - \- ip - \- private_key - \- instance_id - \- key_path - \- ip_address - \- port - -______________________________________________________________________ - - - -## function `deploy_to_aws` - -```python -deploy_to_aws( - instance_metadata: Dict[str, Any], - path_to_model: Path, - number_of_ssh_retries: int = -1, - wait_bar: bool = False, - verbose: bool = False -) -``` - -Deploy a model to a EC2 AWS instance. - -**Arguments:** - -- `instance_metadata` (Dict\[str, Any\]): the metadata of AWS EC2 instance created using AWSInstance or create_instance -- `path_to_model` (Path): the path to the serialized model -- `number_of_ssh_retries` (int): the number of ssh retries (-1 is no limit) -- `wait_bar` (bool): whether to show a wait bar when waiting for ssh connection to be available -- `verbose` (bool): whether to show a logs - -**Returns:** -instance_metadata (Dict\[str, Any\]) - -**Raises:** - -- `RuntimeError`: if launching the server crashed - -______________________________________________________________________ - - - -## function `wait_instance_termination` - -```python -wait_instance_termination(instance_id: str, region_name: Optional[str] = None) -``` - -Wait for AWS EC2 instance termination. - -**Arguments:** - -- `instance_id` (str): the id of the AWS EC2 instance to terminate. -- `region_name` (Optional\[str\]): AWS region (Optional) - -______________________________________________________________________ - - - -## function `terminate_instance` - -```python -terminate_instance(instance_id: str, region_name: Optional[str] = None) -``` - -Terminate a AWS EC2 instance. - -**Arguments:** - -- `instance_id` (str): the id of the AWS EC2 instance to terminate. -- `region_name` (Optional\[str\]): AWS region (Optional) - -______________________________________________________________________ - - - -## function `delete_security_group` - -```python -delete_security_group(security_group_id: str, region_name: Optional[str] = None) -``` - -Terminate a AWS EC2 instance. - -**Arguments:** - -- `security_group_id` (str): the id of the AWS EC2 instance to terminate. -- `region_name` (Optional\[str\]): AWS region (Optional) - -______________________________________________________________________ - - - -## function `main` - -```python -main( - path_to_model: Path, - port: int = 5000, - instance_type: str = 'c5.large', - instance_name: Optional[str] = None, - verbose: bool = False, - wait_bar: bool = False, - terminate_on_shutdown: bool = True -) -``` - -Deploy a model. - -**Arguments:** - -- `path_to_model` (Path): path to serialized model to serve. -- `port` (int): port to use. -- `instance_type` (str): type of AWS EC2 instance to use. -- `instance_name` (Optional\[str\]): the name to use for AWS created objects -- `verbose` (bool): show logs or not -- `wait_bar` (bool): show progress bar when waiting for ssh connection -- `terminate_on_shutdown` (bool): terminate instance when script is over - -______________________________________________________________________ - - - -## class `AWSInstance` - -AWSInstance. - -Context manager for AWS instance that supports ssh and http over one port. - - - -### method `__init__` - -```python -__init__( - instance_type: str = 'c5.large', - open_port=5000, - instance_name: Optional[str] = None, - verbose: bool = False, - terminate_on_shutdown: bool = True, - region_name: Optional[str] = None, - ami_id: str = 'ami-0d7427e883fa00ff3' -) -``` diff --git a/docs/references/api/concrete.ml.deployment.deploy_to_docker.md b/docs/references/api/concrete.ml.deployment.deploy_to_docker.md deleted file mode 100644 index 8d2d08caa..000000000 --- a/docs/references/api/concrete.ml.deployment.deploy_to_docker.md +++ /dev/null @@ -1,90 +0,0 @@ - - - - -# module `concrete.ml.deployment.deploy_to_docker` - -Methods to deploy a server using Docker. - -It takes as input a folder with: -\- client.zip -\- server.zip -\- processing.json - -It builds a Docker image and spawns a Docker container that runs the server. - -This module is untested as it would require to first build the release Docker image. FIXME: https://github.com/zama-ai/concrete-ml-internal/issues/3347 - -## **Global Variables** - -- **DATE_FORMAT** - -______________________________________________________________________ - - - -## function `delete_image` - -```python -delete_image(image_name: str) -``` - -Delete a Docker image. - -**Arguments:** - -- `image_name` (str): to name of the image to delete. - -______________________________________________________________________ - - - -## function `stop_container` - -```python -stop_container(image_name: str) -``` - -Kill all containers that use a given image. - -**Arguments:** - -- `image_name` (str): name of Docker image for which to stop Docker containers. - -______________________________________________________________________ - - - -## function `build_docker_image` - -```python -build_docker_image(path_to_model: Path, image_name: str) -``` - -Build server Docker image. - -**Arguments:** - -- `path_to_model` (Path): path to serialized model to serve. -- `image_name` (str): name to give to the image. - -______________________________________________________________________ - - - -## function `main` - -```python -main(path_to_model: Path, image_name: str) -``` - -Deploy function. - -- Builds Docker image. -- Runs Docker server. -- Stop container and delete image. - -**Arguments:** - -- `path_to_model` (Path): path to model to server -- `image_name` (str): name of the Docker image diff --git a/docs/references/api/concrete.ml.deployment.server.md b/docs/references/api/concrete.ml.deployment.server.md deleted file mode 100644 index 9fc7f0c73..000000000 --- a/docs/references/api/concrete.ml.deployment.server.md +++ /dev/null @@ -1,12 +0,0 @@ - - - - -# module `concrete.ml.deployment.server` - -Deployment server. - -Routes: -\- Get client.zip -\- Add a key -\- Compute diff --git a/docs/references/api/concrete.ml.deployment.utils.md b/docs/references/api/concrete.ml.deployment.utils.md deleted file mode 100644 index 0c8671ef8..000000000 --- a/docs/references/api/concrete.ml.deployment.utils.md +++ /dev/null @@ -1,93 +0,0 @@ - - - - -# module `concrete.ml.deployment.utils` - -Utils. - -- Check if connection possible -- Wait for connection to be available (with timeout) - -______________________________________________________________________ - - - -## function `filter_logs` - -```python -filter_logs(previous_logs: str, current_logs: str) → str -``` - -Filter logs based on previous logs. - -**Arguments:** - -- `previous_logs` (str): previous logs -- `current_logs` (str): current logs - -**Returns:** - -- `str`: filtered logs - -______________________________________________________________________ - - - -## function `wait_for_connection_to_be_available` - -```python -wait_for_connection_to_be_available( - hostname: str, - ip_address: str, - path_to_private_key: Path, - timeout: int = 1, - wait_time: int = 1, - max_retries: int = 20, - wait_bar: bool = False -) -``` - -Wait for connection to be available. - -**Arguments:** - -- `hostname` (str): host name -- `ip_address` (str): ip address -- `path_to_private_key` (Path): path to private key -- `timeout` (int): ssh timeout option -- `wait_time` (int): time to wait between retries -- `max_retries` (int): number of retries, if \< 0 unlimited retries -- `wait_bar` (bool): tqdm progress bar of retries - -**Raises:** - -- `TimeoutError`: if it wasn't able connect to ssh with the given constraints - -______________________________________________________________________ - - - -## function `is_connection_available` - -```python -is_connection_available( - hostname: str, - ip_address: str, - path_to_private_key: Path, - timeout: int = 1 -) -``` - -Check if ssh connection is available. - -**Arguments:** - -- `hostname` (str): host name -- `ip_address` (str): ip address -- `path_to_private_key` (Path): path to private key -- `timeout`: ssh timeout option - -**Returns:** - -- `bool`: True if connection succeeded diff --git a/docs/references/api/concrete.ml.onnx.onnx_utils.md b/docs/references/api/concrete.ml.onnx.onnx_utils.md index 7576c830f..946b81b8b 100644 --- a/docs/references/api/concrete.ml.onnx.onnx_utils.md +++ b/docs/references/api/concrete.ml.onnx.onnx_utils.md @@ -19,7 +19,7 @@ Utils to interpret an ONNX model with numpy. ______________________________________________________________________ - + ## function `get_attribute` @@ -39,7 +39,7 @@ Get the attribute from an ONNX AttributeProto. ______________________________________________________________________ - + ## function `get_op_type` @@ -59,7 +59,7 @@ Construct the qualified type name of the ONNX operator. ______________________________________________________________________ - + ## function `execute_onnx_with_numpy` @@ -80,7 +80,7 @@ Execute the provided ONNX graph on the given inputs. ______________________________________________________________________ - + ## function `execute_onnx_with_numpy_trees` @@ -106,7 +106,7 @@ Execute the provided ONNX graph on the given inputs for tree-based models only. ______________________________________________________________________ - + ## function `remove_initializer_from_input` diff --git a/docs/references/api/concrete.ml.pandas.client_engine.md b/docs/references/api/concrete.ml.pandas.client_engine.md index dd318611f..35d32eed0 100644 --- a/docs/references/api/concrete.ml.pandas.client_engine.md +++ b/docs/references/api/concrete.ml.pandas.client_engine.md @@ -12,13 +12,13 @@ Define the framework used for managing keys (encrypt, decrypt) for encrypted dat ______________________________________________________________________ - + ## class `ClientEngine` Define a framework that manages keys. - + ### method `__init__` @@ -28,7 +28,7 @@ __init__(keygen: bool = True, keys_path: Optional[Path, str] = None) ______________________________________________________________________ - + ### method `decrypt_to_pandas` @@ -48,7 +48,7 @@ Decrypt an encrypted data-frame using the loaded client and return a Pandas data ______________________________________________________________________ - + ### method `encrypt_from_pandas` @@ -68,7 +68,7 @@ Encrypt a Pandas data-frame using the loaded client. ______________________________________________________________________ - + ### method `keygen` diff --git a/docs/references/api/concrete.ml.pandas.dataframe.md b/docs/references/api/concrete.ml.pandas.dataframe.md index d66ad0038..b818ba4d2 100644 --- a/docs/references/api/concrete.ml.pandas.dataframe.md +++ b/docs/references/api/concrete.ml.pandas.dataframe.md @@ -12,13 +12,13 @@ Define the encrypted data-frame framework. ______________________________________________________________________ - + ## class `EncryptedDataFrame` Define an encrypted data-frame framework that supports Pandas operators and parameters. - + ### method `__init__` @@ -105,7 +105,7 @@ Get the evaluation keys. ______________________________________________________________________ - + ### method `get_schema` @@ -123,7 +123,7 @@ The scheme can include column names, dtypes or dtype mappings. It is displayed a ______________________________________________________________________ - + ### classmethod `load` @@ -143,7 +143,7 @@ Load an encrypted data-frame from disk. ______________________________________________________________________ - + ### method `merge` @@ -193,7 +193,7 @@ Pandas documentation for version 2.0 can be found here: https://pandas.pydata.or ______________________________________________________________________ - + ### method `save` diff --git a/docs/references/api/concrete.ml.pandas.md b/docs/references/api/concrete.ml.pandas.md index ed30f4551..5665701be 100644 --- a/docs/references/api/concrete.ml.pandas.md +++ b/docs/references/api/concrete.ml.pandas.md @@ -13,7 +13,7 @@ Public API for encrypted data-frames. ______________________________________________________________________ - + ## function `load_encrypted_dataframe` @@ -33,7 +33,7 @@ Load a serialized encrypted data-frame. ______________________________________________________________________ - + ## function `merge` diff --git a/docs/references/api/concrete.ml.pytest.torch_models.md b/docs/references/api/concrete.ml.pytest.torch_models.md index c1e4850e0..d8d0b68d5 100644 --- a/docs/references/api/concrete.ml.pytest.torch_models.md +++ b/docs/references/api/concrete.ml.pytest.torch_models.md @@ -891,7 +891,7 @@ __init__(input_output, activation_function, n_bits=2, disable_bit_check=False) ______________________________________________________________________ - + ### method `forward` @@ -910,13 +910,13 @@ the output of the NN ______________________________________________________________________ - + ## class `QATTestModule` Torch model that implements a simple non-uniform quantizer. - + ### method `__init__` @@ -926,7 +926,7 @@ __init__(activation_function) ______________________________________________________________________ - + ### method `forward` @@ -945,13 +945,13 @@ the output of the NN ______________________________________________________________________ - + ## class `SingleMixNet` Torch model that with a single conv layer that produces the output, e.g., a blur filter. - + ### method `__init__` @@ -961,7 +961,7 @@ __init__(use_conv, use_qat, inp_size, n_bits) ______________________________________________________________________ - + ### method `forward` @@ -980,7 +980,7 @@ the output of the NN ______________________________________________________________________ - + ## class `DoubleQuantQATMixNet` @@ -988,7 +988,7 @@ Torch model that with two different quantizers on the input. Used to test that it keeps the input TLU. - + ### method `__init__` @@ -998,7 +998,7 @@ __init__(use_conv, use_qat, inp_size, n_bits) ______________________________________________________________________ - + ### method `forward` @@ -1017,18 +1017,18 @@ the output of the NN ______________________________________________________________________ - + ## class `TorchSum` Torch model to test the ReduceSum ONNX operator in a leveled circuit. - + ### method `__init__` ```python -__init__(dim=(0,), keepdim=True, with_pbs=False) +__init__(dim=(0,), keepdim=True) ``` Initialize the module. @@ -1037,11 +1037,10 @@ Initialize the module. - `dim` (Tuple\[int\]): The axis along which the sum should be executed - `keepdim` (bool): If the output should keep the same dimension as the input or not -- `with_pbs` (bool): If the forward function should be forced to consider at least one PBS ______________________________________________________________________ - + ### method `forward` @@ -1061,13 +1060,13 @@ Forward pass. ______________________________________________________________________ - + ## class `NetWithConstantsFoldedBeforeOps` Torch QAT model that does not quantize the inputs. - + ### method `__init__` @@ -1082,7 +1081,7 @@ __init__( ______________________________________________________________________ - + ### method `forward` @@ -1102,13 +1101,13 @@ Forward pass. ______________________________________________________________________ - + ## class `ShapeOperationsNet` Torch QAT model that reshapes the input. - + ### method `__init__` @@ -1118,7 +1117,7 @@ __init__(is_qat) ______________________________________________________________________ - + ### method `forward` @@ -1138,13 +1137,13 @@ Forward pass. ______________________________________________________________________ - + ## class `PaddingNet` Torch QAT model that applies various padding patterns. - + ### method `__init__` @@ -1154,7 +1153,7 @@ __init__() ______________________________________________________________________ - + ### method `forward` @@ -1174,13 +1173,13 @@ Forward pass. ______________________________________________________________________ - + ## class `QuantCustomModel` A small quantized network with Brevitas, trained on make_classification. - + ### method `__init__` @@ -1210,7 +1209,7 @@ Quantized Torch Model with Brevitas. ______________________________________________________________________ - + ### method `forward` @@ -1230,13 +1229,13 @@ Forward pass. ______________________________________________________________________ - + ## class `TorchCustomModel` A small network with Brevitas, trained on make_classification. - + ### method `__init__` @@ -1254,7 +1253,7 @@ Torch Model. ______________________________________________________________________ - + ### method `forward` @@ -1274,13 +1273,13 @@ Forward pass. ______________________________________________________________________ - + ## class `ConcatFancyIndexing` Concat with fancy indexing. - + ### method `__init__` @@ -1306,7 +1305,7 @@ Torch Model. ______________________________________________________________________ - + ### method `forward` @@ -1326,13 +1325,13 @@ Forward pass. ______________________________________________________________________ - + ## class `PartialQATModel` A model with a QAT Module. - + ### method `__init__` @@ -1342,7 +1341,7 @@ __init__(input_shape: int, output_shape: int, n_bits: int) ______________________________________________________________________ - + ### method `forward` @@ -1362,13 +1361,13 @@ Forward pass. ______________________________________________________________________ - + ## class `EncryptedMatrixMultiplicationModel` PyTorch module for performing matrix multiplication between two encrypted values. - + ### method `__init__` @@ -1378,7 +1377,7 @@ __init__(input_output, activation_function) ______________________________________________________________________ - + ### method `forward` @@ -1398,13 +1397,13 @@ Forward function for matrix multiplication. ______________________________________________________________________ - + ## class `ManualLogisticRegressionTraining` PyTorch module for performing SGD training. - + ### method `__init__` @@ -1414,7 +1413,7 @@ __init__(learning_rate=0.1) ______________________________________________________________________ - + ### method `forward` @@ -1437,7 +1436,7 @@ Forward function for matrix multiplication. ______________________________________________________________________ - + ### method `predict` @@ -1459,13 +1458,13 @@ Predicts based on weights and bias as inputs. ______________________________________________________________________ - + ## class `AddNet` Torch model that performs a simple addition between two inputs. - + ### method `__init__` @@ -1475,7 +1474,7 @@ __init__(use_conv, use_qat, input_output, n_bits) ______________________________________________________________________ - + ### method `forward` @@ -1495,13 +1494,13 @@ Result of adding x and y. ______________________________________________________________________ - + ## class `ExpandModel` Minimalist network that expands the input tensor to a larger size. - + ### method `__init__` @@ -1511,7 +1510,7 @@ __init__(is_qat) ______________________________________________________________________ - + ### method `forward` @@ -1531,13 +1530,13 @@ Expand the input tensor to the target size. ______________________________________________________________________ - + ## class `Conv1dModel` Small model that uses a 1D convolution operator. - + ### method `__init__` @@ -1547,7 +1546,7 @@ __init__(input_output, activation_function) → None ______________________________________________________________________ - + ### method `forward` diff --git a/docs/references/api/concrete.ml.pytest.utils.md b/docs/references/api/concrete.ml.pytest.utils.md index 06c48da35..8f900ea55 100644 --- a/docs/references/api/concrete.ml.pytest.utils.md +++ b/docs/references/api/concrete.ml.pytest.utils.md @@ -13,7 +13,7 @@ Common functions or lists for test files, which can't be put in fixtures. ______________________________________________________________________ - + ## function `get_sklearn_linear_models_and_datasets` @@ -43,7 +43,7 @@ Get the pytest parameters to use for testing linear models. ______________________________________________________________________ - + ## function `get_sklearn_tree_models_and_datasets` @@ -73,7 +73,7 @@ Get the pytest parameters to use for testing tree-based models. ______________________________________________________________________ - + ## function `get_sklearn_neural_net_models_and_datasets` @@ -103,7 +103,7 @@ Get the pytest parameters to use for testing neural network models. ______________________________________________________________________ - + ## function `get_sklearn_neighbors_models_and_datasets` @@ -133,7 +133,7 @@ Get the pytest parameters to use for testing neighbor models. ______________________________________________________________________ - + ## function `get_sklearn_all_models_and_datasets` @@ -163,7 +163,7 @@ Get the pytest parameters to use for testing all models available in Concrete ML ______________________________________________________________________ - + ## function `instantiate_model_generic` @@ -186,7 +186,7 @@ Instantiate any Concrete ML model type. ______________________________________________________________________ - + ## function `data_calibration_processing` @@ -212,7 +212,7 @@ Reduce size of the given data-set. ______________________________________________________________________ - + ## function `load_torch_model` @@ -240,7 +240,7 @@ Load an object saved with torch.save() from a file or dict. ______________________________________________________________________ - + ## function `values_are_equal` @@ -263,7 +263,7 @@ This method takes into account objects of type None, numpy.ndarray, numpy.floati ______________________________________________________________________ - + ## function `check_serialization` @@ -289,7 +289,7 @@ This function serializes all objects using the `dump`, `dumps`, `load` and `load ______________________________________________________________________ - + ## function `get_random_samples` @@ -314,7 +314,7 @@ Select `n_sample` random elements from a 2D NumPy array. ______________________________________________________________________ - + ## function `pandas_dataframe_are_equal` diff --git a/docs/references/api/concrete.ml.quantization.quantized_module.md b/docs/references/api/concrete.ml.quantization.quantized_module.md index 6dd778aa1..a90f6def9 100644 --- a/docs/references/api/concrete.ml.quantization.quantized_module.md +++ b/docs/references/api/concrete.ml.quantization.quantized_module.md @@ -14,13 +14,13 @@ QuantizedModule API. ______________________________________________________________________ - + ## class `QuantizedModule` Inference for a quantized model. - + ### method `__init__` @@ -67,12 +67,12 @@ Get the post-processing parameters. ______________________________________________________________________ - + ### method `bitwidth_and_range_report` ```python -bitwidth_and_range_report() → Union[Dict[str, Dict[str, Union[Tuple[int, ], int]]], NoneType] +bitwidth_and_range_report() → Optional[Dict[str, Dict[str, Union[Tuple[int, ], int]]]] ``` Report the ranges and bit-widths for layers that mix encrypted integer values. @@ -83,7 +83,7 @@ Report the ranges and bit-widths for layers that mix encrypted integer values. ______________________________________________________________________ - + ### method `check_model_is_compiled` @@ -99,7 +99,7 @@ Check if the quantized module is compiled. ______________________________________________________________________ - + ### method `compile` @@ -139,7 +139,7 @@ Compile the module's forward function. ______________________________________________________________________ - + ### method `dequantize_output` @@ -159,7 +159,7 @@ Take the last layer q_out and use its de-quant function. ______________________________________________________________________ - + ### method `dump` @@ -175,7 +175,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -191,7 +191,7 @@ Dump itself to a dict. ______________________________________________________________________ - + ### method `dumps` @@ -207,7 +207,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `forward` @@ -235,7 +235,7 @@ This method executes the forward pass in the clear, with simulation or in FHE. I ______________________________________________________________________ - + ### method `load_dict` @@ -255,7 +255,7 @@ Load itself from a string. ______________________________________________________________________ - + ### method `post_processing` @@ -277,7 +277,7 @@ For quantized modules, there is no post-processing step but the method is kept t ______________________________________________________________________ - + ### method `quantize_input` @@ -297,7 +297,7 @@ Take the inputs in fp32 and quantize it using the learned quantization parameter ______________________________________________________________________ - + ### method `quantized_forward` @@ -321,7 +321,7 @@ Forward function for the FHE circuit. ______________________________________________________________________ - + ### method `set_inputs_quantization_parameters` @@ -337,7 +337,7 @@ Set the quantization parameters for the module's inputs. ______________________________________________________________________ - + ### method `set_reduce_sum_copy` diff --git a/docs/references/api/concrete.ml.quantization.quantized_module_passes.md b/docs/references/api/concrete.ml.quantization.quantized_module_passes.md index 205e213a6..79cc3c7fb 100644 --- a/docs/references/api/concrete.ml.quantization.quantized_module_passes.md +++ b/docs/references/api/concrete.ml.quantization.quantized_module_passes.md @@ -8,13 +8,13 @@ Optimization passes for QuantizedModules. ______________________________________________________________________ - + ## class `PowerOfTwoScalingRoundPBSAdapter` Detect neural network patterns that can be optimized with round PBS. - + ### method `__init__` @@ -36,12 +36,12 @@ Patterns could be ignored since a number of rounding bits was set manually throu ______________________________________________________________________ - + ### method `compute_op_predecessors` ```python -compute_op_predecessors() → DefaultDict[Union[QuantizedOp, NoneType], List[Tuple[Union[QuantizedOp, NoneType], str]]] +compute_op_predecessors() → DefaultDict[Optional[QuantizedOp], List[Tuple[Optional[QuantizedOp], str]]] ``` Compute the predecessors for each QuantizedOp in a QuantizedModule. @@ -54,14 +54,14 @@ Stores, for each quantized op, a list of quantized ops that produce its inputs. ______________________________________________________________________ - + ### method `detect_patterns` ```python detect_patterns( predecessors: DefaultDict[Optional[QuantizedOp], List[Tuple[Optional[QuantizedOp], str]]] -) → Dict[QuantizedMixingOp, Tuple[List[Union[QuantizedOp, NoneType]], Union[QuantizedOp, NoneType]]] +) → Dict[QuantizedMixingOp, Tuple[List[Optional[QuantizedOp]], Optional[QuantizedOp]]] ``` Detect the patterns that can be optimized with roundPBS in the QuantizedModule. @@ -76,7 +76,7 @@ Detect the patterns that can be optimized with roundPBS in the QuantizedModule. ______________________________________________________________________ - + ### method `match_path_pattern` @@ -102,12 +102,12 @@ Determine if a pattern has the structure that makes it viable for roundPBS. ______________________________________________________________________ - + ### method `process` ```python -process() → Dict[QuantizedMixingOp, Tuple[List[Union[QuantizedOp, NoneType]], Union[QuantizedOp, NoneType]]] +process() → Dict[QuantizedMixingOp, Tuple[List[Optional[QuantizedOp]], Optional[QuantizedOp]]] ``` Analyze an ONNX graph and detect Gemm/Conv patterns that can use RoundPBS. @@ -122,14 +122,14 @@ Nothing will be done if rounding is already specified. ______________________________________________________________________ - + ### method `process_patterns` ```python process_patterns( valid_paths: Dict[QuantizedMixingOp, Tuple[List[Optional[QuantizedOp]], Optional[QuantizedOp]]] -) → Dict[QuantizedMixingOp, Tuple[List[Union[QuantizedOp, NoneType]], Union[QuantizedOp, NoneType]]] +) → Dict[QuantizedMixingOp, Tuple[List[Optional[QuantizedOp]], Optional[QuantizedOp]]] ``` Configure the rounding bits of roundPBS for the optimizable operations. diff --git a/docs/references/api/concrete.ml.quantization.quantized_ops.md b/docs/references/api/concrete.ml.quantization.quantized_ops.md index 4f4613bd3..3916a7441 100644 --- a/docs/references/api/concrete.ml.quantization.quantized_ops.md +++ b/docs/references/api/concrete.ml.quantization.quantized_ops.md @@ -520,11 +520,11 @@ can_fuse() → bool Determine if this op can be fused. -Max Pooling operation can not be fused since it must be performed over integer tensors and it combines different elements of the input tensors. +Reshape operation can not be fused since it must be performed over integer tensors. **Returns:** -- `bool`: False, this operation can not be fused as it adds different encrypted integers +- `bool`: False, this operation can not be fused. ______________________________________________________________________ @@ -552,13 +552,13 @@ Reshape the input integer encrypted tensor. ______________________________________________________________________ - + ## class `QuantizedConv` Quantized Conv op. - + ### method `__init__` @@ -601,7 +601,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `q_impl` @@ -632,13 +632,13 @@ Allows an optional quantized bias. ______________________________________________________________________ - + ## class `QuantizedAvgPool` Quantized Average Pooling op. - + ### method `__init__` @@ -665,7 +665,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `q_impl` @@ -679,13 +679,13 @@ q_impl( ______________________________________________________________________ - + ## class `QuantizedMaxPool` Quantized Max Pooling op. - + ### method `__init__` @@ -712,7 +712,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `can_fuse` @@ -730,7 +730,7 @@ Max Pooling operation can not be fused since it must be performed over integer t ______________________________________________________________________ - + ### method `q_impl` @@ -743,13 +743,13 @@ q_impl( ______________________________________________________________________ - + ## class `QuantizedPad` Quantized Padding op. - + ### method `__init__` @@ -776,7 +776,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `can_fuse` @@ -794,7 +794,7 @@ Pad operation cannot be fused since it must be performed over integer tensors. ______________________________________________________________________ - + ### method `q_impl` @@ -808,7 +808,7 @@ q_impl( ______________________________________________________________________ - + ## class `QuantizedWhere` @@ -816,7 +816,7 @@ Where operator on quantized arrays. Supports only constants for the results produced on the True/False branches. - + ### method `__init__` @@ -843,7 +843,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedCast` @@ -863,7 +863,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedGreater` @@ -871,7 +871,7 @@ Comparison operator >. Only supports comparison with a constant. - + ### method `__init__` @@ -898,7 +898,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedGreaterOrEqual` @@ -906,7 +906,7 @@ Comparison operator >=. Only supports comparison with a constant. - + ### method `__init__` @@ -933,7 +933,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedLess` @@ -941,7 +941,7 @@ Comparison operator \<. Only supports comparison with a constant. - + ### method `__init__` @@ -968,7 +968,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedLessOrEqual` @@ -976,7 +976,7 @@ Comparison operator \<=. Only supports comparison with a constant. - + ### method `__init__` @@ -1003,7 +1003,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedOr` @@ -1023,7 +1023,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedDiv` @@ -1043,7 +1043,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedMul` @@ -1063,7 +1063,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedSub` @@ -1114,7 +1114,7 @@ q_impl( ______________________________________________________________________ - + ## class `QuantizedBatchNormalization` @@ -1132,7 +1132,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedFlatten` @@ -1150,7 +1150,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `can_fuse` @@ -1168,7 +1168,7 @@ Flatten operation cannot be fused since it must be performed over integer tensor ______________________________________________________________________ - + ### method `q_impl` @@ -1192,13 +1192,13 @@ Flatten the input integer encrypted tensor. ______________________________________________________________________ - + ## class `QuantizedReduceSum` ReduceSum with encrypted input. - + ### method `__init__` @@ -1239,7 +1239,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `calibrate` @@ -1259,7 +1259,7 @@ Create corresponding QuantizedArray for the output of the activation function. ______________________________________________________________________ - + ### method `q_impl` @@ -1285,7 +1285,7 @@ Sum the encrypted tensor's values along the given axes. ______________________________________________________________________ - + ## class `QuantizedErf` @@ -1303,7 +1303,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedNot` @@ -1321,13 +1321,13 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedBrevitasQuant` Brevitas uniform quantization with encrypted input. - + ### method `__init__` @@ -1370,7 +1370,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `calibrate` @@ -1390,7 +1390,7 @@ Create corresponding QuantizedArray for the output of Quantization function. ______________________________________________________________________ - + ### method `q_impl` @@ -1414,7 +1414,7 @@ Quantize values. ______________________________________________________________________ - + ## class `QuantizedTranspose` @@ -1434,7 +1434,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `can_fuse` @@ -1452,7 +1452,7 @@ Transpose can not be fused since it must be performed over integer tensors as it ______________________________________________________________________ - + ### method `q_impl` @@ -1476,7 +1476,7 @@ Transpose the input integer encrypted tensor. ______________________________________________________________________ - + ## class `QuantizedFloor` @@ -1494,7 +1494,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedMax` @@ -1512,7 +1512,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedMin` @@ -1530,7 +1530,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedNeg` @@ -1548,7 +1548,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedSign` @@ -1566,7 +1566,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedUnsqueeze` @@ -1584,7 +1584,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `can_fuse` @@ -1602,7 +1602,7 @@ Unsqueeze can not be fused since it must be performed over integer tensors as it ______________________________________________________________________ - + ### method `q_impl` @@ -1626,7 +1626,7 @@ Unsqueeze the input tensors on a given axis. ______________________________________________________________________ - + ## class `QuantizedConcat` @@ -1644,7 +1644,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `can_fuse` @@ -1662,7 +1662,7 @@ Concatenation can not be fused since it must be performed over integer tensors a ______________________________________________________________________ - + ### method `q_impl` @@ -1686,7 +1686,7 @@ Concatenate the input tensors on a given axis. ______________________________________________________________________ - + ## class `QuantizedSqueeze` @@ -1704,7 +1704,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `can_fuse` @@ -1722,7 +1722,7 @@ Squeeze can not be fused since it must be performed over integer tensors as it r ______________________________________________________________________ - + ### method `q_impl` @@ -1746,7 +1746,7 @@ Squeeze the input tensors on a given axis. ______________________________________________________________________ - + ## class `ONNXShape` @@ -1764,7 +1764,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `can_fuse` @@ -1782,7 +1782,7 @@ This operation returns the shape of the tensor and thus can not be fused into a ______________________________________________________________________ - + ### method `q_impl` @@ -1795,7 +1795,7 @@ q_impl( ______________________________________________________________________ - + ## class `ONNXConstantOfShape` @@ -1813,7 +1813,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `can_fuse` @@ -1831,7 +1831,7 @@ This operation returns a new encrypted tensor and thus can not be fused. ______________________________________________________________________ - + ## class `ONNXGather` @@ -1851,7 +1851,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `can_fuse` @@ -1869,7 +1869,7 @@ This operation returns values from a tensor and thus can not be fused into a uni ______________________________________________________________________ - + ### method `q_impl` @@ -1882,7 +1882,7 @@ q_impl( ______________________________________________________________________ - + ## class `ONNXSlice` @@ -1900,7 +1900,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `can_fuse` @@ -1918,7 +1918,7 @@ This operation returns values from a tensor and thus can not be fused into a uni ______________________________________________________________________ - + ### method `q_impl` @@ -1931,7 +1931,7 @@ q_impl( ______________________________________________________________________ - + ## class `QuantizedExpand` @@ -1949,7 +1949,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `can_fuse` @@ -1967,7 +1967,7 @@ Unsqueeze can not be fused since it must be performed over integer tensors as it ______________________________________________________________________ - + ### method `q_impl` @@ -1991,7 +1991,7 @@ Expand the input tensor to a specified shape. ______________________________________________________________________ - + ## class `QuantizedEqual` @@ -1999,7 +1999,7 @@ Comparison operator ==. Only supports comparison with a constant. - + ### method `__init__` @@ -2026,13 +2026,13 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ## class `QuantizedUnfold` Quantized Unfold op. - + ### method `__init__` @@ -2059,7 +2059,7 @@ Get the names of encrypted integer tensors that are used by this op. ______________________________________________________________________ - + ### method `q_impl` diff --git a/docs/references/api/concrete.ml.quantization.quantizers.md b/docs/references/api/concrete.ml.quantization.quantizers.md index c4ed34e4e..cdef46c2d 100644 --- a/docs/references/api/concrete.ml.quantization.quantizers.md +++ b/docs/references/api/concrete.ml.quantization.quantizers.md @@ -13,7 +13,7 @@ Quantization utilities for a numpy array/tensor. ______________________________________________________________________ - + ## function `fill_from_kwargs` @@ -40,7 +40,7 @@ Fill a parameter set structure from kwargs parameters. ______________________________________________________________________ - + ## class `QuantizationOptions` @@ -48,7 +48,7 @@ Options for quantization. Determines the number of bits for quantization and the method of quantization of the values. Signed quantization allows negative quantized values. Symmetric quantization assumes the float values are distributed symmetrically around x=0 and assigns signed values around 0 to the float values. QAT (quantization aware training) quantization assumes the values are already quantized, taking a discrete set of values, and assigns these values to integers, computing only the scale. - + ### method `__init__` @@ -73,7 +73,7 @@ Get a copy of the quantization parameters. ______________________________________________________________________ - + ### method `copy_opts` @@ -89,7 +89,7 @@ Copy the options from a different structure. ______________________________________________________________________ - + ### method `dump` @@ -105,7 +105,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -121,7 +121,7 @@ Dump itself to a dict. ______________________________________________________________________ - + ### method `dumps` @@ -137,7 +137,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `is_equal` @@ -158,7 +158,7 @@ Compare two quantization options sets. ______________________________________________________________________ - + ### method `load_dict` @@ -178,7 +178,7 @@ Load itself from a string. ______________________________________________________________________ - + ## class `MinMaxQuantizationStats` @@ -186,7 +186,7 @@ Calibration set statistics. This class stores the statistics for the calibration set or for a calibration data batch. Currently we only store min/max to determine the quantization range. The min/max are computed from the calibration set. - + ### method `__init__` @@ -210,7 +210,7 @@ Get a copy of the calibration set statistics. ______________________________________________________________________ - + ### method `check_is_uniform_quantized` @@ -232,7 +232,7 @@ Determines whether the values represented by this QuantizedArray show a quantize ______________________________________________________________________ - + ### method `compute_quantization_stats` @@ -248,7 +248,7 @@ Compute the calibration set quantization statistics. ______________________________________________________________________ - + ### method `copy_stats` @@ -264,7 +264,7 @@ Copy the statistics from a different structure. ______________________________________________________________________ - + ### method `dump` @@ -280,7 +280,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -296,7 +296,7 @@ Dump itself to a dict. ______________________________________________________________________ - + ### method `dumps` @@ -312,7 +312,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `load_dict` @@ -332,7 +332,7 @@ Load itself from a string. ______________________________________________________________________ - + ## class `UniformQuantizationParameters` @@ -340,7 +340,7 @@ Quantization parameters for uniform quantization. This class stores the parameters used for quantizing real values to discrete integer values. The parameters are computed from quantization options and quantization statistics. - + ### method `__init__` @@ -364,7 +364,7 @@ Get a copy of the quantization parameters. ______________________________________________________________________ - + ### method `compute_quantization_parameters` @@ -384,7 +384,7 @@ Compute the quantization parameters. ______________________________________________________________________ - + ### method `copy_params` @@ -400,7 +400,7 @@ Copy the parameters from a different structure. ______________________________________________________________________ - + ### method `dump` @@ -416,7 +416,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -432,7 +432,7 @@ Dump itself to a dict. ______________________________________________________________________ - + ### method `dumps` @@ -448,7 +448,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `load_dict` @@ -468,7 +468,7 @@ Load itself from a string. ______________________________________________________________________ - + ## class `UniformQuantizer` @@ -482,7 +482,7 @@ Contains all information necessary for uniform quantization and provides quantiz - `stats` (Optional\[MinMaxQuantizationStats\]): Quantization batch statistics set - `params` (Optional\[UniformQuantizationParameters\]): Quantization parameters set (scale, zero-point) - + ### method `__init__` @@ -527,7 +527,7 @@ Get a copy of the calibration set statistics. ______________________________________________________________________ - + ### method `check_is_uniform_quantized` @@ -549,7 +549,7 @@ Determines whether the values represented by this QuantizedArray show a quantize ______________________________________________________________________ - + ### method `compute_quantization_parameters` @@ -569,7 +569,7 @@ Compute the quantization parameters. ______________________________________________________________________ - + ### method `compute_quantization_stats` @@ -585,7 +585,7 @@ Compute the calibration set quantization statistics. ______________________________________________________________________ - + ### method `copy_opts` @@ -601,7 +601,7 @@ Copy the options from a different structure. ______________________________________________________________________ - + ### method `copy_params` @@ -617,7 +617,7 @@ Copy the parameters from a different structure. ______________________________________________________________________ - + ### method `copy_stats` @@ -633,7 +633,7 @@ Copy the statistics from a different structure. ______________________________________________________________________ - + ### method `dequant` @@ -653,7 +653,7 @@ De-quantize values. ______________________________________________________________________ - + ### method `dump` @@ -669,7 +669,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -685,7 +685,7 @@ Dump itself to a dict. ______________________________________________________________________ - + ### method `dumps` @@ -701,7 +701,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `is_equal` @@ -722,7 +722,7 @@ Compare two quantization options sets. ______________________________________________________________________ - + ### method `load_dict` @@ -742,7 +742,7 @@ Load itself from a string. ______________________________________________________________________ - + ### method `quant` @@ -762,7 +762,7 @@ Quantize values. ______________________________________________________________________ - + ## class `QuantizedArray` @@ -782,7 +782,7 @@ See https://arxiv.org/abs/1712.05877. - `params` (Optional\[UniformQuantizationParameters\]): Quantization parameters set (scale, zero-point) - `kwargs`: Any member of the options, stats, params sets as a key-value pair. The parameter sets need to be completely parametrized if their members appear in kwargs. - + ### method `__init__` @@ -800,7 +800,7 @@ __init__( ______________________________________________________________________ - + ### method `dequant` @@ -816,7 +816,7 @@ De-quantize self.qvalues. ______________________________________________________________________ - + ### method `dump` @@ -832,7 +832,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -848,7 +848,7 @@ Dump itself to a dict. ______________________________________________________________________ - + ### method `dumps` @@ -864,7 +864,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `load_dict` @@ -884,7 +884,7 @@ Load itself from a string. ______________________________________________________________________ - + ### method `quant` @@ -900,7 +900,7 @@ Quantize self.values. ______________________________________________________________________ - + ### method `update_quantized_values` @@ -922,7 +922,7 @@ Update qvalues to get their corresponding values using the related quantized par ______________________________________________________________________ - + ### method `update_values` diff --git a/docs/references/api/concrete.ml.search_parameters.p_error_search.md b/docs/references/api/concrete.ml.search_parameters.p_error_search.md index 7cc6cd405..3caaec776 100644 --- a/docs/references/api/concrete.ml.search_parameters.p_error_search.md +++ b/docs/references/api/concrete.ml.search_parameters.p_error_search.md @@ -43,7 +43,7 @@ If we don't reach the convergence, a user warning is raised. ______________________________________________________________________ - + ## function `compile_and_simulated_fhe_inference` @@ -91,13 +91,13 @@ Supported models are: ______________________________________________________________________ - + ## class `BinarySearch` Class for `p_error` hyper-parameter search for classification and regression tasks. - + ### method `__init__` @@ -147,7 +147,7 @@ __init__( ______________________________________________________________________ - + ### method `eval_match` @@ -174,7 +174,7 @@ Eval the matches. ______________________________________________________________________ - + ### method `reset_history` @@ -186,7 +186,7 @@ Clean history. ______________________________________________________________________ - + ### method `run` diff --git a/docs/references/api/concrete.ml.sklearn.base.md b/docs/references/api/concrete.ml.sklearn.base.md index ab242bd34..e7419b077 100644 --- a/docs/references/api/concrete.ml.sklearn.base.md +++ b/docs/references/api/concrete.ml.sklearn.base.md @@ -14,7 +14,7 @@ Base classes for all estimators. ______________________________________________________________________ - + ## class `BaseEstimator` @@ -26,7 +26,7 @@ This class does not inherit from sklearn.base.BaseEstimator as it creates some c - `_is_a_public_cml_model` (bool): Private attribute indicating if the class is a public model (as opposed to base or mixin classes). - + ### method `__init__` @@ -44,7 +44,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -84,7 +84,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `check_model_is_compiled` @@ -100,7 +100,7 @@ Check if the model is compiled. ______________________________________________________________________ - + ### method `check_model_is_fitted` @@ -116,7 +116,7 @@ Check if the model is fitted. ______________________________________________________________________ - + ### method `compile` @@ -150,7 +150,7 @@ Compile the model. ______________________________________________________________________ - + ### method `dequantize_output` @@ -172,7 +172,7 @@ This step ensures that the fit method has been called. ______________________________________________________________________ - + ### method `dump` @@ -188,7 +188,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -204,7 +204,7 @@ Dump the object as a dict. ______________________________________________________________________ - + ### method `dumps` @@ -220,7 +220,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `fit` @@ -243,7 +243,7 @@ The fitted estimator. ______________________________________________________________________ - + ### method `fit_benchmark` @@ -270,7 +270,7 @@ The Concrete ML and float equivalent fitted estimators. ______________________________________________________________________ - + ### method `get_sklearn_params` @@ -292,7 +292,7 @@ This method is used to instantiate a scikit-learn model using the Concrete ML mo ______________________________________________________________________ - + ### classmethod `load_dict` @@ -312,7 +312,7 @@ Load itself from a dict. ______________________________________________________________________ - + ### method `post_processing` @@ -336,7 +336,7 @@ For some simple models such a linear regression, there is no post-processing ste ______________________________________________________________________ - + ### method `predict` @@ -360,7 +360,7 @@ Predict values for X, in FHE or in the clear. ______________________________________________________________________ - + ### method `quantize_input` @@ -382,7 +382,7 @@ This step ensures that the fit method has been called. ______________________________________________________________________ - + ## class `BaseClassifier` @@ -390,7 +390,7 @@ Base class for linear and tree-based classifiers in Concrete ML. This class inherits from BaseEstimator and modifies some of its methods in order to align them with classifier behaviors. This notably include applying a sigmoid/softmax post-processing to the predicted values as well as handling a mapping of classes in case they are not ordered. - + ### method `__init__` @@ -408,7 +408,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -472,7 +472,7 @@ Using this attribute is deprecated. ______________________________________________________________________ - + ### method `check_model_is_compiled` @@ -488,7 +488,7 @@ Check if the model is compiled. ______________________________________________________________________ - + ### method `check_model_is_fitted` @@ -504,7 +504,7 @@ Check if the model is fitted. ______________________________________________________________________ - + ### method `compile` @@ -538,7 +538,7 @@ Compile the model. ______________________________________________________________________ - + ### method `dequantize_output` @@ -560,7 +560,7 @@ This step ensures that the fit method has been called. ______________________________________________________________________ - + ### method `dump` @@ -576,7 +576,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -592,7 +592,7 @@ Dump the object as a dict. ______________________________________________________________________ - + ### method `dumps` @@ -608,7 +608,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `fit` @@ -618,7 +618,7 @@ fit(X: 'Data', y: 'Target', **fit_parameters) ______________________________________________________________________ - + ### method `fit_benchmark` @@ -645,7 +645,7 @@ The Concrete ML and float equivalent fitted estimators. ______________________________________________________________________ - + ### method `get_sklearn_params` @@ -667,7 +667,7 @@ This method is used to instantiate a scikit-learn model using the Concrete ML mo ______________________________________________________________________ - + ### classmethod `load_dict` @@ -687,7 +687,7 @@ Load itself from a dict. ______________________________________________________________________ - + ### method `post_processing` @@ -697,7 +697,7 @@ post_processing(y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `predict` @@ -710,7 +710,7 @@ predict( ______________________________________________________________________ - + ### method `predict_proba` @@ -734,7 +734,7 @@ Predict class probabilities. ______________________________________________________________________ - + ### method `quantize_input` @@ -756,13 +756,13 @@ This step ensures that the fit method has been called. ______________________________________________________________________ - + ## class `QuantizedTorchEstimatorMixin` Mixin that provides quantization for a torch module and follows the Estimator API. - + ### method `__init__` @@ -838,7 +838,7 @@ Get the output quantizers. ______________________________________________________________________ - + ### method `check_model_is_compiled` @@ -854,7 +854,7 @@ Check if the model is compiled. ______________________________________________________________________ - + ### method `check_model_is_fitted` @@ -870,7 +870,7 @@ Check if the model is fitted. ______________________________________________________________________ - + ### method `compile` @@ -888,7 +888,7 @@ compile( ______________________________________________________________________ - + ### method `dequantize_output` @@ -898,7 +898,7 @@ dequantize_output(*q_y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `dump` @@ -914,7 +914,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -930,7 +930,7 @@ Dump the object as a dict. ______________________________________________________________________ - + ### method `dumps` @@ -946,7 +946,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `fit` @@ -971,7 +971,7 @@ The fitted estimator. ______________________________________________________________________ - + ### method `fit_benchmark` @@ -1002,7 +1002,7 @@ The Concrete ML and equivalent skorch fitted estimators. ______________________________________________________________________ - + ### method `get_params` @@ -1024,7 +1024,7 @@ This method is overloaded in order to make sure that auto-computed parameters ar ______________________________________________________________________ - + ### method `get_sklearn_params` @@ -1034,7 +1034,7 @@ get_sklearn_params(deep: 'bool' = True) → Dict ______________________________________________________________________ - + ### classmethod `load_dict` @@ -1054,7 +1054,7 @@ Load itself from a dict. ______________________________________________________________________ - + ### method `post_processing` @@ -1064,7 +1064,7 @@ post_processing(y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `predict` @@ -1088,7 +1088,7 @@ Predict values for X, in FHE or in the clear. ______________________________________________________________________ - + ### method `prune` @@ -1116,7 +1116,7 @@ A new pruned copy of the Neural Network model. ______________________________________________________________________ - + ### method `quantize_input` @@ -1126,7 +1126,7 @@ quantize_input(X: 'ndarray') → ndarray ______________________________________________________________________ - + ## class `BaseTreeEstimatorMixin` @@ -1134,7 +1134,7 @@ Mixin class for tree-based estimators. This class inherits from sklearn.base.BaseEstimator in order to have access to scikit-learn's `get_params` and `set_params` methods. - + ### method `__init__` @@ -1156,7 +1156,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -1196,7 +1196,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `check_model_is_compiled` @@ -1212,7 +1212,7 @@ Check if the model is compiled. ______________________________________________________________________ - + ### method `check_model_is_fitted` @@ -1228,7 +1228,7 @@ Check if the model is fitted. ______________________________________________________________________ - + ### method `compile` @@ -1238,7 +1238,7 @@ compile(*args, **kwargs) → Circuit ______________________________________________________________________ - + ### method `dequantize_output` @@ -1248,7 +1248,7 @@ dequantize_output(q_y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `dump` @@ -1264,7 +1264,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -1280,7 +1280,7 @@ Dump the object as a dict. ______________________________________________________________________ - + ### method `dumps` @@ -1296,7 +1296,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `fit` @@ -1306,7 +1306,7 @@ fit(X: 'Data', y: 'Target', **fit_parameters) ______________________________________________________________________ - + ### method `fit_benchmark` @@ -1333,7 +1333,7 @@ The Concrete ML and float equivalent fitted estimators. ______________________________________________________________________ - + ### method `get_sklearn_params` @@ -1355,7 +1355,7 @@ This method is used to instantiate a scikit-learn model using the Concrete ML mo ______________________________________________________________________ - + ### classmethod `load_dict` @@ -1375,7 +1375,7 @@ Load itself from a dict. ______________________________________________________________________ - + ### method `post_processing` @@ -1385,7 +1385,7 @@ post_processing(y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `predict` @@ -1398,7 +1398,7 @@ predict( ______________________________________________________________________ - + ### method `quantize_input` @@ -1408,7 +1408,7 @@ quantize_input(X: 'ndarray') → ndarray ______________________________________________________________________ - + ## class `BaseTreeRegressorMixin` @@ -1416,7 +1416,7 @@ Mixin class for tree-based regressors. This class is used to create a tree-based regressor class that inherits from sklearn.base.RegressorMixin, which essentially gives access to scikit-learn's `score` method for regressors. - + ### method `__init__` @@ -1438,7 +1438,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -1478,7 +1478,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `check_model_is_compiled` @@ -1494,7 +1494,7 @@ Check if the model is compiled. ______________________________________________________________________ - + ### method `check_model_is_fitted` @@ -1510,7 +1510,7 @@ Check if the model is fitted. ______________________________________________________________________ - + ### method `compile` @@ -1520,7 +1520,7 @@ compile(*args, **kwargs) → Circuit ______________________________________________________________________ - + ### method `dequantize_output` @@ -1530,7 +1530,7 @@ dequantize_output(q_y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `dump` @@ -1546,7 +1546,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -1562,7 +1562,7 @@ Dump the object as a dict. ______________________________________________________________________ - + ### method `dumps` @@ -1578,7 +1578,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `fit` @@ -1588,7 +1588,7 @@ fit(X: 'Data', y: 'Target', **fit_parameters) ______________________________________________________________________ - + ### method `fit_benchmark` @@ -1615,7 +1615,7 @@ The Concrete ML and float equivalent fitted estimators. ______________________________________________________________________ - + ### method `get_sklearn_params` @@ -1637,7 +1637,7 @@ This method is used to instantiate a scikit-learn model using the Concrete ML mo ______________________________________________________________________ - + ### classmethod `load_dict` @@ -1657,7 +1657,7 @@ Load itself from a dict. ______________________________________________________________________ - + ### method `post_processing` @@ -1667,7 +1667,7 @@ post_processing(y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `predict` @@ -1680,7 +1680,7 @@ predict( ______________________________________________________________________ - + ### method `quantize_input` @@ -1690,7 +1690,7 @@ quantize_input(X: 'ndarray') → ndarray ______________________________________________________________________ - + ## class `BaseTreeClassifierMixin` @@ -1700,7 +1700,7 @@ This class is used to create a tree-based classifier class that inherits from sk Additionally, this class adjusts some of the tree-based base class's methods in order to make them compliant with classification workflows. - + ### method `__init__` @@ -1722,7 +1722,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -1786,7 +1786,7 @@ Using this attribute is deprecated. ______________________________________________________________________ - + ### method `check_model_is_compiled` @@ -1802,7 +1802,7 @@ Check if the model is compiled. ______________________________________________________________________ - + ### method `check_model_is_fitted` @@ -1818,7 +1818,7 @@ Check if the model is fitted. ______________________________________________________________________ - + ### method `compile` @@ -1828,7 +1828,7 @@ compile(*args, **kwargs) → Circuit ______________________________________________________________________ - + ### method `dequantize_output` @@ -1838,7 +1838,7 @@ dequantize_output(q_y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `dump` @@ -1854,7 +1854,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -1870,7 +1870,7 @@ Dump the object as a dict. ______________________________________________________________________ - + ### method `dumps` @@ -1886,7 +1886,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `fit` @@ -1896,7 +1896,7 @@ fit(X: 'Data', y: 'Target', **fit_parameters) ______________________________________________________________________ - + ### method `fit_benchmark` @@ -1923,7 +1923,7 @@ The Concrete ML and float equivalent fitted estimators. ______________________________________________________________________ - + ### method `get_sklearn_params` @@ -1945,7 +1945,7 @@ This method is used to instantiate a scikit-learn model using the Concrete ML mo ______________________________________________________________________ - + ### classmethod `load_dict` @@ -1965,7 +1965,7 @@ Load itself from a dict. ______________________________________________________________________ - + ### method `post_processing` @@ -1975,7 +1975,7 @@ post_processing(y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `predict` @@ -1988,7 +1988,7 @@ predict( ______________________________________________________________________ - + ### method `predict_proba` @@ -2012,7 +2012,7 @@ Predict class probabilities. ______________________________________________________________________ - + ### method `quantize_input` @@ -2022,7 +2022,7 @@ quantize_input(X: 'ndarray') → ndarray ______________________________________________________________________ - + ## class `SklearnLinearModelMixin` @@ -2030,7 +2030,7 @@ A Mixin class for sklearn linear models with FHE. This class inherits from sklearn.base.BaseEstimator in order to have access to scikit-learn's `get_params` and `set_params` methods. - + ### method `__init__` @@ -2052,7 +2052,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -2092,7 +2092,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `check_model_is_compiled` @@ -2108,7 +2108,7 @@ Check if the model is compiled. ______________________________________________________________________ - + ### method `check_model_is_fitted` @@ -2124,7 +2124,7 @@ Check if the model is fitted. ______________________________________________________________________ - + ### method `compile` @@ -2158,7 +2158,7 @@ Compile the model. ______________________________________________________________________ - + ### method `dequantize_output` @@ -2168,7 +2168,7 @@ dequantize_output(q_y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `dump` @@ -2184,7 +2184,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -2200,7 +2200,7 @@ Dump the object as a dict. ______________________________________________________________________ - + ### method `dumps` @@ -2216,7 +2216,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `fit` @@ -2226,7 +2226,7 @@ fit(X: 'Data', y: 'Target', **fit_parameters) ______________________________________________________________________ - + ### method `fit_benchmark` @@ -2253,7 +2253,7 @@ The Concrete ML and float equivalent fitted estimators. ______________________________________________________________________ - + ### classmethod `from_sklearn_model` @@ -2280,7 +2280,7 @@ The FHE-compliant fitted model. ______________________________________________________________________ - + ### method `get_sklearn_params` @@ -2302,7 +2302,7 @@ This method is used to instantiate a scikit-learn model using the Concrete ML mo ______________________________________________________________________ - + ### classmethod `load_dict` @@ -2322,7 +2322,7 @@ Load itself from a dict. ______________________________________________________________________ - + ### method `post_processing` @@ -2346,7 +2346,7 @@ For some simple models such a linear regression, there is no post-processing ste ______________________________________________________________________ - + ### method `predict` @@ -2370,7 +2370,7 @@ Predict values for X, in FHE or in the clear. ______________________________________________________________________ - + ### method `quantize_input` @@ -2380,7 +2380,7 @@ quantize_input(X: 'ndarray') → ndarray ______________________________________________________________________ - + ## class `SklearnLinearRegressorMixin` @@ -2388,7 +2388,7 @@ A Mixin class for sklearn linear regressors with FHE. This class is used to create a linear regressor class that inherits from sklearn.base.RegressorMixin, which essentially gives access to scikit-learn's `score` method for regressors. - + ### method `__init__` @@ -2410,7 +2410,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -2450,7 +2450,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `check_model_is_compiled` @@ -2466,7 +2466,7 @@ Check if the model is compiled. ______________________________________________________________________ - + ### method `check_model_is_fitted` @@ -2482,7 +2482,7 @@ Check if the model is fitted. ______________________________________________________________________ - + ### method `compile` @@ -2516,7 +2516,7 @@ Compile the model. ______________________________________________________________________ - + ### method `dequantize_output` @@ -2526,7 +2526,7 @@ dequantize_output(q_y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `dump` @@ -2542,7 +2542,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -2558,7 +2558,7 @@ Dump the object as a dict. ______________________________________________________________________ - + ### method `dumps` @@ -2574,7 +2574,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `fit` @@ -2584,7 +2584,7 @@ fit(X: 'Data', y: 'Target', **fit_parameters) ______________________________________________________________________ - + ### method `fit_benchmark` @@ -2611,7 +2611,7 @@ The Concrete ML and float equivalent fitted estimators. ______________________________________________________________________ - + ### classmethod `from_sklearn_model` @@ -2638,7 +2638,7 @@ The FHE-compliant fitted model. ______________________________________________________________________ - + ### method `get_sklearn_params` @@ -2660,7 +2660,7 @@ This method is used to instantiate a scikit-learn model using the Concrete ML mo ______________________________________________________________________ - + ### classmethod `load_dict` @@ -2680,7 +2680,7 @@ Load itself from a dict. ______________________________________________________________________ - + ### method `post_processing` @@ -2704,7 +2704,7 @@ For some simple models such a linear regression, there is no post-processing ste ______________________________________________________________________ - + ### method `predict` @@ -2728,7 +2728,7 @@ Predict values for X, in FHE or in the clear. ______________________________________________________________________ - + ### method `quantize_input` @@ -2738,15 +2738,17 @@ quantize_input(X: 'ndarray') → ndarray ______________________________________________________________________ - + -## class `SklearnSGDRegressorMixin` +## class `SklearnLinearClassifierMixin` -A Mixin class for sklearn SGD regressors with FHE. +A Mixin class for sklearn linear classifiers with FHE. -This class is used to create a SGD regressor class what can be exported to ONNX using Hummingbird. +This class is used to create a linear classifier class that inherits from sklearn.base.ClassifierMixin, which essentially gives access to scikit-learn's `score` method for classifiers. + +Additionally, this class adjusts some of the tree-based base class's methods in order to make them compliant with classification workflows. - + ### method `__init__` @@ -2768,7 +2770,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -2796,6 +2798,18 @@ Indicate if the model is fitted. ______________________________________________________________________ +#### property n_classes\_ + +Get the model's number of classes. + +Using this attribute is deprecated. + +**Returns:** + +- `int`: The model's number of classes. + +______________________________________________________________________ + #### property onnx_model Get the ONNX model. @@ -2808,7 +2822,19 @@ Is None if the model is not fitted. ______________________________________________________________________ - +#### property target_classes\_ + +Get the model's classes. + +Using this attribute is deprecated. + +**Returns:** + +- `Optional[numpy.ndarray]`: The model's classes. + +______________________________________________________________________ + + ### method `check_model_is_compiled` @@ -2824,7 +2850,7 @@ Check if the model is compiled. ______________________________________________________________________ - + ### method `check_model_is_fitted` @@ -2840,7 +2866,7 @@ Check if the model is fitted. ______________________________________________________________________ - + ### method `compile` @@ -2874,7 +2900,31 @@ Compile the model. ______________________________________________________________________ - + + +### method `decision_function` + +```python +decision_function( + X: 'Data', + fhe: 'Union[FheMode, str]' = +) → ndarray +``` + +Predict confidence scores. + +**Args:** + +- `X` (Data): The input values to predict, as a Numpy array, Torch tensor, Pandas DataFrame or List. +- `fhe` (Union\[FheMode, str\]): The mode to use for prediction. Can be FheMode.DISABLE for Concrete ML Python inference, FheMode.SIMULATE for FHE simulation and FheMode.EXECUTE for actual FHE execution. Can also be the string representation of any of these values. Default to FheMode.DISABLE. + +**Returns:** + +- `numpy.ndarray`: The predicted confidence scores. + +______________________________________________________________________ + + ### method `dequantize_output` @@ -2884,7 +2934,7 @@ dequantize_output(q_y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `dump` @@ -2900,7 +2950,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -2916,7 +2966,7 @@ Dump the object as a dict. ______________________________________________________________________ - + ### method `dumps` @@ -2932,7 +2982,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `fit` @@ -2942,7 +2992,7 @@ fit(X: 'Data', y: 'Target', **fit_parameters) ______________________________________________________________________ - + ### method `fit_benchmark` @@ -2969,7 +3019,7 @@ The Concrete ML and float equivalent fitted estimators. ______________________________________________________________________ - + ### classmethod `from_sklearn_model` @@ -2996,7 +3046,7 @@ The FHE-compliant fitted model. ______________________________________________________________________ - + ### method `get_sklearn_params` @@ -3018,7 +3068,7 @@ This method is used to instantiate a scikit-learn model using the Concrete ML mo ______________________________________________________________________ - + ### classmethod `load_dict` @@ -3038,7 +3088,7 @@ Load itself from a dict. ______________________________________________________________________ - + ### method `post_processing` @@ -3046,23 +3096,9 @@ ______________________________________________________________________ post_processing(y_preds: 'ndarray') → ndarray ``` -Apply post-processing to the de-quantized predictions. - -This post-processing step can include operations such as applying the sigmoid or softmax function for classifiers, or summing an ensemble's outputs. These steps are done in the clear because of current technical constraints. They most likely will be integrated in the FHE computations in the future. - -For some simple models such a linear regression, there is no post-processing step but the method is kept to make the API consistent for the client-server API. Other models might need to use attributes stored in `post_processing_params`. - -**Args:** - -- `y_preds` (numpy.ndarray): The de-quantized predictions to post-process. - -**Returns:** - -- `numpy.ndarray`: The post-processed predictions. - ______________________________________________________________________ - + ### method `predict` @@ -3073,20 +3109,22 @@ predict( ) → ndarray ``` -Predict values for X, in FHE or in the clear. - -**Args:** +______________________________________________________________________ -- `X` (Data): The input values to predict, as a Numpy array, Torch tensor, Pandas DataFrame or List. -- `fhe` (Union\[FheMode, str\]): The mode to use for prediction. Can be FheMode.DISABLE for Concrete ML Python inference, FheMode.SIMULATE for FHE simulation and FheMode.EXECUTE for actual FHE execution. Can also be the string representation of any of these values. Default to FheMode.DISABLE. + -**Returns:** +### method `predict_proba` -- `np.ndarray`: The predicted values for X. +```python +predict_proba( + X: 'Data', + fhe: 'Union[FheMode, str]' = +) → ndarray +``` ______________________________________________________________________ - + ### method `quantize_input` @@ -3096,17 +3134,15 @@ quantize_input(X: 'ndarray') → ndarray ______________________________________________________________________ - - -## class `SklearnLinearClassifierMixin` + -A Mixin class for sklearn linear classifiers with FHE. +## class `SklearnSGDRegressorMixin` -This class is used to create a linear classifier class that inherits from sklearn.base.ClassifierMixin, which essentially gives access to scikit-learn's `score` method for classifiers. +A Mixin class for sklearn SGD regressors with FHE. -Additionally, this class adjusts some of the tree-based base class's methods in order to make them compliant with classification workflows. +This class is used to create a SGD regressor class what can be exported to ONNX using Hummingbird. - + ### method `__init__` @@ -3128,7 +3164,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -3156,18 +3192,6 @@ Indicate if the model is fitted. ______________________________________________________________________ -#### property n_classes\_ - -Get the model's number of classes. - -Using this attribute is deprecated. - -**Returns:** - -- `int`: The model's number of classes. - -______________________________________________________________________ - #### property onnx_model Get the ONNX model. @@ -3180,19 +3204,7 @@ Is None if the model is not fitted. ______________________________________________________________________ -#### property target_classes\_ - -Get the model's classes. - -Using this attribute is deprecated. - -**Returns:** - -- `Optional[numpy.ndarray]`: The model's classes. - -______________________________________________________________________ - - + ### method `check_model_is_compiled` @@ -3208,7 +3220,7 @@ Check if the model is compiled. ______________________________________________________________________ - + ### method `check_model_is_fitted` @@ -3224,7 +3236,7 @@ Check if the model is fitted. ______________________________________________________________________ - + ### method `compile` @@ -3258,31 +3270,7 @@ Compile the model. ______________________________________________________________________ - - -### method `decision_function` - -```python -decision_function( - X: 'Data', - fhe: 'Union[FheMode, str]' = -) → ndarray -``` - -Predict confidence scores. - -**Args:** - -- `X` (Data): The input values to predict, as a Numpy array, Torch tensor, Pandas DataFrame or List. -- `fhe` (Union\[FheMode, str\]): The mode to use for prediction. Can be FheMode.DISABLE for Concrete ML Python inference, FheMode.SIMULATE for FHE simulation and FheMode.EXECUTE for actual FHE execution. Can also be the string representation of any of these values. Default to FheMode.DISABLE. - -**Returns:** - -- `numpy.ndarray`: The predicted confidence scores. - -______________________________________________________________________ - - + ### method `dequantize_output` @@ -3292,7 +3280,7 @@ dequantize_output(q_y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `dump` @@ -3308,7 +3296,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -3324,7 +3312,7 @@ Dump the object as a dict. ______________________________________________________________________ - + ### method `dumps` @@ -3340,7 +3328,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `fit` @@ -3350,7 +3338,7 @@ fit(X: 'Data', y: 'Target', **fit_parameters) ______________________________________________________________________ - + ### method `fit_benchmark` @@ -3377,7 +3365,7 @@ The Concrete ML and float equivalent fitted estimators. ______________________________________________________________________ - + ### classmethod `from_sklearn_model` @@ -3404,7 +3392,7 @@ The FHE-compliant fitted model. ______________________________________________________________________ - + ### method `get_sklearn_params` @@ -3426,7 +3414,7 @@ This method is used to instantiate a scikit-learn model using the Concrete ML mo ______________________________________________________________________ - + ### classmethod `load_dict` @@ -3446,7 +3434,7 @@ Load itself from a dict. ______________________________________________________________________ - + ### method `post_processing` @@ -3454,9 +3442,23 @@ ______________________________________________________________________ post_processing(y_preds: 'ndarray') → ndarray ``` +Apply post-processing to the de-quantized predictions. + +This post-processing step can include operations such as applying the sigmoid or softmax function for classifiers, or summing an ensemble's outputs. These steps are done in the clear because of current technical constraints. They most likely will be integrated in the FHE computations in the future. + +For some simple models such a linear regression, there is no post-processing step but the method is kept to make the API consistent for the client-server API. Other models might need to use attributes stored in `post_processing_params`. + +**Args:** + +- `y_preds` (numpy.ndarray): The de-quantized predictions to post-process. + +**Returns:** + +- `numpy.ndarray`: The post-processed predictions. + ______________________________________________________________________ - + ### method `predict` @@ -3467,22 +3469,20 @@ predict( ) → ndarray ``` -______________________________________________________________________ +Predict values for X, in FHE or in the clear. - +**Args:** -### method `predict_proba` +- `X` (Data): The input values to predict, as a Numpy array, Torch tensor, Pandas DataFrame or List. +- `fhe` (Union\[FheMode, str\]): The mode to use for prediction. Can be FheMode.DISABLE for Concrete ML Python inference, FheMode.SIMULATE for FHE simulation and FheMode.EXECUTE for actual FHE execution. Can also be the string representation of any of these values. Default to FheMode.DISABLE. -```python -predict_proba( - X: 'Data', - fhe: 'Union[FheMode, str]' = -) → ndarray -``` +**Returns:** + +- `np.ndarray`: The predicted values for X. ______________________________________________________________________ - + ### method `quantize_input` @@ -3492,7 +3492,7 @@ quantize_input(X: 'ndarray') → ndarray ______________________________________________________________________ - + ## class `SklearnSGDClassifierMixin` @@ -3500,7 +3500,7 @@ A Mixin class for sklearn SGD classifiers with FHE. This class is used to create a SGD classifier class what can be exported to ONNX using Hummingbird. - + ### method `__init__` @@ -3522,7 +3522,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -3586,7 +3586,7 @@ Using this attribute is deprecated. ______________________________________________________________________ - + ### method `check_model_is_compiled` @@ -3602,7 +3602,7 @@ Check if the model is compiled. ______________________________________________________________________ - + ### method `check_model_is_fitted` @@ -3618,7 +3618,7 @@ Check if the model is fitted. ______________________________________________________________________ - + ### method `compile` @@ -3652,7 +3652,7 @@ Compile the model. ______________________________________________________________________ - + ### method `decision_function` @@ -3676,7 +3676,7 @@ Predict confidence scores. ______________________________________________________________________ - + ### method `dequantize_output` @@ -3686,7 +3686,7 @@ dequantize_output(q_y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `dump` @@ -3702,7 +3702,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -3718,7 +3718,7 @@ Dump the object as a dict. ______________________________________________________________________ - + ### method `dumps` @@ -3734,7 +3734,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `fit` @@ -3744,7 +3744,7 @@ fit(X: 'Data', y: 'Target', **fit_parameters) ______________________________________________________________________ - + ### method `fit_benchmark` @@ -3771,7 +3771,7 @@ The Concrete ML and float equivalent fitted estimators. ______________________________________________________________________ - + ### classmethod `from_sklearn_model` @@ -3798,7 +3798,7 @@ The FHE-compliant fitted model. ______________________________________________________________________ - + ### method `get_sklearn_params` @@ -3820,7 +3820,7 @@ This method is used to instantiate a scikit-learn model using the Concrete ML mo ______________________________________________________________________ - + ### classmethod `load_dict` @@ -3840,7 +3840,7 @@ Load itself from a dict. ______________________________________________________________________ - + ### method `post_processing` @@ -3850,7 +3850,7 @@ post_processing(y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `predict` @@ -3863,7 +3863,7 @@ predict( ______________________________________________________________________ - + ### method `predict_proba` @@ -3876,7 +3876,7 @@ predict_proba( ______________________________________________________________________ - + ### method `quantize_input` @@ -3886,7 +3886,7 @@ quantize_input(X: 'ndarray') → ndarray ______________________________________________________________________ - + ## class `SklearnKNeighborsMixin` @@ -3894,7 +3894,7 @@ A Mixin class for sklearn KNeighbors models with FHE. This class inherits from sklearn.base.BaseEstimator in order to have access to scikit-learn's `get_params` and `set_params` methods. - + ### method `__init__` @@ -3914,7 +3914,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -3954,7 +3954,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `check_model_is_compiled` @@ -3970,7 +3970,7 @@ Check if the model is compiled. ______________________________________________________________________ - + ### method `check_model_is_fitted` @@ -3986,7 +3986,7 @@ Check if the model is fitted. ______________________________________________________________________ - + ### method `compile` @@ -4020,7 +4020,7 @@ Compile the model. ______________________________________________________________________ - + ### method `dequantize_output` @@ -4030,7 +4030,7 @@ dequantize_output(q_y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `dump` @@ -4046,7 +4046,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -4062,7 +4062,7 @@ Dump the object as a dict. ______________________________________________________________________ - + ### method `dumps` @@ -4078,7 +4078,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `fit` @@ -4088,7 +4088,7 @@ fit(X: 'Data', y: 'Target', **fit_parameters) ______________________________________________________________________ - + ### method `fit_benchmark` @@ -4115,7 +4115,7 @@ The Concrete ML and float equivalent fitted estimators. ______________________________________________________________________ - + ### method `get_sklearn_params` @@ -4137,7 +4137,7 @@ This method is used to instantiate a scikit-learn model using the Concrete ML mo ______________________________________________________________________ - + ### method `get_topk_labels` @@ -4161,7 +4161,7 @@ Return the K-nearest labels of each point. ______________________________________________________________________ - + ### classmethod `load_dict` @@ -4181,7 +4181,7 @@ Load itself from a dict. ______________________________________________________________________ - + ### method `majority_vote` @@ -4201,7 +4201,7 @@ Determine the most common class among nearest neighborsfor each query. ______________________________________________________________________ - + ### method `post_processing` @@ -4223,7 +4223,7 @@ For KNN, the de-quantization step is not required. Because \_inference returns t ______________________________________________________________________ - + ### method `predict` @@ -4236,7 +4236,7 @@ predict( ______________________________________________________________________ - + ### method `quantize_input` @@ -4246,7 +4246,7 @@ quantize_input(X: 'ndarray') → ndarray ______________________________________________________________________ - + ## class `SklearnKNeighborsClassifierMixin` @@ -4254,7 +4254,7 @@ A Mixin class for sklearn KNeighbors classifiers with FHE. This class is used to create a KNeighbors classifier class that inherits from SklearnKNeighborsMixin and sklearn.base.ClassifierMixin. By inheriting from sklearn.base.ClassifierMixin, it allows this class to be recognized as a classifier." - + ### method `__init__` @@ -4274,7 +4274,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -4314,7 +4314,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `check_model_is_compiled` @@ -4330,7 +4330,7 @@ Check if the model is compiled. ______________________________________________________________________ - + ### method `check_model_is_fitted` @@ -4346,7 +4346,7 @@ Check if the model is fitted. ______________________________________________________________________ - + ### method `compile` @@ -4380,7 +4380,7 @@ Compile the model. ______________________________________________________________________ - + ### method `dequantize_output` @@ -4390,7 +4390,7 @@ dequantize_output(q_y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `dump` @@ -4406,7 +4406,7 @@ Dump itself to a file. ______________________________________________________________________ - + ### method `dump_dict` @@ -4422,7 +4422,7 @@ Dump the object as a dict. ______________________________________________________________________ - + ### method `dumps` @@ -4438,7 +4438,7 @@ Dump itself to a string. ______________________________________________________________________ - + ### method `fit` @@ -4448,7 +4448,7 @@ fit(X: 'Data', y: 'Target', **fit_parameters) ______________________________________________________________________ - + ### method `fit_benchmark` @@ -4475,7 +4475,7 @@ The Concrete ML and float equivalent fitted estimators. ______________________________________________________________________ - + ### method `get_sklearn_params` @@ -4497,7 +4497,7 @@ This method is used to instantiate a scikit-learn model using the Concrete ML mo ______________________________________________________________________ - + ### method `get_topk_labels` @@ -4521,7 +4521,7 @@ Return the K-nearest labels of each point. ______________________________________________________________________ - + ### classmethod `load_dict` @@ -4541,7 +4541,7 @@ Load itself from a dict. ______________________________________________________________________ - + ### method `majority_vote` @@ -4561,7 +4561,7 @@ Determine the most common class among nearest neighborsfor each query. ______________________________________________________________________ - + ### method `post_processing` @@ -4583,7 +4583,7 @@ For KNN, the de-quantization step is not required. Because \_inference returns t ______________________________________________________________________ - + ### method `predict` @@ -4596,7 +4596,7 @@ predict( ______________________________________________________________________ - + ### method `quantize_input` diff --git a/docs/references/api/concrete.ml.sklearn.glm.md b/docs/references/api/concrete.ml.sklearn.glm.md index c31ff654d..ac61eb76e 100644 --- a/docs/references/api/concrete.ml.sklearn.glm.md +++ b/docs/references/api/concrete.ml.sklearn.glm.md @@ -8,7 +8,7 @@ Implement sklearn's Generalized Linear Models (GLM). ______________________________________________________________________ - + ## class `PoissonRegressor` @@ -22,7 +22,7 @@ A Poisson regression model with FHE. For more details on PoissonRegressor please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.PoissonRegressor.html - + ### method `__init__` @@ -31,6 +31,7 @@ __init__( n_bits: 'Union[int, dict]' = 8, alpha: 'float' = 1.0, fit_intercept: 'bool' = True, + solver: 'str' = 'lbfgs', max_iter: 'int' = 100, tol: 'float' = 0.0001, warm_start: 'bool' = False, @@ -44,7 +45,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -84,7 +85,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `dump_dict` @@ -94,7 +95,7 @@ dump_dict() → Dict ______________________________________________________________________ - + ### classmethod `load_dict` @@ -104,7 +105,7 @@ load_dict(metadata: 'Dict') ______________________________________________________________________ - + ### method `post_processing` @@ -114,7 +115,7 @@ post_processing(y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `predict` @@ -127,7 +128,7 @@ predict( ______________________________________________________________________ - + ## class `GammaRegressor` @@ -141,7 +142,7 @@ A Gamma regression model with FHE. For more details on GammaRegressor please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.GammaRegressor.html - + ### method `__init__` @@ -150,6 +151,7 @@ __init__( n_bits: 'Union[int, dict]' = 8, alpha: 'float' = 1.0, fit_intercept: 'bool' = True, + solver: 'str' = 'lbfgs', max_iter: 'int' = 100, tol: 'float' = 0.0001, warm_start: 'bool' = False, @@ -163,7 +165,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -203,7 +205,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `dump_dict` @@ -213,7 +215,7 @@ dump_dict() → Dict ______________________________________________________________________ - + ### classmethod `load_dict` @@ -223,7 +225,7 @@ load_dict(metadata: 'Dict') ______________________________________________________________________ - + ### method `post_processing` @@ -233,7 +235,7 @@ post_processing(y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `predict` @@ -246,7 +248,7 @@ predict( ______________________________________________________________________ - + ## class `TweedieRegressor` @@ -260,7 +262,7 @@ A Tweedie regression model with FHE. For more details on TweedieRegressor please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.TweedieRegressor.html - + ### method `__init__` @@ -271,7 +273,8 @@ __init__( alpha: 'float' = 1.0, fit_intercept: 'bool' = True, link: 'str' = 'auto', - max_iter: 'int' = 100, + max_iter: 'int' = 1000, + solver: 'str' = 'lbfgs', tol: 'float' = 0.0001, warm_start: 'bool' = False, verbose: 'int' = 0 @@ -284,7 +287,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -324,7 +327,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `dump_dict` @@ -334,7 +337,7 @@ dump_dict() → Dict ______________________________________________________________________ - + ### classmethod `load_dict` @@ -344,7 +347,7 @@ load_dict(metadata: 'Dict') ______________________________________________________________________ - + ### method `post_processing` @@ -354,7 +357,7 @@ post_processing(y_preds: 'ndarray') → ndarray ______________________________________________________________________ - + ### method `predict` diff --git a/docs/references/api/concrete.ml.sklearn.linear_model.md b/docs/references/api/concrete.ml.sklearn.linear_model.md index 6ead761ff..925e3bfee 100644 --- a/docs/references/api/concrete.ml.sklearn.linear_model.md +++ b/docs/references/api/concrete.ml.sklearn.linear_model.md @@ -8,7 +8,7 @@ Implement sklearn linear model. ______________________________________________________________________ - + ## class `LinearRegression` @@ -22,19 +22,12 @@ A linear regression model with FHE. For more details on LinearRegression please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html - + ### method `__init__` ```python -__init__( - n_bits=8, - fit_intercept=True, - normalize='deprecated', - copy_X=True, - n_jobs=None, - positive=False -) +__init__(n_bits=8, fit_intercept=True, copy_X=True, n_jobs=None, positive=False) ``` ______________________________________________________________________ @@ -43,7 +36,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -83,7 +76,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `dump_dict` @@ -93,7 +86,7 @@ dump_dict() → Dict[str, Any] ______________________________________________________________________ - + ### classmethod `load_dict` @@ -103,7 +96,7 @@ load_dict(metadata: Dict) ______________________________________________________________________ - + ## class `SGDClassifier` @@ -120,7 +113,7 @@ An FHE linear classifier model fitted with stochastic gradient descent. For more details on SGDClassifier please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDClassifier.html - + ### method `__init__` @@ -159,7 +152,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -223,7 +216,7 @@ Using this attribute is deprecated. ______________________________________________________________________ - + ### method `dump_dict` @@ -233,7 +226,7 @@ dump_dict() → Dict[str, Any] ______________________________________________________________________ - + ### method `fit` @@ -274,7 +267,7 @@ The fitted estimator. ______________________________________________________________________ - + ### method `get_sklearn_params` @@ -284,7 +277,7 @@ get_sklearn_params(deep: bool = True) → dict ______________________________________________________________________ - + ### classmethod `load_dict` @@ -294,7 +287,7 @@ load_dict(metadata: Dict) ______________________________________________________________________ - + ### method `partial_fit` @@ -318,7 +311,7 @@ This function does one iteration of SGD training. Looping n_times over this func ______________________________________________________________________ - + ### method `post_processing` @@ -326,33 +319,19 @@ ______________________________________________________________________ post_processing(y_preds: ndarray) → ndarray ``` -______________________________________________________________________ - - - -### method `predict_proba` - -```python -predict_proba( - X: Union[ndarray, Tensor, ForwardRef('DataFrame'), List], - fhe: Union[FheMode, str] = -) → ndarray -``` - -Probability estimates. +Apply post-processing to the de-quantized predictions. -This method is only available for log loss and modified Huber loss. Multiclass probability estimates are derived from binary (one-vs.-rest) estimates by simple normalization, as recommended by Zadrozny and Elkan. +This is called at the end of the `predict_proba` method and is only available for log loss and modified Huber losses. Multiclass probability estimates are derived from binary (one-vs.-rest) estimates by simple normalization, as recommended by Zadrozny and Elkan. Binary probability estimates for loss="modified_huber" are given by (clip(decision_function(X), -1, 1) + 1) / 2. For other loss functions it is necessary to perform proper probability calibration by wrapping the classifier with `sklearn.calibration.CalibratedClassifierCV` instead. **Args:** -- `X` (Data): The input values to predict, as a Numpy array, Torch tensor, Pandas DataFrame or List. It mush have a shape of (n_samples, n_features). -- `fhe` (Union\[FheMode, str\]): The mode to use for prediction. Can be FheMode.DISABLE for Concrete ML Python inference, FheMode.SIMULATE for FHE simulation and FheMode.EXECUTE for actual FHE execution. Can also be the string representation of any of these values. +- `y_preds` (Data): The de-quantized predictions to post-process. It mush have a shape of (n_samples, n_features). **Returns:** -- `numpy.ndarray`: The predicted class probabilities, with shape (n_samples, n_classes). +- `numpy.ndarray`: The post-processed predictions, with shape (n_samples, n_classes). **Raises:** @@ -368,7 +347,7 @@ The justification for the formula in the loss="modified_huber" case is in the ap ______________________________________________________________________ - + ## class `SGDRegressor` @@ -382,7 +361,7 @@ An FHE linear regression model fitted with stochastic gradient descent. For more details on SGDRegressor please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDRegressor.html - + ### method `__init__` @@ -417,7 +396,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -457,7 +436,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `dump_dict` @@ -467,7 +446,7 @@ dump_dict() → Dict[str, Any] ______________________________________________________________________ - + ### classmethod `load_dict` @@ -477,7 +456,7 @@ load_dict(metadata: Dict) ______________________________________________________________________ - + ## class `ElasticNet` @@ -491,7 +470,7 @@ An ElasticNet regression model with FHE. For more details on ElasticNet please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.ElasticNet.html - + ### method `__init__` @@ -501,7 +480,6 @@ __init__( alpha=1.0, l1_ratio=0.5, fit_intercept=True, - normalize='deprecated', precompute=False, max_iter=1000, copy_X=True, @@ -519,7 +497,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -559,7 +537,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `dump_dict` @@ -569,7 +547,7 @@ dump_dict() → Dict[str, Any] ______________________________________________________________________ - + ### classmethod `load_dict` @@ -579,7 +557,7 @@ load_dict(metadata: Dict) ______________________________________________________________________ - + ## class `Lasso` @@ -593,7 +571,7 @@ A Lasso regression model with FHE. For more details on Lasso please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Lasso.html - + ### method `__init__` @@ -602,7 +580,6 @@ __init__( n_bits=8, alpha: float = 1.0, fit_intercept=True, - normalize='deprecated', precompute=False, copy_X=True, max_iter=1000, @@ -620,7 +597,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -660,7 +637,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `dump_dict` @@ -670,7 +647,7 @@ dump_dict() → Dict[str, Any] ______________________________________________________________________ - + ### classmethod `load_dict` @@ -680,7 +657,7 @@ load_dict(metadata: Dict) ______________________________________________________________________ - + ## class `Ridge` @@ -694,7 +671,7 @@ A Ridge regression model with FHE. For more details on Ridge please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Ridge.html - + ### method `__init__` @@ -703,7 +680,6 @@ __init__( n_bits=8, alpha: float = 1.0, fit_intercept=True, - normalize='deprecated', copy_X=True, max_iter=None, tol=0.001, @@ -719,7 +695,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -759,7 +735,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `dump_dict` @@ -769,7 +745,7 @@ dump_dict() → Dict[str, Any] ______________________________________________________________________ - + ### classmethod `load_dict` @@ -779,7 +755,7 @@ load_dict(metadata: Dict) ______________________________________________________________________ - + ## class `LogisticRegression` @@ -793,7 +769,7 @@ A logistic regression model with FHE. For more details on LogisticRegression please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html - + ### method `__init__` @@ -824,7 +800,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -888,7 +864,7 @@ Using this attribute is deprecated. ______________________________________________________________________ - + ### method `dump_dict` @@ -898,7 +874,7 @@ dump_dict() → Dict[str, Any] ______________________________________________________________________ - + ### classmethod `load_dict` diff --git a/docs/references/api/concrete.ml.sklearn.neighbors.md b/docs/references/api/concrete.ml.sklearn.neighbors.md index bb147fc13..92f4ba52c 100644 --- a/docs/references/api/concrete.ml.sklearn.neighbors.md +++ b/docs/references/api/concrete.ml.sklearn.neighbors.md @@ -8,7 +8,7 @@ Implement sklearn neighbors model. ______________________________________________________________________ - + ## class `KNeighborsClassifier` @@ -20,7 +20,7 @@ A k-nearest neighbors classifier model with FHE. For more details on KNeighborsClassifier please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html - + ### method `__init__` @@ -44,7 +44,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -84,7 +84,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `dump_dict` @@ -94,7 +94,7 @@ dump_dict() → Dict[str, Any] ______________________________________________________________________ - + ### method `kneighbors` @@ -114,7 +114,7 @@ Return the knearest distances and their respective indices for each query point. ______________________________________________________________________ - + ### classmethod `load_dict` @@ -124,7 +124,7 @@ load_dict(metadata: Dict) ______________________________________________________________________ - + ### method `predict_proba` diff --git a/docs/references/api/concrete.ml.sklearn.qnn_module.md b/docs/references/api/concrete.ml.sklearn.qnn_module.md index 47628298e..013e19539 100644 --- a/docs/references/api/concrete.ml.sklearn.qnn_module.md +++ b/docs/references/api/concrete.ml.sklearn.qnn_module.md @@ -8,7 +8,7 @@ Sparse Quantized Neural Network torch module. ______________________________________________________________________ - + ## class `SparseQuantNeuralNetwork` @@ -16,7 +16,7 @@ Sparse Quantized Neural Network. This class implements an MLP that is compatible with FHE constraints. The weights and activations are quantized to low bit-width and pruning is used to ensure accumulators do not surpass an user-provided accumulator bit-width. The number of classes and number of layers are specified by the user, as well as the breadth of the network - + ### method `__init__` @@ -60,7 +60,7 @@ Sparse Quantized Neural Network constructor. ______________________________________________________________________ - + ### method `enable_pruning` @@ -76,7 +76,7 @@ Enable pruning in the network. Pruning must be made permanent to recover pruned ______________________________________________________________________ - + ### method `forward` @@ -96,7 +96,7 @@ Forward pass. ______________________________________________________________________ - + ### method `make_pruning_permanent` @@ -108,7 +108,7 @@ Make the learned pruning permanent in the network. ______________________________________________________________________ - + ### method `max_active_neurons` diff --git a/docs/references/api/concrete.ml.sklearn.rf.md b/docs/references/api/concrete.ml.sklearn.rf.md index 3360ab625..22580f15e 100644 --- a/docs/references/api/concrete.ml.sklearn.rf.md +++ b/docs/references/api/concrete.ml.sklearn.rf.md @@ -8,13 +8,13 @@ Implement RandomForest models. ______________________________________________________________________ - + ## class `RandomForestClassifier` Implements the RandomForest classifier. - + ### method `__init__` @@ -52,7 +52,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -116,7 +116,7 @@ Using this attribute is deprecated. ______________________________________________________________________ - + ### method `dump_dict` @@ -126,7 +126,7 @@ dump_dict() → Dict[str, Any] ______________________________________________________________________ - + ### classmethod `load_dict` @@ -136,7 +136,7 @@ load_dict(metadata: Dict) ______________________________________________________________________ - + ### method `post_processing` @@ -146,13 +146,13 @@ post_processing(y_preds: ndarray) → ndarray ______________________________________________________________________ - + ## class `RandomForestRegressor` Implements the RandomForest regressor. - + ### method `__init__` @@ -189,7 +189,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -229,7 +229,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `dump_dict` @@ -239,7 +239,7 @@ dump_dict() → Dict[str, Any] ______________________________________________________________________ - + ### classmethod `load_dict` diff --git a/docs/references/api/concrete.ml.sklearn.svm.md b/docs/references/api/concrete.ml.sklearn.svm.md index 602234523..c3133b0dd 100644 --- a/docs/references/api/concrete.ml.sklearn.svm.md +++ b/docs/references/api/concrete.ml.sklearn.svm.md @@ -8,7 +8,7 @@ Implement Support Vector Machine. ______________________________________________________________________ - + ## class `LinearSVR` @@ -22,7 +22,7 @@ A Regression Support Vector Machine (SVM). For more details on LinearSVR please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVR.html - + ### method `__init__` @@ -48,7 +48,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -88,7 +88,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `dump_dict` @@ -98,7 +98,7 @@ dump_dict() → Dict[str, Any] ______________________________________________________________________ - + ### classmethod `load_dict` @@ -108,7 +108,7 @@ load_dict(metadata: Dict) ______________________________________________________________________ - + ## class `LinearSVC` @@ -122,7 +122,7 @@ A Classification Support Vector Machine (SVM). For more details on LinearSVC please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVC.html - + ### method `__init__` @@ -150,7 +150,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -214,7 +214,7 @@ Using this attribute is deprecated. ______________________________________________________________________ - + ### method `dump_dict` @@ -224,7 +224,7 @@ dump_dict() → Dict[str, Any] ______________________________________________________________________ - + ### classmethod `load_dict` diff --git a/docs/references/api/concrete.ml.sklearn.tree.md b/docs/references/api/concrete.ml.sklearn.tree.md index d153a94bd..a8c21fc1e 100644 --- a/docs/references/api/concrete.ml.sklearn.tree.md +++ b/docs/references/api/concrete.ml.sklearn.tree.md @@ -8,13 +8,13 @@ Implement DecisionTree models. ______________________________________________________________________ - + ## class `DecisionTreeClassifier` Implements the sklearn DecisionTreeClassifier. - + ### method `__init__` @@ -46,7 +46,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -110,7 +110,7 @@ Using this attribute is deprecated. ______________________________________________________________________ - + ### method `dump_dict` @@ -120,7 +120,7 @@ dump_dict() → Dict[str, Any] ______________________________________________________________________ - + ### classmethod `load_dict` @@ -130,7 +130,7 @@ load_dict(metadata: Dict) ______________________________________________________________________ - + ### method `post_processing` @@ -140,13 +140,13 @@ post_processing(y_preds: ndarray) → ndarray ______________________________________________________________________ - + ## class `DecisionTreeRegressor` Implements the sklearn DecisionTreeClassifier. - + ### method `__init__` @@ -177,7 +177,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -217,7 +217,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `dump_dict` @@ -227,7 +227,7 @@ dump_dict() → Dict[str, Any] ______________________________________________________________________ - + ### classmethod `load_dict` diff --git a/docs/references/api/concrete.ml.sklearn.tree_to_numpy.md b/docs/references/api/concrete.ml.sklearn.tree_to_numpy.md index 3da62cb57..16746f52b 100644 --- a/docs/references/api/concrete.ml.sklearn.tree_to_numpy.md +++ b/docs/references/api/concrete.ml.sklearn.tree_to_numpy.md @@ -15,7 +15,7 @@ Implements the conversion of a tree model to a numpy function. ______________________________________________________________________ - + ## function `get_onnx_model` @@ -38,7 +38,7 @@ Create ONNX model with Hummingbird convert method. ______________________________________________________________________ - + ## function `workaround_squeeze_node_xgboost` @@ -56,7 +56,7 @@ FIXME: https://github.com/zama-ai/concrete-ml-internal/issues/2778 The squeeze o ______________________________________________________________________ - + ## function `assert_add_node_and_constant_in_xgboost_regressor_graph` @@ -72,7 +72,7 @@ Assert if an Add node with a specific constant exists in the ONNX graph. ______________________________________________________________________ - + ## function `add_transpose_after_last_node` @@ -92,7 +92,7 @@ Add transpose after last node. ______________________________________________________________________ - + ## function `preprocess_tree_predictions` @@ -116,7 +116,7 @@ Apply post-processing from the graph. ______________________________________________________________________ - + ## function `tree_onnx_graph_preprocessing` @@ -141,7 +141,7 @@ Apply pre-processing onto the ONNX graph. ______________________________________________________________________ - + ## function `tree_values_preprocessing` @@ -168,7 +168,7 @@ Pre-process tree values. ______________________________________________________________________ - + ## function `tree_to_numpy` diff --git a/docs/references/api/concrete.ml.sklearn.xgb.md b/docs/references/api/concrete.ml.sklearn.xgb.md index 4526b77bc..540c25101 100644 --- a/docs/references/api/concrete.ml.sklearn.xgb.md +++ b/docs/references/api/concrete.ml.sklearn.xgb.md @@ -8,7 +8,7 @@ Implements XGBoost models. ______________________________________________________________________ - + ## class `XGBClassifier` @@ -16,7 +16,7 @@ Implements the XGBoost classifier. See https://xgboost.readthedocs.io/en/stable/python/python_api.html#module-xgboost.sklearn for more information about the parameters used. - + ### method `__init__` @@ -50,7 +50,6 @@ __init__( validate_parameters: Optional[bool] = None, predictor: Optional[str] = None, enable_categorical: bool = False, - use_label_encoder: bool = False, random_state: Optional[int] = None, verbosity: Optional[int] = None ) @@ -62,7 +61,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -126,7 +125,7 @@ Using this attribute is deprecated. ______________________________________________________________________ - + ### method `dump_dict` @@ -136,7 +135,7 @@ dump_dict() → Dict[str, Any] ______________________________________________________________________ - + ### classmethod `load_dict` @@ -146,7 +145,7 @@ load_dict(metadata: Dict) ______________________________________________________________________ - + ## class `XGBRegressor` @@ -154,7 +153,7 @@ Implements the XGBoost regressor. See https://xgboost.readthedocs.io/en/stable/python/python_api.html#module-xgboost.sklearn for more information about the parameters used. - + ### method `__init__` @@ -188,7 +187,6 @@ __init__( validate_parameters: Optional[bool] = None, predictor: Optional[str] = None, enable_categorical: bool = False, - use_label_encoder: bool = False, random_state: Optional[int] = None, verbosity: Optional[int] = None ) @@ -200,7 +198,7 @@ ______________________________________________________________________ Get the FHE circuit. -The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/getting-started/terminology_and_structure) Is None if the model is not fitted. +The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.zama.ai/concrete/get-started/terminology) Is None if the model is not fitted. **Returns:** @@ -240,7 +238,7 @@ Is None if the model is not fitted. ______________________________________________________________________ - + ### method `dump_dict` @@ -250,7 +248,7 @@ dump_dict() → Dict[str, Any] ______________________________________________________________________ - + ### method `fit` @@ -260,7 +258,7 @@ fit(X, y, *args, **kwargs) → Any ______________________________________________________________________ - + ### classmethod `load_dict` @@ -270,7 +268,7 @@ load_dict(metadata: Dict) ______________________________________________________________________ - + ### method `post_processing` diff --git a/docs/references/api/concrete.ml.torch.numpy_module.md b/docs/references/api/concrete.ml.torch.numpy_module.md index 4b622c953..f955eae02 100644 --- a/docs/references/api/concrete.ml.torch.numpy_module.md +++ b/docs/references/api/concrete.ml.torch.numpy_module.md @@ -12,7 +12,7 @@ A torch to numpy module. ______________________________________________________________________ - + ## class `NumpyModule` @@ -24,7 +24,7 @@ General interface to transform a torch.nn.Module to numpy module. - `dummy_input` (Union\[torch.Tensor, Tuple\[torch.Tensor, ...\]\]): Sample tensors for all the module inputs, used in the ONNX export to get a simple to manipulate nn representation. - `debug_onnx_output_file_path`: (Optional\[Union\[Path, str\]\], optional): An optional path to indicate where to save the ONNX file exported by torch for debug. Defaults to None. - + ### method `__init__` @@ -50,7 +50,7 @@ Get the ONNX model. ______________________________________________________________________ - + ### method `forward` diff --git a/poetry.lock b/poetry.lock index 7a40a6902..296f3f21e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -488,47 +488,6 @@ files = [ {file = "boolean.py-4.0.tar.gz", hash = "sha256:17b9a181630e43dde1851d42bef546d616d5d9b4480357514597e78b203d06e4"}, ] -[[package]] -name = "boto3" -version = "1.34.88" -description = "The AWS SDK for Python" -optional = false -python-versions = ">=3.8" -files = [ - {file = "boto3-1.34.88-py3-none-any.whl", hash = "sha256:1bd4cef11b7c5f293cede50f3d33ca89fe3413c51f1864f40163c56a732dd6b3"}, - {file = "boto3-1.34.88.tar.gz", hash = "sha256:168894499578a9d69d6f7deb5811952bf4171c51b95749a9aef32cf67bc71f87"}, -] - -[package.dependencies] -botocore = ">=1.34.88,<1.35.0" -jmespath = ">=0.7.1,<2.0.0" -s3transfer = ">=0.10.0,<0.11.0" - -[package.extras] -crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] - -[[package]] -name = "botocore" -version = "1.34.88" -description = "Low-level, data-driven core of boto 3." -optional = false -python-versions = ">=3.8" -files = [ - {file = "botocore-1.34.88-py3-none-any.whl", hash = "sha256:e87a660599ed3e14b2a770f4efc3df2f2f6d04f3c7bfd64ddbae186667864a7b"}, - {file = "botocore-1.34.88.tar.gz", hash = "sha256:36f2e9e8dfa856e55dbbe703aea601f134db3fddc3615f1020a755b27fd26a5e"}, -] - -[package.dependencies] -jmespath = ">=0.7.1,<2.0.0" -python-dateutil = ">=2.1,<3.0.0" -urllib3 = [ - {version = ">=1.25.4,<1.27", markers = "python_version < \"3.10\""}, - {version = ">=1.25.4,<2.2.0 || >2.2.0,<3", markers = "python_version >= \"3.10\""}, -] - -[package.extras] -crt = ["awscrt (==0.20.9)"] - [[package]] name = "brevitas" version = "0.8.0" @@ -1275,26 +1234,6 @@ files = [ [package.extras] tests = ["asttokens (>=2.1.0)", "coverage", "coverage-enable-subprocess", "ipython", "littleutils", "pytest", "rich"] -[[package]] -name = "fastapi" -version = "0.103.2" -description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production" -optional = false -python-versions = ">=3.7" -files = [ - {file = "fastapi-0.103.2-py3-none-any.whl", hash = "sha256:3270de872f0fe9ec809d4bd3d4d890c6d5cc7b9611d721d6438f9dacc8c4ef2e"}, - {file = "fastapi-0.103.2.tar.gz", hash = "sha256:75a11f6bfb8fc4d2bec0bd710c2d5f2829659c0e8c0afd5560fdda6ce25ec653"}, -] - -[package.dependencies] -anyio = ">=3.7.1,<4.0.0" -pydantic = ">=1.7.4,<1.8 || >1.8,<1.8.1 || >1.8.1,<2.0.0 || >2.0.0,<2.0.1 || >2.0.1,<2.1.0 || >2.1.0,<3.0.0" -starlette = ">=0.27.0,<0.28.0" -typing-extensions = ">=4.5.0" - -[package.extras] -all = ["email-validator (>=2.0.0)", "httpx (>=0.23.0)", "itsdangerous (>=1.1.0)", "jinja2 (>=2.11.2)", "orjson (>=3.2.1)", "pydantic-extra-types (>=2.0.0)", "pydantic-settings (>=2.0.0)", "python-multipart (>=0.0.5)", "pyyaml (>=5.3.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0)", "uvicorn[standard] (>=0.12.0)"] - [[package]] name = "fastjsonschema" version = "2.19.1" @@ -2227,17 +2166,6 @@ MarkupSafe = ">=2.0" [package.extras] i18n = ["Babel (>=2.7)"] -[[package]] -name = "jmespath" -version = "1.0.1" -description = "JSON Matching Expressions" -optional = false -python-versions = ">=3.7" -files = [ - {file = "jmespath-1.0.1-py3-none-any.whl", hash = "sha256:02e2e4cc71b5bcab88332eebf907519190dd9e6e82107fa7f83b1003a6252980"}, - {file = "jmespath-1.0.1.tar.gz", hash = "sha256:90261b206d6defd58fdd5e85f478bf633a2901798906be2ad389150c5c60edbe"}, -] - [[package]] name = "joblib" version = "1.4.0" @@ -4632,58 +4560,6 @@ files = [ {file = "pycparser-2.22.tar.gz", hash = "sha256:491c8be9c040f5390f5bf44a5b07752bd07f56edf992381b05c701439eec10f6"}, ] -[[package]] -name = "pydantic" -version = "1.10.15" -description = "Data validation and settings management using python type hints" -optional = false -python-versions = ">=3.7" -files = [ - {file = "pydantic-1.10.15-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:22ed12ee588b1df028a2aa5d66f07bf8f8b4c8579c2e96d5a9c1f96b77f3bb55"}, - {file = "pydantic-1.10.15-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:75279d3cac98186b6ebc2597b06bcbc7244744f6b0b44a23e4ef01e5683cc0d2"}, - {file = "pydantic-1.10.15-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:50f1666a9940d3d68683c9d96e39640f709d7a72ff8702987dab1761036206bb"}, - {file = "pydantic-1.10.15-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:82790d4753ee5d00739d6cb5cf56bceb186d9d6ce134aca3ba7befb1eedbc2c8"}, - {file = "pydantic-1.10.15-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:d207d5b87f6cbefbdb1198154292faee8017d7495a54ae58db06762004500d00"}, - {file = "pydantic-1.10.15-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:e49db944fad339b2ccb80128ffd3f8af076f9f287197a480bf1e4ca053a866f0"}, - {file = "pydantic-1.10.15-cp310-cp310-win_amd64.whl", hash = "sha256:d3b5c4cbd0c9cb61bbbb19ce335e1f8ab87a811f6d589ed52b0254cf585d709c"}, - {file = "pydantic-1.10.15-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c3d5731a120752248844676bf92f25a12f6e45425e63ce22e0849297a093b5b0"}, - {file = "pydantic-1.10.15-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c365ad9c394f9eeffcb30a82f4246c0006417f03a7c0f8315d6211f25f7cb654"}, - {file = "pydantic-1.10.15-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3287e1614393119c67bd4404f46e33ae3be3ed4cd10360b48d0a4459f420c6a3"}, - {file = "pydantic-1.10.15-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:be51dd2c8596b25fe43c0a4a59c2bee4f18d88efb8031188f9e7ddc6b469cf44"}, - {file = "pydantic-1.10.15-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:6a51a1dd4aa7b3f1317f65493a182d3cff708385327c1c82c81e4a9d6d65b2e4"}, - {file = "pydantic-1.10.15-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:4e316e54b5775d1eb59187f9290aeb38acf620e10f7fd2f776d97bb788199e53"}, - {file = "pydantic-1.10.15-cp311-cp311-win_amd64.whl", hash = "sha256:0d142fa1b8f2f0ae11ddd5e3e317dcac060b951d605fda26ca9b234b92214986"}, - {file = "pydantic-1.10.15-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:7ea210336b891f5ea334f8fc9f8f862b87acd5d4a0cbc9e3e208e7aa1775dabf"}, - {file = "pydantic-1.10.15-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3453685ccd7140715e05f2193d64030101eaad26076fad4e246c1cc97e1bb30d"}, - {file = "pydantic-1.10.15-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9bea1f03b8d4e8e86702c918ccfd5d947ac268f0f0cc6ed71782e4b09353b26f"}, - {file = "pydantic-1.10.15-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:005655cabc29081de8243126e036f2065bd7ea5b9dff95fde6d2c642d39755de"}, - {file = "pydantic-1.10.15-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:af9850d98fc21e5bc24ea9e35dd80a29faf6462c608728a110c0a30b595e58b7"}, - {file = "pydantic-1.10.15-cp37-cp37m-win_amd64.whl", hash = "sha256:d31ee5b14a82c9afe2bd26aaa405293d4237d0591527d9129ce36e58f19f95c1"}, - {file = "pydantic-1.10.15-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:5e09c19df304b8123938dc3c53d3d3be6ec74b9d7d0d80f4f4b5432ae16c2022"}, - {file = "pydantic-1.10.15-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7ac9237cd62947db00a0d16acf2f3e00d1ae9d3bd602b9c415f93e7a9fc10528"}, - {file = "pydantic-1.10.15-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:584f2d4c98ffec420e02305cf675857bae03c9d617fcfdc34946b1160213a948"}, - {file = "pydantic-1.10.15-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:bbc6989fad0c030bd70a0b6f626f98a862224bc2b1e36bfc531ea2facc0a340c"}, - {file = "pydantic-1.10.15-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:d573082c6ef99336f2cb5b667b781d2f776d4af311574fb53d908517ba523c22"}, - {file = "pydantic-1.10.15-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6bd7030c9abc80134087d8b6e7aa957e43d35714daa116aced57269a445b8f7b"}, - {file = "pydantic-1.10.15-cp38-cp38-win_amd64.whl", hash = "sha256:3350f527bb04138f8aff932dc828f154847fbdc7a1a44c240fbfff1b57f49a12"}, - {file = "pydantic-1.10.15-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:51d405b42f1b86703555797270e4970a9f9bd7953f3990142e69d1037f9d9e51"}, - {file = "pydantic-1.10.15-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a980a77c52723b0dc56640ced396b73a024d4b74f02bcb2d21dbbac1debbe9d0"}, - {file = "pydantic-1.10.15-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:67f1a1fb467d3f49e1708a3f632b11c69fccb4e748a325d5a491ddc7b5d22383"}, - {file = "pydantic-1.10.15-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:676ed48f2c5bbad835f1a8ed8a6d44c1cd5a21121116d2ac40bd1cd3619746ed"}, - {file = "pydantic-1.10.15-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:92229f73400b80c13afcd050687f4d7e88de9234d74b27e6728aa689abcf58cc"}, - {file = "pydantic-1.10.15-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:2746189100c646682eff0bce95efa7d2e203420d8e1c613dc0c6b4c1d9c1fde4"}, - {file = "pydantic-1.10.15-cp39-cp39-win_amd64.whl", hash = "sha256:394f08750bd8eaad714718812e7fab615f873b3cdd0b9d84e76e51ef3b50b6b7"}, - {file = "pydantic-1.10.15-py3-none-any.whl", hash = "sha256:28e552a060ba2740d0d2aabe35162652c1459a0b9069fe0db7f4ee0e18e74d58"}, - {file = "pydantic-1.10.15.tar.gz", hash = "sha256:ca832e124eda231a60a041da4f013e3ff24949d94a01154b137fc2f2a43c3ffb"}, -] - -[package.dependencies] -typing-extensions = ">=4.2.0" - -[package.extras] -dotenv = ["python-dotenv (>=0.10.4)"] -email = ["email-validator (>=1.0.3)"] - [[package]] name = "pydocstyle" version = "6.3.0" @@ -5749,23 +5625,6 @@ files = [ {file = "ruff-0.0.191.tar.gz", hash = "sha256:d698c4d5e3b2963cbbb7c2728f404091d5c47cdf8d94db3eb2f335e2a93a6b1b"}, ] -[[package]] -name = "s3transfer" -version = "0.10.1" -description = "An Amazon S3 Transfer Manager" -optional = false -python-versions = ">= 3.8" -files = [ - {file = "s3transfer-0.10.1-py3-none-any.whl", hash = "sha256:ceb252b11bcf87080fb7850a224fb6e05c8a776bab8f2b64b7f25b969464839d"}, - {file = "s3transfer-0.10.1.tar.gz", hash = "sha256:5683916b4c724f799e600f41dd9e10a9ff19871bf87623cc8f491cb4f5fa0a19"}, -] - -[package.dependencies] -botocore = ">=1.33.2,<2.0a.0" - -[package.extras] -crt = ["botocore[crt] (>=1.33.2,<2.0a.0)"] - [[package]] name = "safetensors" version = "0.4.3" @@ -6329,24 +6188,6 @@ pure-eval = "*" [package.extras] tests = ["cython", "littleutils", "pygments", "pytest", "typeguard"] -[[package]] -name = "starlette" -version = "0.27.0" -description = "The little ASGI library that shines." -optional = false -python-versions = ">=3.7" -files = [ - {file = "starlette-0.27.0-py3-none-any.whl", hash = "sha256:918416370e846586541235ccd38a474c08b80443ed31c578a418e2209b3eef91"}, - {file = "starlette-0.27.0.tar.gz", hash = "sha256:6a6b0d042acb8d469a01eba54e9cda6cbd24ac602c4cd016723117d6a7e73b75"}, -] - -[package.dependencies] -anyio = ">=3.4.0,<5" -typing-extensions = {version = ">=3.10.0", markers = "python_version < \"3.10\""} - -[package.extras] -full = ["httpx (>=0.22.0)", "itsdangerous", "jinja2", "python-multipart", "pyyaml"] - [[package]] name = "sympy" version = "1.12" @@ -7062,20 +6903,6 @@ files = [ {file = "types_python_dateutil-2.9.0.20240316-py3-none-any.whl", hash = "sha256:6b8cb66d960771ce5ff974e9dd45e38facb81718cc1e208b10b1baccbfdbee3b"}, ] -[[package]] -name = "types-requests" -version = "2.31.0.6" -description = "Typing stubs for requests" -optional = false -python-versions = ">=3.7" -files = [ - {file = "types-requests-2.31.0.6.tar.gz", hash = "sha256:cd74ce3b53c461f1228a9b783929ac73a666658f223e28ed29753771477b3bd0"}, - {file = "types_requests-2.31.0.6-py3-none-any.whl", hash = "sha256:a2db9cb228a81da8348b49ad6db3f5519452dd20a9c1e1a868c83c5fe88fd1a9"}, -] - -[package.dependencies] -types-urllib3 = "*" - [[package]] name = "types-requests" version = "2.31.0.20240406" @@ -7090,17 +6917,6 @@ files = [ [package.dependencies] urllib3 = ">=2" -[[package]] -name = "types-urllib3" -version = "1.26.25.14" -description = "Typing stubs for urllib3" -optional = false -python-versions = "*" -files = [ - {file = "types-urllib3-1.26.25.14.tar.gz", hash = "sha256:229b7f577c951b8c1b92c1bc2b2fdb0b49847bd2af6d1cc2a2e3dd340f3bda8f"}, - {file = "types_urllib3-1.26.25.14-py3-none-any.whl", hash = "sha256:9683bbb7fb72e32bfe9d2be6e04875fbe1b3eeec3cbb4ea231435aa7fd6b4f0e"}, -] - [[package]] name = "typing-extensions" version = "4.5.0" @@ -7137,22 +6953,6 @@ files = [ [package.extras] dev = ["flake8", "flake8-annotations", "flake8-bandit", "flake8-bugbear", "flake8-commas", "flake8-comprehensions", "flake8-continuation", "flake8-datetimez", "flake8-docstrings", "flake8-import-order", "flake8-literal", "flake8-modern-annotations", "flake8-noqa", "flake8-pyproject", "flake8-requirements", "flake8-typechecking-import", "flake8-use-fstring", "mypy", "pep8-naming", "types-PyYAML"] -[[package]] -name = "urllib3" -version = "1.26.18" -description = "HTTP library with thread-safe connection pooling, file post, and more." -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" -files = [ - {file = "urllib3-1.26.18-py2.py3-none-any.whl", hash = "sha256:34b97092d7e0a3a8cf7cd10e386f401b3737364026c45e622aa02903dffe0f07"}, - {file = "urllib3-1.26.18.tar.gz", hash = "sha256:f8ecc1bba5667413457c529ab955bf8c67b45db799d159066261719e328580a0"}, -] - -[package.extras] -brotli = ["brotli (==1.0.9)", "brotli (>=1.0.9)", "brotlicffi (>=0.8.0)", "brotlipy (>=0.6.0)"] -secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)", "urllib3-secure-extra"] -socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] - [[package]] name = "urllib3" version = "2.2.1" @@ -7170,24 +6970,6 @@ h2 = ["h2 (>=4,<5)"] socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] zstd = ["zstandard (>=0.18.0)"] -[[package]] -name = "uvicorn" -version = "0.21.1" -description = "The lightning-fast ASGI server." -optional = false -python-versions = ">=3.7" -files = [ - {file = "uvicorn-0.21.1-py3-none-any.whl", hash = "sha256:e47cac98a6da10cd41e6fd036d472c6f58ede6c5dbee3dbee3ef7a100ed97742"}, - {file = "uvicorn-0.21.1.tar.gz", hash = "sha256:0fac9cb342ba099e0d582966005f3fdba5b0290579fed4a6266dc702ca7bb032"}, -] - -[package.dependencies] -click = ">=7.0" -h11 = ">=0.8" - -[package.extras] -standard = ["colorama (>=0.4)", "httptools (>=0.5.0)", "python-dotenv (>=0.13)", "pyyaml (>=5.1)", "uvloop (>=0.14.0,!=0.15.0,!=0.15.1)", "watchfiles (>=0.13)", "websockets (>=10.4)"] - [[package]] name = "wcwidth" version = "0.2.13" @@ -7528,4 +7310,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<3.11" -content-hash = "e4555882abf99305a3e42754afe6de09e177de9948e9781719b7533b7e9bfac8" +content-hash = "18e37472ff221c5e6f57c7a32e3d4d84ed999622ee5ec3c9900627bd9e01349a" diff --git a/pylintrc b/pylintrc index b82e516fb..6e76253a8 100644 --- a/pylintrc +++ b/pylintrc @@ -561,7 +561,7 @@ max-branches=12 max-locals=25 # Maximum number of parents for a class (see R0901). -max-parents=7 +max-parents=8 # Maximum number of public methods for a class (see R0904). max-public-methods=20 diff --git a/pyproject.toml b/pyproject.toml index 6d782d618..e35631fcf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,16 +56,6 @@ numpy = "1.23.5" protobuf = "3.20.3" pandas = "2.0.3" -# Deployment -boto3 = "^1.23.5" -fastapi = "^0.103.2" -uvicorn = "^0.21.0" -tqdm = "^4.64.1" -transformers = "^4.36.0" -certifi = "2023.07.22" -pytest-json-report = "1.5.0" -gitpython = "3.1.41" - [tool.poetry.dev-dependencies] isort = "^5.10.1" black = "^24.3.0" @@ -80,6 +70,7 @@ pydocstyle = "^6.1.1" python-semantic-release = "^7.27.0" semver = "^2.13.0" tomlkit = "^0.7.0" +pytest-json-report = "^1.5.0" pytest-xdist = "^3.3.1" pytest-randomly = "^3.11.0" nbmake = "^1.3.0" @@ -99,8 +90,6 @@ jinja2 = "^3.1.2" LinkChecker = "^10.1.0" kaggle = "^1.5.12" tf2onnx = "^1.10.1" -boto3 = "^1.23.5" -requests = "^2.28.0" types-requests = "^2.28.0" transformers = "^4.38.0" pdoc3 = "^0.10.0" diff --git a/src/concrete/ml/sklearn/base.py b/src/concrete/ml/sklearn/base.py index 8902a23a9..125e3f09a 100644 --- a/src/concrete/ml/sklearn/base.py +++ b/src/concrete/ml/sklearn/base.py @@ -834,7 +834,8 @@ def post_processing(self, y_preds: numpy.ndarray) -> numpy.ndarray: class QuantizedTorchEstimatorMixin(BaseEstimator): """Mixin that provides quantization for a torch module and follows the Estimator API.""" - def __init_subclass__(cls): + def __init_subclass__(cls, *args, **kwargs): + super().__init_subclass__(*args, **kwargs) for klass in cls.__mro__: # pylint: disable-next=protected-access if getattr(klass, "_is_a_public_cml_model", False): @@ -1291,7 +1292,8 @@ class BaseTreeEstimatorMixin(BaseEstimator, sklearn.base.BaseEstimator, ABC): #: Model's base framework used, either 'xgboost' or 'sklearn'. Is set for each subclasses. framework: str - def __init_subclass__(cls): + def __init_subclass__(cls, *args, **kwargs): + super().__init_subclass__(*args, **kwargs) for klass in cls.__mro__: # pylint: disable-next=protected-access if getattr(klass, "_is_a_public_cml_model", False): @@ -1500,7 +1502,8 @@ class SklearnLinearModelMixin(BaseEstimator, sklearn.base.BaseEstimator, ABC): `get_params` and `set_params` methods. """ - def __init_subclass__(cls): + def __init_subclass__(cls, *args, **kwargs): + super().__init_subclass__(*args, **kwargs) for klass in cls.__mro__: # pylint: disable-next=protected-access if getattr(klass, "_is_a_public_cml_model", False): @@ -1896,7 +1899,8 @@ class SklearnKNeighborsMixin(BaseEstimator, sklearn.base.BaseEstimator, ABC): `get_params` and `set_params` methods. """ - def __init_subclass__(cls): + def __init_subclass__(cls, *args, **kwargs): + super().__init_subclass__(*args, **kwargs) for klass in cls.__mro__: # pylint: disable-next=protected-access if getattr(klass, "_is_a_public_cml_model", False): diff --git a/src/concrete/ml/sklearn/glm.py b/src/concrete/ml/sklearn/glm.py index 1d8233093..4779d66ec 100644 --- a/src/concrete/ml/sklearn/glm.py +++ b/src/concrete/ml/sklearn/glm.py @@ -325,7 +325,6 @@ def dump_dict(self) -> Dict: # Scikit-Learn metadata["alpha"] = self.alpha metadata["fit_intercept"] = self.fit_intercept - metadata["solver"] = self.solver metadata["max_iter"] = self.max_iter metadata["tol"] = self.tol metadata["warm_start"] = self.warm_start @@ -356,7 +355,6 @@ def load_dict(cls, metadata: Dict): # Scikit-Learn obj.alpha = metadata["alpha"] obj.fit_intercept = metadata["fit_intercept"] - obj.solver = metadata["solver"] obj.max_iter = metadata["max_iter"] obj.tol = metadata["tol"] obj.warm_start = metadata["warm_start"] diff --git a/tests/deployment/test_deployment.py b/tests/deployment/test_deployment.py deleted file mode 100644 index 3e215e1e5..000000000 --- a/tests/deployment/test_deployment.py +++ /dev/null @@ -1,188 +0,0 @@ -"""Test deployment.""" - -import io -import time -import uuid -import warnings -from pathlib import Path - -import numpy -import pytest -import requests -from sklearn.exceptions import ConvergenceWarning - -from concrete.ml.deployment import FHEModelClient, FHEModelDev -from concrete.ml.deployment.deploy_to_aws import AWSInstance, deploy_to_aws -from concrete.ml.deployment.utils import wait_for_connection_to_be_available -from concrete.ml.pytest.utils import instantiate_model_generic -from concrete.ml.sklearn.linear_model import LogisticRegression - -STATUS_OK = 200 -# Internal AWS AMI with private credentials -AMI_ID_WITH_CREDENTIALS = "ami-08fe791e2421787f1" - - -def test_timeout_ssh_connection(): - """Test timeout error raised on ssh connection""" - with pytest.raises( - TimeoutError, match="Timeout reached while trying to check for connection .*" - ): - wait_for_connection_to_be_available( - ip_address="17.57.244.197", - hostname="user", - path_to_private_key=Path(__file__), - timeout=1, - wait_time=1, - max_retries=1, - wait_bar=False, - ) - - -@pytest.mark.filterwarnings("ignore::ResourceWarning") # Due to boto3 -def test_instance_management(): - """Test instance creation.""" - pytest.skip(reason="Issues with AWS") - - with AWSInstance( - instance_type="t3.nano", - region_name="eu-west-3", - instance_name=f"cml_test_aws_deploy-{uuid.uuid4()}", - verbose=True, - ) as metadata: - time.sleep(1) - assert "ip_address" in metadata - - -@pytest.mark.filterwarnings("ignore::ResourceWarning") # Due to boto3 -def test_deploy(load_data, tmp_path): # pylint: disable=too-many-locals,too-many-statements - """Tests the encrypt decrypt api. - - Arguments: - load_data (Callable): load data - tmp_path (Path): temp path - (Callable): load data - """ - pytest.skip(reason="Issues with AWS") - - # Easier than taking the list of fitted models - model_class = LogisticRegression - n_bits = 2 - - # Generate random data - x, y = load_data(model_class) - - x_train = x[:-1] - y_train = y[:-1] - x_test = x[-1:] - y_test = x[-1:] - - model = instantiate_model_generic(model_class, n_bits=n_bits) - - # Fit the model - with warnings.catch_warnings(): - warnings.simplefilter("ignore", category=ConvergenceWarning) - model.fit(x_train, y_train) - - # Compile - extra_params = {"global_p_error": 1 / 100_000} - - fhe_circuit = model.compile( - x_train, - **extra_params, - ) - max_bit_width = fhe_circuit.graph.maximum_integer_bit_width() - print(f"Max width {max_bit_width}") - - # Instantiate the dev client and server FHEModel client server API - path_to_model = tmp_path / "dev" - fhemodel_dev = FHEModelDev(path_dir=path_to_model, model=model) - fhemodel_dev.save() - - with AWSInstance( - instance_type="c5.large", - instance_name=f"cml_test_aws_deploy-{uuid.uuid4()}", - open_port=5000, - region_name="eu-west-3", - verbose=True, - terminate_on_shutdown=True, - ami_id=AMI_ID_WITH_CREDENTIALS, - ) as instance_metadata: - - metadata = deploy_to_aws( - instance_metadata=instance_metadata, - path_to_model=path_to_model, - number_of_ssh_retries=200, - verbose=True, - wait_bar=True, - ) - - url = metadata["URL"] - # Get the necessary data for the client - # client.zip - zip_response = requests.get(f"{url}/get_client") - assert zip_response.status_code == STATUS_OK - with open(tmp_path / "client.zip", "wb") as file: - file.write(zip_response.content) - - # Get the data to infer - assert isinstance(x_test, numpy.ndarray) - assert isinstance(y_test, numpy.ndarray) - - # Let's create the client - client = FHEModelClient(path_dir=tmp_path, key_dir=tmp_path / "keys") - - # The client first need to create the private and evaluation keys. - client.generate_private_and_evaluation_keys() - - # Get the serialized evaluation keys - serialized_evaluation_keys = client.get_serialized_evaluation_keys() - assert isinstance(serialized_evaluation_keys, bytes) - - # Evaluation keys can be quite large files but only have to be shared once with the server. - - # Check the size of the evaluation keys (in MB) - print(f"Evaluation keys size: {len(serialized_evaluation_keys) / (10**6):.2f} MB") - - # Let's send this evaluation key to the server (this has to be done only once) - # send_evaluation_key_to_server(serialized_evaluation_keys) - - # Now we have everything for the client to interact with the server - encrypted_input = None - clear_input = None - - response = requests.post( - f"{url}/add_key", files={"key": io.BytesIO(initial_bytes=serialized_evaluation_keys)} - ) - assert response.status_code == STATUS_OK - uid = response.json()["uid"] - - inferences = [] - # Launch the queries - for i in range(len(x_test)): - clear_input = x_test[[i], :] - - assert isinstance(clear_input, numpy.ndarray) - encrypted_input = client.quantize_encrypt_serialize(clear_input) - assert isinstance(encrypted_input, bytes) - - inferences.append( - requests.post( - f"{url}/compute", - files={ - "model_input": io.BytesIO(encrypted_input), - }, - data={ - "uid": uid, - }, - ) - ) - - # Unpack the results - decrypted_predictions = [] - for result in inferences: - assert result.status_code == STATUS_OK - encrypted_result = result.content - decrypted_prediction = client.deserialize_decrypt_dequantize(encrypted_result)[0] - decrypted_predictions.append(decrypted_prediction) - - assert len(decrypted_predictions) == len(x_test) diff --git a/use_case_examples/deployment/breast_cancer_builtin/Dockerfile.client b/use_case_examples/deployment/breast_cancer/Dockerfile.client similarity index 100% rename from use_case_examples/deployment/breast_cancer_builtin/Dockerfile.client rename to use_case_examples/deployment/breast_cancer/Dockerfile.client diff --git a/use_case_examples/deployment/breast_cancer_builtin/Dockerfile.train b/use_case_examples/deployment/breast_cancer/Dockerfile.train similarity index 100% rename from use_case_examples/deployment/breast_cancer_builtin/Dockerfile.train rename to use_case_examples/deployment/breast_cancer/Dockerfile.train diff --git a/use_case_examples/deployment/breast_cancer_builtin/Makefile b/use_case_examples/deployment/breast_cancer/Makefile similarity index 100% rename from use_case_examples/deployment/breast_cancer_builtin/Makefile rename to use_case_examples/deployment/breast_cancer/Makefile diff --git a/use_case_examples/deployment/breast_cancer_builtin/README.md b/use_case_examples/deployment/breast_cancer/README.md similarity index 82% rename from use_case_examples/deployment/breast_cancer_builtin/README.md rename to use_case_examples/deployment/breast_cancer/README.md index 167e0aee0..f6ca46a94 100644 --- a/use_case_examples/deployment/breast_cancer_builtin/README.md +++ b/use_case_examples/deployment/breast_cancer/README.md @@ -10,10 +10,10 @@ One can also run this example locally using Docker, or just by running the scrip 1. To train your model you can use `train.py`, or `train_with_docker.sh` to use Docker (recommended way). This will train a model and [serialize the FHE circuit](../../../docs/guides/client_server.md) in a new folder called `./dev`. -1. Once that's done you can use the script provided in Concrete ML in `src/concrete/ml/deployment/`, either use `deploy_to_aws.py` or `deploy_to_docker.py` according to your need. +1. Once that's done you can use the script provided in Concrete ML in `use_case_examples/deployment/server/`, either use `deploy_to_aws.py` or `deploy_to_docker.py` according to your need. -- `python -m concrete.ml.deployment.deploy_to_docker --path-to-model ./dev` -- `python -m concrete.ml.deployment.deploy_to_aws --path-to-model ./dev` +- `python use_case_examples/deployment/server/deploy_to_docker.py --path-to-model ./dev` +- `python use_case_examples/deployment/server/deploy_to_aws.py --path-to-model ./dev` this will create and run a Docker container or an AWS EC2 instance. 3. Once that's done you can launch the `build_docker_client_image.py` script to build a client Docker image. diff --git a/use_case_examples/deployment/breast_cancer_builtin/build_docker_client_image.py b/use_case_examples/deployment/breast_cancer/build_docker_client_image.py similarity index 100% rename from use_case_examples/deployment/breast_cancer_builtin/build_docker_client_image.py rename to use_case_examples/deployment/breast_cancer/build_docker_client_image.py diff --git a/use_case_examples/deployment/breast_cancer_builtin/client.py b/use_case_examples/deployment/breast_cancer/client.py similarity index 100% rename from use_case_examples/deployment/breast_cancer_builtin/client.py rename to use_case_examples/deployment/breast_cancer/client.py diff --git a/use_case_examples/deployment/breast_cancer_builtin/client.sh b/use_case_examples/deployment/breast_cancer/client.sh similarity index 100% rename from use_case_examples/deployment/breast_cancer_builtin/client.sh rename to use_case_examples/deployment/breast_cancer/client.sh diff --git a/use_case_examples/deployment/breast_cancer_builtin/client_requirements.txt b/use_case_examples/deployment/breast_cancer/client_requirements.txt similarity index 100% rename from use_case_examples/deployment/breast_cancer_builtin/client_requirements.txt rename to use_case_examples/deployment/breast_cancer/client_requirements.txt diff --git a/use_case_examples/deployment/breast_cancer_builtin/train.py b/use_case_examples/deployment/breast_cancer/train.py similarity index 100% rename from use_case_examples/deployment/breast_cancer_builtin/train.py rename to use_case_examples/deployment/breast_cancer/train.py diff --git a/use_case_examples/deployment/breast_cancer_builtin/train_with_docker.sh b/use_case_examples/deployment/breast_cancer/train_with_docker.sh similarity index 100% rename from use_case_examples/deployment/breast_cancer_builtin/train_with_docker.sh rename to use_case_examples/deployment/breast_cancer/train_with_docker.sh diff --git a/use_case_examples/deployment/cifar/README.md b/use_case_examples/deployment/cifar/README.md index f7c0ef9e4..929d64193 100644 --- a/use_case_examples/deployment/cifar/README.md +++ b/use_case_examples/deployment/cifar/README.md @@ -12,10 +12,10 @@ One can also run this example locally using Docker, or just by running the scrip Deployment this model on your personal machine is not recommended as running a VGG in FHE is computationally intensive. It is recommended to run this on a `m6i.metal` instance from AWS. 1. To compile your model you can use `compile.py`, or `compile_with_docker.py` to use Docker. This will compile the model to an FHE circuit and [serialize it](../../../docs/guides/client_server.md). This will result in a new folder called `./dev`. -1. Once that's done you can use the script provided in Concrete ML in `src/concrete/ml/deployment/`, either use `deploy_to_aws.py` or `deploy_to_docker.py` according to your need. +1. Once that's done you can use the script provided in Concrete ML in `use_case_examples/deployment/server/`, either use `deploy_to_aws.py` or `deploy_to_docker.py` according to your need. -- `python -m concrete.ml.deployment.deploy_to_docker` -- `python -m concrete.ml.deployment.deploy_to_aws --instance-type m6i.metal` +- `python use_case_examples/deployment/server/deploy_to_docker.py` +- `python use_case_examples/deployment/server/deploy_to_aws.py --instance-type m6i.metal` this will create and run a Docker container or an AWS EC2 instance. 3. Once that's done you can launch the `build_docker_client_image.py` script to build a client Docker image. diff --git a/use_case_examples/deployment/sentiment_analysis/README.md b/use_case_examples/deployment/sentiment_analysis/README.md index a1e77b12a..c7e33f1e6 100644 --- a/use_case_examples/deployment/sentiment_analysis/README.md +++ b/use_case_examples/deployment/sentiment_analysis/README.md @@ -14,8 +14,8 @@ One can also run this example locally using Docker, or just by running the scrip This will result in a new folder called `./dev`. 1. Once that's done you can use the script provided in Concrete ML in `src/concrete/ml/deployment/`, either use `deploy_to_aws.py` or `deploy_to_docker.py` according to your need. -- `python -m concrete.ml.deployment.deploy_to_docker` -- `python -m concrete.ml.deployment.deploy_to_aws` +- `python use_case_examples/deployment/server/deploy_to_docker.py` +- `python use_case_examples/deployment/server/deploy_to_aws.py` this will create and run a Docker container or an AWS EC2 instance. 3. Once that's done you can launch the `build_docker_client_image.sh` script to build a client Docker image. diff --git a/src/concrete/ml/deployment/Dockerfile.server b/use_case_examples/deployment/server/Dockerfile.server similarity index 100% rename from src/concrete/ml/deployment/Dockerfile.server rename to use_case_examples/deployment/server/Dockerfile.server diff --git a/use_case_examples/deployment/README.md b/use_case_examples/deployment/server/README.md similarity index 100% rename from use_case_examples/deployment/README.md rename to use_case_examples/deployment/server/README.md diff --git a/src/concrete/ml/deployment/deploy_to_aws.py b/use_case_examples/deployment/server/deploy_to_aws.py similarity index 99% rename from src/concrete/ml/deployment/deploy_to_aws.py rename to use_case_examples/deployment/server/deploy_to_aws.py index a00750a7d..fee46a472 100644 --- a/src/concrete/ml/deployment/deploy_to_aws.py +++ b/use_case_examples/deployment/server/deploy_to_aws.py @@ -23,7 +23,7 @@ import boto3 -from ..deployment.utils import filter_logs, wait_for_connection_to_be_available +from .utils_server import filter_logs, wait_for_connection_to_be_available DATE_FORMAT: str = "%Y_%m_%d_%H_%M_%S" # More up to date public Concrete ML AWS AMI diff --git a/src/concrete/ml/deployment/deploy_to_docker.py b/use_case_examples/deployment/server/deploy_to_docker.py similarity index 100% rename from src/concrete/ml/deployment/deploy_to_docker.py rename to use_case_examples/deployment/server/deploy_to_docker.py diff --git a/src/concrete/ml/deployment/server.py b/use_case_examples/deployment/server/server.py similarity index 100% rename from src/concrete/ml/deployment/server.py rename to use_case_examples/deployment/server/server.py diff --git a/src/concrete/ml/deployment/server_requirements.txt b/use_case_examples/deployment/server/server_requirements.txt similarity index 100% rename from src/concrete/ml/deployment/server_requirements.txt rename to use_case_examples/deployment/server/server_requirements.txt diff --git a/src/concrete/ml/deployment/utils.py b/use_case_examples/deployment/server/utils_server.py similarity index 100% rename from src/concrete/ml/deployment/utils.py rename to use_case_examples/deployment/server/utils_server.py