Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.28k stars 2.37k forks source link

Transpiler fails at optimization level 1 for certain coupling maps #2647

Closed sportwagon closed 5 years ago

sportwagon commented 5 years ago

Information

What is the current behavior?

For a given circuit (in this case created with quantum volume test case), at the transpiler will crash at optimization level 1 for certain coupling maps.


    circuits = parallel_map(_transpile_circuit, list(zip(circuits, transpile_configs)))
  File "/home/awack/anaconda3/lib/python3.6/site-packages/qiskit/tools/parallel.py", line 100, in parallel_map
    return [task(values[0], *task_args, **task_kwargs)]
  File "/home/awack/anaconda3/lib/python3.6/site-packages/qiskit/compiler/transpile.py", line 180, in _transpile_circuit
    return transpile_circuit(circuit, transpile_config)
  File "/home/awack/anaconda3/lib/python3.6/site-packages/qiskit/transpiler/transpile_circuit.py", line 62, in transpile_circuit
    return pass_manager.run(circuit)
  File "/home/awack/anaconda3/lib/python3.6/site-packages/qiskit/transpiler/passmanager.py", line 138, in run
    dag = self._do_pass(pass_, dag, passset.options)
  File "/home/awack/anaconda3/lib/python3.6/site-packages/qiskit/transpiler/passmanager.py", line 168, in _do_pass
    dag = self._run_this_pass(pass_, dag)
  File "/home/awack/anaconda3/lib/python3.6/site-packages/qiskit/transpiler/passmanager.py", line 179, in _run_this_pass
    new_dag = pass_.run(dag)
  File "/home/awack/anaconda3/lib/python3.6/site-packages/qiskit/transpiler/passes/mapping/legacy_swap.py", line 176, in run
    serial_layerlist),
  File "/home/awack/anaconda3/lib/python3.6/site-packages/qiskit/transpiler/passes/mapping/legacy_swap.py", line 388, in swap_mapper_layer_update
    dagcircuit_output.compose_back(layer_list[j]["graph"], layout)
  File "/home/awack/anaconda3/lib/python3.6/site-packages/qiskit/dagcircuit/dagcircuit.py", line 466, in compose_back
    self.cregs)
  File "/home/awack/anaconda3/lib/python3.6/site-packages/qiskit/dagcircuit/dagcircuit.py", line 359, in _check_edgemap_registers
    raise DAGCircuitError("unmapped duplicate reg %s" % k)
qiskit.dagcircuit.exceptions.DAGCircuitError: "unmapped duplicate reg ClassicalRegister(6, 'cr')"```

### Steps to reproduce the problem
See attached test case to reproduce the issue.
[classical_register_err.py.txt](https://github.com/Qiskit/qiskit-terra/files/3298331/classical_register_err.py.txt)

### What is the expected behavior?
Transpiler should not crash

### Suggested solutions
ajavadia commented 5 years ago

This may be fixed after #2584 is taken care of.