Statistics

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.

Basic operations

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

Displaying statistics

You can print all statistics using the show_statistics configuration option:

from concrete import fhe

@fhe.compiler({"x": "encrypted"})
def f(x):
    return (x**2) + (2*x) + 4

inputset = range(2**2)
circuit = f.compile(inputset, show_statistics=True)

This code will print:

Each of these properties can be directly accessed on the circuit (e.g., circuit.programmable_bootstrap_count).

Tags

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:

Last updated

Was this helpful?