This repository was archived by the owner on Oct 31, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Add get samples function to InstructionToSignals for JAX-jit usage #149
Merged
DanPuzzuoli
merged 27 commits into
qiskit-community:main
from
to24toro:jax_implementation_to_pulse
Feb 16, 2023
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
b5e2fad
add sampling pulse for jax jit
to24toro 7e2c039
add a release note
to24toro 9c87d08
comment change of tolerance
to24toro 8adbc79
change test_jit_get_samples
to24toro 6ad5815
add jax_grad test
to24toro c309427
Fix pulse to signal converter (#164)
to24toro 5713e13
wrap signal samples as Array
to24toro 9a3acaa
format
to24toro 3c6a78a
modify test_pulse_to_signals
to24toro ccb9bdc
add test_jit_solve_with_internal_jit
to24toro 42d4b8c
impl jax-jit for pulse simulation
to24toro a1637e0
format by black
to24toro ef502d3
add type hint
to24toro a73d315
add test_SymbolicPulse
to24toro 32ad385
modify test_SymbolicPulse
to24toro 8839c78
modify test_SymbolicPulse
to24toro bf66412
add test_pulse_types_combination_with_jax
to24toro 9bc4972
remove redefined fucntion
to24toro 39a1e90
restore previous comments
to24toro aa10fbe
add removed sentence
to24toro 454f119
rename class name from TestJaxGetSamples to TestPulseToSignalsJAXTran…
to24toro 2814cf0
fix codes about TestPulseToSignalsJAXTransformations
to24toro 4044ebd
Merge branch 'main' into jax_implementation_to_pulse
to24toro f8b055e
modify importing and naming of pulse function
to24toro c3338c5
insert spaces in InstructionToSignals docs
to24toro 5a5d2ac
Merge branch 'main' into jax_implementation_to_pulse
DanPuzzuoli c56c9ca
Merge branch 'main' into jax_implementation_to_pulse
DanPuzzuoli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,5 +81,4 @@ | |
|
|
||
| InstructionToSignals | ||
| """ | ||
|
|
||
| from .pulse_to_signals import InstructionToSignals | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,8 @@ | |
|
|
||
|
|
||
| try: | ||
| from jax import jit | ||
| from jax import core, jit | ||
| import jax.numpy as jnp | ||
| except ImportError: | ||
| pass | ||
|
|
||
|
|
@@ -522,6 +523,8 @@ def solve( | |
| Array.default_backend() == "jax" | ||
| and (method == "jax_odeint" or _is_diffrax_method(method)) | ||
| and all(isinstance(x, Schedule) for x in signals_list) | ||
| # check if jit transformation is already performed. | ||
| and not (isinstance(jnp.array(0), core.Tracer)) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is related with the issue #175 |
||
| ): | ||
| all_results = self._solve_schedule_list_jax( | ||
| t_span_list=t_span_list, | ||
|
|
||
22 changes: 22 additions & 0 deletions
22
releasenotes/notes/get_samples_for_instruction_to_signals-e1de83e3e65a30de.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --- | ||
| features: | ||
| - | | ||
| The logic of :class:`.InstructionToSignals` has been updated. | ||
| This change allows you to jit compile a function including | ||
| the converter with input pulse schedule that contains :class:`.SymbolicPulse`. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| from functools import partial | ||
| import jax | ||
| from qiskit import pulse | ||
| from qiskit_dynamics.pulse import InstructionToSignals | ||
|
|
||
| @partial(jax.jit, static_argnums=(0, 1)) | ||
| def run_simulation(amp, sigma): | ||
| converter = InstructionToSignals(dt=1, carriers=None) | ||
| with pulse.build() as schedule: | ||
| pulse.play(pulse.Gaussian(160, amp, sigma), pulse.DriveChannel(0)) | ||
| signals = converter.get_signals(schedule) | ||
|
|
||
| # continue with simulations |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.