pennylane-qrack 0.10.0__tar.gz → 0.10.1__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 (29) hide show
  1. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/Makefile +1 -1
  2. {pennylane_qrack-0.10.0/pennylane_qrack.egg-info → pennylane-qrack-0.10.1}/PKG-INFO +1 -4
  3. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/pennylane_qrack/_version.py +1 -1
  4. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1/pennylane_qrack.egg-info}/PKG-INFO +1 -4
  5. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/pennylane_qrack.egg-info/SOURCES.txt +1 -9
  6. pennylane_qrack-0.10.0/catalyst/runtime/include/DataView.hpp +0 -147
  7. pennylane_qrack-0.10.0/catalyst/runtime/include/Exception.hpp +0 -87
  8. pennylane_qrack-0.10.0/catalyst/runtime/include/QuantumDevice.hpp +0 -319
  9. pennylane_qrack-0.10.0/catalyst/runtime/include/RuntimeCAPI.h +0 -109
  10. pennylane_qrack-0.10.0/catalyst/runtime/include/Types.h +0 -156
  11. pennylane_qrack-0.10.0/tests/test_apply.py +0 -662
  12. pennylane_qrack-0.10.0/tests/test_integration.py +0 -87
  13. pennylane_qrack-0.10.0/tests/test_units.py +0 -81
  14. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/CHANGELOG.md +0 -0
  15. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/CMakeLists.txt +0 -0
  16. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/LICENSE +0 -0
  17. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/MANIFEST.in +0 -0
  18. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/README.rst +0 -0
  19. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/pennylane_qrack/QrackDeviceConfig.toml +0 -0
  20. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/pennylane_qrack/__init__.py +0 -0
  21. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/pennylane_qrack/qrack_device.cpp +0 -0
  22. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/pennylane_qrack/qrack_device.py +0 -0
  23. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/pennylane_qrack.egg-info/dependency_links.txt +0 -0
  24. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/pennylane_qrack.egg-info/entry_points.txt +0 -0
  25. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/pennylane_qrack.egg-info/requires.txt +1 -1
  26. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/pennylane_qrack.egg-info/top_level.txt +0 -0
  27. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/requirements.txt +0 -0
  28. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/setup.cfg +0 -0
  29. {pennylane_qrack-0.10.0 → pennylane-qrack-0.10.1}/setup.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 61a9f1e4694eab612b5032e884e6f1696842e47d; cd ..
27
+ git clone https://github.com/unitaryfund/qrack.git; cd qrack; git checkout 7b661264a7494f4055504888126d66960e0c26e4; 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.1
2
2
  Name: pennylane-qrack
3
- Version: 0.10.0
3
+ Version: 0.10.1
4
4
  Summary: PennyLane plugin for Qrack.
5
5
  Home-page: http://github.com/vm6502q
6
6
  Maintainer: vm6502q
@@ -26,9 +26,6 @@ Classifier: Topic :: Scientific/Engineering :: Physics
26
26
  Provides: pennylane_qrack
27
27
  Description-Content-Type: text/x-rst
28
28
  License-File: LICENSE
29
- Requires-Dist: pennylane>=0.32
30
- Requires-Dist: pyqrack>=1.30.0
31
- Requires-Dist: numpy>=1.16
32
29
 
33
30
  PennyLane-Qrack Plugin
34
31
  #######################
@@ -16,4 +16,4 @@
16
16
  Version number (major.minor.patch[-label])
17
17
  """
18
18
 
19
- __version__ = "0.10.0"
19
+ __version__ = "0.10.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pennylane-qrack
3
- Version: 0.10.0
3
+ Version: 0.10.1
4
4
  Summary: PennyLane plugin for Qrack.
5
5
  Home-page: http://github.com/vm6502q
6
6
  Maintainer: vm6502q
@@ -26,9 +26,6 @@ Classifier: Topic :: Scientific/Engineering :: Physics
26
26
  Provides: pennylane_qrack
27
27
  Description-Content-Type: text/x-rst
28
28
  License-File: LICENSE
29
- Requires-Dist: pennylane>=0.32
30
- Requires-Dist: pyqrack>=1.30.0
31
- Requires-Dist: numpy>=1.16
32
29
 
33
30
  PennyLane-Qrack Plugin
34
31
  #######################
@@ -6,11 +6,6 @@ Makefile
6
6
  README.rst
7
7
  requirements.txt
8
8
  setup.py
9
- catalyst/runtime/include/DataView.hpp
10
- catalyst/runtime/include/Exception.hpp
11
- catalyst/runtime/include/QuantumDevice.hpp
12
- catalyst/runtime/include/RuntimeCAPI.h
13
- catalyst/runtime/include/Types.h
14
9
  pennylane_qrack/QrackDeviceConfig.toml
15
10
  pennylane_qrack/__init__.py
16
11
  pennylane_qrack/_version.py
@@ -21,7 +16,4 @@ pennylane_qrack.egg-info/SOURCES.txt
21
16
  pennylane_qrack.egg-info/dependency_links.txt
22
17
  pennylane_qrack.egg-info/entry_points.txt
23
18
  pennylane_qrack.egg-info/requires.txt
24
- pennylane_qrack.egg-info/top_level.txt
25
- tests/test_apply.py
26
- tests/test_integration.py
27
- tests/test_units.py
19
+ pennylane_qrack.egg-info/top_level.txt
@@ -1,147 +0,0 @@
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
- if (indices[idx]++ < view.sizes[idx] - 1) {
63
- next_axis = idx;
64
- break;
65
- }
66
- indices[idx] = 0;
67
- loc -= (view.sizes[idx] - 1) * view.strides[idx];
68
- }
69
-
70
- loc = next_axis == -1 ? -1 : loc + view.strides[next_axis];
71
- return *this;
72
- }
73
- iterator operator++(int)
74
- {
75
- auto tmp = *this;
76
- int64_t next_axis = -1;
77
- int64_t idx;
78
- for (int64_t i = R; i > 0; --i) {
79
- idx = i - 1;
80
- if (indices[idx]++ < view.sizes[idx] - 1) {
81
- next_axis = idx;
82
- break;
83
- }
84
- indices[idx] = 0;
85
- loc -= (view.sizes[idx] - 1) * view.strides[idx];
86
- }
87
-
88
- loc = next_axis == -1 ? -1 : loc + view.strides[next_axis];
89
- return tmp;
90
- }
91
- bool operator==(const iterator &other) const
92
- {
93
- return (loc == other.loc && view.data_aligned == other.view.data_aligned);
94
- }
95
- bool operator!=(const iterator &other) const { return !(*this == other); }
96
- };
97
-
98
- explicit DataView(std::vector<T> &buffer) : data_aligned(buffer.data()), offset(0)
99
- {
100
- static_assert(R == 1, "[Class: DataView] Assertion: R == 1");
101
- sizes[0] = buffer.size();
102
- strides[0] = 1;
103
- }
104
-
105
- explicit DataView(T *_data_aligned, size_t _offset, size_t *_sizes, size_t *_strides)
106
- : data_aligned(_data_aligned), offset(_offset)
107
- {
108
- static_assert(R > 0, "[Class: DataView] Assertion: R > 0");
109
- if (_sizes && _strides) {
110
- for (size_t i = 0; i < R; i++) {
111
- sizes[i] = _sizes[i];
112
- strides[i] = _strides[i];
113
- }
114
- } // else sizes = {0}, strides = {0}
115
- }
116
-
117
- [[nodiscard]] auto size() const -> size_t
118
- {
119
- if (!data_aligned) {
120
- return 0;
121
- }
122
-
123
- size_t tsize = 1;
124
- for (size_t i = 0; i < R; i++) {
125
- tsize *= sizes[i];
126
- }
127
- return tsize;
128
- }
129
-
130
- template <typename... I> T &operator()(I... idxs) const
131
- {
132
- static_assert(sizeof...(idxs) == R,
133
- "[Class: DataView] Error in Catalyst Runtime: Wrong number of indices");
134
- size_t indices[] = {static_cast<size_t>(idxs)...};
135
-
136
- size_t loc = offset;
137
- for (size_t axis = 0; axis < R; axis++) {
138
- RT_ASSERT(indices[axis] < sizes[axis]);
139
- loc += indices[axis] * strides[axis];
140
- }
141
- return data_aligned[loc];
142
- }
143
-
144
- iterator begin() { return iterator{*this, static_cast<int64_t>(offset)}; }
145
-
146
- iterator end() { return iterator{*this, -1}; }
147
- };
@@ -1,87 +0,0 @@
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:" << 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
@@ -1,319 +0,0 @@
1
- // Copyright 2022-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 <complex>
18
- #include <memory>
19
- #include <optional>
20
- #include <vector>
21
-
22
- #include "DataView.hpp"
23
- #include "Types.h"
24
-
25
- // A helper template macro to generate the <IDENTIFIER>Factory method by
26
- // calling <CONSTRUCTOR>(kwargs). Check the Custom Devices guideline for details:
27
- // https://docs.pennylane.ai/projects/catalyst/en/stable/dev/custom_devices.html
28
- #define GENERATE_DEVICE_FACTORY(IDENTIFIER, CONSTRUCTOR) \
29
- extern "C" Catalyst::Runtime::QuantumDevice *IDENTIFIER##Factory(const char *kwargs) \
30
- { \
31
- return new CONSTRUCTOR(std::string(kwargs)); \
32
- }
33
-
34
- namespace Catalyst::Runtime {
35
-
36
- /**
37
- * @brief struct API for backend quantum devices.
38
- *
39
- * This device API contains,
40
- * - a set of methods to manage qubit allocations and deallocations, device shot
41
- * noise, and quantum tape recording as well as reference values for the result
42
- * data-type; these are used to implement Quantum Runtime (QR) instructions.
43
- *
44
- * - a set of methods for quantum operations, observables, measurements, and gradient
45
- * of the device; these are used to implement Quantum Instruction Set (QIS) instructions.
46
- *
47
- */
48
- struct QuantumDevice {
49
- QuantumDevice() = default; // LCOV_EXCL_LINE
50
- virtual ~QuantumDevice() = default; // LCOV_EXCL_LINE
51
-
52
- QuantumDevice &operator=(const QuantumDevice &) = delete;
53
- QuantumDevice(const QuantumDevice &) = delete;
54
- QuantumDevice(QuantumDevice &&) = delete;
55
- QuantumDevice &operator=(QuantumDevice &&) = delete;
56
-
57
- /**
58
- * @brief Allocate a qubit.
59
- *
60
- * @return `QubitIdType`
61
- */
62
- virtual auto AllocateQubit() -> QubitIdType = 0;
63
-
64
- /**
65
- * @brief Allocate a vector of qubits.
66
- *
67
- * @param num_qubits The number of qubits to allocate.
68
- *
69
- * @return `std::vector<QubitIdType>`
70
- */
71
- virtual auto AllocateQubits(size_t num_qubits) -> std::vector<QubitIdType> = 0;
72
-
73
- /**
74
- * @brief Release a qubit.
75
- *
76
- * @param qubit The id of the qubit
77
- */
78
- virtual void ReleaseQubit(QubitIdType qubit) = 0;
79
-
80
- /**
81
- * @brief Release all qubits.
82
- */
83
- virtual void ReleaseAllQubits() = 0;
84
-
85
- /**
86
- * @brief Get the number of allocated qubits.
87
- *
88
- * @return `size_t`
89
- */
90
- [[nodiscard]] virtual auto GetNumQubits() const -> size_t = 0;
91
-
92
- /**
93
- * @brief Set the number of device shots.
94
- *
95
- * @param shots The number of noise shots
96
- */
97
- virtual void SetDeviceShots(size_t shots) = 0;
98
-
99
- /**
100
- * @brief Get the number of device shots.
101
- *
102
- * @return `size_t`
103
- */
104
- [[nodiscard]] virtual auto GetDeviceShots() const -> size_t = 0;
105
-
106
- /**
107
- * @brief Start recording a quantum tape if provided.
108
- *
109
- * @note This is backed by the `Catalyst::Runtime::CacheManager<ComplexT>` property in
110
- * the device implementation.
111
- */
112
- virtual void StartTapeRecording() = 0;
113
-
114
- /**
115
- * @brief Stop recording a quantum tape if provided.
116
- *
117
- * @note This is backed by the `Catalyst::Runtime::CacheManager<ComplexT>` property in
118
- * the device implementation.
119
- */
120
- virtual void StopTapeRecording() = 0;
121
-
122
- /**
123
- * @brief Result value for "Zero" used in the measurement process.
124
- *
125
- * @return `Result`
126
- */
127
- [[nodiscard]] virtual auto Zero() const -> Result = 0;
128
-
129
- /**
130
- * @brief Result value for "One" used in the measurement process.
131
- *
132
- * @return `Result`
133
- */
134
- [[nodiscard]] virtual auto One() const -> Result = 0;
135
-
136
- /**
137
- * @brief A helper method to print the state vector of a device.
138
- */
139
- virtual void PrintState() = 0;
140
-
141
- /**
142
- * @brief Apply a single gate to the state vector of a device with its name if this is
143
- * supported.
144
- *
145
- * @param name The name of the gate to apply
146
- * @param params Optional parameter list for parametric gates
147
- * @param wires Wires to apply gate to
148
- * @param inverse Indicates whether to use inverse of gate
149
- * @param controlled_wires Optional controlled wires applied to the operation
150
- * @param controlled_values Optional controlled values applied to the operation
151
- */
152
- virtual void
153
- NamedOperation(const std::string &name, const std::vector<double> &params,
154
- const std::vector<QubitIdType> &wires, [[maybe_unused]] bool inverse = false,
155
- [[maybe_unused]] const std::vector<QubitIdType> &controlled_wires = {},
156
- [[maybe_unused]] const std::vector<bool> &controlled_values = {}) = 0;
157
-
158
- /**
159
- * @brief Apply a given matrix directly to the state vector of a device.
160
- *
161
- * @param matrix The matrix of data in row-major format
162
- * @param wires Wires to apply gate to
163
- * @param inverse Indicates whether to use inverse of gate
164
- * @param controlled_wires Controlled wires applied to the operation
165
- * @param controlled_values Controlled values applied to the operation
166
- */
167
- virtual void
168
- MatrixOperation(const std::vector<std::complex<double>> &matrix,
169
- const std::vector<QubitIdType> &wires, [[maybe_unused]] bool inverse = false,
170
- [[maybe_unused]] const std::vector<QubitIdType> &controlled_wires = {},
171
- [[maybe_unused]] const std::vector<bool> &controlled_values = {}) = 0;
172
-
173
- /**
174
- * @brief Construct a named (Identity, PauliX, PauliY, PauliZ, and Hadamard)
175
- * or Hermitian observable.
176
- *
177
- * @param id The type of the observable
178
- * @param matrix The matrix of data to construct a hermitian observable
179
- * @param wires Wires to apply observable to
180
- *
181
- * @return `ObsIdType` Index of the constructed observable
182
- */
183
- virtual auto Observable(ObsId id, const std::vector<std::complex<double>> &matrix,
184
- const std::vector<QubitIdType> &wires) -> ObsIdType = 0;
185
-
186
- /**
187
- * @brief Construct a tensor product of observables.
188
- *
189
- * @param obs The vector of observables indices of type ObsIdType
190
- *
191
- * @return `ObsIdType` Index of the constructed observable
192
- */
193
- virtual auto TensorObservable(const std::vector<ObsIdType> &obs) -> ObsIdType = 0;
194
-
195
- /**
196
- * @brief Construct a Hamiltonian observable.
197
- *
198
- * @param coeffs The vector of coefficients
199
- * @param obs The vector of observables indices of size `coeffs`
200
- *
201
- * @return `ObsIdType` Index of the constructed observable
202
- */
203
- virtual auto HamiltonianObservable(const std::vector<double> &coeffs,
204
- const std::vector<ObsIdType> &obs) -> ObsIdType = 0;
205
-
206
- /**
207
- * @brief Compute the expected value of an observable.
208
- *
209
- * @param obsKey The index of the constructed observable
210
- *
211
- * @return `double` The expected value
212
- */
213
- virtual auto Expval(ObsIdType obsKey) -> double = 0;
214
-
215
- /**
216
- * @brief Compute the variance of an observable.
217
- *
218
- * @param obsKey The index of the constructed observable
219
- *
220
- * @return `double` The variance
221
- */
222
- virtual auto Var(ObsIdType obsKey) -> double = 0;
223
-
224
- /**
225
- * @brief Get the state-vector of a device.
226
- *
227
- * @param state The pre-allocated `DataView<complex<double>, 1>`
228
- */
229
- virtual void State(DataView<std::complex<double>, 1> &state) = 0;
230
-
231
- /**
232
- * @brief Compute the probabilities of each computational basis state.
233
-
234
- * @param probs The pre-allocated `DataView<double, 1>`
235
- */
236
- virtual void Probs(DataView<double, 1> &probs) = 0;
237
-
238
- /**
239
- * @brief Compute the probabilities for a subset of the full system.
240
- *
241
- * @param probs The pre-allocated `DataView<double, 1>`
242
- * @param wires Wires will restrict probabilities to a subset of the full system
243
- */
244
- virtual void PartialProbs(DataView<double, 1> &probs,
245
- const std::vector<QubitIdType> &wires) = 0;
246
-
247
- /**
248
- * @brief Compute samples with the number of shots on the entire wires,
249
- * returing raw samples.
250
- *
251
- * @param samples The pre-allocated `DataView<double, 2>`representing a matrix of
252
- * shape `shots * numQubits`. The built-in iterator in `DataView<double, 2>`
253
- * iterates over all elements of `samples` row-wise.
254
- * @param shots The number of shots
255
- */
256
- virtual void Sample(DataView<double, 2> &samples, size_t shots) = 0;
257
-
258
- /**
259
- * @brief Compute partial samples with the number of shots on `wires`,
260
- * returing raw samples.
261
- *
262
- * @param samples The pre-allocated `DataView<double, 2>`representing a matrix of
263
- * shape `shots * numWires`. The built-in iterator in `DataView<double, 2>`
264
- * iterates over all elements of `samples` row-wise.
265
- * @param wires Wires to compute samples on
266
- * @param shots The number of shots
267
- */
268
- virtual void PartialSample(DataView<double, 2> &samples, const std::vector<QubitIdType> &wires,
269
- size_t shots) = 0;
270
-
271
- /**
272
- * @brief Sample with the number of shots on the entire wires, returning the
273
- * number of counts for each sample.
274
- *
275
- * @param eigvals The pre-allocated `DataView<double, 1>`
276
- * @param counts The pre-allocated `DataView<int64_t, 1>`
277
- * @param shots The number of shots
278
- */
279
- virtual void Counts(DataView<double, 1> &eigvals, DataView<int64_t, 1> &counts,
280
- size_t shots) = 0;
281
-
282
- /**
283
- * @brief Partial sample with the number of shots on `wires`, returning the
284
- * number of counts for each sample.
285
- *
286
- * @param eigvals The pre-allocated `DataView<double, 1>`
287
- * @param counts The pre-allocated `DataView<int64_t, 1>`
288
- * @param wires Wires to compute samples on
289
- * @param shots The number of shots
290
- */
291
- virtual void PartialCounts(DataView<double, 1> &eigvals, DataView<int64_t, 1> &counts,
292
- const std::vector<QubitIdType> &wires, size_t shots) = 0;
293
-
294
- /**
295
- * @brief A general measurement method that acts on a single wire.
296
- *
297
- * @param wire The wire to compute Measure on
298
- * @param postselect Which basis state to postselect after a mid-circuit measurement (-1 denotes
299
- no post-selection)
300
-
301
- * @return `Result` The measurement result
302
- */
303
- virtual auto Measure(QubitIdType wire, std::optional<int32_t> postselect) -> Result = 0;
304
-
305
- /**
306
- * @brief Compute the gradient of a quantum tape, that is cached using
307
- * `Catalyst::Runtime::Simulator::CacheManager`, for a specific set of trainable
308
- * parameters.
309
- *
310
- * @param gradients The vector of pre-allocated `DataView<double, 1>*`
311
- * to store gradients resutls for the list of cached observables.
312
- * @param trainParams The vector of trainable parameters; if none, all parameters
313
- * would be assumed trainable
314
- *
315
- */
316
- virtual void Gradient(std::vector<DataView<double, 1>> &gradients,
317
- const std::vector<size_t> &trainParams) = 0;
318
- };
319
- } // namespace Catalyst::Runtime