Skip to content
Open
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,4 @@ target_include_directories(capi-demo
${QISKIT_CPP_ROOT}/src
)

target_compile_options(capi-demo PRIVATE "-DQRMI_ROOT=${QRMI_ROOT}")
2 changes: 1 addition & 1 deletion deps/boost/config
Submodule config updated 164 files
2 changes: 1 addition & 1 deletion deps/qiskit
Submodule qiskit updated 226 files
2 changes: 1 addition & 1 deletion deps/qiskit-cpp
Submodule qiskit-cpp updated 39 files
+33 −0 .github/workflows/tests.yml
+4 −0 .gitignore
+45 −21 README.md
+10 −0 releasenotes/notes/add_support_multiple_cregs-db972b595457f252.yaml
+22 −14 samples/CMakeLists.txt
+0 −0 samples/circuit_test.cpp
+0 −0 samples/observable_test.cpp
+46 −15 samples/sampler_test.cpp
+0 −0 samples/transpile_test.cpp
+1 −1 src/circuit/library/standard_gates/i.hpp
+2 −2 src/circuit/library/standard_gates/standard_gates.hpp
+32 −3 src/circuit/quantumcircuit_def.hpp
+23 −14 src/circuit/quantumcircuit_impl.hpp
+1 −1 src/circuit/register.hpp
+2 −2 src/compiler/transpiler.hpp
+48 −16 src/primitives/backend_sampler_job.hpp
+2 −1 src/primitives/backend_sampler_v2.hpp
+2 −10 src/primitives/base/base_primitive_job.hpp
+105 −6 src/primitives/containers/bit_array.hpp
+5 −33 src/primitives/containers/primitive_result.hpp
+1 −1 src/primitives/containers/sampler_pub.hpp
+67 −5 src/primitives/containers/sampler_pub_result.hpp
+2 −18 src/providers/backend.hpp
+58 −0 src/providers/job.hpp
+118 −0 src/providers/qkrt_backend.hpp
+135 −0 src/providers/qkrt_job.hpp
+3 −79 src/providers/qrmi_backend.hpp
+141 −0 src/providers/qrmi_job.hpp
+4 −4 src/quantum_info/sparse_observable.hpp
+209 −0 src/service/qiskit_runtime_service qrmi.hpp
+81 −105 src/service/qiskit_runtime_service.hpp
+6 −0 src/transpiler/target.hpp
+32 −1 src/utils/bitvector.hpp
+83 −0 src/utils/utils.hpp
+70 −0 test/CMakeLists.txt
+28 −0 test/Makefile
+39 −0 test/common.c
+32 −0 test/common.h
+627 −0 test/test_circuit.cpp
47 changes: 41 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "primitives/backend_sampler_v2.hpp"
#include "service/qiskit_runtime_service.hpp"

using namespace Qiskit;
using namespace Qiskit::circuit;
using namespace Qiskit::providers;
using namespace Qiskit::primitives;
Expand Down Expand Up @@ -307,10 +308,25 @@ int main(int argc, char *argv[])
auto instructions = hf_and_ucj_op_spin_balanced_jw(qubits, nelec, ucj_op);

// Quantum circuit with Qiskit C++
auto qr = QuantumRegister(2 * norb); // quantum registers
auto cr = ClassicalRegister(2 * norb); // classical registers
auto circ =
QuantumCircuit(qr, cr); // create a quantum circuits with registers
// quantum registers
auto qr = QuantumRegister(2 * norb);
// classical registers
auto cr = ClassicalRegister(2 * norb, "meas");
// classical registers for test
auto cr_test = ClassicalRegister(2 * norb, "test");
std::vector<ClassicalRegister> cregs({cr});
if (sqd_data.use_reset_mitigation) {
cregs.push_back(cr_test);
}
// create a quantum circuits with registers
auto circ = QuantumCircuit(std::vector<QuantumRegister>({qr}), cregs);

if (sqd_data.use_reset_mitigation) {
// add measure to all qubits and store to test bits
circ.measure(qr, cr_test);
for (int i = 0; i < 2 * norb; i++)
circ.barrier(i);
}

// add gates from instruction list from hf_and_ucj_op_spin_balanced_jw
// for demo: calling Qiskit C++ circuit functions to make quantum circuit
Expand Down Expand Up @@ -370,7 +386,26 @@ int main(int argc, char *argv[])

// Extract classical counts from the execution result.
// These form the classical distribution for downstream recovery/selection.
counts = pub_result.data().get_counts();
if (sqd_data.use_reset_mitigation) {
auto meas_bits = pub_result.data("meas");
auto test_bits = pub_result.data("test");

// get index whose bitcout is zero
auto bitcounts = test_bits.bitcount();
reg_t zero_index;
zero_index.reserve(bitcounts.size());
for (uint_t i = 0; i < bitcounts.size(); i++) {
if (bitcounts[i] == 0) {
zero_index.push_back(i);
}
}

// return bits only whose bitcount are zero
counts = meas_bits.get_counts(zero_index);
} else {
counts = pub_result.data().get_counts();
}

#endif // USE_RANDOM_SHOTS
}

Expand Down Expand Up @@ -435,7 +470,7 @@ int main(int argc, char *argv[])
// per iteration.
Qiskit::addon::sqd::subsample(
batch, postselected_bitstrings, postselected_probs,
samples_per_batch, rng
std::min(samples_per_batch, postselected_bitstrings.size()), rng
);
// Write alpha-determinants file for SBD input (includes run id /
// iteration for traceability).
Expand Down
4 changes: 4 additions & 0 deletions src/sqd_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ struct SQD {
uint64_t samples_per_batch = 1000; // number of samples per batch
bool verbose = false; // print messages to stdout
bool with_hf = true; // use Hartree-Fock as a reference state
bool use_reset_mitigation = false;

std::string backend_name = "";
uint64_t num_shots = 10000;
Expand Down Expand Up @@ -358,6 +359,9 @@ SQD generate_sqd_data(int argc, char *argv[])
if (std::string(argv[i]) == "-v") {
sqd.verbose = true;
}
if (std::string(argv[i]) == "--use_reset_mitigation") {
sqd.use_reset_mitigation = true;
}
}
return sqd;
}
Expand Down
Loading