ConcreteML + Concrete for Postprocessing

I have a neural network in Concrete ML and some postprocessing implemented in Concrete, and I would like to have them tied together in an end-to-end system. How possible is it to combine Concrete ML with base Concrete?

My understanding is the compilers operate are converted on the same MLIR instruction sets first and then into the lower level dialects as part of the compilation process. So, in theory, it is possible to create one function using these tools, but it may require combining and editing at this MLIR level and lower.

Any advice you have would be appreciated.

Hello @lfolkerts , very interesting question!

There is no strong composability for now in Concrete so you will not be able to combine both circuits directly.

But what you could do is try to compile the model and the post-processing function in one circuit.

If you are targetting a builtin model you could probably hack something using the private method _get_module_to_compile to get the proxy function that you could then chain with your post_processing function in one unique function and wrap this new function in a Compiler object.

If you are targetting a torch model you will have to first build a QuantizedModule and then extract the model as a function, as done in the compile method where a forward_proxy function is created. And then do the same wrapping as for the builtin model.

That being said you will have to manually handle the post-processing of the model itself, or at least take into account in your post-processing function that the results of the model circuit are quantized.