Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sample prob var with shot support #561

Merged
merged 79 commits into from
Nov 29, 2023
Merged
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
8b61616
init commit with PauliX,Y,Z, Hardmard support
multiphaseCFD Nov 7, 2023
fba9221
add unit tests & sample
multiphaseCFD Nov 8, 2023
5c8c286
add PauliX, Y, Z & Hadamard support
multiphaseCFD Nov 9, 2023
56f02e8
move expval shots to base class
multiphaseCFD Nov 9, 2023
d9cacbc
Auto update version
github-actions[bot] Nov 9, 2023
b3a21d1
add MPI support
multiphaseCFD Nov 9, 2023
62b3714
add samples_to_counts to measurement base class
multiphaseCFD Nov 9, 2023
05cfb89
tidy up tests
multiphaseCFD Nov 9, 2023
ddfdb72
move tests to measurement base
multiphaseCFD Nov 9, 2023
44df765
move mpi tests to measurement base class
multiphaseCFD Nov 9, 2023
b3931e9
make format
multiphaseCFD Nov 9, 2023
3a52184
add python layer
multiphaseCFD Nov 10, 2023
d714e0e
add mpi tests
multiphaseCFD Nov 10, 2023
9d1a418
remove else
multiphaseCFD Nov 10, 2023
d9d7a7d
add tensor product support
multiphaseCFD Nov 12, 2023
5745f4f
add more tests for tensor prod obs shots
multiphaseCFD Nov 12, 2023
bcb46d1
make format
multiphaseCFD Nov 12, 2023
68f2865
add Hamiltonian support
multiphaseCFD Nov 14, 2023
bc58332
make format
multiphaseCFD Nov 14, 2023
5288491
quick fix
multiphaseCFD Nov 14, 2023
c7f5ea2
add hamiltonian tests
multiphaseCFD Nov 14, 2023
4b56805
add more py tests for tensorprod
multiphaseCFD Nov 14, 2023
f09342f
remove changes made in py layer
multiphaseCFD Nov 15, 2023
d13e9f2
revert more changes in py layer
multiphaseCFD Nov 15, 2023
9ef8dac
tidy up code
multiphaseCFD Nov 15, 2023
bd8fd5a
update measurement base and kokkos
multiphaseCFD Nov 15, 2023
15d8244
make format
multiphaseCFD Nov 15, 2023
1bc196f
refactor and add _sample_state method
multiphaseCFD Nov 15, 2023
e5b64a0
for loop sum to accumulate sum
multiphaseCFD Nov 15, 2023
6fda049
refactor and add _preprocess_state() method
multiphaseCFD Nov 15, 2023
2949500
add more unit tests for LK backend
multiphaseCFD Nov 16, 2023
70637dc
Merge branch 'master' into add_shot_expval
multiphaseCFD Nov 16, 2023
2cbd160
Auto update version
github-actions[bot] Nov 16, 2023
5595a8a
tidy up docstring
multiphaseCFD Nov 16, 2023
d41f2b2
remove samples() and samples2counts method
multiphaseCFD Nov 16, 2023
ebf80f0
fix typo
multiphaseCFD Nov 16, 2023
3238a08
quick fix
multiphaseCFD Nov 16, 2023
35065d1
update LQRaw object creation
multiphaseCFD Nov 16, 2023
264481f
fix for multiple backends
multiphaseCFD Nov 16, 2023
2d3cf11
update format
multiphaseCFD Nov 16, 2023
b12885d
format fix
multiphaseCFD Nov 16, 2023
ad1e11d
format update
multiphaseCFD Nov 16, 2023
288e01e
make format & trigger MPI CI
multiphaseCFD Nov 16, 2023
e08cb85
add changelog and codecov for expval(obs) method
multiphaseCFD Nov 16, 2023
2e495db
add shot_range coverage
multiphaseCFD Nov 16, 2023
0acc096
tidy up code
multiphaseCFD Nov 16, 2023
4f5f634
add more unit tests
multiphaseCFD Nov 16, 2023
fe042f6
fix typos
multiphaseCFD Nov 16, 2023
06ecd06
add MPI Hamiltonian tests for shots
multiphaseCFD Nov 17, 2023
602f16c
add HamBase tests for applyInPlaceShots
multiphaseCFD Nov 17, 2023
e839cf2
update based on comments
multiphaseCFD Nov 17, 2023
7408813
add more unit tests
multiphaseCFD Nov 17, 2023
00be785
move tests for non-distributed backends to base
multiphaseCFD Nov 17, 2023
6c4dfbd
move all unit tests into the base class
multiphaseCFD Nov 17, 2023
0d07d9c
move getTotalNumQubits to base and tidy up code
multiphaseCFD Nov 17, 2023
055d6b3
tidy up code
multiphaseCFD Nov 17, 2023
1a92ebf
revert changes in Test_MeasurementLQ
multiphaseCFD Nov 17, 2023
2c29713
initial commit
multiphaseCFD Nov 17, 2023
42ab1cc
tidy up code
multiphaseCFD Nov 17, 2023
6a5c5fe
Merge branch 'master' into add_sample_prob_var_obs
multiphaseCFD Nov 17, 2023
92571cb
Auto update version
github-actions[bot] Nov 17, 2023
77cba24
add var obs tests
multiphaseCFD Nov 18, 2023
ecf4683
add tests for prob for all backend and var for MPI
multiphaseCFD Nov 20, 2023
38748b3
quick fix
multiphaseCFD Nov 20, 2023
e3bb395
add unit tests for counts & samples obs
multiphaseCFD Nov 20, 2023
0ee73cb
add more sample() & counts() unit tests
multiphaseCFD Nov 20, 2023
531f386
add sample counts tests for mpi backend
multiphaseCFD Nov 20, 2023
e23a349
make format
multiphaseCFD Nov 20, 2023
a8cb9bc
Trigger MPI CI
multiphaseCFD Nov 20, 2023
f2c7923
tidy up code
multiphaseCFD Nov 21, 2023
17539d9
add changelogs and tidy up unit tests
multiphaseCFD Nov 21, 2023
b42d42d
update docstring
multiphaseCFD Nov 21, 2023
674dc8c
fix typo
multiphaseCFD Nov 21, 2023
3f70c2a
update return type of counts & tidy up code
multiphaseCFD Nov 24, 2023
ac4cb28
Merge branch 'master' into add_sample_prob_var_obs
multiphaseCFD Nov 24, 2023
70b208d
Auto update version
github-actions[bot] Nov 24, 2023
20366b9
update brief of probs(obs)
multiphaseCFD Nov 24, 2023
7101e5f
update based on comments
multiphaseCFD Nov 28, 2023
76317e1
fix typo
multiphaseCFD Nov 28, 2023
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
Prev Previous commit
Next Next commit
move mpi tests to measurement base class
  • Loading branch information
multiphaseCFD committed Nov 9, 2023
commit 44df7652b77ffa83869739bb1c724a1d28bff8cd
Original file line number Diff line number Diff line change
Expand Up @@ -189,110 +189,6 @@ TEMPLATE_TEST_CASE("Expected Values", "[MeasurementsMPI]", float, double) {
LightningException,
"Currently unsupported observable");
}

SECTION("Testing for expval with obs & shots PauliX") {
std::vector<PrecisionT> exp_values;
std::vector<PrecisionT> exp_values_ref;

size_t num_shots = 10000;
std::vector<size_t> shots_range = {};
size_t num_qubits = 3;

for(size_t i = 0; i < num_qubits; i++){
StateVectorT sv(mpi_manager, dt_local, mpi_buffersize, nGlobalIndexBits,
nLocalIndexBits);
sv.CopyHostDataToGpu(sv_data_local.data(), sv_data_local.size(), false);
mpi_manager.Barrier();

MeasurementsMPI<StateVectorT> Measurer(sv);
mpi_manager.Barrier();

NamedObsMPI<StateVectorT> obs("PauliX", {i});
auto expval_shot = Measurer.expval(obs, num_shots, shots_range);
exp_values.push_back(expval_shot);
}
exp_values_ref = {0.49272486, 0.42073549, 0.28232124};

REQUIRE_THAT(exp_values, Catch::Approx(exp_values_ref).margin(5e-2));
}

SECTION("Testing for expval with obs & shots PauliY") {
std::vector<PrecisionT> exp_values;
std::vector<PrecisionT> exp_values_ref;

size_t num_shots = 10000;
std::vector<size_t> shots_range = {};
size_t num_qubits = 3;

for(size_t i = 0; i < num_qubits; i++){
StateVectorT sv(mpi_manager, dt_local, mpi_buffersize, nGlobalIndexBits,
nLocalIndexBits);
sv.CopyHostDataToGpu(sv_data_local.data(), sv_data_local.size(), false);
mpi_manager.Barrier();

MeasurementsMPI<StateVectorT> Measurer(sv);
mpi_manager.Barrier();

NamedObs<StateVectorT> obs("PauliY", {i});
auto expval_shot = Measurer.expval(obs, num_shots, shots_range);
exp_values.push_back(expval_shot);
}
exp_values_ref = {-0.64421768, -0.47942553, -0.29552020};

REQUIRE_THAT(exp_values, Catch::Approx(exp_values_ref).margin(5e-2));
}

SECTION("Testing for expval with obs & shots PauliZ") {
std::vector<PrecisionT> exp_values;
std::vector<PrecisionT> exp_values_ref;

size_t num_shots = 10000;
std::vector<size_t> shots_range = {};
size_t num_qubits = 3;

for(size_t i = 0; i < num_qubits; i++){
StateVectorT sv(mpi_manager, dt_local, mpi_buffersize, nGlobalIndexBits,
nLocalIndexBits);
sv.CopyHostDataToGpu(sv_data_local.data(), sv_data_local.size(), false);
mpi_manager.Barrier();

MeasurementsMPI<StateVectorT> Measurer(sv);
mpi_manager.Barrier();

NamedObs<StateVectorT> obs("PauliZ", {i});
auto expval_shot = Measurer.expval(obs, num_shots, shots_range);
exp_values.push_back(expval_shot);
}
exp_values_ref = {0.58498357, 0.77015115, 0.91266780};

REQUIRE_THAT(exp_values, Catch::Approx(exp_values_ref).margin(5e-2));
}

SECTION("Testing for expval with obs & shots Hadamard") {
std::vector<PrecisionT> exp_values;
std::vector<PrecisionT> exp_values_ref;

size_t num_shots = 10000;
std::vector<size_t> shots_range = {};
size_t num_qubits = 3;

for(size_t i = 0; i < num_qubits; i++){
StateVectorT sv(mpi_manager, dt_local, mpi_buffersize, nGlobalIndexBits,
nLocalIndexBits);
sv.CopyHostDataToGpu(sv_data_local.data(), sv_data_local.size(), false);
mpi_manager.Barrier();

MeasurementsMPI<StateVectorT> Measurer(sv);
mpi_manager.Barrier();

NamedObs<StateVectorT> obs("Hadamard", {i});
auto expval_shot = Measurer.expval(obs, num_shots, shots_range);
exp_values.push_back(expval_shot);
}
exp_values_ref = {0.7620549436, 0.8420840225, 0.8449848566};

REQUIRE_THAT(exp_values, Catch::Approx(exp_values_ref).margin(5e-2));
}
}

TEMPLATE_TEST_CASE("Pauliwords base on expval", "[MeasurementsMPI]", float,
Expand Down