Skip to content
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

Arraylias integration - Rotating frame - #214

Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions docs/tutorials/dynamics_backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,9 @@ To enable running of the single qubit experiments, we add the following to the `
backend.
- Add definitions of ``RZ`` gates as phase shifts. These instructions control the phase of the drive
channels, as well as any control channels acting on a given qubit.
- Add a ``CX`` gate which applies to all qubits. While this tutorial will not be utilizing it, this
ensures that validation steps checking that the device is fully connected will pass.
- Add a ``CX`` gate between qubits :math:`(0, 1)` and :math:`(1, 0)`. While this tutorial will not
be utilizing it, this ensures that validation steps checking that the device is fully connected
will pass.

.. jupyter-execute::

Expand All @@ -336,7 +337,7 @@ To enable running of the single qubit experiments, we add the following to the `
target.add_instruction(XGate(), properties={(0,): None, (1,): None})
target.add_instruction(SXGate(), properties={(0,): None, (1,): None})

target.add_instruction(CXGate())
target.add_instruction(CXGate(), properties={(0, 1): None, (1, 0): None})

# Add RZ instruction as phase shift for drag cal
phi = Parameter("phi")
Expand Down Expand Up @@ -472,11 +473,6 @@ values for the single qubit gates calibrated above.

from qiskit_experiments.library import CrossResonanceHamiltonian

backend.target.add_instruction(
instruction=CrossResonanceHamiltonian.CRPulseGate(width=Parameter("width")),
properties={(0, 1): None, (1, 0): None}
)

cr_ham_experiment = CrossResonanceHamiltonian(
qubits=(0, 1),
flat_top_widths=np.linspace(0, 5000, 17),
Expand Down
22 changes: 22 additions & 0 deletions qiskit_dynamics/arraylias_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,36 @@

from typing import Union
from arraylias import numpy_alias
from scipy.sparse import csr_matrix
from .array import Array
try:
from jax.experimental.sparse import BCOO
except ImportError:
pass


DYNAMICS_ALIAS = numpy_alias()

# Set qiskit_dynamics.array.Array to be dispatched to numpy
DYNAMICS_ALIAS.register_type(Array, "numpy")

# register required custom versions of functions for csr type here
DYNAMICS_ALIAS.register_type(csr_matrix, lib="scipy_sparse")
to24toro marked this conversation as resolved.
Show resolved Hide resolved

# register required custom versions of functions for BCOO type here
DYNAMICS_ALIAS.register_type(BCOO, lib="jax_sparse")


@DYNAMICS_ALIAS.register_function(lib="scipy_sparse", path="asarray")
def _(csr: csr_matrix):
return csr.toarray()


@DYNAMICS_ALIAS.register_function(lib="jax_sparse", path="asarray")
def _(bcoo: BCOO):
return bcoo.todense()


DYNAMICS_NUMPY = DYNAMICS_ALIAS()

ArrayLike = Union[DYNAMICS_ALIAS.registered_types()]
Loading