Concatenating quantum circuits

No items found.
Date
05 Sep 2024
Share this article
Topics
Date
2 May 2025
Our Library
Share this article

The Classiq synthesis engine significantly improves the generation of quantum circuits. For example, starting from a functional model, the engine can produce a shallower circuit or with fewer two-qubit gates, which are difficult for the hardware to perform. 

Concatenating two quantum circuits can be beneficial when one circuit is very large. Synthesizing an optimized circuit takes a long time, but it only needs to be done once. The second circuit is smaller, and the synthesis process is faster, as it needs to be repeated multiple times.

To do so, we synthesize the big circuit and small circuit separately:


from classiq import *
big_qprog = synthesize(big_qmod)
small_qprog = synthesize(small_qmod)

If the circuits have a different number of qubits, we then connect the two circuits on the right register. Let's call this register “res”. First, we find this register after the synthesis by:


classiq_big_circuit = QuantumProgram.from_qprog(big_qprog)classiq_small_circuit = 
QuantumProgram.from_qprog(small_qprog)output_registers_big_circuit = 
classiq_big_circuit.data.qubit_mapping.physical_outputsres_register = 
list(output_registers_big_circuit["res"])

Similarly, we do the same to the small circuit. In this case, let’s assume the small circuit has only the “res” register. 

Then, we take the circuits' qasm files and connect the circuits using Qiskit:


big_qasm = classiq_big_circuit.qasmsmall_qasm = classiq_small_circuit.qasmfrom qiskit import 
QuantumCircuitqc = QuantumCircuit(classiq_big_circuit.data.width)
# The first part of qc is the small circuit connected to the “res” qubits.qc = 
qc.compose(QuantumCircuit.from_qasm_str(small_qasm), res_register)qc = 
qc.compose(QuantumCircuit.from_qasm_str(big_qasm))

Now, the quantum circuit `qc` is connected from the small and the big circuits. To execute the circuit, save its qasm file and upload it to the Classiq IDE. 

For a concrete example, the HHL algorithm finds x for Ax=b, for a given A and b. The difficult part of the algorithm deals with A and the easy block deals with only state preparation for b. For problems that b change iteratively, we can synthesize iteratively the state preparation block and keep using the circuit that deals with A. These kinds of problems are common in engineering, and in physical systems. 

This simulation was demonstrated together with Hewlett Packard Enterprise.

References:

https://arxiv.org/abs/2312.04933

https://www.computer.org/csdl/proceedings-article/qce/2023/432302a117/1SuQSLYiTT2 

The Classiq synthesis engine significantly improves the generation of quantum circuits. For example, starting from a functional model, the engine can produce a shallower circuit or with fewer two-qubit gates, which are difficult for the hardware to perform. 

Concatenating two quantum circuits can be beneficial when one circuit is very large. Synthesizing an optimized circuit takes a long time, but it only needs to be done once. The second circuit is smaller, and the synthesis process is faster, as it needs to be repeated multiple times.

To do so, we synthesize the big circuit and small circuit separately:


from classiq import *
big_qprog = synthesize(big_qmod)
small_qprog = synthesize(small_qmod)

If the circuits have a different number of qubits, we then connect the two circuits on the right register. Let's call this register “res”. First, we find this register after the synthesis by:


classiq_big_circuit = QuantumProgram.from_qprog(big_qprog)classiq_small_circuit = 
QuantumProgram.from_qprog(small_qprog)output_registers_big_circuit = 
classiq_big_circuit.data.qubit_mapping.physical_outputsres_register = 
list(output_registers_big_circuit["res"])

Similarly, we do the same to the small circuit. In this case, let’s assume the small circuit has only the “res” register. 

Then, we take the circuits' qasm files and connect the circuits using Qiskit:


big_qasm = classiq_big_circuit.qasmsmall_qasm = classiq_small_circuit.qasmfrom qiskit import 
QuantumCircuitqc = QuantumCircuit(classiq_big_circuit.data.width)
# The first part of qc is the small circuit connected to the “res” qubits.qc = 
qc.compose(QuantumCircuit.from_qasm_str(small_qasm), res_register)qc = 
qc.compose(QuantumCircuit.from_qasm_str(big_qasm))

Now, the quantum circuit `qc` is connected from the small and the big circuits. To execute the circuit, save its qasm file and upload it to the Classiq IDE. 

For a concrete example, the HHL algorithm finds x for Ax=b, for a given A and b. The difficult part of the algorithm deals with A and the easy block deals with only state preparation for b. For problems that b change iteratively, we can synthesize iteratively the state preparation block and keep using the circuit that deals with A. These kinds of problems are common in engineering, and in physical systems. 

This simulation was demonstrated together with Hewlett Packard Enterprise.

References:

https://arxiv.org/abs/2312.04933

https://www.computer.org/csdl/proceedings-article/qce/2023/432302a117/1SuQSLYiTT2 

Start Creating Quantum Software Without Limits