Skip to content

Synthesis Preferences

You can modify these synthesis process preferences:

In the example below, the chosen output format includes both Q# and OpenQASM. In addition, specific basis gates were selected for the synthesis: controlled not, controlled phase, square root of not, Z-rotation, and not gates.

  "function_library": {
    "functions": [
        "name": "main",
        "logic_flow": [{
            "function": "StatePreparation",
            "function_params": {
              "probabilities": [0.5, 0.1, 0.2, 0.005, 0.015, 0.12, 0.035, 0.025],
              "error_metric": { "KL": { "upper_bound": 0.3 }}
            "outputs": "sp_out"
            "function": "QFT",
            "function_params": {
              "num_qubits": 3
            "inputs": "sp_out"
  "preferences": {
    "output_format": ["qsharp", "qasm"],
      "basis_gates":["cx", "cp", "sx", "rz", "x"]
from classiq import Model

from classiq.model import (
from classiq.builtin_functions.state_preparation import Metrics
from classiq.builtin_functions.range_types import NonNegativeFloatRange

from classiq.builtin_functions import QFT, StatePreparation

custom_hardware_settings = CustomHardwareSettings(
    basis_gates=["cx", "cp", "sx", "rz", "x"]
preferences = Preferences(
    output_format=["qasm", "qsharp"], custom_hardware_settings=custom_hardware_settings
model = Model(preferences=preferences)

num_qubits = 3

probabilities = (0.5, 0.1, 0.2, 0.005, 0.015, 0.12, 0.035, 0.025)
sp_params = StatePreparation(
    error_metric={Metrics.KL: NonNegativeFloatRange(upper_bound=0.3)},
x = model.StatePreparation(sp_params)["OUT"]

qft_params = QFT(num_qubits=num_qubits)
model.QFT(qft_params, in_wires=x)

circuit = model.synthesize()

Output Formats

The Classiq platform provides different ways to format the output of generated circuits. You can choose multiple output formats.

  • In the SDK, you can print or save the desired output format after synthesizing.
  • In the IDE, you can download the desired output format after synthesizing.

The output options:

  • "qasm" - OpenQASM. The qasm circuit is in circuit.qasm.
    • By default, the Classiq platform uses OpenQASM 2.0. To use OpenQASM 3.0 instead, set the qasm3 field of the preferences to True.
  • "qsharp" - Q#. The qsharp circuit is in circuit.qsharp.
  • "qir" - Microsoft's QIR. The QIR circuit is in circuit.qir.
  • "ionq" - IonQ Json format is found in circuit.ionq.
  • "cirq_json" - Cirq Json format is found in circuit.cirq_json.
  • "qasm_cirq_compatible" - OpenQASM 2.0 is compatible with Cirq, which is in circuit.qasm_cirq_compatible.


The Classiq platform offers two timeouts: the generation timeout and the optimization timeout. Both timeouts are specified in a whole number of seconds.

The generation timeout, timeout_seconds, governs the entire synthesis process.

Amongst other tasks, the synthesis engine performs optimization (see Optimization Parameter), which may take a long time to complete. Therefore, to limit the amount of time the engine spends optimizing, set optimization_timeout_seconds. If no optimization occurs (for example, if you did not specify an optimization parameter), this timeout has no effect.

When the optimization timeout is reached, the synthesis engine returns the best solution found so far. If the engine does not find a solution within that time, it issues a message.

You can specify both timeouts. Just make sure that the optimization timeout is smaller than the generation timeout.