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

Transpiling with AerSimulator with coupling map gives TypeError: 'NoneType' object is not iterable #12353

Open
kevinsung opened this issue May 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@kevinsung
Copy link
Contributor

Environment

  • Qiskit version: 1.0.2
  • Python version: 3.12.2
  • Operating system: Fedora 40

What is happening?

If the coupling map is not passed, it transpiles with no issue.

How can we reproduce the issue?

from qiskit.circuit.library import EfficientSU2
from qiskit.transpiler import CouplingMap
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_aer import AerSimulator

# Construct circuit
n_qubits = 5
circuit = EfficientSU2(n_qubits, entanglement="pairwise")

# Initialize simulator backend
coupling_map = CouplingMap.from_line(n_qubits)
backend = AerSimulator(
    basis_gates=["ecr", "id", "rz", "sx", "x"],
    coupling_map=coupling_map,
    n_qubits=coupling_map.size(),
)

# Transpile circuit
pass_manager = generate_preset_pass_manager(
    optimization_level=3, backend=backend, seed_transpiler=1234
)
pass_manager.run(circuit)
Traceback (most recent call last):
  File "/home/kevinsung/projects/documentation/scratch/repro.py", line 22, in <module>
    pass_manager.run(circuit)
  File "/home/kevinsung/.local/share/virtualenvs/env-documentation/lib64/python3.12/site-packages/qiskit/transpiler/passmanager.py", line 397, in run
    return super().run(circuits, output_name, callback, num_processes=num_processes)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevinsung/.local/share/virtualenvs/env-documentation/lib64/python3.12/site-packages/qiskit/transpiler/passmanager.py", line 420, in wrapper
    return meth(*meth_args, **meth_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevinsung/.local/share/virtualenvs/env-documentation/lib64/python3.12/site-packages/qiskit/transpiler/passmanager.py", line 182, in run
    return super().run(
           ^^^^^^^^^^^^
  File "/home/kevinsung/.local/share/virtualenvs/env-documentation/lib64/python3.12/site-packages/qiskit/passmanager/passmanager.py", line 229, in run
    out_program = _run_workflow(
                  ^^^^^^^^^^^^^^
  File "/home/kevinsung/.local/share/virtualenvs/env-documentation/lib64/python3.12/site-packages/qiskit/passmanager/passmanager.py", line 292, in _run_workflow
    passmanager_ir, final_state = flow_controller.execute(
                                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevinsung/.local/share/virtualenvs/env-documentation/lib64/python3.12/site-packages/qiskit/passmanager/base_tasks.py", line 218, in execute
    passmanager_ir, state = next_task.execute(
                            ^^^^^^^^^^^^^^^^^^
  File "/home/kevinsung/.local/share/virtualenvs/env-documentation/lib64/python3.12/site-packages/qiskit/passmanager/base_tasks.py", line 218, in execute
    passmanager_ir, state = next_task.execute(
                            ^^^^^^^^^^^^^^^^^^
  File "/home/kevinsung/.local/share/virtualenvs/env-documentation/lib64/python3.12/site-packages/qiskit/passmanager/base_tasks.py", line 98, in execute
    ret = self.run(passmanager_ir)
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevinsung/.local/share/virtualenvs/env-documentation/lib64/python3.12/site-packages/qiskit/transpiler/passes/layout/vf2_layout.py", line 149, in run
    has_operations = set(itertools.chain.from_iterable(self.target.qargs))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable

What should happen?

Should work.

Any suggestions?

No response

@kevinsung kevinsung added the bug Something isn't working label May 6, 2024
@t-imamichi
Copy link
Member

I guess it is due to convert_to_target. I made a patch in the past, but it is not accepted #11333.
We might need to update the transpiler side.

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

2 participants