From ec7471f9f17a1e1ef0492aaebb1eca79396ccbce Mon Sep 17 00:00:00 2001 From: Vlad Gheorghiu Date: Fri, 6 Oct 2023 16:38:17 -0400 Subject: [PATCH] Version 3.3 --- pystaq/staq_wrapper.cpp | 6 +++--- tools/grid_synth.cpp | 20 +++++++++----------- tools/qasm_synth.cpp | 2 +- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/pystaq/staq_wrapper.cpp b/pystaq/staq_wrapper.cpp index c518c92b..36783e16 100644 --- a/pystaq/staq_wrapper.cpp +++ b/pystaq/staq_wrapper.cpp @@ -346,8 +346,8 @@ PYBIND11_MODULE(pystaq, m) { py::arg("check") = false, py::arg("details") = false, py::arg("verbose") = false, py::arg("timer") = false); m.def("grid_synth", - py::overload_cast(&grid_synth), + py::overload_cast(&grid_synth), "Approximate Z-rotation angle(s) (in units of PI)", py::arg("theta"), py::arg("prec"), py::arg("pollard-rho") = staq::grid_synth::MAX_ATTEMPTS_POLLARD_RHO, @@ -361,7 +361,7 @@ PYBIND11_MODULE(pystaq, m) { py::arg("verbose") = false); #endif /* GRID_SYNTH */ m.def("lattice_surgery", &lattice_surgery, - "Compiles OpenQASM2 to lattice surgery instruction set", + "Compiles OpenQASM 2.0 to lattice surgery instruction set", py::arg("prog")); py::class_(m, "Device") diff --git a/tools/grid_synth.cpp b/tools/grid_synth.cpp index 1f53a120..f0d8cb80 100644 --- a/tools/grid_synth.cpp +++ b/tools/grid_synth.cpp @@ -49,8 +49,9 @@ int main(int argc, char** argv) { CLI::App app{"Grid Synthesis"}; CLI::Option* thetas_op = - app.add_option("theta", thetas, - "Z-rotation angle(s) in units of PI"); + app.add_option("theta", thetas, "Z-rotation angle(s) in units of PI") + ->required(); + CLI::Option* prec_opt = app.add_option( "-p, --precision", prec, @@ -76,8 +77,9 @@ int main(int argc, char** argv) { CLI11_PARSE(app, argc, argv); - if (verbose) + if (verbose) { std::cerr << thetas.size() << " angle(s) read." << '\n'; + } GridSynthOptions opt{prec, factor_effort, check, details, verbose, timer}; GridSynthesizer synthesizer = make_synthesizer(opt); @@ -89,19 +91,15 @@ int main(int argc, char** argv) { for (const auto& angle : thetas) { str_t op_str = synthesizer.get_op_str(real_t(angle) * gmpf::gmp_pi()); - for (char c : op_str) + for (char c : op_str) { std::cout << c << ' '; + } std::cout << '\n'; } } if (timer) { - std::cerr << std::fixed - << "Duration = " << synthesizer.get_duration() - << " seconds" << '\n'; - } - else { - std::cerr << "No angle provided. Exiting.\n"; - return 0; + std::cerr << std::fixed << "Duration = " << synthesizer.get_duration() + << " seconds" << '\n'; } } diff --git a/tools/qasm_synth.cpp b/tools/qasm_synth.cpp index 0cdd17f4..f4d3e16a 100644 --- a/tools/qasm_synth.cpp +++ b/tools/qasm_synth.cpp @@ -43,7 +43,7 @@ int main(int argc, char** argv) { int factor_effort; domega_matrix_table_t s3_table; - CLI::App app{"Grid Synthesis rx/ry/rz substitution"}; + CLI::App app{"Grid Synthesis rx/ry/rz substitution in OpenQASM 2.0 files"}; CLI::Option* prec_opt = app.add_option(