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

PassManagerConfig.from_backend fails with AerSimulator #9265

Closed
kevinsung opened this issue Dec 8, 2022 · 0 comments · Fixed by #9719
Closed

PassManagerConfig.from_backend fails with AerSimulator #9265

kevinsung opened this issue Dec 8, 2022 · 0 comments · Fixed by #9719
Labels
bug Something isn't working mod: transpiler Issues and PRs related to Transpiler

Comments

@kevinsung
Copy link
Contributor

Environment

  • Qiskit Terra version: 088f600
  • Python version: 3.10.8
  • Operating system: Fedora 36
  • Qiskit Aer version: 0.11.2

What is happening?

See repro.

How can we reproduce the issue?

from qiskit.transpiler.passmanager_config import PassManagerConfig
from qiskit_aer import AerSimulator

backend = AerSimulator()
pass_manager_config = PassManagerConfig.from_backend(backend)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In [1], line 5
      2 from qiskit_aer import AerSimulator
      4 backend = AerSimulator()
----> 5 pass_manager_config = PassManagerConfig.from_backend(backend)

File ~/projects/qiskit-terra/qiskit/transpiler/passmanager_config.py:139, in PassManagerConfig.from_backend(cls, backend, **pass_manager_options)
    137 if backend_version < 2:
    138     if hasattr(backend, "defaults"):
--> 139         res.inst_map = backend.defaults().instruction_schedule_map
    140 else:
    141     res.inst_map = backend.instruction_schedule_map

AttributeError: 'NoneType' object has no attribute 'instruction_schedule_map'

What should happen?

It should work.

Any suggestions?

No response

@kevinsung kevinsung added the bug Something isn't working label Dec 8, 2022
@HuangJunye HuangJunye added the mod: transpiler Issues and PRs related to Transpiler label Jan 4, 2023
mtreinish added a commit to mtreinish/qiskit-core that referenced this issue Mar 3, 2023
This commit fixes two small oversights that would appear when calling
PassManagerConfig.from_backend() with a simulator BackendV1 backend.
The handling of optional fields in the BackendProperties and
PulseDefaults objects for BackendV1 backends was missing that a
BackendProperties object's gates field could be None and that the
defaults() method could return None in the absense of any pulse
calibrations (both of which typically only are True for simulators). In
these cases this would cause an error constructing the
InstructionDurations object and the InstructionScheduleMap object
respectively. This fixes the handling of these edge cases so that
PassManagerConfig.from_backend() will work with any BackendV1 based
backend.

Fixes Qiskit#8546
Fixes Qiskit#9265
mtreinish added a commit to mtreinish/qiskit-core that referenced this issue Mar 3, 2023
This commit fixes two small oversights that would appear when calling
PassManagerConfig.from_backend() with a simulator BackendV1 backend.
The handling of optional fields in the BackendProperties and
PulseDefaults objects for BackendV1 backends was missing that a
BackendProperties object's gates field could be None and that the
defaults() method could return None in the absense of any pulse
calibrations (both of which typically only are True for simulators). In
these cases this would cause an error constructing the
InstructionDurations object and the InstructionScheduleMap object
respectively. This fixes the handling of these edge cases so that
PassManagerConfig.from_backend() will work with any BackendV1 based
backend.

Fixes Qiskit#8546
Fixes Qiskit#9265
@mergify mergify bot closed this as completed in #9719 Mar 3, 2023
mergify bot added a commit that referenced this issue Mar 3, 2023
#9719)

This commit fixes two small oversights that would appear when calling
PassManagerConfig.from_backend() with a simulator BackendV1 backend.
The handling of optional fields in the BackendProperties and
PulseDefaults objects for BackendV1 backends was missing that a
BackendProperties object's gates field could be None and that the
defaults() method could return None in the absense of any pulse
calibrations (both of which typically only are True for simulators). In
these cases this would cause an error constructing the
InstructionDurations object and the InstructionScheduleMap object
respectively. This fixes the handling of these edge cases so that
PassManagerConfig.from_backend() will work with any BackendV1 based
backend.

Fixes #8546
Fixes #9265

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
mergify bot pushed a commit that referenced this issue Mar 3, 2023
#9719)

This commit fixes two small oversights that would appear when calling
PassManagerConfig.from_backend() with a simulator BackendV1 backend.
The handling of optional fields in the BackendProperties and
PulseDefaults objects for BackendV1 backends was missing that a
BackendProperties object's gates field could be None and that the
defaults() method could return None in the absense of any pulse
calibrations (both of which typically only are True for simulators). In
these cases this would cause an error constructing the
InstructionDurations object and the InstructionScheduleMap object
respectively. This fixes the handling of these edge cases so that
PassManagerConfig.from_backend() will work with any BackendV1 based
backend.

Fixes #8546
Fixes #9265

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 35feded)
mergify bot added a commit that referenced this issue Mar 4, 2023
#9719) (#9725)

This commit fixes two small oversights that would appear when calling
PassManagerConfig.from_backend() with a simulator BackendV1 backend.
The handling of optional fields in the BackendProperties and
PulseDefaults objects for BackendV1 backends was missing that a
BackendProperties object's gates field could be None and that the
defaults() method could return None in the absense of any pulse
calibrations (both of which typically only are True for simulators). In
these cases this would cause an error constructing the
InstructionDurations object and the InstructionScheduleMap object
respectively. This fixes the handling of these edge cases so that
PassManagerConfig.from_backend() will work with any BackendV1 based
backend.

Fixes #8546
Fixes #9265

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 35feded)

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
king-p3nguin pushed a commit to king-p3nguin/qiskit-terra that referenced this issue May 22, 2023
Qiskit#9719)

This commit fixes two small oversights that would appear when calling
PassManagerConfig.from_backend() with a simulator BackendV1 backend.
The handling of optional fields in the BackendProperties and
PulseDefaults objects for BackendV1 backends was missing that a
BackendProperties object's gates field could be None and that the
defaults() method could return None in the absense of any pulse
calibrations (both of which typically only are True for simulators). In
these cases this would cause an error constructing the
InstructionDurations object and the InstructionScheduleMap object
respectively. This fixes the handling of these edge cases so that
PassManagerConfig.from_backend() will work with any BackendV1 based
backend.

Fixes Qiskit#8546
Fixes Qiskit#9265

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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
Development

Successfully merging a pull request may close this issue.

2 participants