New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make InstructionScheduleMap support ParameterExpressions #4940
Make InstructionScheduleMap support ParameterExpressions #4940
Conversation
b22852f
to
4563c30
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a couple minor changes recommended.
c744dd1
to
e2b89bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were we going to cast a ParameterExpression
to a float
in the ParameterizedSchedule
if supplied?
@menehune23 Thanks for the update. This is really great and I've been waiting this for long time.
Pulse scheduler always pass *args. This cannot generate **kwargs due to its implementation. For example, is it possible to create an entry of Rx(theta) gate as shown in this paper? We may want to add Then scheduler pass
In |
@taalexander Per the discussion in #3923, my understanding was that for this issue, we'd cast to float just before passing to any callable schedule (i.e. functions and I know that eventually, the |
d4a3afe
to
7dc40ed
Compare
If you take a look at the test changes, you'll see how to bind a value to a
I understand the problem, and I agree that it seems like a bug. That said, it looks like a pre-existing bug that should be filed separately. |
c8127c1
to
c054633
Compare
In your test case the parameter is bound before set to the generator function (this is the PR to add parameter object to schedule, so basically this test case is already enough). However we want to keep them as unbound parameter objects and bind a value before sending the program to the backend. Perhaps we can use parametric pulses because they can keep argument as parameters.
This is not a bug, it's intentional. In the textualized CmdDef of U3 gate there are three parameters I agree that those can be addressed in another PR. |
@nkanazawa1989 My apologies. I misunderstood where the binding was expected to happen. I'll look into this further when I have some time outside of work. |
@taalexander @nkanazawa1989 I'm realizing too that my original thoughts around this issue were based on replacing the param type with |
b46c25b
to
1c1f2a2
Compare
1c1f2a2
to
ad82083
Compare
@taalexander @nkanazawa1989 Now that I've had a chance to revisit this with better understanding, please take another fresh look. I summarized the changes in the release note, so please let me know if my understanding of when binds should occur is correct. Thanks! |
ad82083
to
162079e
Compare
…e generators - Resolves Qiskit#3923
162079e
to
99c6892
Compare
|
||
inst_map = InstructionScheduleMap() | ||
inst_map.add('f', (0,), test_func) | ||
self.assertEqual(inst_map.get('f', (0,), x_test), ref_sched) | ||
self.assertEqual(inst_map.get('f', (0,), dur_expr), expected_sched) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this testcase dur_expr
is fixed by dur_val
defined in outer scope of generator (so parameter is kind of static). I understand that we have lack of framework that manages unbound parameters in the instruction schedule map, but here you intend in future this will be supported and dur_expr
will be able to be updated dynamically? i.e.
inst_map.get('f', (0,), t=10)
inst_map.get('f', (0,), t=20)
inst_map.get('f', (0,), t=30)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nkanazawa1989 Ah yes, that should be possible. In fact, I’ll update the test case to demonstrate this, when I get a chance. Great thought! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nkanazawa1989 Updated. Let me know your thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I misunderstood the purpose of this PR (in my example above it doesn't need to use ParameterExpression
and we can just feed the parameter t
into generator). Now I understand the intention of your test case. Anyways the code looks good now.
Summary
InstructionScheduleMap
schedule generator params to allowParameterExpression
s in addition to numbers (Resolves InstructionScheduleMap parameters should be ParameterExpressions #3923).