ブログ
5
September
,
2024
Tamuz Danzig

Concatenating quantum circuits

Share the article
Our library

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 

About "The Qubit Guy's Podcast"

Hosted by The Qubit Guy (Yuval Boger, our Chief Marketing Officer), the podcast hosts thought leaders in quantum computing to discuss business and technical questions that impact the quantum computing ecosystem. Our guests provide interesting insights about quantum computer software and algorithm, quantum computer hardware, key applications for quantum computing, market studies of the quantum industry and more.

If you would like to suggest a guest for the podcast, please contact us.

See Also

No items found.

量子ソフトウェア開発を開始

お問い合わせ