mithril-security / blindai

Confidential AI deployment with secure enclaves :lock:
https://www.mithrilsecurity.io/
Apache License 2.0
500 stars 35 forks source link

Multiple models support #50

Closed CerineBnsd closed 2 years ago

CerineBnsd commented 2 years ago

Description [ Updated ]

This pull request adds multiple models support.

What has been done so far:

Related Issue

Solves #39

Type of change

How Has This Been Tested?

With a modified test_distelbert, and tested the other cases (like delete_model) locally

Checklist:

CerineBnsd commented 2 years ago

@JoFrost When you have some time, would you please take a look at this so that it would be faster to integrate it tomorrow with Charles work? Thank youu!

CerineBnsd commented 2 years ago

A quick snippet on how it looks now (from the test)

        client.connect_server(
            addr="localhost",
            simulation=self.simulation,
            policy=policy_file,
            certificate=certificate_file,
        )

        response = client.upload_model(
            model=model_path,
            shape=inputs.shape,
            dtype=ModelDatumType.I64,
            model_name=self.model_name,
        )
        model_id = response.model_id #retreive the model_id

        response = client.run_model(run_inputs, model_id=model_id)

        client.delete_model(model_id)
cchudant commented 2 years ago

I merged this with master and i had some concerns. I talked a bit with Mehdi:

The models will take a lot of memory when running "upload_model" multiple times (during testing/getting started with thel ib

The solution we came up with was to deduplicate models based on their hash. If two models have the same hash, they will only be stored once in memory.

OOM (out of memory) handling

I will try to catch the panics and return an error, we'll see if it is practical/possible. If not, memory management / resource management will probably be left for future work (permissions model?)

Backward compatibility

We decided to break backward compability and update Daniel's blogpost. (add the model_id argument) The reason is that we would be forced to store the last UUID in the server side forever, which could be a security issue / technical dept long term.

Delete-all models / List-models commands

Left for future work.