Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Simulation/Simulators.Tests/Circuits/ResourcesEstimator.qs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,24 @@ namespace Microsoft.Quantum.Simulation.Simulators.Tests
ResetAll([q[1], q[0]]);
}
}

// Tests for Depth and Width lower bounds
operation DepthDifferentQubits () : Unit
{
using(q = Qubit[3]) {
T(q[0]);
T(q[1]);
T(q[2]);
T(q[0]);
}
}
operation DepthVersusWidth () : Unit
{
using(q = Qubit()) {
T(q);
}
using(q = Qubit()) {
T(q);
}
}
}
37 changes: 37 additions & 0 deletions src/Simulation/Simulators.Tests/ResourcesEstimatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,43 @@ public void ToTSVTest()
var cliffords = rows.First(r => r.StartsWith("QubitClifford")).Split('\t');
Assert.Equal(2, cliffords.Length);
Assert.Equal("2", cliffords[1]);
}

/// <summary>
/// Shows that T gates on different qubits are counted for depth purposes as
/// executing in parallel.
/// </summary>
[Fact]
public void DepthDifferentQubitsTest()
{
var sim = new ResourcesEstimator();

// using(q = Qubit[3]) { T(q[0]); T(q[1]); T(q[3]); T(q[0]); }
DepthDifferentQubits.Run(sim).Wait();
var data = sim.Data;

Assert.Equal(4.0, data.Rows.Find("T")["Sum"]);
Assert.Equal(3.0, data.Rows.Find("Width")["Sum"]);
Assert.Equal(2.0, data.Rows.Find("Depth")["Sum"]);
}

/// <summary>
/// Documents that the width and depth statistics reflect independent lower
/// bounds for each (two T gates cannot be combined into a circuit of depth
/// one and width one).
/// </summary>
[Fact]
public void DepthVersusWidthTest()
{
var sim = new ResourcesEstimator();

// using(q = Qubit()) { T(q); } using(q = Qubit()) { T(q); } (yes, twice)
DepthVersusWidth.Run(sim).Wait();
var data = sim.Data;

Assert.Equal(2.0, data.Rows.Find("T")["Sum"]);
Assert.Equal(1.0, data.Rows.Find("Width")["Sum"]);
Assert.Equal(1.0, data.Rows.Find("Depth")["Sum"]);
}
}
}