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

Internal transpiler error in CommutativeCancellation #8553

Closed
jakelishman opened this issue Aug 16, 2022 · 2 comments · Fixed by #8556
Closed

Internal transpiler error in CommutativeCancellation #8553

jakelishman opened this issue Aug 16, 2022 · 2 comments · Fixed by #8556
Assignees
Labels
bug Something isn't working mod: transpiler Issues and PRs related to Transpiler

Comments

@jakelishman
Copy link
Member

Environment

  • Qiskit Terra version: main @ f37dcf9
  • Python version: 3.9
  • Operating system: macOS

What is happening?

Randomised testing has detected a reliable reproducer for transpiler failures in the commutative cancellation pass, showing TranspilerError("internal error"). I imagine it's related to the instruction-level condition, but I don't know entirely.

I bisected the failure to #8184. The line triggering the error is in CommutativeCancellation, though, which wasn't directly touched: https://github.com/Qiskit/qiskit-terra/blob/f37dcf9d9c879867140b3072483a3dbd36cb5c1f/qiskit/transpiler/passes/optimization/commutative_cancellation.py#L132-L143

How can we reproduce the issue?

import qiskit
from qiskit.providers.fake_provider import FakeAthens

qc = qiskit.QuantumCircuit(3, 3)
qc.u(0, 0, 0, 1)
qc.ccx(2, 1, 0).c_if(qc.cregs[0], 0)
qc.measure(2, 2)
qiskit.transpile(qc, FakeAthens(), optimization_level=2)

This gives a transpiler error:

Traceback (most recent call last):
  File "/Users/jake/code/qiskit/terra/repro.py", line 8, in <module>
    qiskit.transpile(qc, FakeAthens(), optimization_level=2)
  File "/Users/jake/code/qiskit/terra/qiskit/compiler/transpiler.py", line 341, in transpile
    _serial_transpile_circuit(
  File "/Users/jake/code/qiskit/terra/qiskit/compiler/transpiler.py", line 434, in _serial_transpile_circuit
    result = pass_manager.run(circuit, callback=callback, output_name=output_name)
  File "/Users/jake/code/qiskit/terra/qiskit/transpiler/passmanager.py", line 511, in run
    return super().run(circuits, output_name, callback)
  File "/Users/jake/code/qiskit/terra/qiskit/transpiler/passmanager.py", line 224, in run
    return self._run_single_circuit(circuits, output_name, callback)
  File "/Users/jake/code/qiskit/terra/qiskit/transpiler/passmanager.py", line 279, in _run_single_circuit
    result = running_passmanager.run(circuit, output_name=output_name, callback=callback)
  File "/Users/jake/code/qiskit/terra/qiskit/transpiler/runningpassmanager.py", line 124, in run
    dag = self._do_pass(pass_, dag, passset.options)
  File "/Users/jake/code/qiskit/terra/qiskit/transpiler/runningpassmanager.py", line 167, in _do_pass
    dag = self._run_this_pass(pass_, dag)
  File "/Users/jake/code/qiskit/terra/qiskit/transpiler/runningpassmanager.py", line 196, in _run_this_pass
    new_dag = pass_.run(dag)
  File "/Users/jake/code/qiskit/terra/qiskit/transpiler/passes/optimization/commutative_cancellation.py", line 143, in run
    raise TranspilerError("internal error")
qiskit.transpiler.exceptions.TranspilerError: 'internal error'

What should happen?

This is a regression - the same reproducer succeeds before #8184, so some logic might have got a little tangled.

Any suggestions?

No response

@alexanderivrii
Copy link
Contributor

Sorry for breaking this, submitted a fix.

@jakelishman
Copy link
Member Author

No worries, it's not a problem - that's why we have the randomised testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mod: transpiler Issues and PRs related to Transpiler
Projects
None yet
2 participants