Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Qiskit/qiskit into oxidize-qc-data-…
Browse files Browse the repository at this point in the history
…perf
  • Loading branch information
kevinhartman committed Nov 29, 2023
2 parents 9c3d837 + 3556740 commit 07fd24f
Show file tree
Hide file tree
Showing 280 changed files with 1,291 additions and 32,392 deletions.
5 changes: 2 additions & 3 deletions .azure/lint-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
./qiskit_pkg \
-e .
# Build and install both qiskit and qiskit-terra so that any optionals
# depending on `qiskit` will resolve correctly.
Expand All @@ -38,7 +37,7 @@ jobs:
set -e
source test-job/bin/activate
echo "Running black, any errors reported can be fixed with 'tox -eblack'"
black --check qiskit test tools examples setup.py qiskit_pkg
black --check qiskit test tools examples setup.py
echo "Running rustfmt check, any errors reported can be fixed with 'cargo fmt'"
cargo fmt --check
displayName: "Formatting"
Expand All @@ -47,7 +46,7 @@ jobs:
set -e
source test-job/bin/activate
echo "Running ruff"
ruff qiskit test tools examples setup.py qiskit_pkg/setup.py
ruff qiskit test tools examples setup.py
echo "Running pylint"
pylint -rn qiskit test tools
echo "Running Cargo Clippy"
Expand Down
4 changes: 1 addition & 3 deletions .azure/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,11 @@ jobs:
python -m pip install -U pip
python -m pip install -U build
python -m build --sdist .
python -m build --sdist qiskit_pkg
python -m pip install -U \
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
dist/qiskit*.tar.gz
dist/qiskit-*.tar.gz
# Build and install both qiskit and qiskit-terra so that any optionals
# depending on `qiskit` will resolve correctly.
displayName: "Install Terra from sdist"
Expand All @@ -92,7 +91,6 @@ jobs:
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
./qiskit_pkg \
-e .
# Build and install both qiskit and qiskit-terra so that any optionals
# depending on `qiskit` will resolve correctly.
Expand Down
1 change: 0 additions & 1 deletion .azure/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ jobs:
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
./qiskit_pkg \
-e .
# Build and install both qiskit and qiskit-terra so that any optionals
# depending on `qiskit` will resolve correctly.
Expand Down
1 change: 0 additions & 1 deletion .azure/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
./qiskit_pkg \
-e .
# Build and install both qiskit and qiskit-terra so that any optionals
# depending on `qiskit` will resolve correctly.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: python -m pip install -c constraints.txt --upgrade pip setuptools wheel

- name: Build and install qiskit-terra
run: python -m pip install -c constraints.txt -e . ./qiskit_pkg
run: python -m pip install -c constraints.txt -e .
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Cinstrument-coverage"
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/neko.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ jobs:
- uses: Qiskit/qiskit-neko@main
with:
test_selection: terra
repo_install_command: "pip install -c constraints.txt ."
# We have to forcibly uninstall any old version of qiskit or qiskit-terra during the
# changeover, because it's not possible to safely upgrade an existing installation to 1.0.
repo_install_command: "pip uninstall qiskit qiskit-terra && pip install -c constraints.txt ."
2 changes: 1 addition & 1 deletion .github/workflows/slow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
python -m pip install -U pip setuptools wheel
python -m pip install -U -r requirements.txt -c constraints.txt
python -m pip install -U -r requirements-dev.txt -c constraints.txt
python -m pip install -c constraints.txt -e . ./qiskit_pkg
python -m pip install -c constraints.txt -e .
python -m pip install "qiskit-aer" "z3-solver" "cplex" -c constraints.txt
env:
SETUPTOOLS_ENABLE_FEATURES: "legacy-editable"
Expand Down
42 changes: 7 additions & 35 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
python-version: '3.10'
- uses: dtolnay/rust-toolchain@stable
- name: Build wheels
uses: pypa/cibuildwheel@v2.13.0
uses: pypa/cibuildwheel@v2.16.2
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
Expand All @@ -42,7 +42,7 @@ jobs:
python-version: '3.10'
- uses: dtolnay/rust-toolchain@stable
- name: Build wheels
uses: pypa/cibuildwheel@v2.13.0
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_BEFORE_ALL: rustup target add aarch64-apple-darwin
CIBW_ARCHS_MACOS: arm64 universal2
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
with:
platforms: all
- name: Build wheels
uses: pypa/cibuildwheel@v2.13.0
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_ARCHS_LINUX: s390x
CIBW_TEST_SKIP: "cp*"
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
with:
platforms: all
- name: Build wheels
uses: pypa/cibuildwheel@v2.13.0
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_ARCHS_LINUX: ppc64le
CIBW_TEST_SKIP: "cp*"
Expand Down Expand Up @@ -157,7 +157,7 @@ jobs:
with:
platforms: all
- name: Build wheels
uses: pypa/cibuildwheel@v2.13.0
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_ARCHS_LINUX: aarch64
- uses: actions/upload-artifact@v3
Expand All @@ -168,7 +168,7 @@ jobs:
with:
packages-dir: wheelhouse/
sdist:
name: Build and publish terra sdist
name: Build and publish sdist
runs-on: ${{ matrix.os }}
needs: ["upload_shared_wheels"]
environment: release
Expand All @@ -185,36 +185,8 @@ jobs:
with:
python-version: '3.10'
- name: Install deps
run: pip install -U twine setuptools-rust wheel build
run: pip install -U build
- name: Build sdist
run: python -m build . --sdist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
metapackage:
name: Build and publish terra sdist
runs-on: ${{ matrix.os }}
needs: ["sdist"]
environment: release
permissions:
id-token: write
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.10'
- name: Install deps
run: pip install -U twine setuptools-rust wheel build
- name: Build packages
run: |
set -e
cd qiskit_pkg
python -m build .
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: qiskit_pkg/dist
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ def test_method2(self):
self.assertEqual(result, <expected>)
```

`test_method1_deprecated` can be removed after `Obj.method1` is removed (following the [Qiskit Deprecation Policy](https://qiskit.org/documentation/contributing_to_qiskit.html#deprecation-policy)).
`test_method1_deprecated` can be removed after `Obj.method1` is removed (following the [Qiskit Deprecation Policy](./DEPRECATION.md)).

## Using dependencies

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ It also contains a transpiler that supports optimizing quantum circuits and a qu

For more details on how to use Qiskit, refer to the documentation located here:

<https://qiskit.org/documentation/>
<https://docs.quantum.ibm.com/>


## Installation
Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ parameters:
- name: "supportedPythonVersions"
displayName: "All supported versions of Python"
type: object
default: ["3.8", "3.9", "3.10", "3.11"]
default: ["3.8", "3.9", "3.10", "3.11", "3.12"]

- name: "minimumPythonVersion"
displayName: "Minimum supported version of Python"
Expand All @@ -41,7 +41,7 @@ parameters:
- name: "maximumPythonVersion"
displayName: "Maximum supported version of Python"
type: string
default: "3.11"
default: "3.12"

# These two versions of Python can be chosen somewhat arbitrarily, but we get
# slightly better coverage per PR if they're neither the maximum nor minimum
Expand Down
12 changes: 1 addition & 11 deletions constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@
# 4.0+. The pin can be removed after nbformat is updated.
jsonschema==3.2.0

# Numpy 1.25 deprecated some behaviours that we used, and caused the isometry
# tests to flake. See https://github.com/Qiskit/qiskit-terra/issues/10305,
# remove pin when resolving that.
numpy<1.25

# Scipy 1.11 seems to have caused an instability in the Weyl coordinates
# eigensystem code for one of the test cases. See
# https://github.com/Qiskit/qiskit-terra/issues/10345 for current details.
scipy<1.11

# Aer 0.13 causes several randomised tests to begin failing, and some
# `QuantumInstance` use of noise models to raise exceptions. These need fixes
# on Terra.
qiskit-aer==0.12.2
scipy<1.11; python_version<'3.12'
28 changes: 16 additions & 12 deletions crates/accelerate/src/euler_one_qubit_decomposer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,22 +380,26 @@ fn circuit_rr(
if !simplify {
atol = -1.0;
}
if theta.abs() < atol && phi.abs() < atol && lam.abs() < atol {
return OneQubitGateSequence {
gates: circuit,
global_phase: phase,
};
}
if (theta - PI).abs() > atol {

if mod_2pi((phi + lam) / 2., atol).abs() < atol {
// This can be expressed as a single R gate
if theta.abs() > atol {
circuit.push((String::from("r"), vec![theta, mod_2pi(PI / 2. + phi, atol)]));
}
} else {
// General case: use two R gates
if (theta - PI).abs() > atol {
circuit.push((
String::from("r"),
vec![theta - PI, mod_2pi(PI / 2. - lam, atol)],
));
}
circuit.push((
String::from("r"),
vec![theta - PI, mod_2pi(PI / 2. - lam, atol)],
vec![PI, mod_2pi(0.5 * (phi - lam + PI), atol)],
));
}
circuit.push((
String::from("r"),
vec![PI, mod_2pi(0.5 * (phi - lam + PI), atol)],
));

OneQubitGateSequence {
gates: circuit,
global_phase: phase,
Expand Down
12 changes: 6 additions & 6 deletions crates/accelerate/src/quantum_circuit/circuit_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ impl CircuitData {
}

// Note: we also rely on this to make us iterable!
pub fn __getitem__<'py>(&self, py: Python<'py>, index: &PyAny) -> PyResult<PyObject> {
pub fn __getitem__(&self, py: Python, index: &PyAny) -> PyResult<PyObject> {
// Internal helper function to get a specific
// instruction by index.
fn get_at(
Expand Down Expand Up @@ -491,7 +491,7 @@ impl CircuitData {
}
}

pub fn __delitem__(&mut self, py: Python<'_>, index: SliceOrInt) -> PyResult<()> {
pub fn __delitem__(&mut self, index: SliceOrInt) -> PyResult<()> {
match index {
SliceOrInt::Slice(slice) => {
let slice = {
Expand All @@ -504,7 +504,7 @@ impl CircuitData {
s
};
for i in slice.into_iter() {
self.__delitem__(py, SliceOrInt::Int(i))?;
self.__delitem__(SliceOrInt::Int(i))?;
}
Ok(())
}
Expand Down Expand Up @@ -545,7 +545,7 @@ impl CircuitData {
}

for (i, v) in slice.iter().zip(values.iter()) {
self.__setitem__(py, SliceOrInt::Int(*i), *v)?;
self.__setitem__(py, SliceOrInt::Int(*i), v)?;
}

if slice.len() > values.len() {
Expand All @@ -556,7 +556,7 @@ impl CircuitData {
indices.stop,
1isize,
);
self.__delitem__(py, SliceOrInt::Slice(slice))?;
self.__delitem__(SliceOrInt::Slice(slice))?;
} else {
// Insert any extra values.
for v in values.iter().skip(slice.len()).rev() {
Expand Down Expand Up @@ -593,7 +593,7 @@ impl CircuitData {
let index =
index.unwrap_or_else(|| std::cmp::max(0, self.data.len() as isize - 1).into_py(py));
let item = self.__getitem__(py, index.as_ref(py))?;
self.__delitem__(py, index.as_ref(py).extract()?)?;
self.__delitem__(index.as_ref(py).extract()?)?;
Ok(item)
}

Expand Down
Loading

0 comments on commit 07fd24f

Please sign in to comment.