Skip to content

Commit

Permalink
Merge branch 'main' into move-to-gh
Browse files Browse the repository at this point in the history
  • Loading branch information
raynelfss authored Dec 10, 2024
2 parents 55f5480 + 17648eb commit eae4d08
Show file tree
Hide file tree
Showing 28 changed files with 739 additions and 400 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/wheels-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
os:
- ubuntu-latest
# Used for the x86_64 builds.
- macos-12
- macos-13
# Used for the ARM builds.
- macos-14
- windows-latest
Expand Down Expand Up @@ -121,6 +121,7 @@ jobs:
cat >>"$GITHUB_ENV" <<EOF
CIBW_BEFORE_BUILD=bash ./tools/build_pgo.sh $PGO_WORK_DIR $PGO_OUT_PATH
CIBW_ENVIRONMENT=RUSTUP_TOOLCHAIN=stable RUSTFLAGS='-Cprofile-use=$PGO_OUT_PATH -Cllvm-args=-pgo-warn-missing-function'
CIBW_ENVIRONMENT_MACOS=MACOSX_DEPLOYMENT_TARGET='10.12' RUSTUP_TOOLCHAIN=stable RUSTFLAGS='-Cprofile-use=$PGO_OUT_PATH -Cllvm-args=-pgo-warn-missing-function'
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"
EOF
env:
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ lint:
tools/verify_headers.py qiskit test tools
tools/find_optional_imports.py
tools/find_stray_release_notes.py
tools/verify_images.py

# Only pylint on files that have changed from origin/main. Also parallelize (disables cyclic-import check)
lint-incr:
-git fetch -q https://github.com/Qiskit/qiskit-terra.git :lint_incr_latest
tools/pylint_incr.py -j4 -rn -sn --paths :/qiskit/*.py :/test/*.py :/tools/*.py
tools/verify_headers.py qiskit test tools
tools/find_optional_imports.py
tools/verify_images.py

ruff:
ruff qiskit test tools setup.py
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ from qiskit.primitives import StatevectorSampler
sampler = StatevectorSampler()
job = sampler.run([qc_measured], shots=1000)
result = job.result()
print(f" > Counts: {result[0].meas.get_counts()}")
print(f" > Counts: {result[0].data["meas"].get_counts()}")
```
Running this will give an outcome similar to `{'000': 497, '111': 503}` which is `000` 50% of the time and `111` 50% of the time up to statistical fluctuations.
To illustrate the power of Estimator, we now use the quantum information toolbox to create the operator $XXY+XYX+YXX-YYY$ and pass it to the `run()` function, along with our quantum circuit. Note the Estimator requires a circuit _**without**_ measurement, so we use the `qc_example` circuit we created earlier.
Expand Down
2 changes: 1 addition & 1 deletion crates/accelerate/src/twirling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ fn generate_twirled_circuit(
custom_gate_map: Option<&CustomGateTwirlingMap>,
optimizer_target: Option<&Target>,
) -> PyResult<CircuitData> {
let mut out_circ = CircuitData::clone_empty_like(circ, None);
let mut out_circ = CircuitData::clone_empty_like(py, circ, None)?;

for inst in circ.data() {
if let Some(custom_gate_map) = custom_gate_map {
Expand Down
25 changes: 19 additions & 6 deletions crates/circuit/src/circuit_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ impl CircuitData {
instruction_iter.size_hint().0,
global_phase,
)?;

for item in instruction_iter {
let (operation, params, qargs, cargs) = item?;
let qubits = res.qargs_interner.insert_owned(qargs);
Expand Down Expand Up @@ -996,9 +997,13 @@ impl CircuitData {
qubits,
clbits,
param_table: ParameterTable::new(),
global_phase,
global_phase: Param::Float(0.0),
};

// use the global phase setter to ensure parameters are registered
// in the parameter table
res.set_global_phase(py, global_phase)?;

for inst in instruction_iter {
res.data.push(inst?);
res.track_instruction_parameters(py, res.data.len() - 1)?;
Expand Down Expand Up @@ -1040,6 +1045,7 @@ impl CircuitData {
instruction_iter.size_hint().0,
global_phase,
)?;

let no_clbit_index = res.cargs_interner.get_default();
for (operation, params, qargs) in instruction_iter {
let qubits = res.qargs_interner.insert(&qargs);
Expand Down Expand Up @@ -1073,8 +1079,13 @@ impl CircuitData {
qubits: BitData::new(py, "qubits".to_string()),
clbits: BitData::new(py, "clbits".to_string()),
param_table: ParameterTable::new(),
global_phase,
global_phase: Param::Float(0.0),
};

// use the global phase setter to ensure parameters are registered
// in the parameter table
res.set_global_phase(py, global_phase)?;

if num_qubits > 0 {
let qubit_cls = QUBIT.get_bound(py);
for _i in 0..num_qubits {
Expand Down Expand Up @@ -1528,16 +1539,18 @@ impl CircuitData {
/// * capacity - The capacity for instructions to use in the output `CircuitData`
/// If `None` the length of `other` will be used, if `Some` the integer
/// value will be used as the capacity.
pub fn clone_empty_like(other: &Self, capacity: Option<usize>) -> Self {
CircuitData {
pub fn clone_empty_like(py: Python, other: &Self, capacity: Option<usize>) -> PyResult<Self> {
let mut empty = CircuitData {
data: Vec::with_capacity(capacity.unwrap_or(other.data.len())),
qargs_interner: other.qargs_interner.clone(),
cargs_interner: other.cargs_interner.clone(),
qubits: other.qubits.clone(),
clbits: other.clbits.clone(),
param_table: ParameterTable::new(),
global_phase: other.global_phase.clone(),
}
global_phase: Param::Float(0.0),
};
empty.set_global_phase(py, other.global_phase.clone())?;
Ok(empty)
}

/// Append a PackedInstruction to the circuit data.
Expand Down
6 changes: 3 additions & 3 deletions crates/circuit/src/dag_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ impl DAGCircuit {
py,
concat!(
"The property ``qiskit.dagcircuit.dagcircuit.DAGCircuit.duration`` is ",
"deprecated as of qiskit 1.3.0. It will be removed in Qiskit 2.0.0.",
"deprecated as of Qiskit 1.3.0. It will be removed in Qiskit 2.0.0.",
)
),
py.get_type_bound::<PyDeprecationWarning>(),
Expand All @@ -433,7 +433,7 @@ impl DAGCircuit {
py,
concat!(
"The property ``qiskit.dagcircuit.dagcircuit.DAGCircuit.unit`` is ",
"deprecated as of qiskit 1.3.0. It will be removed in Qiskit 2.0.0.",
"deprecated as of Qiskit 1.3.0. It will be removed in Qiskit 2.0.0.",
)
),
py.get_type_bound::<PyDeprecationWarning>(),
Expand Down Expand Up @@ -7039,7 +7039,7 @@ fn emit_pulse_dependency_deprecation(py: Python, msg: &str) {
PyString::new_bound(
py,
&format!(
"The {} is deprecated as of qiskit 1.3.0. It will be removed in Qiskit 2.0.0. \
"The {} is deprecated as of Qiskit 1.3.0. It will be removed in Qiskit 2.0.0. \
The entire Qiskit Pulse package is being deprecated \
and this is a dependency on the package.",
msg
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ environment = 'PATH="$PATH:$HOME/.cargo/bin" CARGO_NET_GIT_FETCH_WITH_CLI="true"
repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel} && pipx run abi3audit --strict --report {wheel}"

[tool.cibuildwheel.macos]
environment = "MACOSX_DEPLOYMENT_TARGET=10.12"
repair-wheel-command = "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} && pipx run abi3audit --strict --report {wheel}"

[tool.cibuildwheel.windows]
Expand Down
Loading

0 comments on commit eae4d08

Please sign in to comment.