Describe the bug
ResourcesEstimator does not reset internal state and a single instance cannot be used to simulate two operations.
To Reproduce
Operation.qs
namespace Namespace {
open Microsoft.Quantum.Intrinsic;
operation Operation1() : Unit {
using ((a, b) = (Qubit(), Qubit())) {
CNOT(a, b);
CNOT(a, b);
CNOT(a, b);
}
}
operation Operation2() : Unit {
using ((a, b) = (Qubit(), Qubit())) {
CNOT(a, b);
CNOT(a, b);
CNOT(a, b);
CNOT(a, b);
CNOT(a, b);
}
}
}
Driver.cs
using System;
using Microsoft.Quantum.Simulation.Simulators;
namespace Namespace {
public class Program {
public static void Main(string[] args) {
var sim = new ResourcesEstimator();
Operation1.Run(sim).Wait();
Console.WriteLine(sim.ToTSV());
Operation2.Run(sim).Wait();
Console.WriteLine(sim.ToTSV());
}
}
}
Expected behavior
Output should be to accumulate the estimates:
Metric Sum
CNOT 3
QubitClifford 0
R 0
Measure 0
T 0
Depth 0
Width 2
BorrowedWidth 0
Metric Sum
CNOT 8
QubitClifford 0
R 0
Measure 0
T 0
Depth 0
Width 2
BorrowedWidth 0
or to reset the estimates:
Metric Sum
CNOT 3
QubitClifford 0
R 0
Measure 0
T 0
Depth 0
Width 2
BorrowedWidth 0
Metric Sum
CNOT 5
QubitClifford 0
R 0
Measure 0
T 0
Depth 0
Width 2
BorrowedWidth 0
Actual behavior
Output currently shows the estimates for the first operation:
Metric Sum
CNOT 3
QubitClifford 0
R 0
Measure 0
T 0
Depth 0
Width 2
BorrowedWidth 0
Metric Sum
CNOT 3
QubitClifford 0
R 0
Measure 0
T 0
Depth 0
Width 2
BorrowedWidth 0
System information
- Q# Version: 0.11.2004.2825
- .NET Core Version: 3.1.201
Describe the bug
ResourcesEstimatordoes not reset internal state and a single instance cannot be used to simulate two operations.To Reproduce
Operation.qs
Driver.cs
Expected behavior
Output should be to accumulate the estimates:
or to reset the estimates:
Actual behavior
Output currently shows the estimates for the first operation:
System information