-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add analytic pulse function samplers #2042
Conversation
b63167b
to
936ff28
Compare
Can you add |
Since the |
qiskit/pulse/samplers/decorators.py
Outdated
They operate on a function with the signature: | ||
`def f(times: np.ndarray, *args, **kwargs) -> np.ndarray` | ||
Where `times` is a numpy array of floats with length `n_times` and the output array | ||
is a complex numpy array with length `n_times`. The output of the decorator is an |
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.
update documentation (n_times
not defined anywhere)
qiskit/pulse/samplers/decorators.py
Outdated
return generate_sampler | ||
|
||
|
||
def left_sample_fun(continuous_pulse: Callable, duration: int, *args, **kwargs) -> np.ndarray: |
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.
seems like this function should be deleted.
can you help me understand this:
So And then in the above, do we get an instance of a continuous pulse somewhere? I may be a bit lost here but what benefit do decorators have over just something simple like pulse objects having methods
|
All samplers concern themselves with doing is taking a function whose input is a list of continuous times and outputting a function whose first input is a duration, and then wrapping with a The approach you suggest means having another type of WIth the current implementations samplers are used like @pulse.sample.left
def linear(times, m, b):
return m*times + b
duration = 10
m= 0.01
b = 0.0
sched += linear(duration, m, b) |
…-defaults-required
…iskit-terra into issue-2098-pulse-defaults-required
…iskit-terra into issue-1935-samplers
…o issue-1935-samplers
Ok i'm fine moving forward. Tagged @kdk in case he has comments on the design, but I think we can also revisit later. |
* Update remote simulator test for backend IBMQ/Aer changes * Added test module and case for samplers. * Added base sampling decorator along with left, right, and midpoint samplers * Added tests to samplers. * change FunctionalPulse to decorator * update error function and imports * update unittest * add functools.wraps * remove getter, setter from sample pulse * fix lint * Added dynamic updating of docstrings for decorated sampled functions. * Added explicit documentation for standard library samplers. * Added extensive sampler module docstring for developers. * Update changelog with sampler. * Separate standard library and external libraries * Updated changelog for functional_pulse. * update sampler for functional_pulse decorator. Add additional tests. * Changed all instances of 'analytic' to 'continuous' * Update sampler module structure to separate sampling functions and decorators. * Remove sampler prefix to sampler module's modules. * Update small bug from rename * Change dtype casting to np.complex_ * remove accidental remote simulator file. * Removed required default parameters. * Update changelog. Update defaults model validation to add nonetypes. * Update changelog. * Readd parameters to be required. * Update docstring and delete extra function following review.
Summary
Add analytic pulse sampler which convert an analytic pulse of signature:
def f(times: np.ndarray, *args, **kwargs) -> np.ndarray
to a discrete pulse:
def g(duration: int, *args, **kwargs) -> SamplePulse
These will be used to implement the discrete pulse library from analytic pulse functions.
Closes #1935.
Details and comments
Currently implemented samplers:
left
right
midpoint
These are decorators that may be used like: