-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingmod: pulseRelated to the Pulse moduleRelated to the Pulse modulemod: transpilerIssues and PRs related to TranspilerIssues and PRs related to Transpiler
Description
Environment
- Qiskit Terra version: 0.41.1
- Python version: 3.9.12
- Operating system: Linux
What is happening?
Defining a new gate, and attaching pulses to it, triggers an error during transpilation. The same code works well with the old provider.
How can we reproduce the issue?
from qiskit import QuantumCircuit, pulse, transpile, IBMQ
from qiskit.circuit import Gate
from qiskit.pulse import InstructionScheduleMap
from qiskit_ibm_provider import IBMProvider
provider = IBMProvider()
# provider = IBMQ.load_account()
backend = provider.backend.ibmq_lima
amp = 0.1
sigma = 10
num_samples = 128
gauss = pulse.library.Gaussian(num_samples, amp, sigma, name="Parametric Gauss")
with pulse.build(backend, default_alignment="sequential") as gatepulse:
with pulse.align_left():
pulse.play(gauss, pulse.control_channels(0, 1)[0])
inst_map = InstructionScheduleMap()
inst_map.add("newgate", [0, 1], gatepulse)
newgate = Gate("newgate", 2, [])
circ = QuantumCircuit(2)
circ.append(newgate, [0, 1])
circ = transpile(circ, backend, inst_map=inst_map, basis_gates=["newgate"])
Output:
Traceback (most recent call last):
File "/mnt/c/Users/143721756/wsl/balagan/szxbug.py", line 31, in <module>
circ = transpile(circ, backend, inst_map=inst_map, basis_gates=["newgate"])
File "/home/yaelbh/miniconda3/envs/env1/lib/python3.9/site-packages/qiskit/compiler/transpiler.py", line 381, in transpile
_serial_transpile_circuit(
File "/home/yaelbh/miniconda3/envs/env1/lib/python3.9/site-packages/qiskit/compiler/transpiler.py", line 474, in _serial_transpile_circuit
result = pass_manager.run(circuit, callback=callback, output_name=output_name)
File "/home/yaelbh/miniconda3/envs/env1/lib/python3.9/site-packages/qiskit/transpiler/passmanager.py", line 528, in run
return super().run(circuits, output_name, callback)
File "/home/yaelbh/miniconda3/envs/env1/lib/python3.9/site-packages/qiskit/transpiler/passmanager.py", line 228, in run
return self._run_single_circuit(circuits, output_name, callback)
File "/home/yaelbh/miniconda3/envs/env1/lib/python3.9/site-packages/qiskit/transpiler/passmanager.py", line 283, in _run_single_circuit
result = running_passmanager.run(circuit, output_name=output_name, callback=callback)
File "/home/yaelbh/miniconda3/envs/env1/lib/python3.9/site-packages/qiskit/transpiler/runningpassmanager.py", line 125, in run
dag = self._do_pass(pass_, dag, passset.options)
File "/home/yaelbh/miniconda3/envs/env1/lib/python3.9/site-packages/qiskit/transpiler/runningpassmanager.py", line 173, in _do_pass
dag = self._run_this_pass(pass_, dag)
File "/home/yaelbh/miniconda3/envs/env1/lib/python3.9/site-packages/qiskit/transpiler/runningpassmanager.py", line 202, in _run_this_pass
new_dag = pass_.run(dag)
File "/home/yaelbh/miniconda3/envs/env1/lib/python3.9/site-packages/qiskit/transpiler/passes/basis/unroll_custom_definitions.py", line 102, in run
raise QiskitError(
qiskit.exceptions.QiskitError: "Cannot unroll the circuit to the given basis, ['newgate']. Instruction newgate not found in equivalence library and no rule found to expand."
What should happen?
Should work.
Any suggestions?
@haggaila says:
An exception happens in file qiskit/transpiler/passes/basis/unroll_custom_definitions.py
, in the method UnrollCustomDefinitions.run
. With the old provider, self._target
is None
upon entrance to the function, and everything gets properly initialized (in particular device_insts
contains the added newgate
). With the new IBM provider, self._target
is initialized to something, resulting in an exception.
@nkanazawa1989 please share your observations.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingmod: pulseRelated to the Pulse moduleRelated to the Pulse modulemod: transpilerIssues and PRs related to TranspilerIssues and PRs related to Transpiler