Hi, thanks for the quick reply. Here is some minimal code to reproduce the error I got:
import torch
import torch.nn as nn
from concrete.ml.torch.compile import compile_brevitas_qat_model
class SimpleDivide(nn.Module):
def __init__(self, bit_width):
super().__init__()
self.id1 = qnn.QuantIdentity(bit_width=bit_width)
self.id2 = qnn.QuantIdentity(bit_width=bit_width)
def forward(self, x, y):
"""Forward pass of the model."""
x = self.id1(x)
y = self.id2(y)
u = 1000 / y
v = (x * u) / 1000
return v
model = SimpleDivide(bit_width=8)
tensor_x = torch.randn(1, 100, 200)
tensor_y = torch.ones(1, 100, 200) * 10
encrypted = compile_brevitas_qat_model(
model, (tensor_x, tensor_y), verbose=True, n_bits=8
)
This yields
ValueError: The following ONNX operators are required to convert the torch model to numpy but are not currently implemented: Reciprocal.
And this code:
from concrete import fhe
class SimpleDivideFHE(nn.Module):
def __init__(self, bit_width):
super().__init__()
self.id1 = qnn.QuantIdentity(bit_width=bit_width)
self.id2 = qnn.QuantIdentity(bit_width=bit_width)
def forward(self, x, y):
"""Forward pass of the model."""
x = self.id1(x)
y = self.id2(y)
v = fhe.multivariate(lambda x, y: x // y)(x, y)
return v
model = SimpleDivideFHE(bit_width=4)
tensor_x = torch.randn(1, 100, 200)
tensor_y = torch.ones(1, 100, 200) * 10
encrypted = compile_brevitas_qat_model(
model, (tensor_x, tensor_y), verbose=True, n_bits=4
)
yields:
AssertionError: Do not support this type of operation between encrypted tensors
I am using Concrete-ML 1.5.0.
Thank you for taking the time to look into this! Let me know if you need more details.