This document explains how to format and draw a compiled circuit in Python.
To convert your compiled circuit into its textual representation, use the str
function:
If you just want to see the output on your terminal, you can directly print it as well:
Formatting is designed for debugging purpose only. It's not possible to create the circuit back from its textual representation. See How to Deploy if that's your goal.
Drawing functionality requires the installation of the package with the full feature set. See the Installation section for instructions.
To draw your compiled circuit, use the draw
method:
This method draws the circuit, saves it as a temporary PNG file and returns the file path.
You can display the drawing in a Jupyter notebook:
Alternatively, you can use the show
option of the draw
method to display the drawing with matplotlib
:
Using this option will clear any existing matplotlib plots.
Lastly, to save the drawing to a specific path, use the save_to
option:
This document provides an overview of how to analyze compiled circuits and extract statistical data for performance evaluation in Concrete. These statistics help identify bottlenecks and compare circuits.
Concrete calculates statistics based on the following six basic operations:
Clear addition: x + y
where x
is encrypted and y
is clear
Encrypted addition: x + y
where both x
and y
are encrypted
Clear multiplication: x * y
where x
is encrypted and y
is clear
Encrypted negation: -x
where x
is encrypted
Key switch: A building block for table lookups
Packing key switch: A building block for table lookups
Programmable bootstrapping: A building block for table lookups
You can print all statistics using the show_statistics
configuration option:
This code will print:
Each of these properties can be directly accessed on the circuit (e.g., circuit.programmable_bootstrap_count
).
You can also use tags to analyze specific sections of your circuit. See more detailed explanation in tags documentation.
Imagine you have a neural network with 10 layers, each of them tagged, you can easily see the number of additions and multiplications required for matrix multiplications per layer:
This document introduces the progressbar feature that provides visual feedback on the execution progress of large circuits, which can take considerable time to execute.
The following Python code demonstrates how to enable and use the progressbar:
When you run this code, you will see a progressbar like this one:
As the execution proceeds, the progress bar updates:
The progress bar does not measure time. When it shows 50%, it indicates that half of the nodes in the computation graph have been processed, not that half of the time has elapsed. The duration of processing different node types may vary, so the progress bar should not be used to estimate the remaining time.
Once the progressbar fills and execution completes, you will see the following figure: