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

Transpiler fails after 1000 iterations on simple circuit at optimization_level=3 #5627

Closed
nonhermitian opened this issue Jan 14, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@nonhermitian
Copy link
Contributor

Information

  • Qiskit Terra version: latest
  • Python version:
  • Operating system:

What is the current behavior?

The following circuit + backend + transpiler (optim level =3) combo:

qc = QuantumCircuit(3, 1) 
qc.reset(range(3))

qc.x(0)
qc.barrier()
qc.ccx(0, 1, 2) 
qc.barrier()
qc.measure(2, 0) 

backend = provider.get_backend('ibmq_athens')
qc_trans = transpile(qc, backend, initial_layout=[2,3,4], optimization_level=3)

fails with the error:

Traceback (most recent call last):
File "", line 10, in
qc_trans = transpile(qc, backend2, initial_layout=[2,3,4], optimization_level=3)
File "/opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/compiler/transpile.py", line 243, in transpile
circuits = parallel_map(_transpile_circuit, list(zip(circuits, transpile_args)))
File "/opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/tools/parallel.py", line 106, in parallel_map
return [task(values[0], *task_args, **task_kwargs)]
File "/opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/compiler/transpile.py", line 327, in _transpile_circuit
output_name=transpile_config['output_name'])
File "/opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/transpiler/passmanager.py", line 225, in run
return self._run_single_circuit(circuits, output_name, callback)
File "/opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/transpiler/passmanager.py", line 288, in run_single_circuit
result = running_passmanager.run(circuit, output_name=output_name, callback=callback)
File "/opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/transpiler/runningpassmanager.py", line 112, in run
for pass
in passset:
File "/opt/miniconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/transpiler/runningpassmanager.py", line 311, in iter
raise TranspilerError("Maximum iteration reached. max_iteration=%i" % self.max_iteration)
TranspilerError: 'Maximum iteration reached. max_iteration=1000'

It only fails for level 3.

Steps to reproduce the problem

What is the expected behavior?

Suggested solutions

@nonhermitian nonhermitian added the bug Something isn't working label Jan 14, 2021
@nonhermitian nonhermitian changed the title Transpiler fails after 1000 iterations on simple circuit Transpiler fails after 1000 iterations on simple circuit at optimization_level=3 Jan 14, 2021
@kdk
Copy link
Member

kdk commented Jan 14, 2021

I'm not currently able to replicate this on master. (A similar issue was recently fixed in #5583 .)

Can you define a callback like:

def callback(pass_, dag, time, property_set, count):
    from qiskit.transpiler import TransformationPass
    if isinstance(pass_, TransformationPass):
        print(pass_.name(), dag.depth(), list(dag.count_ops()))

re-run transpile(..., callback=callback) and post the log?

@nonhermitian
Copy link
Contributor Author

I should point out it is also stochastic in it failure. More often than not though

callback.txt

@nonhermitian
Copy link
Contributor Author

If it is fixed in Master than feel free to close. Can re-open if need be.

@kdk
Copy link
Member

kdk commented Jan 14, 2021

Thanks, this should fixed by #5583 and will be included in the next patch release. Feel free to re-open if this persists.

@kdk kdk closed this as completed Jan 14, 2021
@ishapoval
Copy link

ishapoval commented Jan 27, 2021

Hi! After updating qiskit-terra from 0.16.1 to 0.16.2 I started getting

TranspilerError: 'Maximum iteration reached. max_iteration=1000'

when transpiling my own circuit in optimization level 3. Level 2 passes through just fine. Also, hitting the max iteration seems to be device-dependent. E.g., transpiling onto ibmq_manhattan yields the error, but ibmq_16_melbourne does not.

@mtreinish
Copy link
Member

@ishapoval can you open a new issue with a recreate scenario. 0.16.2 included a backport of the fix for this original issue (#5583 and it's backport #5585) so I suspect something else might be causing the failure for you, but I'll need to dig into it to be sure.

@ishapoval
Copy link

ishapoval commented Jan 29, 2021

@mtreinish Thanks for the prompt reply! Unfortunately, I can't post my circuit at this point and I didn't manage to reproduce the problem with a simpler scenario. My circuit is parametrized, and while in 0.16.1 it could be transpiled for all my parameters, in 0.16.2 it doesn't transpile for some of them. I narrowed down the problem to the difference in RZZGate angle. Another observation is that if I dump that offending circuit to the QASM string and construct a new circuit back from that string then it can be successfully transpiled. I will open a new issue if I have enough details to reliably reproduce the case in a simple scenario.

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

No branches or pull requests

4 participants