Skip to content

Commit

Permalink
Merge branch 'main' into fix-sparsepauliop-phase
Browse files Browse the repository at this point in the history
  • Loading branch information
aeddins-ibm authored Aug 14, 2024
2 parents 3e91386 + 592c5f4 commit a5463e6
Show file tree
Hide file tree
Showing 63 changed files with 1,520 additions and 628 deletions.
6 changes: 6 additions & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
disallowed-types = [
"std::collections::HashSet",
"std::collections::HashMap",
"ahash::HashSet",
"ahash::HashMap",
]
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ the code. It also lets the community know what you're working on, and if you
need help, you can reference the issue when discussing it with other community
and team members.

* For documentation issues relating to pages in the Start, Build, Transpile, Verify, Run, and Migration guides sections of [docs.quantum.ibm.com](https://docs.quantum.ibm.com/), please open an issue in the [Qiskit/documentation repo](https://github.com/Qiskit/documentation/issues/new/choose) rather than the Qiskit/qiskit repo. In other words, any page that DOES NOT have `/api/` in the url should be addressed in the Qiskit/documentation repo. (Exception: the [Migration guide](https://docs.quantum.ibm.com/api/migration-guides) urls contain `/api/` but are managed in the Qiskit/documentation repo.)
* For documentation issues relating to pages in the Start, Build, Transpile, Verify, Run, and Migration guides sections of [docs.quantum.ibm.com](https://docs.quantum.ibm.com/), please open an issue in the [Qiskit/documentation repo](https://github.com/Qiskit/documentation/issues/new/choose) rather than the Qiskit/qiskit repo. In other words, any page that DOES NOT have `/api/` in the url should be addressed in the Qiskit/documentation repo.
* For issues relating to API reference pages (any page that contains `/api/` in the url), please open an issue in the repo specific to that API reference, for example [Qiskit/qiskit](https://github.com/Qiskit/qiskit/issues/new/choose), [Qiskit/qiskit-aer](https://github.com/Qiskit/qiskit-aer/issues/new/choose), or [Qiskit/qiskit-ibm-runtime](https://github.com/Qiskit/qiskit-ibm-runtime/issues/new/choose).

If you've written some code but need help finishing it, want to get initial
Expand Down
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ license = "Apache-2.0"
# Each crate can add on specific features freely as it inherits.
[workspace.dependencies]
bytemuck = "1.16"
indexmap.version = "2.3.0"
indexmap.version = "2.4.0"
hashbrown.version = "0.14.0"
num-bigint = "0.4"
num-complex = "0.4"
ndarray = "^0.15.6"
numpy = "0.21.0"
smallvec = "1.13"
thiserror = "1.0"
ahash = "0.8.11"

# Most of the crates don't need the feature `extension-module`, since only `qiskit-pyext` builds an
# actual C extension (the feature disables linking in `libpython`, which is forbidden in Python
Expand Down
4 changes: 2 additions & 2 deletions DEPRECATION.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Deprecation Policy

Starting from the 1.0.0 release, Qiskit follows semantic versioning, with a yearly release cycle for major releases.
[Full details of the scheduling are hosted with the external public documentation](https://docs.quantum.ibm.com/start/install#release-schedule).
[Full details of the scheduling are hosted with the external public documentation](https://docs.quantum.ibm.com/open-source/qiskit-sdk-version-strategy).

This document is primarily intended for developers of Qiskit themselves.

Expand Down Expand Up @@ -42,7 +42,7 @@ Similarly, while it is permissible where necessary for behavior to change with n
## What is the public interface?

> [!NOTE]
> This section should be in sync with [the release schedule documentation of Qiskit](https://docs.quantum.ibm.com/start/install#release-schedule).
> This section should be in sync with [the release schedule documentation of Qiskit](https://docs.quantum.ibm.com/open-source/qiskit-sdk-version-strategy).
> Please [open an issue against Qiskit](https://github.com/Qiskit/qiskit/issues/new/choose) if there are discrepancies so we can clarify them.
For the purposes of semantic versioning, the Qiskit public API comprises all *publicly documented* packages, modules, classes, functions, methods, and attributes.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ For more details on how to use Qiskit, refer to the documentation located here:
## Installation

> [!WARNING]
> Do not try to upgrade an existing Qiskit 0.* environment to Qiskit 1.0 in-place. [Read more](https://docs.quantum.ibm.com/api/migration-guides/qiskit-1.0-installation).
> Do not try to upgrade an existing Qiskit 0.* environment to Qiskit 1.0 in-place. [Read more](https://docs.quantum.ibm.com/migration-guides/qiskit-1.0-installation).
We encourage installing Qiskit via ``pip``:

Expand All @@ -33,7 +33,7 @@ pip install qiskit

Pip will handle all dependencies automatically and you will always install the latest (and well-tested) version.

To install from source, follow the instructions in the [documentation](https://docs.quantum.ibm.com/start/install-qiskit-source).
To install from source, follow the instructions in the [documentation](https://docs.quantum.ibm.com/guides/install-qiskit-source).

## Create your first quantum program in Qiskit

Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ For example, if the most recent release is 1.0.1, then the current major release
The 1.0.x series will be supported with bug fixes, until the release of 1.1.0, which will include new features.
The last version of the previous major release, 0.46.x, is supported with bugfixes only until six months after the final release of 1.0.0.

We provide more detail on [the release and support schedule of Qiskit in our documentation](https://docs.quantum.ibm.com/start/install#release-schedule).
We provide more detail on [the release and support schedule of Qiskit in our documentation](https://docs.quantum.ibm.com/open-source/qiskit-sdk-version-strategy).

## Reporting a Vulnerability

Expand Down
2 changes: 1 addition & 1 deletion crates/accelerate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ numpy.workspace = true
rand = "0.8"
rand_pcg = "0.3"
rand_distr = "0.4.3"
ahash = "0.8.11"
ahash.workspace = true
num-traits = "0.2"
num-complex.workspace = true
num-bigint.workspace = true
Expand Down
5 changes: 3 additions & 2 deletions crates/accelerate/src/synthesis/clifford/greedy_synthesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// copyright notice, and modified files need to carry a notice indicating
// that they have been altered from the originals.

use ahash::RandomState;
use indexmap::IndexSet;
use ndarray::{s, ArrayView2};
use smallvec::smallvec;
Expand Down Expand Up @@ -102,7 +103,7 @@ pub struct GreedyCliffordSynthesis<'a> {
symplectic_matrix: SymplecticMatrix,

/// Unprocessed qubits.
unprocessed_qubits: IndexSet<usize>,
unprocessed_qubits: IndexSet<usize, RandomState>,
}

impl GreedyCliffordSynthesis<'_> {
Expand All @@ -121,7 +122,7 @@ impl GreedyCliffordSynthesis<'_> {
smat: tableau.slice(s![.., 0..2 * num_qubits]).to_owned(),
};

let unprocessed_qubits: IndexSet<usize> = (0..num_qubits).collect();
let unprocessed_qubits = (0..num_qubits).collect();

Ok(GreedyCliffordSynthesis {
tableau,
Expand Down
6 changes: 3 additions & 3 deletions crates/accelerate/src/target_transpiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::ops::Index;

use ahash::RandomState;

use ahash::HashSet;
use hashbrown::HashSet;
use indexmap::{IndexMap, IndexSet};
use itertools::Itertools;
use nullable_index_map::NullableIndexMap;
Expand Down Expand Up @@ -305,7 +305,7 @@ impl Target {
match instruction {
TargetOperation::Variadic(_) => {
qargs_val = PropsMap::with_capacity(1);
qargs_val.extend([(None, None)].into_iter());
qargs_val.extend([(None, None)]);
self.variable_class_operations.insert(name.to_string());
}
TargetOperation::Normal(_) => {
Expand Down Expand Up @@ -872,7 +872,7 @@ impl Target {
.unwrap()
.extract::<GateMapState>()?
.into_iter()
.map(|(name, prop_map)| (name, PropsMap::from_iter(prop_map.into_iter()))),
.map(|(name, prop_map)| (name, PropsMap::from_iter(prop_map))),
);
self._gate_name_map = state
.get_item("gate_name_map")?
Expand Down
10 changes: 3 additions & 7 deletions crates/accelerate/src/target_transpiler/nullable_index_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ where
pub fn iter(&self) -> Iter<K, V> {
Iter {
map: self.map.iter(),
null_value: &self.null_val,
null_value: self.null_val.as_ref(),
}
}

Expand Down Expand Up @@ -209,7 +209,7 @@ where
/// Iterator for the key-value pairs in `NullableIndexMap`.
pub struct Iter<'a, K, V> {
map: BaseIter<'a, K, V>,
null_value: &'a Option<V>,
null_value: Option<&'a V>,
}

impl<'a, K, V> Iterator for Iter<'a, K, V> {
Expand All @@ -218,12 +218,8 @@ impl<'a, K, V> Iterator for Iter<'a, K, V> {
fn next(&mut self) -> Option<Self::Item> {
if let Some((key, val)) = self.map.next() {
Some((Some(key), val))
} else if let Some(value) = self.null_value {
let value = value;
self.null_value = &None;
Some((None, value))
} else {
None
self.null_value.take().map(|value| (None, value))
}
}

Expand Down
90 changes: 41 additions & 49 deletions crates/accelerate/src/two_qubit_decompose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,6 @@ impl Specialization {
}
}

type WeylCircuitSequence = Vec<(StandardGate, SmallVec<[Param; 3]>, SmallVec<[Qubit; 2]>)>;

#[derive(Clone, Debug)]
#[allow(non_snake_case)]
#[pyclass(module = "qiskit._accelerate.two_qubit_decompose", subclass)]
Expand Down Expand Up @@ -430,56 +428,49 @@ impl TwoQubitWeylDecomposition {
fn weyl_gate(
&self,
simplify: bool,
sequence: &mut WeylCircuitSequence,
sequence: &mut CircuitData,
atol: f64,
global_phase: &mut f64,
) {
) -> PyResult<()> {
match self.specialization {
Specialization::MirrorControlledEquiv => {
sequence.push((
StandardGate::SwapGate,
SmallVec::new(),
smallvec![Qubit(0), Qubit(1)],
));
sequence.push((
sequence.push_standard_gate(StandardGate::SwapGate, &[], &[Qubit(0), Qubit(1)])?;
sequence.push_standard_gate(
StandardGate::RZZGate,
smallvec![Param::Float((PI4 - self.c) * 2.)],
smallvec![Qubit(0), Qubit(1)],
));
&[Param::Float((PI4 - self.c) * 2.)],
&[Qubit(0), Qubit(1)],
)?;
*global_phase += PI4
}
Specialization::SWAPEquiv => {
sequence.push((
StandardGate::SwapGate,
SmallVec::new(),
smallvec![Qubit(0), Qubit(1)],
));
sequence.push_standard_gate(StandardGate::SwapGate, &[], &[Qubit(0), Qubit(1)])?;
*global_phase -= 3. * PI / 4.
}
_ => {
if !simplify || self.a.abs() > atol {
sequence.push((
sequence.push_standard_gate(
StandardGate::RXXGate,
smallvec![Param::Float(-self.a * 2.)],
smallvec![Qubit(0), Qubit(1)],
));
&[Param::Float(-self.a * 2.)],
&[Qubit(0), Qubit(1)],
)?;
}
if !simplify || self.b.abs() > atol {
sequence.push((
sequence.push_standard_gate(
StandardGate::RYYGate,
smallvec![Param::Float(-self.b * 2.)],
smallvec![Qubit(0), Qubit(1)],
));
&[Param::Float(-self.b * 2.)],
&[Qubit(0), Qubit(1)],
)?;
}
if !simplify || self.c.abs() > atol {
sequence.push((
sequence.push_standard_gate(
StandardGate::RZZGate,
smallvec![Param::Float(-self.c * 2.)],
smallvec![Qubit(0), Qubit(1)],
));
&[Param::Float(-self.c * 2.)],
&[Qubit(0), Qubit(1)],
)?;
}
}
}
Ok(())
}

/// Instantiate a new TwoQubitWeylDecomposition with rust native
Expand Down Expand Up @@ -1070,7 +1061,7 @@ impl TwoQubitWeylDecomposition {
};
let target_1q_basis_list: Vec<EulerBasis> = vec![euler_basis];

let mut gate_sequence: WeylCircuitSequence = Vec::with_capacity(21);
let mut gate_sequence = CircuitData::with_capacity(py, 2, 0, 21, Param::Float(0.))?;
let mut global_phase: f64 = self.global_phase;

let c2r = unitary_to_gate_sequence_inner(
Expand All @@ -1083,11 +1074,11 @@ impl TwoQubitWeylDecomposition {
)
.unwrap();
for gate in c2r.gates {
gate_sequence.push((
gate_sequence.push_standard_gate(
gate.0,
gate.1.into_iter().map(Param::Float).collect(),
smallvec![Qubit(0)],
))
&gate.1.into_iter().map(Param::Float).collect::<Vec<_>>(),
&[Qubit(0)],
)?
}
global_phase += c2r.global_phase;
let c2l = unitary_to_gate_sequence_inner(
Expand All @@ -1100,19 +1091,19 @@ impl TwoQubitWeylDecomposition {
)
.unwrap();
for gate in c2l.gates {
gate_sequence.push((
gate_sequence.push_standard_gate(
gate.0,
gate.1.into_iter().map(Param::Float).collect(),
smallvec![Qubit(1)],
))
&gate.1.into_iter().map(Param::Float).collect::<Vec<_>>(),
&[Qubit(1)],
)?
}
global_phase += c2l.global_phase;
self.weyl_gate(
simplify,
&mut gate_sequence,
atol.unwrap_or(ANGLE_ZERO_EPSILON),
&mut global_phase,
);
)?;
let c1r = unitary_to_gate_sequence_inner(
self.K1r.view(),
&target_1q_basis_list,
Expand All @@ -1123,11 +1114,11 @@ impl TwoQubitWeylDecomposition {
)
.unwrap();
for gate in c1r.gates {
gate_sequence.push((
gate_sequence.push_standard_gate(
gate.0,
gate.1.into_iter().map(Param::Float).collect(),
smallvec![Qubit(0)],
))
&gate.1.into_iter().map(Param::Float).collect::<Vec<_>>(),
&[Qubit(0)],
)?
}
global_phase += c2r.global_phase;
let c1l = unitary_to_gate_sequence_inner(
Expand All @@ -1140,13 +1131,14 @@ impl TwoQubitWeylDecomposition {
)
.unwrap();
for gate in c1l.gates {
gate_sequence.push((
gate_sequence.push_standard_gate(
gate.0,
gate.1.into_iter().map(Param::Float).collect(),
smallvec![Qubit(1)],
))
&gate.1.into_iter().map(Param::Float).collect::<Vec<_>>(),
&[Qubit(1)],
)?
}
CircuitData::from_standard_gates(py, 2, gate_sequence, Param::Float(global_phase))
gate_sequence.set_global_phase(py, Param::Float(global_phase))?;
Ok(gate_sequence)
}
}

Expand Down
Loading

0 comments on commit a5463e6

Please sign in to comment.