pennylane-qrack 0.21.1__tar.gz → 0.22.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pennylane-qrack might be problematic. Click here for more details.

Files changed (34) hide show
  1. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/Makefile +1 -1
  2. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/PKG-INFO +3 -2
  3. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/README.rst +2 -1
  4. pennylane_qrack-0.22.0/catalyst/runtime/include/DataView.hpp +150 -0
  5. pennylane_qrack-0.22.0/catalyst/runtime/include/Exception.hpp +87 -0
  6. pennylane_qrack-0.22.0/catalyst/runtime/include/OQDRuntimeCAPI.h +56 -0
  7. pennylane_qrack-0.22.0/catalyst/runtime/include/QuantumDevice.hpp +576 -0
  8. pennylane_qrack-0.22.0/catalyst/runtime/include/RuntimeCAPI.h +117 -0
  9. pennylane_qrack-0.22.0/catalyst/runtime/include/Types.h +165 -0
  10. pennylane_qrack-0.22.0/pennylane_qrack/QrackStabilizerDeviceConfig.toml +99 -0
  11. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/pennylane_qrack/_version.py +1 -1
  12. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/pennylane_qrack/qrack_ace_device.py +1 -1
  13. pennylane_qrack-0.22.0/pennylane_qrack/qrack_stabilizer_device.py +296 -0
  14. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/pennylane_qrack.egg-info/PKG-INFO +3 -2
  15. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/pennylane_qrack.egg-info/SOURCES.txt +8 -0
  16. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/pennylane_qrack.egg-info/entry_points.txt +1 -0
  17. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/setup.py +1 -1
  18. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/CHANGELOG.md +0 -0
  19. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/CMakeLists.txt +0 -0
  20. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/LICENSE +0 -0
  21. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/MANIFEST.in +0 -0
  22. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/pennylane_qrack/QrackAceDeviceConfig.toml +0 -0
  23. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/pennylane_qrack/QrackDeviceConfig.toml +0 -0
  24. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/pennylane_qrack/__init__.py +0 -0
  25. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/pennylane_qrack/qrack_device.cpp +0 -0
  26. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/pennylane_qrack/qrack_device.py +0 -0
  27. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/pennylane_qrack.egg-info/dependency_links.txt +0 -0
  28. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/pennylane_qrack.egg-info/requires.txt +0 -0
  29. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/pennylane_qrack.egg-info/top_level.txt +0 -0
  30. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/requirements.txt +0 -0
  31. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/setup.cfg +0 -0
  32. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/tests/test_apply.py +0 -0
  33. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/tests/test_integration.py +0 -0
  34. {pennylane_qrack-0.21.1 → pennylane_qrack-0.22.0}/tests/test_units.py +0 -0
@@ -24,7 +24,7 @@ help:
24
24
  build-deps:
25
25
  ifneq ($(OS),Windows_NT)
26
26
  ifeq ($(QRACK_PRESENT),)
27
- git clone https://github.com/unitaryfund/qrack.git; cd qrack; git checkout 9bbd10bbadf800d7604dc73f0315e84180f3939c; cd ..
27
+ git clone https://github.com/unitaryfund/qrack.git; cd qrack; git checkout 4b2d031d880a9ab3abbcc6dcd7d8a19464e2df89; cd ..
28
28
  endif
29
29
  mkdir -p qrack/build
30
30
  ifeq ($(UNAME_S),Linux)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pennylane-qrack
3
- Version: 0.21.1
3
+ Version: 0.22.0
4
4
  Summary: PennyLane plugin for Qrack.
5
5
  Home-page: http://github.com/vm6502q
6
6
  Maintainer: vm6502q
@@ -65,7 +65,8 @@ Features
65
65
 
66
66
  * Provides access to a PyQrack simulator backend via the ``qrack.simulator`` device
67
67
  * Provides access to a (C++) Qrack simulator backend for Catalyst (also) via the ``qrack.simulator`` device
68
- * Provides access to a PyQrack simulator backend optimized for approximate NISQ-scale TFIM via the ``qrack.ace`` device
68
+ * Provides access to a PyQrack Clifford-only simulator backend via the ``qrack.stabilizer`` device
69
+ * Provides access to a PyQrack simulator backend optimized for large-scale approximate simulation via the ``qrack.ace`` device
69
70
 
70
71
  .. installation-start-inclusion-marker-do-not-remove
71
72
 
@@ -22,7 +22,8 @@ Features
22
22
 
23
23
  * Provides access to a PyQrack simulator backend via the ``qrack.simulator`` device
24
24
  * Provides access to a (C++) Qrack simulator backend for Catalyst (also) via the ``qrack.simulator`` device
25
- * Provides access to a PyQrack simulator backend optimized for approximate NISQ-scale TFIM via the ``qrack.ace`` device
25
+ * Provides access to a PyQrack Clifford-only simulator backend via the ``qrack.stabilizer`` device
26
+ * Provides access to a PyQrack simulator backend optimized for large-scale approximate simulation via the ``qrack.ace`` device
26
27
 
27
28
  .. installation-start-inclusion-marker-do-not-remove
28
29
 
@@ -0,0 +1,150 @@
1
+ // Copyright 2023 Xanadu Quantum Technologies Inc.
2
+
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #pragma once
16
+
17
+ #include <Exception.hpp>
18
+
19
+ /**
20
+ * A multi-dimensional view for MemRef-like and std::vector<T> types.
21
+ *
22
+ * @tparam T The underlying data type
23
+ * @tparam R The Rank (R > 0)
24
+ *
25
+ * @note A forward iterator is implemented in this view for traversing over the entire
26
+ * elements of MemRef types rank-by-rank starting from the last dimension (R-1). For example,
27
+ * The DataView iterator for MemRef<T, 2> starts from index (0, 0) and traverses elements
28
+ * in the following order:
29
+ * (0, 0), ..., (0, sizes[1]-1), (1, 0), ..., (1, sizes[1]-1), ... (sizes[0]-1, sizes[1]-1).
30
+ */
31
+ template <typename T, size_t R> class DataView {
32
+ private:
33
+ T *data_aligned;
34
+ size_t offset;
35
+ size_t sizes[R] = {0};
36
+ size_t strides[R] = {0};
37
+
38
+ public:
39
+ class iterator {
40
+ private:
41
+ const DataView<T, R> &view;
42
+
43
+ int64_t loc; // physical index
44
+ size_t indices[R] = {0};
45
+
46
+ public:
47
+ using iterator_category = std::forward_iterator_tag; // LCOV_EXCL_LINE
48
+ using value_type = T; // LCOV_EXCL_LINE
49
+ using difference_type = std::ptrdiff_t; // LCOV_EXCL_LINE
50
+ using pointer = T *; // LCOV_EXCL_LINE
51
+ using reference = T &; // LCOV_EXCL_LINE
52
+
53
+ iterator(const DataView<T, R> &_view, int64_t begin_idx) : view(_view), loc(begin_idx) {}
54
+ pointer operator->() const { return &view.data_aligned[loc]; }
55
+ reference operator*() const { return view.data_aligned[loc]; }
56
+ iterator &operator++()
57
+ {
58
+ int64_t next_axis = -1;
59
+ int64_t idx;
60
+ for (int64_t i = R; i > 0; --i) {
61
+ idx = i - 1;
62
+ RT_ASSERT(view.sizes[idx] > 0);
63
+ if (indices[idx]++ < view.sizes[idx] - 1) {
64
+ next_axis = idx;
65
+ break;
66
+ }
67
+ indices[idx] = 0;
68
+ loc -= (view.sizes[idx] - 1) * view.strides[idx];
69
+ }
70
+
71
+ loc = next_axis == -1 ? -1 : loc + view.strides[next_axis];
72
+ return *this;
73
+ }
74
+ iterator operator++(int)
75
+ {
76
+ auto tmp = *this;
77
+ int64_t next_axis = -1;
78
+ int64_t idx;
79
+ for (int64_t i = R; i > 0; --i) {
80
+ idx = i - 1;
81
+ RT_ASSERT(view.sizes[idx] > 0);
82
+ if (indices[idx]++ < view.sizes[idx] - 1) {
83
+ next_axis = idx;
84
+ break;
85
+ }
86
+ indices[idx] = 0;
87
+ loc -= (view.sizes[idx] - 1) * view.strides[idx];
88
+ }
89
+
90
+ loc = next_axis == -1 ? -1 : loc + view.strides[next_axis];
91
+ return tmp;
92
+ }
93
+ bool operator==(const iterator &other) const
94
+ {
95
+ return (loc == other.loc && view.data_aligned == other.view.data_aligned);
96
+ }
97
+ bool operator!=(const iterator &other) const { return !(*this == other); }
98
+ };
99
+
100
+ explicit DataView(std::vector<T> &buffer) : data_aligned(buffer.data()), offset(0)
101
+ {
102
+ static_assert(R == 1, "[Class: DataView] Assertion: R == 1");
103
+ sizes[0] = buffer.size();
104
+ strides[0] = 1;
105
+ }
106
+
107
+ explicit DataView(T *_data_aligned, size_t _offset, const size_t *_sizes,
108
+ const size_t *_strides)
109
+ : data_aligned(_data_aligned), offset(_offset)
110
+ {
111
+ static_assert(R > 0, "[Class: DataView] Assertion: R > 0");
112
+ if (_sizes != nullptr && _strides != nullptr) {
113
+ for (size_t i = 0; i < R; i++) {
114
+ sizes[i] = _sizes[i];
115
+ strides[i] = _strides[i];
116
+ }
117
+ } // else sizes = {0}, strides = {0}
118
+ }
119
+
120
+ [[nodiscard]] auto size() const -> size_t
121
+ {
122
+ if (!data_aligned) {
123
+ return 0;
124
+ }
125
+
126
+ size_t tsize = 1;
127
+ for (size_t i = 0; i < R; i++) {
128
+ tsize *= sizes[i];
129
+ }
130
+ return tsize;
131
+ }
132
+
133
+ template <typename... I> T &operator()(I... idxs) const
134
+ {
135
+ static_assert(sizeof...(idxs) == R,
136
+ "[Class: DataView] Error in Catalyst Runtime: Wrong number of indices");
137
+ size_t indices[] = {static_cast<size_t>(idxs)...};
138
+
139
+ size_t loc = offset;
140
+ for (size_t axis = 0; axis < R; axis++) {
141
+ RT_ASSERT(indices[axis] < sizes[axis]);
142
+ loc += indices[axis] * strides[axis];
143
+ }
144
+ return data_aligned[loc];
145
+ }
146
+
147
+ iterator begin() { return iterator{*this, static_cast<int64_t>(offset)}; }
148
+
149
+ iterator end() { return iterator{*this, -1}; }
150
+ };
@@ -0,0 +1,87 @@
1
+ // Copyright 2023 Xanadu Quantum Technologies Inc.
2
+
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #pragma once
16
+
17
+ #include <exception>
18
+ #include <iostream>
19
+
20
+ #include <sstream>
21
+ #include <string>
22
+ #include <type_traits>
23
+ #include <utility>
24
+
25
+ /**
26
+ * @brief Macro that throws `RuntimeException` with given message.
27
+ */
28
+ #define RT_FAIL(message) Catalyst::Runtime::_abort((message), __FILE__, __LINE__, __func__)
29
+
30
+ /**
31
+ * @brief Macro that throws `RuntimeException` if expression evaluates
32
+ * to true.
33
+ */
34
+ #define RT_FAIL_IF(expression, message) \
35
+ if ((expression)) { \
36
+ RT_FAIL(message); \
37
+ }
38
+
39
+ /**
40
+ * @brief Macro that throws `RuntimeException` with the given expression
41
+ * and source location if expression evaluates to false.
42
+ */
43
+ #define RT_ASSERT(expression) RT_FAIL_IF(!(expression), "Assertion: " #expression)
44
+
45
+ namespace Catalyst::Runtime {
46
+
47
+ /**
48
+ * @brief This is the general exception thrown by Catalyst for runtime errors
49
+ * that is derived from `std::exception`.
50
+ */
51
+ class RuntimeException : public std::exception {
52
+ private:
53
+ const std::string err_msg;
54
+
55
+ public:
56
+ explicit RuntimeException(std::string msg) noexcept
57
+ : err_msg{std::move(msg)} {} // LCOV_EXCL_LINE
58
+ ~RuntimeException() override = default; // LCOV_EXCL_LINE
59
+
60
+ RuntimeException(const RuntimeException &) = default;
61
+ RuntimeException(RuntimeException &&) noexcept = default;
62
+
63
+ RuntimeException &operator=(const RuntimeException &) = delete;
64
+ RuntimeException &operator=(RuntimeException &&) = delete;
65
+
66
+ [[nodiscard]] auto what() const noexcept -> const char * override
67
+ {
68
+ return err_msg.c_str();
69
+ } // LCOV_EXCL_LINE
70
+ };
71
+
72
+ /**
73
+ * @brief Throws a `RuntimeException` with the given error message.
74
+ *
75
+ * @note This is not supposed to be called directly.
76
+ */
77
+ [[noreturn]] inline void _abort(const char *message, const char *file_name, size_t line,
78
+ const char *function_name)
79
+ {
80
+ std::stringstream sstream;
81
+ sstream << "[" << file_name << ":" << line << "][Function:" << function_name
82
+ << "] Error in Catalyst Runtime: " << message;
83
+
84
+ throw RuntimeException(sstream.str());
85
+ } // LCOV_EXCL_LINE
86
+
87
+ } // namespace Catalyst::Runtime
@@ -0,0 +1,56 @@
1
+ // Copyright 2025 Xanadu Quantum Technologies Inc.
2
+
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #pragma once
16
+ #ifndef OQDRUNTIMECAPI_H
17
+ #define OQDRUNTIMECAPI_H
18
+
19
+ #include <array>
20
+ #include <cstdint>
21
+
22
+ #include "Exception.hpp"
23
+ #include "Types.h"
24
+
25
+ #ifdef __cplusplus
26
+ extern "C" {
27
+ #endif
28
+
29
+ struct Beam {
30
+ int64_t transition_index;
31
+ double rabi;
32
+ double detuning;
33
+ std::array<int64_t, 3> polarization;
34
+ std::array<int64_t, 3> wavevector;
35
+ };
36
+
37
+ struct Pulse {
38
+ Beam *beam;
39
+ size_t target;
40
+ double duration;
41
+ double phase;
42
+ };
43
+
44
+ // OQD Runtime Instructions
45
+ void __catalyst__oqd__rt__initialize();
46
+ void __catalyst__oqd__rt__finalize(const std::string &openapl_file_name);
47
+ void __catalyst__oqd__ion(const std::string &ion_specs);
48
+ void __catalyst__oqd__modes(const std::vector<std::string> &phonon_specs);
49
+ Pulse *__catalyst__oqd__pulse(QUBIT *qubit, double duration, double phase, Beam *beam);
50
+ void __catalyst__oqd__ParallelProtocol(Pulse **pulses, size_t n);
51
+
52
+ #ifdef __cplusplus
53
+ } // extern "C"
54
+ #endif
55
+
56
+ #endif