In this section, you will learn how to debug the compilation process easily and get help in case you cannot resolve your issue.
Debug artifacts
Concrete has an artifact system to simplify the process of debugging issues.
Automatic export.
In case of compilation failures, artifacts are exported automatically to the .artifacts directory under the working directory. Let's intentionally create a compilation failure to show what is exported.
deff(x):return np.sin(x)
This function fails to compile because Concrete does not support floating-point outputs. When you try to compile it, an exception will be raised and the artifacts will be exported automatically. If you go to the .artifacts directory under the working directory, you'll see the following files:
environment.txt
This file contains information about your setup (i.e., your operating system and python version).
This file contains information about the error you received.
Traceback (most recent call last):
File "/path/to/your/script.py", line 9, in <module>
circuit = f.compile(inputset)
File "/usr/local/lib/python3.10/site-packages/concrete/fhe/compilation/decorators.py", line 159, in compile
return self.compiler.compile(inputset, configuration, artifacts, **kwargs)
File "/usr/local/lib/python3.10/site-packages/concrete/fhe/compilation/compiler.py", line 437, in compile
mlir = GraphConverter.convert(self.graph)
File "/usr/local/lib/python3.10/site-packages/concrete/fhe/mlir/graph_converter.py", line 677, in convert
GraphConverter._check_graph_convertibility(graph)
File "/usr/local/lib/python3.10/site-packages/concrete/fhe/mlir/graph_converter.py", line 240, in _check_graph_convertibility
raise RuntimeError(message)
RuntimeError: Function you are trying to compile cannot be converted to MLIR
%0 = x # EncryptedScalar<uint3> ∈ [3, 5]
%1 = sin(%0) # EncryptedScalar<float64> ∈ [-0.958924, 0.14112]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ only integer operations are supported
/path/to/your/script.py:6
return %1
Manual exports.
Manual exports are mostly used for visualization. They can be very useful for demonstrations. Here is how to perform one:
from concrete import fheimport numpy as npartifacts = fhe.DebugArtifacts("/tmp/custom/export/path")@fhe.compiler({"x": "encrypted"})deff(x):return127- (50* (np.sin(x)+1)).astype(np.int64)inputset =range(2**3)circuit = f.compile(inputset, artifacts=artifacts)artifacts.export()
If you go to the /tmp/custom/export/path directory, you'll see the following files:
1.initial.graph.txt
This file contains the textual representation of the initial computation graph right after tracing.