qiskit-tutorials icon indicating copy to clipboard operation
qiskit-tutorials copied to clipboard

Add documentation on using Parameters with Schedules

Open lcapelluto opened this issue 3 years ago • 1 comments

Step 1: Update "Building Pulse Schedules" docs

In tutorials/circuits_advanced/06_building_pulse_schedules.ipynb (see here) add a new section titled "Schedules with Parameters".

In this section, answer these questions for your reader:

  • What is a Parameter? documentation here
    • Mention something about ParameterExpressions: parameters can be used in algebraic expressions
  • How do you use a parameter in a Pulse instruction?
    • This is simple. Should be enough to show some examples with a brief explanation, such as Gaussian(duration=128, amp=1j*amp, sigma=16) where the variable amp is a Parameter instance (amp = Parameter('amp'))
  • How do you assign parameters?
    • For instance, schedule.assign_parameters({amp: 0.5})
    • You might want to draw your parameterized schedule before and after assigning parameters, to show how assignment has set the free parameters to specific values

Step 2: Update "Pulse Gates" docs

In tutorials/circuits_advanced/05_pulse_gates.html (see here) add a new section titled "Pulse Gates with parameterized Schedules"

Now that you've explained how to create Schedules with Parameters, we should answer "How does this work with Pulse gates"? There are some examples already for how to add a Pulse gate where the gate has parameters, but none of the examples have parameterized schedules. I will leave the explanation to the implementer, but to get you started, I'll write up an example which you may want to use in this section. Play around with this to make sure you understand how it is working.

Screen Shot 2021-07-06 at 11 04 40 AM

Note that the parameter drive_amp is the same object shared between the circuit and schedule. Is this required? What happens if they're not the same? Also take care to notice that parameters are referenced by object, so even if you instantiate two different parameters with the same name, they won't be treated as the same parameter. (I.e., I can create a = Parameter('test') and b = Parameter('test'), but if I use a in my circuit, and try to execute assign_parameters({b: val}), this will have no effect.)

Nice to have:

  • 06_building_pulse_schedules.ipynb could benefit from a simple table of contents to dispatch readers to the three main sections: "Schedule Instructions", "Pulse Builder", and the new one "Schedules with Parameters". This can be a manual TOC (i.e., a bulleted list with three items, linking to the three headers [text](#link-to-header))

lcapelluto avatar Jul 06 '21 15:07 lcapelluto

Dear @lcapelluto , can I have a look at this?

MartinBeseda avatar Jul 20 '21 12:07 MartinBeseda