From b7d562e092b37415485da6a91536051eabab462a Mon Sep 17 00:00:00 2001 From: DanPuzzuoli Date: Thu, 7 Mar 2024 11:52:54 -0800 Subject: [PATCH 01/11] removing comments --- docs/tutorials/dynamics_backend.rst | 44 +++++++++++++---------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/docs/tutorials/dynamics_backend.rst b/docs/tutorials/dynamics_backend.rst index 46b45332a..e0e2b432a 100644 --- a/docs/tutorials/dynamics_backend.rst +++ b/docs/tutorials/dynamics_backend.rst @@ -13,29 +13,24 @@ definitions, and calibration and characterization experiments from Qiskit Experi The sections of this tutorial are as follows: -1. Configure Dynamics to use JAX. +1. Configure JAX. 2. Instantiating a minimally-configured :class:`.DynamicsBackend` with a 2 qubit model. 3. Simulating pulse schedules on the :class:`.DynamicsBackend`. 4. Simulating circuits at the pulse level using the :class:`.DynamicsBackend`. 5. Simulating single-qubit calibration processes via Qiskit Experiments. 6. Simulating 2 qubit interaction characterization via the |CRHamitonian| experiment. -1. Configure Dynamics to use JAX --------------------------------- +1. Configure JAX +---------------- Note that the :class:`.DynamicsBackend` internally performs just-in-time compilation automatically -when configured to use JAX. See the :ref:`User Guide entry on using different array libraries with -Qiskit Dynamics ` for more information. +when using a JAX solver method. Here we configure JAX to run on CPU in 64 bit mode. See the +:ref:`User Guide entry on using different array libraries with Qiskit Dynamics ` for more information. .. jupyter-execute:: - :hide-code: - import warnings - warnings.filterwarnings('ignore', message='', category=Warning, module='', lineno=0, append=False) - -.. jupyter-execute:: - - # Configure to use JAX internally + # Configure JAX import jax jax.config.update("jax_enable_x64", True) jax.config.update("jax_platform_name", "cpu") @@ -46,9 +41,7 @@ Qiskit Dynamics ` for more information. To create the :class:`.DynamicsBackend`, first specify a :class:`.Solver` instance using the model details. Note that the choice of model depends on the type of device you wish to simulate. Here, we will use a :math:`2` qubit fixed-frequency transmon model with fixed coupling, with the following -Hamiltonian (see the `Qiskit Textbook page on Circuit Quantum Electrodynamics -`_ for details on how transmon -Hamiltonians are derived): +Hamiltonian: .. math:: @@ -132,6 +125,7 @@ performance. hamiltonian_channels=["d0", "d1", "u0", "u1"], channel_carrier_freqs={"d0": v0, "d1": v1, "u0": v1, "u1": v0}, dt=dt, + array_library="jax", ) Next, instantiate the :class:`.DynamicsBackend`. The ``solver`` is used for simulation, @@ -472,27 +466,27 @@ values for the single qubit gates calibrated above. .. jupyter-execute:: - #from qiskit_experiments.library import CrossResonanceHamiltonian + from qiskit_experiments.library import CrossResonanceHamiltonian - #cr_ham_experiment = CrossResonanceHamiltonian( - # physical_qubits=(0, 1), - # durations=np.linspace(10, 5000, 17), - # backend=backend - #) + cr_ham_experiment = CrossResonanceHamiltonian( + physical_qubits=(0, 1), + durations=np.linspace(10, 5000, 17), + backend=backend + ) - #backend.target.update_from_instruction_schedule_map(cals.get_inst_map()) + backend.target.update_from_instruction_schedule_map(cals.get_inst_map()) .. jupyter-execute:: - #cr_ham_experiment.circuits()[10].draw("mpl") + cr_ham_experiment.circuits()[10].draw("mpl") Run the simulation. .. jupyter-execute:: - #%time data_cr = cr_ham_experiment.run().block_for_results() + %time data_cr = cr_ham_experiment.run().block_for_results() .. jupyter-execute:: - #data_cr.figure(0) + data_cr.figure(0) From 45eea237ec890e72227cc524b97d9ace8d882cd8 Mon Sep 17 00:00:00 2001 From: DanPuzzuoli Date: Fri, 8 Mar 2024 07:35:45 -0800 Subject: [PATCH 02/11] fixing durations of CrossResonanceHamiltonian --- docs/tutorials/dynamics_backend.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/dynamics_backend.rst b/docs/tutorials/dynamics_backend.rst index e0e2b432a..64c02b700 100644 --- a/docs/tutorials/dynamics_backend.rst +++ b/docs/tutorials/dynamics_backend.rst @@ -470,7 +470,7 @@ values for the single qubit gates calibrated above. cr_ham_experiment = CrossResonanceHamiltonian( physical_qubits=(0, 1), - durations=np.linspace(10, 5000, 17), + durations=np.linspace(1e-7, 1e-6, 17), backend=backend ) From 934a43d9373dc86e08c6340e204cd40b1b5a613c Mon Sep 17 00:00:00 2001 From: DanPuzzuoli Date: Fri, 8 Mar 2024 08:21:08 -0800 Subject: [PATCH 03/11] bumping python version for docs build --- .github/workflows/docs.yml | 2 +- .github/workflows/main.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 39e905dbe..a97e06aac 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.10' + python-version: '3.11' - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a029e4d95..bcb50a0b1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -64,10 +64,10 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set up Python 3.10 + - name: Set up Python 3.11 uses: actions/setup-python@v2 with: - python-version: '3.10' + python-version: '3.11' - name: Pip cache uses: actions/cache@v2 with: From 2af5a2f7e0d2f4addfa1ab4d338154d1beba6717 Mon Sep 17 00:00:00 2001 From: DanPuzzuoli Date: Fri, 8 Mar 2024 08:30:15 -0800 Subject: [PATCH 04/11] bumping python version again --- .github/workflows/docs.yml | 2 +- .github/workflows/main.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a97e06aac..608970438 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.11' + python-version: '3.12' - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bcb50a0b1..060bddef8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -64,10 +64,10 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set up Python 3.11 + - name: Set up Python 3.12 uses: actions/setup-python@v2 with: - python-version: '3.11' + python-version: '3.12' - name: Pip cache uses: actions/cache@v2 with: From eb2b8167d88d67e9bf4366b2f4c11571be951736 Mon Sep 17 00:00:00 2001 From: DanPuzzuoli Date: Fri, 8 Mar 2024 08:41:15 -0800 Subject: [PATCH 05/11] reverting to python 3.11 and disabling multithreading in docs build --- .github/workflows/docs.yml | 2 +- .github/workflows/main.yml | 4 ++-- tox.ini | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 608970438..a97e06aac 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.12' + python-version: '3.11' - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 060bddef8..bcb50a0b1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -64,10 +64,10 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set up Python 3.12 + - name: Set up Python 3.11 uses: actions/setup-python@v2 with: - python-version: '3.12' + python-version: '3.11' - name: Pip cache uses: actions/cache@v2 with: diff --git a/tox.ini b/tox.ini index 2ecc009e6..029addfc5 100644 --- a/tox.ini +++ b/tox.ini @@ -45,7 +45,7 @@ deps = setenv = PYDEVD_DISABLE_FILE_VALIDATION = 1 commands = - sphinx-build -j auto -W -T --keep-going {posargs} docs/ docs/_build/html + sphinx-build auto -W -T --keep-going {posargs} docs/ docs/_build/html [testenv:docs-clean] skip_install = true From 99c82806d810b94050186d2ef7b42c38a124c118 Mon Sep 17 00:00:00 2001 From: DanPuzzuoli Date: Fri, 8 Mar 2024 08:47:30 -0800 Subject: [PATCH 06/11] removing auto --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 029addfc5..bf05c7787 100644 --- a/tox.ini +++ b/tox.ini @@ -45,7 +45,7 @@ deps = setenv = PYDEVD_DISABLE_FILE_VALIDATION = 1 commands = - sphinx-build auto -W -T --keep-going {posargs} docs/ docs/_build/html + sphinx-build -W -T --keep-going {posargs} docs/ docs/_build/html [testenv:docs-clean] skip_install = true From 95fa06525829c65a16dd205753c573b7cf423c37 Mon Sep 17 00:00:00 2001 From: DanPuzzuoli Date: Fri, 8 Mar 2024 09:07:51 -0800 Subject: [PATCH 07/11] adding warning filter for debugging --- docs/userguide/perturbative_solvers.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/userguide/perturbative_solvers.rst b/docs/userguide/perturbative_solvers.rst index 10d5ef489..0f773fb6a 100644 --- a/docs/userguide/perturbative_solvers.rst +++ b/docs/userguide/perturbative_solvers.rst @@ -75,6 +75,9 @@ on the perturbative solver speed. .. jupyter-execute:: + import warnings + warnings.filterwarnings("error") + import numpy as np dim = 10 # Oscillator dimension From cbf41305b6791ff489033001d46cecbaed8c0a4e Mon Sep 17 00:00:00 2001 From: DanPuzzuoli Date: Fri, 8 Mar 2024 09:16:56 -0800 Subject: [PATCH 08/11] moving the warnings -> error --- docs/conf.py | 5 ++++- docs/userguide/perturbative_solvers.rst | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index a2284016a..f688887ea 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -76,4 +76,7 @@ # nbsphinx_execute = os.getenv('QISKIT_DOCS_BUILD_TUTORIALS', 'never') nbsphinx_execute = 'always' nbsphinx_widgets_path = '' -exclude_patterns = ['_build', '**.ipynb_checkpoints'] \ No newline at end of file +exclude_patterns = ['_build', '**.ipynb_checkpoints'] + +import warnings +warnings.filterwarnings("error") \ No newline at end of file diff --git a/docs/userguide/perturbative_solvers.rst b/docs/userguide/perturbative_solvers.rst index 0f773fb6a..10d5ef489 100644 --- a/docs/userguide/perturbative_solvers.rst +++ b/docs/userguide/perturbative_solvers.rst @@ -75,9 +75,6 @@ on the perturbative solver speed. .. jupyter-execute:: - import warnings - warnings.filterwarnings("error") - import numpy as np dim = 10 # Oscillator dimension From b8629516c71edcf2f23aaea56331f7aa16622719 Mon Sep 17 00:00:00 2001 From: DanPuzzuoli Date: Fri, 8 Mar 2024 09:22:54 -0800 Subject: [PATCH 09/11] moving --- docs/conf.py | 5 +---- docs/tutorials/dynamics_backend.rst | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index f688887ea..a2284016a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -76,7 +76,4 @@ # nbsphinx_execute = os.getenv('QISKIT_DOCS_BUILD_TUTORIALS', 'never') nbsphinx_execute = 'always' nbsphinx_widgets_path = '' -exclude_patterns = ['_build', '**.ipynb_checkpoints'] - -import warnings -warnings.filterwarnings("error") \ No newline at end of file +exclude_patterns = ['_build', '**.ipynb_checkpoints'] \ No newline at end of file diff --git a/docs/tutorials/dynamics_backend.rst b/docs/tutorials/dynamics_backend.rst index 64c02b700..10b2ccf45 100644 --- a/docs/tutorials/dynamics_backend.rst +++ b/docs/tutorials/dynamics_backend.rst @@ -30,6 +30,8 @@ array libraries>` for more information. .. jupyter-execute:: + import warnings + warnings.filterwarnings("error") # Configure JAX import jax jax.config.update("jax_enable_x64", True) From 7bb04d432fe004d55acfbe8a924ea14545013607 Mon Sep 17 00:00:00 2001 From: DanPuzzuoli Date: Fri, 8 Mar 2024 09:37:52 -0800 Subject: [PATCH 10/11] attempting to remove specific warning --- docs/tutorials/dynamics_backend.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/dynamics_backend.rst b/docs/tutorials/dynamics_backend.rst index 10b2ccf45..a72f41db3 100644 --- a/docs/tutorials/dynamics_backend.rst +++ b/docs/tutorials/dynamics_backend.rst @@ -31,7 +31,7 @@ array libraries>` for more information. .. jupyter-execute:: import warnings - warnings.filterwarnings("error") + warnings.filterwarnings("ignore", message="os.fork") # Configure JAX import jax jax.config.update("jax_enable_x64", True) From e8db59d63d39e6aafa780f331ac1b2f108952a97 Mon Sep 17 00:00:00 2001 From: DanPuzzuoli Date: Fri, 8 Mar 2024 09:47:07 -0800 Subject: [PATCH 11/11] adding hidden warning suppression --- docs/tutorials/dynamics_backend.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/tutorials/dynamics_backend.rst b/docs/tutorials/dynamics_backend.rst index a72f41db3..a78058248 100644 --- a/docs/tutorials/dynamics_backend.rst +++ b/docs/tutorials/dynamics_backend.rst @@ -29,9 +29,14 @@ when using a JAX solver method. Here we configure JAX to run on CPU in 64 bit mo array libraries>` for more information. .. jupyter-execute:: + :hide-code: + # a parallelism warning raised by JAX is being raised due to somethign outside of Dynamics import warnings warnings.filterwarnings("ignore", message="os.fork") + +.. jupyter-execute:: + # Configure JAX import jax jax.config.update("jax_enable_x64", True)