Qiskit-terra: Support for `Parameter`s with complex values

Created on 25 Sep 2020  路  11Comments  路  Source: Qiskit/qiskit-terra


What is the expected enhancement?

Parameters are now used in schedules. Schedules have pulses which may have complex amplitudes. I'd like to be able to do this:

from qiskit import pulse
from qiskit.circuit import Parameter

amp = Parameter('amp')
sched = pulse.Schedule()
sched += pulse.Play(pulse.Gaussian(duration=128, sigma=16, amp=amp),
                    pulse.DriveChannel(0))
sched.assign_parameters({amp: 0.2j})
good first issue help wanted enhancement

All 11 comments

Hey! I'd like to work on this.

Excellent, @paniash! I've assigned. Please feel free to ask about any questions you may have 馃槃 .

Thanks a lot! Will do! :)

@taalexander Just wanted to clarify something. In the current master branch, pulse supports pulse.Schedule.assign_parameters() but only real amplitudes. The enhancement is to include complex amplitudes as well. Am I right?

Hey! Is this issue open? Can I check this out?

@Arijit02 Hey! Thanks for your interest but I'm currently working on it. :)

Okay, fine.

@paniash, the changes will mostly be in circuit/parameterexpression.py. There will likely be a couple changes required in pulse/ once complex values are supported, but that can be done in a separate PR after this issue is completed. If you run the short snippet from the description, I believe the error is raised in _raise_if_passed_non_real_value in ParameterExpression

Will this also allow us to do things like below?

beta = Parameter('尾')
1.0j*beta

I actually implemented this before for personal use but never opened a PR because I couldn't find a use-case for it. @paniash looking at the early stage of your PR it might be best if I open one and you can help contribute if there's something left, what do you think? 馃槃
Complex parameters should also include some validation to not end up with expressions such as RY(0.2j) which will crash the execution.

@Cryoris I'd be glad to! Given my knowledge of python, I don't want to be a bottleneck to merge this PR, so by all means, go ahead. I'm willing to contribute any missing pieces, if present, to your PR.

P.S. Should I close my PR then? Maybe @lcapelluto could confirm.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaygambetta picture jaygambetta  路  5Comments

we-taper picture we-taper  路  3Comments

Zhuravlev-A-E picture Zhuravlev-A-E  路  6Comments

ewinston picture ewinston  路  3Comments

Sridhar-Majety-UCD picture Sridhar-Majety-UCD  路  3Comments