Skip to content

Commit 052972a

Browse files
Merge branch 'main' into port-hls-to-rust
2 parents 4eba6fa + 682e2d3 commit 052972a

File tree

254 files changed

+3229
-13997
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

254 files changed

+3229
-13997
lines changed

.github/workflows/tests.yml

+6-10
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,15 @@ concurrency:
1313
jobs:
1414
tests:
1515
if: github.repository_owner == 'Qiskit'
16-
name: macOS-arm64-tests-Python-${{ matrix.python-version }}
17-
runs-on: macOS-14
16+
name: ${{ matrix.os }}-arm64-tests-Python-${{ matrix.python-version }}
17+
runs-on: ${{ matrix.os }}
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
# Normally we test min and max version but we can't run python
22-
# 3.9 on arm64 until actions/setup-python#808 is resolved
23-
python-version: ["3.10", "3.13"]
21+
python-version: ["3.9", "3.13"]
22+
os: ["macOS-14", "ubuntu-24.04-arm"]
2423
steps:
2524
- uses: actions/checkout@v4
26-
- name: Install Rust toolchain
27-
uses: dtolnay/rust-toolchain@1.70
28-
if: matrix.python-version == '3.10'
2925
- name: Set up Python ${{ matrix.python-version }}
3026
uses: actions/setup-python@v5
3127
with:
@@ -36,7 +32,7 @@ jobs:
3632
python -m pip install -U -r requirements.txt -c constraints.txt
3733
python -m pip install -U -r requirements-dev.txt -c constraints.txt
3834
python -m pip install -c constraints.txt -e .
39-
if: matrix.python-version == '3.10'
35+
if: matrix.python-version == '3.9'
4036
env:
4137
QISKIT_NO_CACHE_GATES: 1
4238
- name: 'Install dependencies'
@@ -49,6 +45,6 @@ jobs:
4945
run: |
5046
python -m pip install -r requirements-optional.txt -c constraints.txt
5147
python tools/report_numpy_state.py
52-
if: matrix.python-version == '3.10'
48+
if: matrix.python-version == '3.9'
5349
- name: 'Run tests'
5450
run: stestr run

.github/workflows/wheels-build.yml

+10-28
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ on:
4343
default: "default"
4444
required: false
4545

46-
wheels-linux-aarch64:
47-
description: >-
48-
The action to take for Linux AArch64 wheels.
49-
Choose from 'default', 'build' or 'skip'.
50-
type: string
51-
default: "default"
52-
required: false
53-
5446
artifact-prefix:
5547
description: "A prefix to give all artifacts uploaded with 'actions/upload-artifact'."
5648
type: string
@@ -85,12 +77,12 @@ jobs:
8577
# Used for the ARM builds.
8678
- macos-14
8779
- windows-latest
80+
- ubuntu-24.04-arm
8881
steps:
8982
- uses: actions/checkout@v4
9083
- uses: actions/setup-python@v5
9184
with:
9285
python-version: ${{ inputs.python-version }}
93-
architecture: ${{ matrix.os == 'macos-14' && 'arm64' || 'x64' }}
9486
- uses: dtolnay/rust-toolchain@stable
9587
with:
9688
components: llvm-tools-preview
@@ -108,12 +100,19 @@ jobs:
108100
run: |
109101
set -e
110102
mkdir -p "$PGO_WORK_DIR"
111-
103+
if [[ `uname -m` == "aarch64" ]] ; then
104+
INSTALL_RUST_PATH=tools/install_rust_msrv.sh
105+
RUST_TOOLCHAIN=1.79
106+
else
107+
INSTALL_RUST_PATH=tools/install_rust.sh
108+
RUST_TOOLCHAIN=stable
109+
fi
112110
cat >>"$GITHUB_ENV" <<EOF
111+
CIBW_BEFORE_ALL_LINUX=yum install -y wget && {package}/$INSTALL_RUST_PATH
113112
CIBW_BEFORE_BUILD=bash ./tools/build_pgo.sh $PGO_WORK_DIR $PGO_OUT_PATH
114113
CIBW_ENVIRONMENT=RUSTUP_TOOLCHAIN=stable RUSTFLAGS='-Cprofile-use=$PGO_OUT_PATH -Cllvm-args=-pgo-warn-missing-function'
115114
CIBW_ENVIRONMENT_MACOS=MACOSX_DEPLOYMENT_TARGET='10.12' RUSTUP_TOOLCHAIN=stable RUSTFLAGS='-Cprofile-use=$PGO_OUT_PATH -Cllvm-args=-pgo-warn-missing-function'
116-
CIBW_ENVIRONMENT_LINUX=RUSTUP_TOOLCHAIN=stable RUSTFLAGS='-Cprofile-use=$PGO_OUT_PATH -Cllvm-args=-pgo-warn-missing-function' PATH="\$PATH:\$HOME/.cargo/bin" CARGO_NET_GIT_FETCH_WITH_CLI="true"
115+
CIBW_ENVIRONMENT_LINUX=RUSTUP_TOOLCHAIN=$RUST_TOOLCHAIN RUSTFLAGS='-Cprofile-use=$PGO_OUT_PATH -Cllvm-args=-pgo-warn-missing-function' PATH="\$PATH:\$HOME/.cargo/bin" CARGO_NET_GIT_FETCH_WITH_CLI="true"
117116
EOF
118117
env:
119118
PGO_WORK_DIR: ${{ github.workspace }}/pgo-data
@@ -123,7 +122,6 @@ jobs:
123122
with:
124123
path: ./wheelhouse/*.whl
125124
name: ${{ inputs.artifact-prefix }}wheels-tier-1-${{ matrix.os }}
126-
127125
wheels-linux-s390x:
128126
name: "Wheels / Linux s390x"
129127
if: (inputs.wheels-linux-s390x == 'default' && inputs.default-action || inputs.wheels-linux-s390x) == 'build'
@@ -170,22 +168,6 @@ jobs:
170168
path: ./wheelhouse/*.whl
171169
name: ${{ inputs.artifact-prefix }}wheels-linux-ppc64le
172170

173-
wheels-linux-aarch64:
174-
name: "Wheels / Linux AArch64"
175-
if: (inputs.wheels-linux-aarch64 == 'default' && inputs.default-action || inputs.wheels-linux-aarch64) == 'build'
176-
runs-on: ubuntu-24.04-arm
177-
steps:
178-
- uses: actions/checkout@v4
179-
- uses: actions/setup-python@v5
180-
with:
181-
python-version: ${{ inputs.python-version }}
182-
- uses: dtolnay/rust-toolchain@stable
183-
- uses: pypa/cibuildwheel@v2.22.0
184-
- uses: actions/upload-artifact@v4
185-
with:
186-
path: ./wheelhouse/*.whl
187-
name: ${{ inputs.artifact-prefix }}wheels-linux-aarch64
188-
189171
sdist:
190172
name: "sdist"
191173
if: (inputs.sdist == 'default' && inputs.default-action || inputs.sdist) == 'build'

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ resolver = "2"
55
[workspace.package]
66
version = "2.0.0"
77
edition = "2021"
8-
rust-version = "1.79" # Keep in sync with README.md and rust-toolchain.toml.
8+
rust-version = "1.79" # 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

crates/accelerate/src/barrier_before_final_measurement.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use pyo3::prelude::*;
1414
use rayon::prelude::*;
1515
use rustworkx_core::petgraph::stable_graph::NodeIndex;
1616

17-
use qiskit_circuit::circuit_instruction::ExtraInstructionAttributes;
1817
use qiskit_circuit::dag_circuit::{DAGCircuit, NodeType};
1918
use qiskit_circuit::operations::{OperationRef, StandardInstruction};
2019
use qiskit_circuit::packed_instruction::{PackedInstruction, PackedOperation};
@@ -150,7 +149,7 @@ pub fn barrier_before_final_measurements(
150149
qargs.as_slice(),
151150
&[],
152151
None,
153-
ExtraInstructionAttributes::new(label, None, None, None),
152+
label,
154153
#[cfg(feature = "cache_pygates")]
155154
None,
156155
)?;

crates/accelerate/src/basis/basis_translator/compose_transforms.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub(super) fn compose_transforms<'a>(
7575
} else {
7676
Some(gate_obj.params)
7777
},
78-
gate_obj.extra_attrs,
78+
gate_obj.label.map(|x| *x),
7979
#[cfg(feature = "cache_pygates")]
8080
Some(gate.into()),
8181
)?;
@@ -121,7 +121,7 @@ pub(super) fn compose_transforms<'a>(
121121
op_node.bind(py),
122122
&replace_dag,
123123
None,
124-
true,
124+
None,
125125
)?;
126126
}
127127
}

crates/accelerate/src/basis/basis_translator/mod.rs

+6-21
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ fn apply_translation(
522522
} else {
523523
Some(new_op.params)
524524
},
525-
new_op.extra_attrs,
525+
new_op.label.map(|x| *x),
526526
#[cfg(feature = "cache_pygates")]
527527
None,
528528
)?;
@@ -543,7 +543,7 @@ fn apply_translation(
543543
.collect(),
544544
)
545545
},
546-
node_obj.extra_attrs.clone(),
546+
node_obj.label.as_ref().map(|x| x.as_ref().clone()),
547547
#[cfg(feature = "cache_pygates")]
548548
None,
549549
)?;
@@ -571,7 +571,7 @@ fn apply_translation(
571571
.collect(),
572572
)
573573
},
574-
node_obj.extra_attrs.clone(),
574+
node_obj.label.as_ref().map(|x| x.as_ref().clone()),
575575
#[cfg(feature = "cache_pygates")]
576576
None,
577577
)?;
@@ -595,7 +595,7 @@ fn apply_translation(
595595
.collect(),
596596
)
597597
},
598-
node_obj.extra_attrs.clone(),
598+
node_obj.label.as_ref().map(|x| x.as_ref().clone()),
599599
#[cfg(feature = "cache_pygates")]
600600
None,
601601
)?;
@@ -667,27 +667,12 @@ fn replace_node(
667667
} else {
668668
inner_node.op.clone()
669669
};
670-
if node.condition().is_some() {
671-
match new_op.view() {
672-
OperationRef::Gate(gate) => {
673-
gate.gate.setattr(py, "condition", node.condition())?
674-
}
675-
OperationRef::Instruction(inst) => {
676-
inst.instruction
677-
.setattr(py, "condition", node.condition())?
678-
}
679-
OperationRef::Operation(oper) => {
680-
oper.operation.setattr(py, "condition", node.condition())?
681-
}
682-
_ => (),
683-
}
684-
}
685670
let new_params: SmallVec<[Param; 3]> = inner_node
686671
.params_view()
687672
.iter()
688673
.map(|param| param.clone_ref(py))
689674
.collect();
690-
let new_extra_props = node.extra_attrs.clone();
675+
let new_extra_props = node.label.as_ref().map(|x| x.as_ref().clone());
691676
dag.apply_operation_back(
692677
py,
693678
new_op,
@@ -802,7 +787,7 @@ fn replace_node(
802787
} else {
803788
Some(new_params)
804789
},
805-
inner_node.extra_attrs.clone(),
790+
inner_node.label.as_ref().map(|x| x.as_ref().clone()),
806791
#[cfg(feature = "cache_pygates")]
807792
None,
808793
)?;

crates/accelerate/src/commutation_analysis.rs

-2
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,10 @@ pub(crate) fn analyze_commutations_inner(
9595
py,
9696
&op1,
9797
params1,
98-
&packed_inst0.extra_attrs,
9998
qargs1,
10099
cargs1,
101100
&op2,
102101
params2,
103-
&packed_inst1.extra_attrs,
104102
qargs2,
105103
cargs2,
106104
MAX_NUM_QUBITS,

crates/accelerate/src/commutation_checker.rs

+2-16
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use pyo3::types::{PyBool, PyDict, PySequence, PyTuple};
2525
use pyo3::BoundObject;
2626

2727
use qiskit_circuit::bit_data::BitData;
28-
use qiskit_circuit::circuit_instruction::{ExtraInstructionAttributes, OperationFromPython};
28+
use qiskit_circuit::circuit_instruction::OperationFromPython;
2929
use qiskit_circuit::dag_node::DAGOpNode;
3030
use qiskit_circuit::imports::QI_OPERATOR;
3131
use qiskit_circuit::operations::OperationRef::{Gate as PyGateType, Operation as PyOperationType};
@@ -178,12 +178,10 @@ impl CommutationChecker {
178178
py,
179179
&op1.instruction.operation.view(),
180180
&op1.instruction.params,
181-
&op1.instruction.extra_attrs,
182181
&qargs1,
183182
&cargs1,
184183
&op2.instruction.operation.view(),
185184
&op2.instruction.params,
186-
&op2.instruction.extra_attrs,
187185
&qargs2,
188186
&cargs2,
189187
max_num_qubits,
@@ -215,12 +213,10 @@ impl CommutationChecker {
215213
py,
216214
&op1.operation.view(),
217215
&op1.params,
218-
&op1.extra_attrs,
219216
&qargs1,
220217
&cargs1,
221218
&op2.operation.view(),
222219
&op2.params,
223-
&op2.extra_attrs,
224220
&qargs2,
225221
&cargs2,
226222
max_num_qubits,
@@ -285,12 +281,10 @@ impl CommutationChecker {
285281
py: Python,
286282
op1: &OperationRef,
287283
params1: &[Param],
288-
attrs1: &ExtraInstructionAttributes,
289284
qargs1: &[Qubit],
290285
cargs1: &[Clbit],
291286
op2: &OperationRef,
292287
params2: &[Param],
293-
attrs2: &ExtraInstructionAttributes,
294288
qargs2: &[Qubit],
295289
cargs2: &[Clbit],
296290
max_num_qubits: u32,
@@ -321,12 +315,10 @@ impl CommutationChecker {
321315
let commutation: Option<bool> = commutation_precheck(
322316
op1,
323317
params1,
324-
attrs1,
325318
qargs1,
326319
cargs1,
327320
op2,
328321
params2,
329-
attrs2,
330322
qargs2,
331323
cargs2,
332324
max_num_qubits,
@@ -576,21 +568,15 @@ impl CommutationChecker {
576568
fn commutation_precheck(
577569
op1: &OperationRef,
578570
params1: &[Param],
579-
attrs1: &ExtraInstructionAttributes,
580571
qargs1: &[Qubit],
581572
cargs1: &[Clbit],
582573
op2: &OperationRef,
583574
params2: &[Param],
584-
attrs2: &ExtraInstructionAttributes,
585575
qargs2: &[Qubit],
586576
cargs2: &[Clbit],
587577
max_num_qubits: u32,
588578
) -> Option<bool> {
589-
if op1.control_flow()
590-
|| op2.control_flow()
591-
|| attrs1.condition().is_some()
592-
|| attrs2.condition().is_some()
593-
{
579+
if op1.control_flow() || op2.control_flow() {
594580
return Some(false);
595581
}
596582

crates/accelerate/src/consolidate_blocks.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use rustworkx_core::petgraph::stable_graph::NodeIndex;
2121
use smallvec::smallvec;
2222

2323
use qiskit_circuit::circuit_data::CircuitData;
24-
use qiskit_circuit::circuit_instruction::ExtraInstructionAttributes;
2524
use qiskit_circuit::dag_circuit::DAGCircuit;
2625
use qiskit_circuit::gate_matrix::{ONE_QUBIT_IDENTITY, TWO_QUBIT_IDENTITY};
2726
use qiskit_circuit::imports::{QI_OPERATOR, QUANTUM_CIRCUIT};
@@ -125,7 +124,7 @@ pub(crate) fn consolidate_blocks(
125124
inst_node,
126125
PackedOperation::from_unitary(Box::new(unitary_gate)),
127126
smallvec![],
128-
ExtraInstructionAttributes::default(),
127+
None,
129128
)?;
130129
continue;
131130
}
@@ -199,7 +198,7 @@ pub(crate) fn consolidate_blocks(
199198
&block,
200199
PackedOperation::from_unitary(Box::new(unitary_gate)),
201200
smallvec![],
202-
ExtraInstructionAttributes::default(),
201+
None,
203202
false,
204203
&block_index_map,
205204
&clbit_pos_map,
@@ -238,7 +237,7 @@ pub(crate) fn consolidate_blocks(
238237
&block,
239238
PackedOperation::from_unitary(Box::new(unitary_gate)),
240239
smallvec![],
241-
ExtraInstructionAttributes::default(),
240+
None,
242241
false,
243242
&qubit_pos_map,
244243
&clbit_pos_map,
@@ -276,7 +275,7 @@ pub(crate) fn consolidate_blocks(
276275
first_inst_node,
277276
PackedOperation::from_unitary(Box::new(unitary_gate)),
278277
smallvec![],
279-
ExtraInstructionAttributes::default(),
278+
None,
280279
)?;
281280
continue;
282281
}
@@ -320,7 +319,7 @@ pub(crate) fn consolidate_blocks(
320319
&run,
321320
PackedOperation::from_unitary(Box::new(unitary_gate)),
322321
smallvec![],
323-
ExtraInstructionAttributes::default(),
322+
None,
324323
false,
325324
&block_index_map,
326325
&clbit_pos_map,

0 commit comments

Comments
 (0)