This repository was archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 90
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
ResourcesEstimator instance shows wrong estimates when used more than once #189
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
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
martinquantum
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working