Accessing the Actual Circuit in Zama's Concrete-ML API: Seeking Guidance on Extracting Circuit Details from Built-in FNN Model

I’m currently leveraging Zama’s Concrete-ML API, specifically with its built-in Fully Connected Neural Network (FNN) model. While the API conveniently provides a computational graph representation of the neural network, I’m also interested in delving deeper and accessing the actual circuit that is generated during the compilation process.

Since Zama’s API abstracts away some of the lower-level details, I’m curious to know if there’s a way to access the underlying circuit itself. If so, I would greatly appreciate any guidance on how to access this information or pointers to relevant documentation/resources that explain the process.

The compile method of Concrete ML models returns a Circuit object. You can inspect the mlir attribute of this object to see a low-level representation of the model circuit.

For models compiled with compile_torch_model you can do print(compiled_model.fhe_circuit.mlir).

See here for more info: Debugging models | 1.5 | Concrete ML

1 Like

Thanks! The circuit seems to be an arithmetic circuit with operations matrix multiplication , addition, rounding, applying a lookup table, and converting between signed and unsigned integers.

1 Like

Yes, that’s it!

Concrete ML produces arithmetic circuits that work on integers. The floating point values in NN models are quantized to integers to work with this circuit architecture.

1 Like