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

Update wire order support for probabilities #707

Merged
merged 27 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b8bf98b
Begin expansion of probs tests
mlxd May 2, 2024
5361ef0
Update tests to exhaustively compute probs with wires
mlxd May 2, 2024
1aacd37
Update all tests in LQ Meas to use CHECK instead of REQUIRES for bett…
mlxd May 2, 2024
a8a47fb
Add Jet Permuter
mlxd May 2, 2024
b6b3308
Add noisy functionality
mlxd May 2, 2024
5a3a286
Fix permutation ordering
mlxd May 3, 2024
611f7ac
Update changelog
mlxd May 3, 2024
669770b
Merge branch 'v0.36.0_rc' into bugfix/nd_permuter
mlxd May 3, 2024
2d2f451
Fix wrong ordering in probs tests
mlxd May 3, 2024
04c212b
Merge branch 'bugfix/nd_permuter' of github.com:PennyLaneAI/pennylane…
mlxd May 3, 2024
4eeb474
Add recommendation from apache flink to purge azure dirs
mlxd May 3, 2024
61435eb
Forbid out of order indices for probs with LK and LG in CPP layer
mlxd May 3, 2024
0e4e6fd
Remove MSFT tools from GH Actions
mlxd May 3, 2024
44ca70e
Just try to remove dotnet
mlxd May 3, 2024
20542bc
List opt hostedtoolcache
mlxd May 3, 2024
b3f7051
Remove packages from /opt/hostedtoolcache
mlxd May 3, 2024
7da8718
Fix missing test hit
mlxd May 3, 2024
a0bbe34
Forbid and remove broken tests from LK probs ordering
mlxd May 3, 2024
f96c425
Fix clang-tidy isms
mlxd May 3, 2024
45eec89
Ensure libopenblas is not broken from failed apt pull with dev
mlxd May 3, 2024
db41f3e
Appease GH Action
mlxd May 3, 2024
4d49be3
Full remove GH action modifier step due to unexplained failures
mlxd May 3, 2024
ac86237
Add bidreictional wire validation for LGPU CPP layer
mlxd May 3, 2024
e8d7c33
Clang-tidy warning fix
mlxd May 3, 2024
cc43f5d
Appease CT
mlxd May 3, 2024
c34f711
Merge branch 'bugfix/nd_permuter' of github.com:PennyLaneAI/pennylane…
mlxd May 3, 2024
feb55a4
Update JET license agreement
mlxd May 3, 2024
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
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@

### Bug fixes

* Fix wire order permutations when using `qml.probs` with out-of-order wires.
[(#707)](https://github.com/PennyLaneAI/pennylane-lightning/pull/707)

* Lightning Qubit once again respects the wire order specified on device instantiation.
[(#705)](https://github.com/PennyLaneAI/pennylane-lightning/pull/705)

Expand Down
81 changes: 81 additions & 0 deletions .github/workflows/tests_linux_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Remove GH Action tooling
run: |
# Following instructions from Apache Flink
# https://github.com/apache/flink/blob/release-1.15/tools/azure-pipelines/free_disk_space.sh
echo "=============================================================================="
echo "Freeing up disk space on CI system"
echo "=============================================================================="
echo "Listing 100 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
df -h
echo "Removing large packages"
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y microsoft-edge-stable
sudo apt-get autoremove -y
sudo apt-get clean
df -h
echo "Removing large directories"
# deleting 15GB
rm -rf /usr/share/dotnet/
df -h
- uses: actions/setup-python@v5
name: Install Python
with:
Expand Down Expand Up @@ -132,6 +152,27 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Remove GH Action tooling
mlxd marked this conversation as resolved.
Show resolved Hide resolved
run: |
# Following instructions from Apache Flink
# https://github.com/apache/flink/blob/release-1.15/tools/azure-pipelines/free_disk_space.sh
echo "=============================================================================="
echo "Freeing up disk space on CI system"
echo "=============================================================================="
echo "Listing 100 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
df -h
echo "Removing large packages"
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y microsoft-edge-stable
sudo apt-get autoremove -y
sudo apt-get clean
df -h
echo "Removing large directories"
# deleting 15GB
rm -rf /usr/share/dotnet/
df -h

- uses: actions/setup-python@v5
name: Install Python
with:
Expand Down Expand Up @@ -198,6 +239,26 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Remove GH Action tooling
run: |
# Following instructions from Apache Flink
# https://github.com/apache/flink/blob/release-1.15/tools/azure-pipelines/free_disk_space.sh
echo "=============================================================================="
echo "Freeing up disk space on CI system"
echo "=============================================================================="
echo "Listing 100 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
df -h
echo "Removing large packages"
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y microsoft-edge-stable
sudo apt-get autoremove -y
sudo apt-get clean
df -h
echo "Removing large directories"
# deleting 15GB
rm -rf /usr/share/dotnet/
df -h
- uses: actions/setup-python@v5
name: Install Python
with:
Expand Down Expand Up @@ -292,6 +353,26 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Remove GH Action tooling
run: |
# Following instructions from Apache Flink
# https://github.com/apache/flink/blob/release-1.15/tools/azure-pipelines/free_disk_space.sh
echo "=============================================================================="
echo "Freeing up disk space on CI system"
echo "=============================================================================="
echo "Listing 100 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
df -h
echo "Removing large packages"
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y microsoft-edge-stable
sudo apt-get autoremove -y
sudo apt-get clean
df -h
echo "Removing large directories"
# deleting 15GB
rm -rf /usr/share/dotnet/
df -h
- uses: actions/setup-python@v5
name: Install Python
with:
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/tests_lkcpu_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Remove GH Action tooling
run: |
# Following instructions from Apache Flink
# https://github.com/apache/flink/blob/release-1.15/tools/azure-pipelines/free_disk_space.sh
echo "=============================================================================="
echo "Freeing up disk space on CI system"
echo "=============================================================================="
echo "Listing 100 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
df -h
echo "Removing large packages"
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y microsoft-edge-stable
sudo apt-get autoremove -y
sudo apt-get clean
df -h
echo "Removing large directories"
# deleting 15GB
rm -rf /usr/share/dotnet/
df -h
- name: Checkout PennyLane-Lightning
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -148,6 +168,27 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Remove GH Action tooling
run: |
# Following instructions from Apache Flink
# https://github.com/apache/flink/blob/release-1.15/tools/azure-pipelines/free_disk_space.sh
echo "=============================================================================="
echo "Freeing up disk space on CI system"
echo "=============================================================================="
echo "Listing 100 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
df -h
echo "Removing large packages"
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y microsoft-edge-stable
sudo apt-get autoremove -y
sudo apt-get clean
df -h
echo "Removing large directories"
# deleting 15GB
rm -rf /usr/share/dotnet/
df -h

- uses: actions/setup-python@v5
name: Install Python
with:
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/tests_lqcpu_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Remove GH Action tooling
run: |
# Following instructions from Apache Flink
# https://github.com/apache/flink/blob/release-1.15/tools/azure-pipelines/free_disk_space.sh
echo "=============================================================================="
echo "Freeing up disk space on CI system"
echo "=============================================================================="
echo "Listing 100 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
df -h
echo "Removing large packages"
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y microsoft-edge-stable
sudo apt-get autoremove -y
sudo apt-get clean
df -h
echo "Removing large directories"
# deleting 15GB
rm -rf /usr/share/dotnet/
df -h

- uses: actions/setup-python@v5
name: Install Python
with:
Expand Down Expand Up @@ -122,6 +143,27 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Remove GH Action tooling
run: |
# Following instructions from Apache Flink
# https://github.com/apache/flink/blob/release-1.15/tools/azure-pipelines/free_disk_space.sh
echo "=============================================================================="
echo "Freeing up disk space on CI system"
echo "=============================================================================="
echo "Listing 100 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
df -h
echo "Removing large packages"
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y microsoft-edge-stable
sudo apt-get autoremove -y
sudo apt-get clean
df -h
echo "Removing large directories"
# deleting 15GB
rm -rf /usr/share/dotnet/
df -h

- uses: actions/setup-python@v5
name: Install Python
with:
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/wheel_linux_x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,27 @@ jobs:
container: ${{ matrix.container_img }}

steps:
- name: Remove GH Action tooling
run: |
# Following instructions from Apache Flink
# https://github.com/apache/flink/blob/release-1.15/tools/azure-pipelines/free_disk_space.sh
echo "=============================================================================="
echo "Freeing up disk space on CI system"
echo "=============================================================================="
echo "Listing 100 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
df -h
echo "Removing large packages"
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y microsoft-edge-stable
sudo apt-get autoremove -y
sudo apt-get clean
df -h
echo "Removing large directories"
# deleting 15GB
rm -rf /usr/share/dotnet/
df -h

- name: Cache installation directories
id: kokkos-cache
uses: actions/cache@v3
Expand Down Expand Up @@ -107,6 +128,26 @@ jobs:
container: ${{ matrix.container_img }}

steps:
- name: Remove GH Action tooling
run: |
# Following instructions from Apache Flink
# https://github.com/apache/flink/blob/release-1.15/tools/azure-pipelines/free_disk_space.sh
echo "=============================================================================="
echo "Freeing up disk space on CI system"
echo "=============================================================================="
echo "Listing 100 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
df -h
echo "Removing large packages"
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y microsoft-edge-stable
sudo apt-get autoremove -y
sudo apt-get clean
df -h
echo "Removing large directories"
# deleting 15GB
rm -rf /usr/share/dotnet/
df -h
- name: Restoring cached dependencies
id: kokkos-cache
uses: actions/cache@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,36 +84,41 @@ template <typename TypeList> void testProbabilities() {
// Expected results calculated with Pennylane default.qubit:
std::vector<std::pair<std::vector<size_t>, std::vector<PrecisionT>>>
input = {
#ifdef _ENABLE_PLGPU
#if defined(_ENABLE_PLGPU)
// Bit index reodering conducted in the python layer
// for L-GPU. Also L-GPU backend doesn't support
// out of order wires for probability calculation
{{2, 1, 0},
{0.67078706, 0.03062806, 0.0870997, 0.00397696, 0.17564072,
0.00801973, 0.02280642, 0.00104134}}
#else
{{0, 1, 2},
{0.67078706, 0.03062806, 0.0870997, 0.00397696, 0.17564072,
0.00801973, 0.02280642, 0.00104134}},
#if defined(_ENABLE_PLQUBIT)
// LightningQubit currently supports arbitrary wire index
// ordering.
{{0, 2, 1},
{0.67078706, 0.0870997, 0.03062806, 0.00397696, 0.17564072,
0.02280642, 0.00801973, 0.00104134}},
{{1, 0, 2},
{0.67078706, 0.03062806, 0.17564072, 0.00801973, 0.0870997,
0.00397696, 0.02280642, 0.00104134}},
{{1, 2, 0},
{0.67078706, 0.0870997, 0.17564072, 0.02280642, 0.03062806,
0.00397696, 0.00801973, 0.00104134}},
{{2, 0, 1},
{0.67078706, 0.17564072, 0.03062806, 0.00801973, 0.0870997,
0.02280642, 0.00397696, 0.00104134}},
{{2, 0, 1},
{0.67078706, 0.0870997, 0.17564072, 0.02280642, 0.03062806,
0.00397696, 0.00801973, 0.00104134}},
{{2, 1, 0},
{0.67078706, 0.17564072, 0.0870997, 0.02280642, 0.03062806,
0.00801973, 0.00397696, 0.00104134}},
{{2, 1}, {0.84642778, 0.10990612, 0.0386478, 0.0050183}},

#endif
{{0, 1, 2},
{0.67078706, 0.03062806, 0.0870997, 0.00397696, 0.17564072,
0.00801973, 0.02280642, 0.00104134}},
{{0, 1}, {0.70141512, 0.09107666, 0.18366045, 0.02384776}},
{{0, 2}, {0.75788676, 0.03460502, 0.19844714, 0.00906107}},
{{1, 2}, {0.84642778, 0.0386478, 0.10990612, 0.0050183}},
{{2, 1}, {0.84642778, 0.10990612, 0.0386478, 0.0050183}},
{{0}, {0.79249179, 0.20750821}},
{{1}, {0.88507558, 0.11492442}},
{{2}, {0.9563339, 0.0436661}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ class Measurements final
* @return std::vector<PrecisionT>
*/
auto probs(const std::vector<size_t> &wires) -> std::vector<PrecisionT> {
PL_ABORT_IF_NOT(std::is_sorted(wires.cbegin(), wires.cend()),
"LightningGPU does not currently support out-of-order "
"wire indices with probability calculations");

// Data return type fixed as double in custatevec function call
std::vector<double> probabilities(Pennylane::Util::exp2(wires.size()));
// this should be built upon by the wires not participating
Expand Down Expand Up @@ -193,6 +197,10 @@ class Measurements final

std::vector<PrecisionT> probs(const std::vector<size_t> &wires,
size_t num_shots) {
PL_ABORT_IF_NOT(std::is_sorted(wires.cbegin(), wires.cend()),
"LightningGPU does not currently support out-of-order "
"wire indices with probability calculations");

return BaseType::probs(wires, num_shots);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,10 @@ class Measurements final
* The basis columns are rearranged according to wires.
*/
std::vector<PrecisionT> probs(const std::vector<size_t> &wires) {
PL_ABORT_IF_NOT(
std::is_sorted(wires.cbegin(), wires.cend()),
"LightningKokkos does not currently support out-of-order wire "
"indices with probability calculations");
using MDPolicyType_2D =
Kokkos::MDRangePolicy<Kokkos::Rank<2, Kokkos::Iterate::Left>>;

Expand Down Expand Up @@ -645,6 +649,11 @@ class Measurements final

std::vector<PrecisionT> probs(const std::vector<size_t> &wires,
size_t num_shots) {
PL_ABORT_IF_NOT(
std::is_sorted(wires.cbegin(), wires.cend()),
"LightningKokkos does not currently support out-of-order wire "
"indices with probability calculations");

return BaseType::probs(wires, num_shots);
}

Expand Down
Loading
Loading