Skip to content
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ wasm-bindgen-futures = "0.4"
rand = "0.8"
serde_json = "1.0"
pyo3 = "0.24"
quantum-sparse-sim = { git = "https://github.com/qir-alliance/qir-runner", rev = "e1930df15ef02b3bf273a6f536f46bf6871448c5" }
quantum-sparse-sim = { git = "https://github.com/qir-alliance/qir-runner", rev = "8cd6fa698521ecf96d459f88254e53dd6e5d6877" }
async-trait = "0.1"
tokio = { version = "1.44", features = ["macros", "rt"] }

Expand Down
59 changes: 59 additions & 0 deletions source/compiler/qsc/benches/bench5x5.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/// Copied from https://github.com/microsoft/qsharp-runtime/tree/main/AdvantageBenchmark,
/// updated for the latest Q# syntax. Originally used for testing the performance of the Q# simulator.
operation Main() : Unit {
use qs = Qubit[25];
ApplyToEach(H, qs);
CZ(qs[2], qs[3]);
CZ(qs[12], qs[13]);
CZ(qs[22], qs[23]);
CZ(qs[5], qs[6]);
CZ(qs[9], qs[10]);
CZ(qs[15], qs[16]);
CZ(qs[19], qs[20]);
ApplyToEach(H, qs);
CZ(qs[0], qs[1]);
CZ(qs[4], qs[5]);
CZ(qs[10], qs[11]);
CZ(qs[14], qs[15]);
CZ(qs[20], qs[21]);
CZ(qs[7], qs[8]);
CZ(qs[17], qs[18]);
ApplyToEach(H, qs);
CZ(qs[15], qs[20]);
CZ(qs[17], qs[22]);
CZ(qs[19], qs[24]);
CZ(qs[6], qs[11]);
CZ(qs[8], qs[13]);
ApplyToEach(H, qs);
CZ(qs[5], qs[10]);
CZ(qs[7], qs[12]);
CZ(qs[9], qs[14]);
CZ(qs[16], qs[21]);
CZ(qs[18], qs[23]);
ApplyToEach(H, qs);
CZ(qs[3], qs[4]);
CZ(qs[13], qs[14]);
CZ(qs[23], qs[24]);
CZ(qs[6], qs[7]);
CZ(qs[16], qs[17]);
ApplyToEach(H, qs);
CZ(qs[1], qs[2]);
CZ(qs[11], qs[12]);
CZ(qs[21], qs[22]);
CZ(qs[8], qs[9]);
CZ(qs[18], qs[19]);
ApplyToEach(H, qs);
CZ(qs[0], qs[5]);
CZ(qs[2], qs[7]);
CZ(qs[4], qs[9]);
CZ(qs[11], qs[16]);
CZ(qs[13], qs[18]);
ApplyToEach(H, qs);
CZ(qs[10], qs[15]);
CZ(qs[12], qs[17]);
CZ(qs[14], qs[19]);
CZ(qs[1], qs[6]);
CZ(qs[3], qs[8]);
ApplyToEach(H, qs);
MResetEachZ(qs);
}
24 changes: 24 additions & 0 deletions source/compiler/qsc/benches/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const TELEPORT: &str = include_str!("../../../../samples/algorithms/Teleportatio
const DEUTSCHJOZSA: &str = include_str!("../../../../samples/algorithms/DeutschJozsa.qs");
const LARGE: &str = include_str!("./large.qs");
const ARRAY_LITERAL: &str = include_str!("./array_literal");
const BENCH5X5: &str = include_str!("./bench5x5.qs");

pub fn teleport(c: &mut Criterion) {
c.bench_function("Teleport evaluation", |b| {
Expand Down Expand Up @@ -79,6 +80,28 @@ pub fn large_file(c: &mut Criterion) {
});
}

pub fn bench5x5(c: &mut Criterion) {
c.bench_function("Bench 5x5 evaluation", |b| {
let sources = SourceMap::new([("bench5x5.qs".into(), BENCH5X5.into())], None);
let (std_id, store) = qsc::compile::package_store_with_stdlib(TargetCapabilityFlags::all());
let mut evaluator = Interpreter::new(
sources,
PackageType::Exe,
TargetCapabilityFlags::all(),
LanguageFeatures::default(),
store,
&[(std_id, None)],
)
.expect("code should compile");

b.iter(move || {
let mut out = Vec::new();
let mut rec = GenericReceiver::new(&mut out);
assert!(evaluator.eval_entry(&mut rec).is_ok());
});
});
}

pub fn array_append(c: &mut Criterion) {
c.bench_function("Array append evaluation", |b| {
let sources = SourceMap::new(
Expand Down Expand Up @@ -213,6 +236,7 @@ criterion_group!(
teleport,
deutsch_jozsa,
large_file,
bench5x5,
array_append,
array_update,
array_literal,
Expand Down
Loading