Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/qutip/qutip-qip into simu…
Browse files Browse the repository at this point in the history
…lator_refactor.py
  • Loading branch information
BoxiLi committed Apr 3, 2024
2 parents 55705f1 + 2aca4e0 commit d1bd5bb
Show file tree
Hide file tree
Showing 48 changed files with 252 additions and 141 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/black.yml
Expand Up @@ -10,4 +10,5 @@ jobs:
- uses: psf/black@stable
with:
options: "--check --diff"
src: "./src"
src: "./src"
version: "~= 24.0"
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Expand Up @@ -54,7 +54,7 @@ jobs:
# For the sdist we should be as conservative as possible with our
# Python version. This should be the lowest supported version. This
# means that no unsupported syntax can sneak through.
python-version: '3.7'
python-version: '3.11'

- name: Install pip build
run: |
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
name: Install Python
with:
# This is about the build environment, not the released wheel version.
python-version: '3.7'
python-version: '3.11'

- name: Install pip build
run: |
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.7'
python-version: '3.11'

- name: Verify this is not a dev version
shell: bash
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/build_documentation.yml
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.8'
python-version: '3.9'

- name: Install Pandoc
run: |
Expand All @@ -27,7 +27,8 @@ jobs:
- name: Install qutip-qip from GitHub
run: |
python -mpip install -e .[full]
python -mpip install qutip==4.7.3
python -mpip install -e .
# Install in editable mode so it doesn't matter if we import from
# inside the installation directory, otherwise we can get some errors
# because we're importing from the wrong location.
Expand Down
37 changes: 13 additions & 24 deletions .github/workflows/test.yml
Expand Up @@ -12,11 +12,11 @@ jobs:
strategy:
matrix:
include:
- case-name: qutip@5.0.0a1
- case-name: qutip@5.0.0
os: ubuntu-latest
qutip-version: '==5.0.0a1'
qutip-version: '==5.0.0'
pyqir-version: ''
python-version: '3.10'
python-version: '3.11'
- case-name: qutip@qutip-4.7.X
os: ubuntu-latest
qutip-version: '@qutip-4.7.X'
Expand All @@ -26,37 +26,31 @@ jobs:
os: ubuntu-latest
qutip-version: '@master'
pyqir-version: ''
python-version: '3.11'
- case-name: qutip@4.6
os: windows-latest
qutip-version: '==4.6.*'
qiskit-version: ''
pyqir-version: ''
python-version: '3.8'
python-version: '3.12'
- case-name: qutip@4.7
os: macOS-latest
qutip-version: '==4.7.*'
qiskit-version: ''
pyqir-version: ''
python-version: '3.9'
python-version: '3.11'
- case-name: qiskit+qir
os: windows-latest
qutip-version: ''
qiskit-version: '==0.36.*'
qiskit-version: '==0.46.*'
pyqir-version: '==0.6.2'
python-version: '3.8'
python-version: '3.9'
- case-name: qiskit+qir
os: macOS-latest
qutip-version: ''
qiskit-version: '==0.36.*'
qiskit-version: '==0.46.*'
pyqir-version: '==0.6.2'
python-version: '3.9'
- case-name: qiskit+qir
os: ubuntu-latest
qutip-version: ''
qiskit-version: '==0.36.*'
qiskit-version: '==0.46.*'
pyqir-version: '==0.6.2'
python-version: '3.7'
python-version: '3.9'

steps:
- uses: actions/checkout@v3
Expand All @@ -74,15 +68,9 @@ jobs:
run: |
python -m pip install 'git+https://github.com/qutip/qutip.git${{ matrix.qutip-version }}'
# For qutip-v5 qutip.control is replaced by qutip-qtrl
- name: Install qutip-qtrl from PyPI
if: ${{ matrix.qutip-version == '@master'}}
run: |
python -m pip install 'git+https://github.com/qutip/qutip-qtrl.git'
- name: Install Qiskit from PyPI
if: ${{ matrix.qiskit-version != '' }}
run: python -m pip install 'qiskit${{ matrix.qiskit-version }}'
run: python -m pip install 'qiskit${{ matrix.qiskit-version }}' 'qiskit-aer==0.14.0.1'

- name: Install PyQIR from PyPI
if: ${{ matrix.pyqir-version != '' }}
Expand Down Expand Up @@ -111,11 +99,12 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -mpip install -r doc/requirements.txt
pip install qutip==4.7.3
pip install .
- name: Test code snippets in the documentation
run: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -16,7 +16,7 @@ The qutip-qip package, QuTiP quantum information processing, aims at providing b
Compared to other libraries for quantum information processing, qutip-qip puts additional emphasis on the physics layer and the interaction with the QuTiP package.
The package offers two different approaches for simulating quantum circuits, one with `QubitCircuit` calculating unitary evolution under quantum gates by matrix product, another called `Processor` using open system solvers in QuTiP to simulate noisy quantum device.

If you would like to know the future development plan and ideas, have a look at the [discussion panel](https://github.com/qutip/qutip-qip/discussions) as well as the [qutip documentation for ideas](https://qutip.org/docs/latest/development/ideas.html).
If you would like to know the future development plan and ideas, have a look at the [discussion panel](https://github.com/qutip/qutip-qip/discussions) as well as the [qutip documentation for ideas](https://qutip.readthedocs.io/en/stable/development/ideas.html).

Quick start
-----------
Expand Down
5 changes: 3 additions & 2 deletions doc/requirements.txt
Expand Up @@ -4,11 +4,12 @@ qutip==4.7.3
cython==0.29.30
sphinx==5.0.2
sphinx_rtd_theme==1.0.0
readthedocs-sphinx-search==0.1.2
readthedocs-sphinx-search==0.3.2
numpydoc==1.4.0
matplotlib==3.5.2
docutils==0.17.1
sphinxcontrib-bibtex==2.4.2
pyqir-generator==0.6.2
pyqir-parser==0.6.2
qiskit==0.37.2
qiskit==0.46.1
qiskit-aer==0.14.0.1
2 changes: 1 addition & 1 deletion doc/source/conf.py
Expand Up @@ -185,5 +185,5 @@ def qutip_qip_version():
# -- Options for intersphinx ---------------------------------------

intersphinx_mapping = {
'qutip': ('https://qutip.org/docs/latest/', None),
'qutip': ('https://qutip.readthedocs.io/en/stable/', None),
}
2 changes: 1 addition & 1 deletion doc/source/contribution-code.rst
Expand Up @@ -7,7 +7,7 @@ Contributing to the source code
Build up an development environment
===================================

Please follow the instruction on the `QuTiP contribution guide <https://qutip.org/docs/latest/development/contributing.html#building>`_ to
Please follow the instruction on the `QuTiP contribution guide <https://qutip.readthedocs.io/en/stable/development/contributing.html#building>`_ to
build a conda environment.
You don't need to build ``qutip`` in the editable mode unless you also want to contribute to `qutip`.
Instead, you need to install ``qutip-qip`` by downloading the source code and run
Expand Down
2 changes: 1 addition & 1 deletion doc/source/installation.rst
Expand Up @@ -24,7 +24,7 @@ Prerequisites
This package is built upon QuTiP, of which the installation guide can be found at on `QuTiP Installation <http://qutip.org/docs/latest/installation.html>`_.
The only difference is that C++ compilers are not required here
since there is no run-time compiling for qutip-qip.
The minimal Python version supported is Python 3.7.
The minimal Python version supported is Python 3.9.


In particular, following packages are necessary for running qutip-qip
Expand Down
2 changes: 1 addition & 1 deletion doc/source/tutorials-website/tutorials.html.jinja
Expand Up @@ -5,7 +5,7 @@
</div>

<h4 id="quantum-information-processing">Quantum information processing</h4>
<p>This section contains tutorials for QuTiP Version 5. You can find the tutorials for QuTiP Version 4 <a href="https://qutip.org/qutip-tutorials/">here</a>. To check the version of QuTiP, you can use the <code>qutip.about()</code> command.</p>
<p>This section contains tutorials for QuTiP Version 5. You can find the tutorials for QuTiP Version 4 <a href="https://qutip.org/qutip-tutorials/index-v4">here</a>. To check the version of QuTiP, you can use the <code>qutip.about()</code> command.</p>

<h5 id="qip-circuits">Quantum circuits and algorithms</h5>
<ul>
Expand Down
1 change: 0 additions & 1 deletion doc/source/w-state.qasm
Expand Up @@ -2,7 +2,6 @@
// Name of Experiment: W-state v1

OPENQASM 2.0;
include "qelib1.inc";


qreg q[3];
Expand Down
5 changes: 4 additions & 1 deletion setup.cfg
Expand Up @@ -40,10 +40,13 @@ where = src

[options.extras_require]
graphics = matplotlib>=1.3.0
control = qutip-qtrl
tests =
pytest>=5.2
full =
%(graphics)s
%(tests)s
%(control)s
qiskit =
qiskit>=0.36.2
qiskit<1.0.0
qiskit_aer
1 change: 0 additions & 1 deletion src/qutip_qip/algorithms/qft.py
Expand Up @@ -2,7 +2,6 @@
This module provides the circuit implementation for Quantum Fourier Transform.
"""


import numpy as np
from ..operations import Gate, snot, cphase, swap, expand_operator
from ..circuit import QubitCircuit
Expand Down
1 change: 1 addition & 0 deletions src/qutip_qip/circuit/__init__.py
@@ -1,4 +1,5 @@
"""Circuit representation and simulation at the gate level."""

from .circuit import *
from .circuit_latex import *
from .circuitsimulator import *
Expand Down
1 change: 1 addition & 0 deletions src/qutip_qip/circuit/_decompose.py
Expand Up @@ -3,6 +3,7 @@
Those decomposition functions should be moved to the
individual gate classes.
"""

import numpy as np
from ..operations import Gate

Expand Down
1 change: 1 addition & 0 deletions src/qutip_qip/circuit/circuit.py
@@ -1,6 +1,7 @@
"""
Quantum circuit representation and simulation.
"""

from collections.abc import Iterable
from itertools import product
import inspect
Expand Down
1 change: 1 addition & 0 deletions src/qutip_qip/compat.py
@@ -1,6 +1,7 @@
"""
For the compatibility between qutip-v5 and v4.
"""

from itertools import chain
from functools import reduce
from packaging.version import parse as parse_version
Expand Down
1 change: 1 addition & 0 deletions src/qutip_qip/compiler/__init__.py
@@ -1,4 +1,5 @@
"""Compilers for the hardware models in :obj:`device`"""

from .instruction import Instruction
from .scheduler import Scheduler
from .gatecompiler import GateCompiler
Expand Down
1 change: 1 addition & 0 deletions src/qutip_qip/decompose/__init__.py
@@ -1,2 +1,3 @@
"""Unitary decomposition. (experimental)"""

from .decompose_single_qubit_gate import *
1 change: 1 addition & 0 deletions src/qutip_qip/device/__init__.py
@@ -1,6 +1,7 @@
"""
Simulation of quantum hardware.
"""

from .processor import Processor, Model
from .modelprocessor import ModelProcessor
from .spinchain import (
Expand Down
1 change: 1 addition & 0 deletions src/qutip_qip/noise.py
@@ -1,4 +1,5 @@
"""Noise of quantum hardware."""

import numbers
import warnings
from collections.abc import Iterable
Expand Down
1 change: 1 addition & 0 deletions src/qutip_qip/operations/__init__.py
@@ -1,6 +1,7 @@
"""
Operations on quantum circuits.
"""

from .gates import *
from .gateclass import *
from .measurement import *
12 changes: 10 additions & 2 deletions src/qutip_qip/operations/gates.py
@@ -1,4 +1,5 @@
import numbers
from packaging.version import parse as parse_version
from collections.abc import Iterable
from itertools import product
from functools import partial, reduce
Expand Down Expand Up @@ -1207,7 +1208,7 @@ def _targets_to_list(targets, oper=None, N=None):


def expand_operator(
oper, N=None, targets=None, dims=None, cyclic_permutation=False
oper, N=None, targets=None, dims=None, cyclic_permutation=False, dtype=None
):
"""
Expand an operator to one that acts on a system with desired dimensions.
Expand All @@ -1225,13 +1226,16 @@ def expand_operator(
The indices of subspace that are acted on.
Permutation can also be realized by changing the orders of the indices.
N : int
Deprecated. Number of qubits. Please use `dims`.
Deprecated. Number of qubits. Please use `dims`.
cyclic_permutation : boolean, optional
Deprecated.
Expand for all cyclic permutation of the targets.
E.g. if ``N=3`` and `oper` is a 2-qubit operator,
the result will be a list of three operators,
each acting on qubits 0 and 1, 1 and 2, 2 and 0.
dtype : str, optional
Data type of the output `Qobj`. Only for qutip version larger than 5.
Returns
-------
Expand Down Expand Up @@ -1276,6 +1280,10 @@ def expand_operator(
[0. 0. 0. 0. 0. 0. 1. 0.]
[0. 0. 0. 1. 0. 0. 0. 0.]]
"""
if parse_version(qutip.__version__) >= parse_version("5.dev"):
# If no data type specified, use CSR
dtype = dtype or qutip.settings.core["default_dtype"] or qutip.data.CSR
oper = oper.to(dtype)
if N is not None:
warnings.warn(
"The function expand_operator has been generalized to "
Expand Down
1 change: 1 addition & 0 deletions src/qutip_qip/pulse.py
@@ -1,4 +1,5 @@
"""Pulse representation of a quantum circuit."""

from packaging.version import parse as parse_version
import numpy as np
from scipy.interpolate import CubicSpline
Expand Down

0 comments on commit d1bd5bb

Please sign in to comment.