Skip to content

Commit

Permalink
Add minor tweaks (#74)
Browse files Browse the repository at this point in the history
* Add minor tweaks

* Fix some of the tests

* Fix another test

* Fix another test

* Fix another test

* Format python files using black

* Update changelog

Co-authored-by: Trevor Vincent <[email protected]>
  • Loading branch information
trevor-vincent and trevor-vincent authored Jun 15, 2022
1 parent b0cc4f6 commit 14bfedb
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
## Release 0.2.3 (development release)

### Patches

* The calculation in the function GetPathFlops has been altered so that it is consistent
with the way Cotengra and the jet paper computes the FLOPS for a given path.

### Improvements

* The Jet Python package no longer specifies a version constraint for NumPy. [(#75)](https://github.com/XanaduAI/jet/pull/75)

### Documentation

* The jet paper reference in the README.md has been updated because it is now
published in the Quantum journal.
* The centralized [Xanadu Sphinx Theme](https://github.com/XanaduAI/xanadu-sphinx-theme)
is now used to style the Sphinx documentation.
[(#73)](https://github.com/XanaduAI/jet/pull/73)
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Jet is the work of `many contributors <https://github.com/XanaduAI/jet/graphs/co

If you are doing research using Jet, please cite our paper:

Trevor Vincent, Lee J. O'Riordan, Mikhail Andrenkov, Jack Brown, Nathan Killoran, Haoyu Qi, and Ish Dhand. *Jet: Fast quantum circuit simulations with parallel task-based tensor-network contraction.* 2021. `arxiv:2107.09793 <https://arxiv.org/abs/2107.09793>`_
Trevor Vincent, Lee J. O'Riordan, Mikhail Andrenkov, Jack Brown, Nathan Killoran, Haoyu Qi, and Ish Dhand. *Jet: Fast quantum circuit simulations with parallel task-based tensor-network contraction.* 2022. `Published in Quantum <https://doi.org/10.22331/q-2022-05-09-709>`_.

License
=======
Expand Down
2 changes: 1 addition & 1 deletion include/jet/PathInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class PathInfo {
const auto it = index_to_size_map_.find(index);
muls *= it == index_to_size_map_.end() ? 1 : it->second;
}
double adds = muls - 1;
double adds = muls;

// Find the number of elements in the tensor.
double size = 1;
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_task_based_contractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ def test_contract(self, dtype, tensor_network):
assert tbc.name_to_parents_map == want_name_to_parents_map
assert tbc.results == [want_result]
assert tbc.reduction_result == want_result
assert tbc.flops == 18
assert tbc.flops == 2 * 2 * 4 + 2 * 4
assert tbc.memory == 6
10 changes: 5 additions & 5 deletions test/Test_PathInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ TEST_CASE("PathInfo::GetPathStepFlops()", "[PathInfo]")
const PathInfo path_info(tn, {{0, 1}});

const double have_flops = path_info.GetPathStepFlops(2);
const double want_flops = 1;
const double want_flops = 2;
CHECK(have_flops == want_flops);
}

Expand All @@ -294,7 +294,7 @@ TEST_CASE("PathInfo::GetPathStepFlops()", "[PathInfo]")
const PathInfo path_info(tn, {{0, 1}});

const double have_flops = path_info.GetPathStepFlops(2);
const double want_flops = 6;
const double want_flops = 12;
CHECK(have_flops == want_flops);
}

Expand All @@ -309,7 +309,7 @@ TEST_CASE("PathInfo::GetPathStepFlops()", "[PathInfo]")
const PathInfo path_info(tn, {{0, 1}});

const double have_flops = path_info.GetPathStepFlops(2);
const double want_flops = 3 + 2;
const double want_flops = 3 + 3;
CHECK(have_flops == want_flops);
}

Expand All @@ -324,7 +324,7 @@ TEST_CASE("PathInfo::GetPathStepFlops()", "[PathInfo]")
const PathInfo path_info(tn, {{0, 1}});

const double have_flops = path_info.GetPathStepFlops(2);
const double want_flops = (4 * 5) * (6 + 5);
const double want_flops = (4 * 5) * (6 + 6);
CHECK(have_flops == want_flops);
}
SECTION("Path step with invalid ID")
Expand Down Expand Up @@ -382,7 +382,7 @@ TEST_CASE("PathInfo::GetTotalFlops()", "[PathInfo]")
const PathInfo path_info(tn, {{0, 1}, {2, 3}});

const double have_flops = path_info.GetTotalFlops();
const double want_flops = 12 * (2 + 1) + 20 * (3 + 2);
const double want_flops = 12 * (2 + 2) + 20 * (3 + 3);
CHECK(have_flops == want_flops);
}

Expand Down
10 changes: 5 additions & 5 deletions test/Test_TaskBasedContractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ TEST_CASE("TaskBasedContractor::AddContractionTasks()", "[TaskBasedContractor]")
CHECK(have_shared_tasks == want_shared_tasks);

const double have_flops = tbc.GetFlops();
const double want_flops = (3 * 4) * 3 + (2 * 4) * 5 + (2 * 3) * 7;
const double want_flops = (3 * 4) * 4 + (2 * 4) * 6 + (2 * 3) * 8;
CHECK(have_flops == want_flops);

const double have_memory = tbc.GetMemory();
Expand Down Expand Up @@ -246,7 +246,7 @@ TEST_CASE("TaskBasedContractor::AddContractionTasks()", "[TaskBasedContractor]")
CHECK(have_shared_tasks_2 == want_shared_tasks_2);

const double have_flops = tbc.GetFlops();
const double want_flops = 3 * 3 + 2 * 5;
const double want_flops = 3 * 4 + 2 * 6;
CHECK(have_flops == want_flops);

const double have_memory = tbc.GetMemory();
Expand Down Expand Up @@ -707,7 +707,7 @@ TEST_CASE("TaskBasedContractor<CudaTensor>::AddContractionTasks()",
CHECK(have_shared_tasks == want_shared_tasks);

const double have_flops = tbc.GetFlops();
const double want_flops = (3 * 4) * 3 + (2 * 4) * 5 + (2 * 3) * 7;
const double want_flops = (3 * 4) * 4 + (2 * 4) * 6 + (2 * 3) * 8;
CHECK(have_flops == want_flops);

const double have_memory = tbc.GetMemory();
Expand Down Expand Up @@ -789,7 +789,7 @@ TEST_CASE("TaskBasedContractor<CudaTensor>::AddContractionTasks()",
CHECK(have_shared_tasks_2 == want_shared_tasks_2);

const double have_flops = tbc.GetFlops();
const double want_flops = 3 * 3 + 2 * 5;
const double want_flops = 3 * 4 + 2 * 6;
CHECK(have_flops == want_flops);

const double have_memory = tbc.GetMemory();
Expand Down Expand Up @@ -1108,4 +1108,4 @@ TEST_CASE("TaskBasedContractor<CudaTensor>::AddReductionTask()",
}
}

#endif
#endif

0 comments on commit 14bfedb

Please sign in to comment.