Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into bit_u32_sequel
Browse files Browse the repository at this point in the history
  • Loading branch information
raynelfss committed Feb 10, 2025
2 parents 8445bc4 + 1b6fccf commit a2b04cc
Show file tree
Hide file tree
Showing 87 changed files with 1,427 additions and 5,172 deletions.
7 changes: 2 additions & 5 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@

# Qiskit folders (also their corresponding tests)
providers/ @Qiskit/terra-core @jyu00
quantum_info/ @Qiskit/terra-core
qpy/ @Qiskit/terra-core
pulse/ @Qiskit/terra-core @eggerdj @wshanks
synthesis/ @Qiskit/terra-core @alexanderivrii @ShellyGarion
scheduler/ @Qiskit/terra-core @eggerdj @wshanks
pulse/ @Qiskit/terra-core @eggerdj @wshanks @nkanazawa1989
scheduler/ @Qiskit/terra-core @eggerdj @wshanks @nkanazawa1989
visualization/ @Qiskit/terra-core @nonhermitian
primitives/ @Qiskit/terra-core @Qiskit/qiskit-primitives
# Override the release notes directories to have _no_ code owners, so any review
Expand Down
76 changes: 74 additions & 2 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ indexmap.version = "2.7.1"
hashbrown.version = "0.14.5"
num-bigint = "0.4"
num-complex = "0.4"
nalgebra = "0.33"
ndarray = "0.15"
numpy = "0.23"
smallvec = "1.13"
Expand Down Expand Up @@ -48,6 +49,10 @@ qiskit-qasm3 = { path = "crates/qasm3" }
# which uses the `::std::cmp::Ordering` enum as a return. Both styles are acceptable, and the `if`
# chain can be more legible to people.
comparison-chain = "allow"
# Forbid `{,e}print{,ln}!` calls. These can be allowed locally if absolutely required, but the
# vast majority of these are debug statements that we forget about.
print_stdout = "deny"
print_stderr = "deny"

[workspace.lints.rust]
# In Rust 2021, the bodies of `unsafe fn` may use `unsafe` functions themselves without marking
Expand Down
19 changes: 11 additions & 8 deletions crates/accelerate/src/commutation_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,17 @@ impl CommutationChecker {

// For our cache to work correctly, we require the gate's definition to only depend on the
// ``params`` attribute. This cannot be guaranteed for custom gates, so we only check
// the cache for our standard gates, which we know are defined by the ``params`` AND
// that the ``params`` are float-only at this point.
let whitelist = get_standard_gate_names();
let check_cache = whitelist.contains(&first_op.name())
&& whitelist.contains(&second_op.name())
&& first_params.iter().all(|p| matches!(p, Param::Float(_)))
&& second_params.iter().all(|p| matches!(p, Param::Float(_)));
// the cache for
// * gates we know are in the cache (SUPPORTED_OPS), or
// * standard gates with float params (otherwise we cannot cache them)
let standard_gates = get_standard_gate_names();
let is_cachable = |name: &str, params: &[Param]| {
SUPPORTED_OP.contains(name)
|| (standard_gates.contains(&name)
&& params.iter().all(|p| matches!(p, Param::Float(_))))
};
let check_cache = is_cachable(first_op.name(), first_params)
&& is_cachable(second_op.name(), second_params);

if !check_cache {
return self.commute_matmul(
Expand Down Expand Up @@ -681,7 +685,6 @@ fn map_rotation<'a>(
if let Some(gate) = generator {
return (gate, &[], false);
};
return (op, &[], false);
}
(op, params, false)
}
Expand Down
6 changes: 3 additions & 3 deletions crates/accelerate/src/sparse_observable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,10 +687,10 @@ impl SparseObservable {
.multi_cartesian_product();

for combination in combinations {
let mut positive = true;
let mut positive = true; // keep track of the global sign

for (index, (sign, bit)) in combination.iter().enumerate() {
positive &= sign;
positive ^= !sign; // accumulate the sign; global_sign *= local_sign
if let Some(bit) = bit {
paulis.push(*bit);
indices.push(view.indices[index]);
Expand Down Expand Up @@ -2481,7 +2481,7 @@ impl PySparseObservable {
/// list and back.
///
/// Examples:
///
///
/// >>> obs = SparseObservable.from_list([("IIXIZ", 2j), ("IIZIX", 2j)])
/// >>> reconstructed = SparseObservable.from_sparse_list(obs.to_sparse_list(), obs.num_qubits)
///
Expand Down
3 changes: 3 additions & 0 deletions crates/accelerate/src/target_transpiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,9 @@ impl Target {
OperationRef::Gate(gate) => gate.gate.clone_ref(py),
OperationRef::Instruction(instruction) => instruction.instruction.clone_ref(py),
OperationRef::Operation(operation) => operation.operation.clone_ref(py),
OperationRef::Unitary(unitary) => unitary
.create_py_op(py, &ExtraInstructionAttributes::default())?
.into_any(),
},
TargetOperation::Variadic(op_cls) => op_cls.clone_ref(py),
};
Expand Down
Loading

0 comments on commit a2b04cc

Please sign in to comment.