Skip to content

Commit

Permalink
Merge branch 'master' into pr/149
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxiLi committed Mar 14, 2023
2 parents 0e10089 + 4c72680 commit 380b559
Show file tree
Hide file tree
Showing 72 changed files with 5,652 additions and 3,521 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: psf/black@stable
with:
options: "--check --diff"
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ jobs:
OVERRIDE_VERSION: ${{ github.event.inputs.override_version }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
name: Install Python
with:
# 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.6'
python-version: '3.7'

- name: Install pip build
run: |
Expand All @@ -68,7 +68,7 @@ jobs:
# dependencies are specified by our setup code.
python -m build --sdist .
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: sdist
path: dist/*.tar.gz
Expand All @@ -83,9 +83,9 @@ jobs:
OVERRIDE_VERSION: ${{ github.event.inputs.override_version }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
name: Install Python
with:
# This is about the build environment, not the released wheel version.
Expand All @@ -105,7 +105,7 @@ jobs:
# dependencies are specified by our setup code.
python -m build --wheel --outdir wheelhouse .
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: wheels
path: ./wheelhouse/*.whl
Expand All @@ -124,9 +124,9 @@ jobs:

steps:
- name: Download build artifacts to local runner
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.7'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.8'
Expand Down Expand Up @@ -39,7 +39,7 @@ jobs:
# -T : display a full traceback if a Python exception occurs
- name: Upload built files
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: qutip_qip_html_docs
path: doc/_build/html/*
Expand Down
70 changes: 57 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,57 @@ on:
pull_request:

jobs:
test:
cases:
name: ${{ matrix.os }}, python${{ matrix.python-version }}, ${{ matrix.case-name }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
qutip-version: '@dev.major'
python-version: '3.6'
- os: windows-latest
qutip-version: '==4.6.*'
- case-name: qutip@qutip-4.7.X
os: ubuntu-latest
qutip-version: '@qutip-4.7.X'
pyqir-version: ''
python-version: '3.10'
- os: macOS-latest
- case-name: qutip@master
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'
- case-name: qutip@4.7
os: macOS-latest
qutip-version: '==4.7.*'
qiskit-version: ''
pyqir-version: ''
python-version: '3.9'
- case-name: qiskit+qir
os: windows-latest
qutip-version: ''
qiskit-version: '==0.36.*'
pyqir-version: '==0.6.2'
python-version: '3.8'
- case-name: qiskit+qir
os: macOS-latest
qutip-version: ''
qiskit-version: '==0.36.*'
pyqir-version: '==0.6.2'
python-version: '3.9'
- os: ubuntu-latest
- case-name: qiskit+qir
os: ubuntu-latest
qutip-version: ''
qiskit-version: '==0.36.*'
pyqir-version: '==0.6.2'
python-version: '3.7'

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -41,6 +70,21 @@ jobs:
python -m pip install numpy scipy cython
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 qutip-qtrl
- name: Install Qiskit from PyPI
if: ${{ matrix.qiskit-version != '' }}
run: python -m pip install 'qiskit${{ matrix.qiskit-version }}'

- name: Install PyQIR from PyPI
if: ${{ matrix.pyqir-version != '' }}
# We use each subpackage explicitly here; see https://github.com/qir-alliance/pyqir/issues/167.
run: python -m pip install 'pyqir-generator${{ matrix.pyqir-version }}' 'pyqir-parser${{ matrix.pyqir-version }}'

- name: Install qutip-qip
# Installing in-place so that coveralls can locate the source code.
run: |
Expand All @@ -59,9 +103,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
Expand All @@ -81,7 +125,7 @@ jobs:
finalise:
name: Finalise coverage reporting
needs: [test]
needs: [cases]
runs-on: ubuntu-latest
container: python:3-slim
steps:
Expand Down
10 changes: 4 additions & 6 deletions doc/pulse-paper/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
import numpy as np
from qutip import (
fidelity, sigmax, sigmay, sigmaz, basis, qeye, tensor, Qobj, fock_dm)
from qutip_qip.circuit import QubitCircuit, Gate
from qutip_qip.circuit import QubitCircuit
from qutip_qip.operations import Gate
from qutip_qip.device import ModelProcessor, Model
from qutip_qip.compiler import GateCompiler, Instruction
import qutip
from packaging.version import parse as parse_version
if parse_version(qutip.__version__) < parse_version('5.dev'):
from qutip import Options as SolverOptions
else:
from qutip import SolverOptions
from qutip import Options
from qutip_qip.noise import Noise


Expand Down Expand Up @@ -219,7 +217,7 @@ def single_crosstalk_simulation(num_gates):
init_state = tensor(
[Qobj([[init_fid, 0], [0, 0.025]]), Qobj([[init_fid, 0], [0, 0.025]])]
)
options = SolverOptions(nsteps=10000) # increase the maximal allowed steps
options = Options(nsteps=10000) # increase the maximal allowed steps
e_ops = [tensor([qeye(2), fock_dm(2)])] # observable

# compute results of the run using a solver of choice with custom options
Expand Down
11 changes: 3 additions & 8 deletions doc/pulse-paper/dj_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
OptPulseProcessor, LinearSpinChain, SCQubits, SpinChainModel)
from qutip_qip.circuit import QubitCircuit
from qutip import sigmaz, sigmax, identity, tensor, basis
from qutip_qip.compat import to_scalar


# Deutsch-Josza algorithm
dj_circuit = QubitCircuit(num_qubits)
Expand Down Expand Up @@ -79,7 +81,6 @@
ax[i].fill_between([full_tlist[point2], full_tlist[point3]], [vmin ,vmin], [vmax, vmax], color="lightgray", alpha=0.5)
ax[i].vlines([full_tlist[point2], full_tlist[point3]], vmin, vmax, "gray", "--", linewidth=0.8, alpha=0.5)

fig.tight_layout()
fig.savefig("optimal_control_pulse.pdf")
fig.show()

Expand Down Expand Up @@ -123,13 +124,7 @@
ax3[9].set_xlabel(r"$t$")

full_tlist = scqubits_processor.get_full_tlist()
two_qubit_gate_region = np.array([[0, 6, -18], [0, 6, -4], [0, 9, -4], [0, 6, -18], [0, 6, -4], [0, 11, -4], [0, 6, -18], [0, 6, -4], [0, 6, -4]]) * 500
for i, (point1, point2, point3) in enumerate(two_qubit_gate_region):
vmin, vmax = ax3[i].get_ylim()
ax3[i].fill_between([full_tlist[point2], full_tlist[point3]], [vmin ,vmin], [vmax, vmax], color="lightgray", alpha=0.5)
ax3[i].vlines([full_tlist[point2], full_tlist[point3]], vmin, vmax, "gray", "--", linewidth=0.8, alpha=0.5)

fig3.tight_layout()
fig3.savefig("transmon_pulse.pdf")
fig3.show()

Expand All @@ -151,7 +146,7 @@
for state in result1.states:
tmp = state.ptrace([0,1])
tmp = basis([2,2], [0,0]).dag() * tmp * basis([2,2], [0,0])
expect.append(np.real(tmp[0, 0]))
expect.append(np.real(to_scalar(tmp)))

fig5, ax5 = plt.subplots(figsize=(LINEWIDTH, LINEWIDTH*0.7), dpi=200)
ax5.plot(t_record, expect, color="slategrey")
Expand Down
8 changes: 6 additions & 2 deletions doc/pulse-paper/qft.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


import numpy as np
from qutip import basis, fidelity
from qutip import basis, fidelity, Options
from qutip_qip.device import LinearSpinChain
from qutip_qip.algorithms import qft_gate_sequence

Expand All @@ -23,7 +23,11 @@
# Pulse-level simulation
processor = LinearSpinChain(num_qubits)
processor.load_circuit(qc)
state2 = processor.run_state(basis([2]*num_qubits, [0]*num_qubits)).states[-1]
options = Options(max_step=5000)
state2 = processor.run_state(
basis([2]*num_qubits, [0]*num_qubits),
options=options
).states[-1]

assert(abs(1 - fidelity(state1, state2)) < 1.e-4)

Expand Down
25 changes: 14 additions & 11 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
numpy==1.21
scipy==1.7
qutip==4.6
cython==0.29
sphinx==4.5
sphinx_rtd_theme==0.5.1
readthedocs-sphinx-search==0.1.0rc3
numpydoc==1.1
matplotlib==3.3
docutils==0.16
sphinxcontrib-bibtex==2.4
numpy==1.22.4
scipy==1.7.3
qutip==4.7.0
cython==0.29.30
sphinx==5.0.2
sphinx_rtd_theme==1.0.0
readthedocs-sphinx-search==0.1.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
11 changes: 11 additions & 0 deletions doc/source/apidoc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Simulation based on operator-state multiplication.
qutip_qip.qubits
qutip_qip.decompose
qutip_qip.qasm
qutip_qip.qir
qutip_qip.vqa

Pulse-level simulation
Expand All @@ -33,3 +34,13 @@ Simulation based on the master equation.
qutip_qip.compiler
qutip_qip.pulse
qutip_qip.noise

Qiskit Circuit Simulation
--------------------------
Simulation of qiskit circuits based on qutip_qip backends.

.. autosummary::
:toctree: apidoc/
:template: autosummary/module.rst

qutip_qip.qiskit
1 change: 0 additions & 1 deletion doc/source/apidoc/qutip_qip.circuit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ qutip\_qip.circuit
QubitCircuit
CircuitResult
CircuitSimulator
Measurement
4 changes: 1 addition & 3 deletions doc/source/apidoc/qutip_qip.operations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ qutip\_qip.operations
.. autosummary::

Gate
Measurement
GATE_CLASS_MAP
X
Y
Expand Down Expand Up @@ -63,9 +64,6 @@ qutip\_qip.operations
cz_gate
expand_operator
fredkin
gate_expand_1toN
gate_expand_2toN
gate_expand_3toN
gate_sequence_product
globalphase
hadamard_transform
Expand Down
16 changes: 16 additions & 0 deletions doc/source/apidoc/qutip_qip.qir.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
:orphan:

qutip\_qip.qir
===============

.. automodule:: qutip_qip.qir
:members:
:show-inheritance:
:imported-members:

.. rubric:: Functions

.. autosummary::

QirFormat
circuit_to_qir
Loading

0 comments on commit 380b559

Please sign in to comment.