Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebalance CircuitInstruction and PackedInstruction #12730

Merged
merged 11 commits into from
Jul 23, 2024
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.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ license = "Apache-2.0"
#
# Each crate can add on specific features freely as it inherits.
[workspace.dependencies]
bytemuck = "1.16"
indexmap.version = "2.2.6"
hashbrown.version = "0.14.0"
num-complex = "0.4"
Expand Down
33 changes: 12 additions & 21 deletions crates/accelerate/src/euler_one_qubit_decomposer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ pub fn compute_error_list(
.iter()
.map(|node| {
(
node.instruction.operation.name().to_string(),
node.instruction.op().name().to_string(),
smallvec![], // Params not needed in this path
)
})
Expand Down Expand Up @@ -988,11 +988,10 @@ pub fn optimize_1q_gates_decomposition(
.iter()
.map(|node| {
if let Some(err_map) = error_map {
error *=
compute_error_term(node.instruction.operation.name(), err_map, qubit)
error *= compute_error_term(node.instruction.op().name(), err_map, qubit)
}
node.instruction
.operation
.op()
.matrix(&node.instruction.params)
.expect("No matrix defined for operation")
})
Expand Down Expand Up @@ -1046,24 +1045,16 @@ fn matmul_1q(operator: &mut [[Complex64; 2]; 2], other: Array2<Complex64>) {

#[pyfunction]
pub fn collect_1q_runs_filter(node: &Bound<PyAny>) -> bool {
let op_node = node.downcast::<DAGOpNode>();
match op_node {
Ok(bound_node) => {
let node = bound_node.borrow();
node.instruction.operation.num_qubits() == 1
&& node.instruction.operation.num_clbits() == 0
&& node
.instruction
.operation
.matrix(&node.instruction.params)
.is_some()
&& match &node.instruction.extra_attrs {
None => true,
Some(attrs) => attrs.condition.is_none(),
}
let Ok(node) = node.downcast::<DAGOpNode>() else { return false };
let node = node.borrow();
let op = node.instruction.op();
op.num_qubits() == 1
&& op.num_clbits() == 0
&& op.matrix(&node.instruction.params).is_some()
&& match &node.instruction.extra_attrs {
None => true,
Some(attrs) => attrs.condition.is_none(),
}
Err(_) => false,
}
}

#[pymodule]
Expand Down
1 change: 1 addition & 0 deletions crates/circuit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ name = "qiskit_circuit"
doctest = false

[dependencies]
bytemuck.workspace = true
hashbrown.workspace = true
num-complex.workspace = true
ndarray.workspace = true
Expand Down
Loading
Loading