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

Inst map in transpile is always ignored with V2 backend #9489

Closed
nkanazawa1989 opened this issue Jan 31, 2023 · 1 comment · Fixed by #9587
Closed

Inst map in transpile is always ignored with V2 backend #9489

nkanazawa1989 opened this issue Jan 31, 2023 · 1 comment · Fixed by #9587
Labels
bug Something isn't working mod: transpiler Issues and PRs related to Transpiler

Comments

@nkanazawa1989
Copy link
Contributor

Environment

  • Qiskit Terra version: 0.23
  • Python version: any
  • Operating system: any

What is happening?

When we explicitly specify the inst_map argument in transpile, this must check the provided inst map and apply pulse gate if available. In #9343 support for target argument is added to the pulse gate pass. When both target and inst_map are provided for the pass, the inst map in the target overrides user provided inst_map value.

However, even if we don't explicitly specify the target, this parse function implicitly set the target option and the user specified inst map is always ignored with the V2 backend.
https://github.com/Qiskit/qiskit-terra/blob/a3b359b899d5d963272a7b424c8a283bc6bd4c0d/qiskit/compiler/transpiler.py#L999-L1003

How can we reproduce the issue?

from qiskit.providers.fake_provider import FakeHanoi, FakeHanoiV2
from qiskit.pulse import ScheduleBlock, InstructionScheduleMap
from qiskit import transpile, QuantumCircuit

inst_map = InstructionScheduleMap()
inst_map.add("x", (0,), schedule=ScheduleBlock(name="custom_x"))

qc = QuantumCircuit(1)
qc.x(0)

qc1 = transpile(qc, FakeHanoi(), inst_map=inst_map)
qc2 = transpile(qc, FakeHanoiV2(), inst_map=inst_map)

qc1 == qc2

This results in

False

Because

>>> qc1.calibrations
{'x': {((0,), ()): ScheduleBlock(, name="custom_x", transform=AlignLeft())}}

>>> qc2.calibrations
{}

What should happen?

Pulse gate should be applied to circuit with V2 backend.

Any suggestions?

No response

@nkanazawa1989 nkanazawa1989 added bug Something isn't working mod: transpiler Issues and PRs related to Transpiler labels Jan 31, 2023
@wshanks
Copy link
Contributor

wshanks commented Feb 15, 2023

Qiskit Terra version: 0.23

This threw me off at first because I only started seeing this when I tested against main rather than 0.23. I think #9343 introduced this issue which is not in 0.23.

Besides the code block you referenced that shows the target always getting pulled from the backend when not provided, the other part of the code that is problematic is blocks like this:

https://github.com/Qiskit/qiskit-terra/blob/e016f9ca612482fe2b15af4d54828cf3c1899f6f/qiskit/transpiler/passes/calibration/pulse_gate.py#L66-L68

which override the provided inst_map with the one from the target.

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