Skip to content

Commit

Permalink
Re-add qubit to cluster if multi-op unentangled it
Browse files Browse the repository at this point in the history
When applying multi qubit operations sometimes each individual one would make the qubit drop out of entanglement, which would then trigger removal during iteration. This is a quick fix to that, but it needs some careful considerations about when qubits remove themselves from things.

It may be easier to simply revert to the high level to do it for clusters.
  • Loading branch information
chemix-lunacy committed Oct 17, 2024
1 parent 785aba8 commit 7778426
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/rasqal/src/analysis/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1812,6 +1812,12 @@ impl QuantumSolver {
);

for qb in controls {
// If a single iteration drops entanglement we need to re-add the qubit for analysis.
// TODO: Rethink.
if !target_cluster.contains(&target.index) {
target_cluster.add(self.qubit_for(&target.index));
}

target_cluster.CX(&qb.index, &target.index, radians);
}

Expand Down Expand Up @@ -1845,6 +1851,12 @@ impl QuantumSolver {
);

for qb in controls {
// If a single iteration drops entanglement we need to re-add the qubit for analysis.
// TODO: Rethink.
if !target_cluster.contains(&target.index) {
target_cluster.add(self.qubit_for(&target.index));
}

target_cluster.CY(&qb.index, &target.index, radians);
}

Expand Down Expand Up @@ -1878,7 +1890,13 @@ impl QuantumSolver {
);

for qb in controls {
target_cluster.CY(&qb.index, &target.index, radians);
// If a single iteration drops entanglement we need to re-add the qubit for analysis.
// TODO: Rethink.
if !target_cluster.contains(&target.index) {
target_cluster.add(self.qubit_for(&target.index));
}

target_cluster.CZ(&qb.index, &target.index, radians);
}

if self.is_tracing() {
Expand Down

0 comments on commit 7778426

Please sign in to comment.