Skip to content

Commit a84ded2

Browse files
Noise debug (#1021)
* Check behavior of Catalyst noise, based on commit hash * Fix depolarizing noise * Fix depolarizing noise * Fix depolarizing noise * Cut bugged strong depolarizing noise channel method
1 parent 84fec8d commit a84ded2

File tree

3 files changed

+12
-43
lines changed

3 files changed

+12
-43
lines changed

include/qinterface.hpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3047,19 +3047,6 @@ class QInterface : public ParallelFor {
30473047
*/
30483048
virtual void DepolarizingChannelWeak1Qb(bitLenInt qubit, real1_f lambda);
30493049

3050-
/**
3051-
* Simulate a local qubit depolarizing noise channel, under a "strong simulation condition." "Strong" condition
3052-
* supports measurement sampling and direct queries of state, but the expression of state is in terms of one
3053-
* retained ancillary qubit per applied noise channel. condition, sampling and exact state queries are not accurate,
3054-
* but sampling can be achieved via repeated full execution of a noisy circuit, for each hardware-realistic
3055-
* measurement sample.
3056-
*
3057-
* This method returns a newly-allocated qubit ancilla index which must be retained to maintain "strong" simulation.
3058-
* Note that "strong" ancilla can be measured at any time and discarded, but this makes the simulation condition
3059-
* "weak".
3060-
*/
3061-
virtual bitLenInt DepolarizingChannelStrong1Qb(bitLenInt qubit, real1_f lambda);
3062-
30633050
/** @} */
30643051
};
30653052
} // namespace Qrack

include/qinterface_noisy.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ class QInterfaceNoisy : public QInterface {
4141
if (n <= ZERO_R1_F) {
4242
return;
4343
}
44+
4445
engine->DepolarizingChannelWeak1Qb(qb, n);
46+
4547
if ((n + FP_NORM_EPSILON) >= ONE_R1_F) {
4648
logFidelity = -1 * std::numeric_limits<float>::infinity();
4749
} else {

src/qinterface/gates.cpp

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -490,36 +490,16 @@ void QInterface::DepolarizingChannelWeak1Qb(bitLenInt qubit, real1_f lambda)
490490
return;
491491
}
492492

493-
// Original qubit, Z->X basis
494-
H(qubit);
495-
496-
// Allocate an ancilla
497-
const bitLenInt ancilla = Allocate(1U);
498-
// Partially entangle with the ancilla
499-
CRY(2 * asin(std::pow((real1_s)lambda, (real1_s)(1.0f / 4.0f))), qubit, ancilla);
500-
// Partially collapse the original state
501-
M(ancilla);
502-
// The ancilla is fully separable, after measurement.
503-
Dispose(ancilla, 1U);
504-
505-
// Uncompute
506-
H(qubit);
507-
}
508-
509-
bitLenInt QInterface::DepolarizingChannelStrong1Qb(bitLenInt qubit, real1_f lambda)
510-
{
511-
// Original qubit, Z->X basis
512-
H(qubit);
513-
514-
// Allocate an ancilla
515-
const bitLenInt ancilla = Allocate(1U);
516-
// Partially entangle with the ancilla
517-
CRY(2 * asin(std::pow((real1_s)lambda, (real1_s)(1.0f / 4.0f))), qubit, ancilla);
518-
519-
// Uncompute
520-
H(qubit);
521-
522-
return ancilla;
493+
const real1_f thirdLambda = lambda / 3;
494+
if (Rand() < thirdLambda) {
495+
X(qubit);
496+
}
497+
if (Rand() < thirdLambda) {
498+
Y(qubit);
499+
}
500+
if (Rand() < thirdLambda) {
501+
Z(qubit);
502+
}
523503
}
524504

525505
} // namespace Qrack

0 commit comments

Comments
 (0)