Skip to content

Commit

Permalink
Removed Deprecated Pulse Call Instruction (#11537)
Browse files Browse the repository at this point in the history
* removed deprecated pulse.Call

* up reno right location

* doc fix

* fixes qpy error

* fix temporary files

* updated release note

* Update releasenotes/notes/deprecate-pulse-instruction-call-52dca0dd26e1c768.yaml

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* reintroduced testcases that used Pulse.Call

---------

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>
  • Loading branch information
sbrandhsn and nkanazawa1989 authored Jan 16, 2024
1 parent 4aff15a commit 0a860fd
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 536 deletions.
1 change: 0 additions & 1 deletion qiskit/pulse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@
from qiskit.pulse.instruction_schedule_map import InstructionScheduleMap
from qiskit.pulse.instructions import (
Acquire,
Call,
Delay,
Instruction,
Play,
Expand Down
2 changes: 0 additions & 2 deletions qiskit/pulse/instructions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
:toctree: ../stubs/
Acquire
Call
Reference
Delay
Play
Expand All @@ -60,7 +59,6 @@
from .acquire import Acquire
from .delay import Delay
from .directives import Directive, RelativeBarrier, TimeBlockade
from .call import Call
from .instruction import Instruction
from .frequency import SetFrequency, ShiftFrequency
from .phase import ShiftPhase, SetPhase
Expand Down
177 changes: 0 additions & 177 deletions qiskit/pulse/instructions/call.py

This file was deleted.

26 changes: 0 additions & 26 deletions qiskit/pulse/parameter_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,24 +162,6 @@ def visit_AlignmentKind(self, node: AlignmentKind):

# Mid layer: Assign parameters to instructions

def visit_Call(self, node: instructions.Call):
"""Assign parameters to ``Call`` instruction.
.. note:: ``Call`` instruction has a special parameter handling logic.
This instruction separately keeps program, i.e. parametrized schedule,
and bound parameters until execution. The parameter assignment operation doesn't
immediately override its operand data.
"""
if node.is_parameterized():
new_table = copy(node.arguments)

for parameter, value in new_table.items():
if isinstance(value, ParameterExpression):
new_table[parameter] = self._assign_parameter_expression(value)
node.arguments = new_table

return node

def visit_Instruction(self, node: instructions.Instruction):
"""Assign parameters to general pulse instruction.
Expand Down Expand Up @@ -300,14 +282,6 @@ def visit_AlignmentKind(self, node: AlignmentKind):

# Mid layer: Get parameters from instructions

def visit_Call(self, node: instructions.Call):
"""Get parameters from ``Call`` instruction.
.. note:: ``Call`` instruction has a special parameter handling logic.
This instruction separately keeps parameters and program.
"""
self.parameters |= node.parameters

def visit_Instruction(self, node: instructions.Instruction):
"""Get parameters from general pulse instruction.
Expand Down
25 changes: 2 additions & 23 deletions qiskit/pulse/transforms/canonicalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,7 @@ def _inline_schedule(schedule: Schedule) -> Schedule:
for t0, inst in schedule.children:
# note that schedule.instructions unintentionally flatten the nested schedule.
# this should be performed by another transformer node.
if isinstance(inst, instructions.Call):
# bind parameter
subroutine = inst.assigned_subroutine()
# convert into schedule if block is given
if isinstance(subroutine, ScheduleBlock):
subroutine = block_to_schedule(subroutine)
# recursively inline the program
inline_schedule = _inline_schedule(subroutine)
ret_schedule.insert(t0, inline_schedule, inplace=True)
elif isinstance(inst, Schedule):
if isinstance(inst, Schedule):
# recursively inline the program
inline_schedule = _inline_schedule(inst)
ret_schedule.insert(t0, inline_schedule, inplace=True)
Expand All @@ -196,19 +187,7 @@ def _inline_block(block: ScheduleBlock) -> ScheduleBlock:
"""
ret_block = ScheduleBlock.initialize_from(block)
for inst in block.blocks:
if isinstance(inst, instructions.Call):
# bind parameter
subroutine = inst.assigned_subroutine()
if isinstance(subroutine, Schedule):
raise PulseError(
f"A subroutine {subroutine.name} is a pulse Schedule. "
"This program cannot be inserted into ScheduleBlock because "
"t0 associated with instruction will be lost."
)
# recursively inline the program
inline_block = _inline_block(subroutine)
ret_block.append(inline_block, inplace=True)
elif isinstance(inst, ScheduleBlock):
if isinstance(inst, ScheduleBlock):
# recursively inline the program
inline_block = _inline_block(inst)
ret_block.append(inline_block, inplace=True)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
upgrade:
- |
Removed the deprecated class :class:`qiskit.pulse.instructions.Call`.
No alternative pulse instruction is provided.
20 changes: 0 additions & 20 deletions test/python/pulse/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,26 +657,6 @@ def test_get_assigend_duration(self):

self.assertEqual(block.duration, 400)

def test_nested_parametrized_instructions(self):
"""Test parameters of nested schedule can be assigned."""
test_waveform = pulse.Constant(100, self.amp0)

param_sched = pulse.Schedule(pulse.Play(test_waveform, self.d0))
with self.assertWarns(DeprecationWarning):
call_inst = pulse.instructions.Call(param_sched)

sub_block = pulse.ScheduleBlock()
sub_block += call_inst

block = pulse.ScheduleBlock()
block += sub_block

self.assertTrue(block.is_parameterized())

# assign durations
block = block.assign_parameters({self.amp0: 0.1})
self.assertFalse(block.is_parameterized())

def test_equality_of_parametrized_channels(self):
"""Test check equality of blocks involving parametrized channels."""
par_ch = circuit.Parameter("ch")
Expand Down
3 changes: 1 addition & 2 deletions test/python/pulse/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,7 @@ def test_call(self):
reference += instructions.Delay(20, d1)

ref_sched = pulse.Schedule()
with self.assertWarns(DeprecationWarning):
ref_sched += pulse.instructions.Call(reference)
ref_sched += reference

with pulse.build() as schedule:
with pulse.align_right():
Expand Down
Loading

0 comments on commit 0a860fd

Please sign in to comment.