Skip to content

Internal transpiler error in CommutativeCancellation #8553

@jakelishman

Description

@jakelishman

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

Metadata

Metadata

Labels

bugSomething isn't workingmod: transpilerIssues and PRs related to Transpiler

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions