Unverified Commit 1d2d12fd authored by Mccaskey, Alex's avatar Mccaskey, Alex Committed by GitHub
Browse files

Merge pull request #484 from ausbin/feature/qpp-post-meas

qpp Accelerator: Check for post-measure gates more accurately
parents 17c30f48 e741af2d
Pipeline #162949 passed with stage
in 12 minutes and 32 seconds
......@@ -148,9 +148,9 @@ namespace {
bool shotCountFromFinalStateVec(const std::shared_ptr<CompositeInstruction>& in_composite)
{
InstructionIterator it(in_composite);
bool measureAtTheEnd = true;
bool measureEncountered = false;
std::set<std::size_t> bitsMeasured;
bool hasReset = false;
bool postMeasureGates = false;
while (it.hasNext())
{
auto nextInst = it.next();
......@@ -158,25 +158,32 @@ namespace {
{
if (nextInst->name() == "Reset") {
hasReset = true;
break;
}
auto bits = nextInst->bits();
if (isMeasureGate(nextInst))
{
// Flag that we have seen a Measure gate.
measureEncountered = true;
bitsMeasured.insert(bits.begin(), bits.end());
}
// We have seen a Measure gate but this one is not another Measure gate.
if (measureEncountered && !isMeasureGate(nextInst))
else
{
measureAtTheEnd = false;
postMeasureGates = std::any_of(bits.begin(), bits.end(),
[&](std::size_t bit) {
return bitsMeasured.count(bit);
});
if (postMeasureGates)
{
break;
}
}
}
}
// If Measure gates are at the very end and no reset,
// this Composite can be simulated by random sampling from the state vec.
return !hasReset && measureAtTheEnd;
return !hasReset && !postMeasureGates;
}
Eigen::MatrixXcd convertToEigenMat(const NoiseModelUtils::cMat& in_stdMat)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment