Using LRE to Deploy your Encrypted Model¶
This notebook describes deployment of a LEIP Optimize encrypted model. Encryption of the model has to be done in your host environment described in the LEIP Optimize encryption tutorial.
You should have produced a bundle which has a modelLibrary.so and a modelKey.bin. You will also have used a password during the encryption. You will need these 3 artifacts to decrypt your model.
First, we will locate these artifacts for deployment.
- path to
modelLibrary.sois set tomodel_path - path to
modelKey.binis set tokey_path - password string is set to
password
from pylre import LatentRuntimeEngine as LRE
encrypted_output_dir = "encrypted_output"
model_path = f"{encrypted_output_dir}/modelLibrary.so"
key_path = f"{encrypted_output_dir}/modelKey.bin"
password = "test_password"
We will first check if the model can be loaded, just like we did in the Deploy a Model tutorial. You will run into an error saying this is an encrypted model.
try:
lre_llvm_insecure = LRE(model_path)
except Exception as e:
print(f"Error initializing LRE: {e}")
Now let's load the model with the proper credentials.
lre_llvm_secure = LRE(model_path, password="test_password", key_path=key_path)
Now you can use the lre_llvm_secure LRE object like we did in the Deploy a Model tutorial. However, please note that once decrypted, the lre_llvm_secure is no longer secure. Please ensure your deployment environment is sandboxed before decrypting to maintain your model security.