Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

qiskit.pulse.builder.call

call(target, name=None, value_dict=None, **kw_params)

GitHub

Call the target within the currently active builder context with arbitrary parameters which will be assigned to the target program.

Note

The target program is inserted as a Call instruction. This instruction defines a subroutine. See Call for more details.

Examples:

from qiskit import circuit, pulse, schedule, transpile
from qiskit.test.mock import FakeOpenPulse2Q
 
backend = FakeOpenPulse2Q()
 
qc = circuit.QuantumCircuit(2)
qc.cx(0, 1)
qc_transpiled = transpile(qc, optimization_level=3)
sched = schedule(qc_transpiled, backend)
 
with pulse.build(backend) as pulse_prog:
        pulse.call(sched)
        pulse.call(qc)

This function can optionally take parameter dictionary with the parameterized target program.

from qiskit import circuit, pulse
 
amp = circuit.Parameter('amp')
 
with pulse.build() as subroutine:
    pulse.play(pulse.Gaussian(160, amp, 40), pulse.DriveChannel(0))
 
with pulse.build() as main_prog:
    pulse.call(subroutine, amp=0.1)
    pulse.call(subroutine, amp=0.3)

If there is any parameter name collision, you can distinguish them by specifying each parameter object as a python dictionary. Otherwise amp1 and amp2 will be updated with the same value.

from qiskit import circuit, pulse
 
amp1 = circuit.Parameter('amp')
amp2 = circuit.Parameter('amp')
 
with pulse.build() as subroutine:
    pulse.play(pulse.Gaussian(160, amp1, 40), pulse.DriveChannel(0))
    pulse.play(pulse.Gaussian(160, amp2, 40), pulse.DriveChannel(1))
 
with pulse.build() as main_prog:
    pulse.call(subroutine, value_dict={amp1: 0.1, amp2: 0.2})

Parameters

  • target (Union[QuantumCircuit, Schedule, ScheduleBlock]) – Target circuit or pulse schedule to call.
  • name (Optional[str]) – Name of subroutine if defined.
  • value_dict (Optional[Dict[Union[ParameterExpression, float], Union[ParameterExpression, float]]]) – Parameter object and assigned value mapping. This is more precise way to identify a parameter since mapping is managed with unique object id rather than name. Especially there is any name collision in a parameter table.
  • kw_params (Union[ParameterExpression, float]) – Parameter values to bind to the target subroutine with string parameter names. If there are parameter name overlapping, these parameters are updated with the same assigned value.

Raises

exceptions.PulseError – If the input target type is not supported.

Was this page helpful?
Report a bug or request content on GitHub.