Skip to content

Quantum Program Formats

The synthesis process produces a general, abstract circuit able to run on multiple backends. However, to execute on hardware, one must provide a circuit specified in a certain format, specified by the hardware provider. The format may include a certain language and specific gates supported by the device. Therefore, it is necessary to transform the circuit generated by Classiq to the required execution format. To do so, one may simply use the to_program command:

circuit = model_designer.synthesize()
program = circuit.to_program()
executor = Executor(...)
result = executor.execute_quantum_program(quantum_program=program)

The use of the automatic to_program command is encouraged. It chooses the format according hardware data if it was provided during the synthesis process. One may also construct the object manually, if, for example, one wants to run a circuit synthesized for one device on another.

from classiq.interface.executor.quantum_program import (
    QuantumInstructionSet,
    QuantumProgram,
)

circuit = model_designer.synthesize()
program = QuantumProgram(
    code=circuit.transpiled_circuit.qasm, syntax=QuantumInstructionSet.QASM
)

Note that one may need to specify the format in the synthesis preferences for it to be available. The transpiled circuit contains versions of the program decomposed to basis gates.