Skip to content

Commit 9fa17a3

Browse files
Bump MSRV to 1.87 and nalgebra to the 0.34 release (#16045)
* Bump MSRV to 1.87 and nalgebra to the 0.34 release This commit updates nalgebra to the latest release 0.34 and also increases our MSRV to the minimum version compatible with that nalgebra release 1.87. Nalgebra 0.34 was release in July of 2025 and we didn't upgrade at the time because we had just increased our msrv to 1.85 and bumping it again would have been overly onerous. But since we're now using nalgebra more in critical code paths (2q decomposition) it makes sense to make this change now especially since rust 1.87 is over 1 year old now (being release in March 2025). The rust code changes made in this are to fix clippy warnings due to new clippy rules being enabled with the higher msrv of 1.87. * Update releasenotes/notes/msrv-187-fe3d9818f5c4103d.yaml Co-authored-by: Jake Lishman <jake@binhbar.com> --------- Co-authored-by: Jake Lishman <jake@binhbar.com>
1 parent ceba759 commit 9fa17a3

16 files changed

Lines changed: 192 additions & 28 deletions

File tree

Cargo.lock

Lines changed: 163 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ resolver = "2"
55
[workspace.package]
66
version = "2.5.0-dev"
77
edition = "2024"
8-
rust-version = "1.85" # Keep in sync with README.md, rust-toolchain.toml, and tools/install_rust_msrv.sh
8+
rust-version = "1.87" # Keep in sync with README.md, rust-toolchain.toml, and tools/install_rust_msrv.sh
99
license = "Apache-2.0"
1010

1111
# Shared dependencies that can be inherited. This just helps a little with
@@ -20,7 +20,7 @@ indexmap.version = "2.10.0"
2020
hashbrown.version = "0.15.5"
2121
num-bigint = "0.4"
2222
num-complex = "0.4"
23-
nalgebra = "0.33"
23+
nalgebra = "0.34"
2424
faer = "0.24"
2525
numpy = "0.28"
2626
ndarray = "0.16"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Downloads](https://img.shields.io/pypi/dm/qiskit.svg)](https://pypi.org/project/qiskit/)
77
[![Coverage Status](https://coveralls.io/repos/github/Qiskit/qiskit/badge.svg?branch=main)](https://coveralls.io/github/Qiskit/qiskit?branch=main)
88
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/qiskit)
9-
[![Minimum rustc 1.85](https://img.shields.io/badge/rustc-1.85+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
9+
[![Minimum rustc 1.87](https://img.shields.io/badge/rustc-1.87+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
1010
[![Downloads](https://static.pepy.tech/badge/qiskit)](https://pepy.tech/project/qiskit)<!--- long-description-skip-end -->
1111
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2583252.svg)](https://doi.org/10.5281/zenodo.2583252)
1212

crates/circuit_library/src/entanglement.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn shift_circular_alternating(
8787
let shifted = circular(num_qubits, block_size)
8888
.skip(split as usize)
8989
.chain(circular(num_qubits, block_size).take(split as usize));
90-
if offset % 2 == 0 {
90+
if offset.is_multiple_of(2) {
9191
Box::new(shifted)
9292
} else {
9393
// if the offset is odd, reverse the indices inside the qubit block (e.g. turn CX

crates/circuit_library/src/pauli_feature_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ fn _default_reduce(parameters: Vec<Param>) -> Param {
201201
let acc = parameters.iter().fold(Param::Float(1.0), |acc, param| {
202202
multiply_params(acc, add_param(param, -PI))
203203
});
204-
if parameters.len() % 2 == 0 {
204+
if parameters.len().is_multiple_of(2) {
205205
acc
206206
} else {
207207
multiply_param(&acc, -1.0) // take care of parity

crates/circuit_library/src/suzuki_trotter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn suzuki_trotter_evolution(
3636
preserve_order: bool,
3737
insert_barriers: bool,
3838
) -> Result<CircuitData, EvolutionError> {
39-
if order > 1 && order % 2 != 0 || order == 0 {
39+
if order > 1 && !order.is_multiple_of(2) || order == 0 {
4040
return Err(EvolutionError::OrderSymmetry(order));
4141
}
4242

crates/quantum_info/src/sparse_pauli_op.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,10 @@ impl MatrixCompressedPaulis {
383383
// Technically this discards part of the storable data, but in practice, a dense
384384
// operator with more than 32 qubits needs in the region of 1 ZiB memory. We still use
385385
// `u64` to help sparse-matrix construction, though.
386-
let coeff = if (i_row as u32 & z_like as u32).count_ones() % 2 == 0 {
386+
let coeff = if (i_row as u32 & z_like as u32)
387+
.count_ones()
388+
.is_multiple_of(2)
389+
{
387390
coeff
388391
} else {
389392
-coeff

crates/quantum_info/src/unitary_compose.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn _einsum_matmul(
8787
) -> Result<Array<Complex64, IxDyn>, &'static str> {
8888
let rank = tensor.ndim();
8989
let rank_mat = mat.ndim();
90-
if rank_mat % 2 != 0 {
90+
if !rank_mat.is_multiple_of(2) {
9191
return Err("Contracted matrix must have an even number of indices.");
9292
}
9393
// Get einsum indices for tensor

crates/synthesis/src/linear/pmh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn _index(transpose: bool, i: usize, j: usize) -> (usize, usize) {
3131

3232
fn _ceil_fraction(numerator: usize, denominator: usize) -> usize {
3333
let mut fraction = numerator / denominator;
34-
if numerator % denominator > 0 {
34+
if !numerator.is_multiple_of(denominator) {
3535
fraction += 1;
3636
}
3737
fraction

crates/synthesis/src/linear_phase/cx_cz_depth_lnn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fn _update_phase_schedule(
150150
(k != i)
151151
&& (k != j)
152152
&& (order_comp[min(k, j)] < order_comp[i])
153-
&& (phase_schedule[[min(k, j), max(k, j)]] % 4 != 0)
153+
&& !phase_schedule[[min(k, j), max(k, j)]].is_multiple_of(4)
154154
})
155155
.collect();
156156

0 commit comments

Comments
 (0)