Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Error during mapping: Circuit contains gates with more than one control. Please make sure that the input circuit's gates are decomposed to the appropriate gate set! #263

Open
YongsooHWANG opened this issue Mar 15, 2023 · 1 comment · May be fixed by #235
Assignees
Labels
bug Something isn't working

Comments

@YongsooHWANG
Copy link

mqt.qmap version

mqt.qmap == 2.1.2

OS

ubuntu

Python version

3.8

C++ compiler

No response

Additional environment information

No response

Description

For some benchmark algorithms, the following error happens.

qc_mapped, res = qmap.compile(qc, arch, method="exact")
File "/home/user/anaconda3/lib/python3.8/site-packages/mqt/qmap/compile.py", line 138, in compile
results = map(circ, architecture, config)
ValueError: Error during mapping: Circuit contains gates with more than one control. Please make sure that the input circuit's gates are decomposed to the appropriate gate set!

Screen Shot 2023-03-15 at 4 16 04 PM

Expected behavior

No response

How to Reproduce

from mqt import qmap, bench
from qiskit.providers.fake_provider import FakeNairobi

arch = FakeNairobi()
qc = bench.get_benchmark(benchmark_name="qft", circuit_size=7, level="indep")

qc_mapped, res = qmap.compile(qc, arch, method="exact")

@YongsooHWANG YongsooHWANG added the bug Something isn't working label Mar 15, 2023
@burgholzer
Copy link
Member

Hey 👋🏼

Thanks for submitting this bug report. The cause for the exception is the (currently) underlying assumption of QMAP that the input circuit only consists of arbitrary single-qubit gates and CNOT gates, i.e., that the only supported two-qubit gate is the CNOT.
While the code doesn't complain currently, when another controlled-rotation gate is used in the circuit (such as a cs gate), it does throw an exception if a two-target gate is encountered. This is precisely what happens above in case of the QFT circuit, which contains SWAP operations at the very end.

There is an ongoing development in #235 for supporting arbitrary two-qubit gates. Once that is in, this example should work out-of-the-box. So I'll close this issue once #235 is merged.

For the moment, a possible workaround is to explicitly decompose the input circuit to basis gates, e.g., via

from mqt import qmap, bench
from qiskit.providers.fake_provider import FakeNairobi
from qiskit import transpile

arch = FakeNairobi()
qc = bench.get_benchmark(benchmark_name="qft", circuit_size=7, level="indep")
qc_basis_gates = transpile(qc, basis_gates=arch.configuration().basis_gates)
qc_mapped, res = qmap.compile(qc_basis_gates, arch, method="exact")

Note, however, that decomposition will most likely introduce further CNOT gates and increase the depth of the circuit, which makes the subsequent mapping problem harder/more complex. As a result, this can only be considered a temporary workaround that does not reflect the real performance.

@burgholzer burgholzer linked a pull request Mar 15, 2023 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants