pennylane-qrack 0.10.10__tar.gz → 0.10.12__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.
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/Makefile +1 -1
- {pennylane_qrack-0.10.10/pennylane_qrack.egg-info → pennylane_qrack-0.10.12}/PKG-INFO +1 -1
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/catalyst/runtime/include/DataView.hpp +3 -2
- pennylane_qrack-0.10.12/catalyst/runtime/include/DynamicLibraryLoader.hpp +79 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/catalyst/runtime/include/QuantumDevice.hpp +4 -2
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/catalyst/runtime/include/Types.h +13 -13
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/pennylane_qrack/_version.py +1 -1
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/pennylane_qrack/qrack_device.cpp +6 -8
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12/pennylane_qrack.egg-info}/PKG-INFO +1 -1
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/pennylane_qrack.egg-info/SOURCES.txt +1 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/CHANGELOG.md +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/CMakeLists.txt +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/LICENSE +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/MANIFEST.in +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/README.rst +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/catalyst/runtime/include/Exception.hpp +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/catalyst/runtime/include/RuntimeCAPI.h +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/pennylane_qrack/QrackDeviceConfig.toml +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/pennylane_qrack/__init__.py +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/pennylane_qrack/qrack_device.py +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/pennylane_qrack.egg-info/dependency_links.txt +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/pennylane_qrack.egg-info/entry_points.txt +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/pennylane_qrack.egg-info/requires.txt +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/pennylane_qrack.egg-info/top_level.txt +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/requirements.txt +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/setup.cfg +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/setup.py +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/tests/test_apply.py +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/tests/test_integration.py +0 -0
- {pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/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
|
|
27
|
+
git clone https://github.com/unitaryfund/qrack.git; cd qrack; git checkout bc1d5d890a0537bafde7f9f853640487a5e4b69f; cd ..
|
|
28
28
|
endif
|
|
29
29
|
mkdir -p qrack/build
|
|
30
30
|
ifeq ($(UNAME_S),Linux)
|
|
@@ -102,11 +102,12 @@ template <typename T, size_t R> class DataView {
|
|
|
102
102
|
strides[0] = 1;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
explicit DataView(T *_data_aligned, size_t _offset, size_t *_sizes,
|
|
105
|
+
explicit DataView(T *_data_aligned, size_t _offset, const size_t *_sizes,
|
|
106
|
+
const size_t *_strides)
|
|
106
107
|
: data_aligned(_data_aligned), offset(_offset)
|
|
107
108
|
{
|
|
108
109
|
static_assert(R > 0, "[Class: DataView] Assertion: R > 0");
|
|
109
|
-
if (_sizes && _strides) {
|
|
110
|
+
if (_sizes != nullptr && _strides != nullptr) {
|
|
110
111
|
for (size_t i = 0; i < R; i++) {
|
|
111
112
|
sizes[i] = _sizes[i];
|
|
112
113
|
strides[i] = _strides[i];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Copyright 2024 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 <dlfcn.h>
|
|
18
|
+
#include <string_view>
|
|
19
|
+
|
|
20
|
+
#include "Exception.hpp"
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @brief A utility struct to handle opening, closing and retrieving symbols
|
|
24
|
+
* from dynamic shared objects.
|
|
25
|
+
*/
|
|
26
|
+
struct DynamicLibraryLoader {
|
|
27
|
+
void *handle;
|
|
28
|
+
|
|
29
|
+
DynamicLibraryLoader(std::string_view library_name, int mode = RTLD_LAZY | RTLD_NODELETE)
|
|
30
|
+
{
|
|
31
|
+
// Load the shared library
|
|
32
|
+
handle = dlopen(library_name.data(), mode);
|
|
33
|
+
if (!handle) {
|
|
34
|
+
const char *err_msg = dlerror();
|
|
35
|
+
RT_FAIL(err_msg);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
~DynamicLibraryLoader()
|
|
40
|
+
{
|
|
41
|
+
if (handle) {
|
|
42
|
+
// TODO: This is non-sensical.
|
|
43
|
+
// We are using RTLD_NODELETE, why would calling dlclose have a side-effect?
|
|
44
|
+
// Worst of all, the side-effect is not in our code.
|
|
45
|
+
// When we have dlclose, everything works well the first time.
|
|
46
|
+
// However, when trying to compile a second time, we will find that jaxlib will now
|
|
47
|
+
// raise a StopIteration exception. This doesn't really make any sense.
|
|
48
|
+
// My guess is that somehow dlclosing here will unload a the StopIteration symbol (?)
|
|
49
|
+
// rebind it with another equivalent (but with different id?)
|
|
50
|
+
// and then the MLIR python bindings are unable to catch it and stop the iteration and
|
|
51
|
+
// it gets propagated upwards.
|
|
52
|
+
//
|
|
53
|
+
// Is not calling dlclose bad?
|
|
54
|
+
// A little bit, although dlclose implies intent and does not create any requirements
|
|
55
|
+
// upon the implementation. See here:
|
|
56
|
+
// https://pubs.opengroup.org/onlinepubs/000095399/functions/dlclose.html
|
|
57
|
+
// https://github.com/pybind/pybind11/blob/75e48c5f959b4f0a49d8c664e059b6fb4b497102/include/pybind11/detail/internals.h#L108-L113
|
|
58
|
+
//
|
|
59
|
+
#ifndef __APPLE__
|
|
60
|
+
dlclose(handle);
|
|
61
|
+
#endif
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Get symbol from library
|
|
66
|
+
template <typename T> T getSymbol(std::string_view symbol_name)
|
|
67
|
+
{
|
|
68
|
+
// Clear any existing errors
|
|
69
|
+
dlerror();
|
|
70
|
+
|
|
71
|
+
// Retrieve symbol
|
|
72
|
+
T symbol = reinterpret_cast<T>(dlsym(handle, symbol_name.data()));
|
|
73
|
+
const char *err_msg = dlerror();
|
|
74
|
+
if (err_msg != nullptr) {
|
|
75
|
+
RT_FAIL(err_msg);
|
|
76
|
+
}
|
|
77
|
+
return symbol;
|
|
78
|
+
}
|
|
79
|
+
};
|
{pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/catalyst/runtime/include/QuantumDevice.hpp
RENAMED
|
@@ -165,7 +165,8 @@ struct QuantumDevice {
|
|
|
165
165
|
* @param state A state vector of size 2**len(wires)
|
|
166
166
|
* @param wires The wire(s) the operation acts on
|
|
167
167
|
*/
|
|
168
|
-
virtual void SetState(DataView<std::complex<double>, 1>
|
|
168
|
+
virtual void SetState([[maybe_unused]] DataView<std::complex<double>, 1> &state,
|
|
169
|
+
[[maybe_unused]] std::vector<QubitIdType> &wires)
|
|
169
170
|
{
|
|
170
171
|
RT_FAIL("Unsupported functionality");
|
|
171
172
|
}
|
|
@@ -176,7 +177,8 @@ struct QuantumDevice {
|
|
|
176
177
|
* @param n Prepares the basis state |n>, where n is an array of integers from the set {0, 1}
|
|
177
178
|
* @param wires The wire(s) the operation acts on
|
|
178
179
|
*/
|
|
179
|
-
virtual void SetBasisState(DataView<int8_t, 1>
|
|
180
|
+
virtual void SetBasisState([[maybe_unused]] DataView<int8_t, 1> &n,
|
|
181
|
+
[[maybe_unused]] std::vector<QubitIdType> &wires)
|
|
180
182
|
{
|
|
181
183
|
RT_FAIL("Unsupported functionality");
|
|
182
184
|
}
|
|
@@ -26,13 +26,13 @@ extern "C" {
|
|
|
26
26
|
|
|
27
27
|
// Qubit, Result and Observable types
|
|
28
28
|
struct QUBIT;
|
|
29
|
-
|
|
29
|
+
using QubitIdType = intptr_t;
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
using RESULT = bool;
|
|
32
|
+
using Result = RESULT *;
|
|
33
|
+
using QirArray = void *;
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
using ObsIdType = intptr_t;
|
|
36
36
|
|
|
37
37
|
enum ObsId : int8_t {
|
|
38
38
|
Identity = 0,
|
|
@@ -149,14 +149,14 @@ struct Modifiers {
|
|
|
149
149
|
bool *controlled_values;
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
152
|
+
using CplxT_double = struct CplxT_double;
|
|
153
|
+
using MemRefT_CplxT_double_1d = struct MemRefT_CplxT_double_1d;
|
|
154
|
+
using MemRefT_CplxT_double_2d = struct MemRefT_CplxT_double_2d;
|
|
155
|
+
using MemRefT_double_1d = struct MemRefT_double_1d;
|
|
156
|
+
using MemRefT_double_2d = struct MemRefT_double_2d;
|
|
157
|
+
using MemRefT_int64_1d = struct MemRefT_int64_1d;
|
|
158
|
+
using PairT_MemRefT_double_int64_1d = struct PairT_MemRefT_double_int64_1d;
|
|
159
|
+
using Modifiers = struct Modifiers;
|
|
160
160
|
|
|
161
161
|
#ifdef __cplusplus
|
|
162
162
|
} // extern "C"
|
|
@@ -184,8 +184,8 @@ struct QrackDevice final : public Catalyst::Runtime::QuantumDevice {
|
|
|
184
184
|
const Qrack::real1 omega = inverse ? -params[0U] : params[2U];
|
|
185
185
|
const Qrack::real1 cos0 = (Qrack::real1)cos(theta / 2);
|
|
186
186
|
const Qrack::real1 sin0 = (Qrack::real1)sin(theta / 2);
|
|
187
|
-
const Qrack::complex expP = exp(Qrack::I_CMPLX * (phi + omega)
|
|
188
|
-
const Qrack::complex expM = exp(Qrack::I_CMPLX * (phi - omega)
|
|
187
|
+
const Qrack::complex expP = exp(Qrack::I_CMPLX * (phi + omega) * HALF_R1);
|
|
188
|
+
const Qrack::complex expM = exp(Qrack::I_CMPLX * (phi - omega) * HALF_R1);
|
|
189
189
|
const Qrack::complex mtrx[4U]{
|
|
190
190
|
cos0 / expP, -sin0 * expM,
|
|
191
191
|
sin0 / expM, cos0 * expP
|
|
@@ -226,14 +226,12 @@ struct QrackDevice final : public Catalyst::Runtime::QuantumDevice {
|
|
|
226
226
|
QRACK_CONST Qrack::complex NEG_SQRTI_2_CMPLX(ZERO_R1, -Qrack::SQRT1_2_R1);
|
|
227
227
|
const Qrack::complex QBRTI_2_CMPLX(ZERO_R1, sqrt(Qrack::SQRT1_2_R1));
|
|
228
228
|
const Qrack::complex NEG_QBRTI_2_CMPLX(ZERO_R1, sqrt(-Qrack::SQRT1_2_R1));
|
|
229
|
-
QRACK_CONST Qrack::complex ONE_PLUS_I_DIV_2 = Qrack::complex((Qrack::real1)(ONE_R1 / 2), (Qrack::real1)(ONE_R1 / 2));
|
|
230
|
-
QRACK_CONST Qrack::complex ONE_MINUS_I_DIV_2 = Qrack::complex((Qrack::real1)(ONE_R1 / 2), (Qrack::real1)(-ONE_R1 / 2));
|
|
231
229
|
|
|
232
230
|
QRACK_CONST Qrack::complex pauliX[4U] = { Qrack::ZERO_CMPLX, Qrack::ONE_CMPLX, Qrack::ONE_CMPLX, Qrack::ZERO_CMPLX };
|
|
233
231
|
QRACK_CONST Qrack::complex pauliY[4U] = { Qrack::ZERO_CMPLX, NEG_I_CMPLX, Qrack::I_CMPLX, Qrack::ZERO_CMPLX };
|
|
234
232
|
QRACK_CONST Qrack::complex pauliZ[4U] = { Qrack::ONE_CMPLX, Qrack::ZERO_CMPLX, Qrack::ZERO_CMPLX, NEG_1_CMPLX };
|
|
235
|
-
QRACK_CONST Qrack::complex sqrtX[4U]{
|
|
236
|
-
QRACK_CONST Qrack::complex iSqrtX[4U]{
|
|
233
|
+
QRACK_CONST Qrack::complex sqrtX[4U]{ Qrack::HALF_I_HALF_CMPLX, Qrack::HALF_NEG_I_HALF_CMPLX, Qrack::HALF_NEG_I_HALF_CMPLX, Qrack::HALF_I_HALF_CMPLX };
|
|
234
|
+
QRACK_CONST Qrack::complex iSqrtX[4U]{ Qrack::HALF_NEG_I_HALF_CMPLX, Qrack::HALF_I_HALF_CMPLX, Qrack::HALF_I_HALF_CMPLX, Qrack::HALF_NEG_I_HALF_CMPLX };
|
|
237
235
|
QRACK_CONST Qrack::complex hadamard[4U]{ SQRT1_2_CMPLX, SQRT1_2_CMPLX, SQRT1_2_CMPLX, NEG_SQRT1_2_CMPLX };
|
|
238
236
|
|
|
239
237
|
if ((name == "PauliX") || (name == "CNOT") || (name == "Toffoli") || (name == "MultiControlledX")) {
|
|
@@ -348,8 +346,8 @@ struct QrackDevice final : public Catalyst::Runtime::QuantumDevice {
|
|
|
348
346
|
const Qrack::real1 omega = inverse ? -params[0U] : params[2U];
|
|
349
347
|
const Qrack::real1 cos0 = (Qrack::real1)cos(theta / 2);
|
|
350
348
|
const Qrack::real1 sin0 = (Qrack::real1)sin(theta / 2);
|
|
351
|
-
const Qrack::complex expP = exp(Qrack::I_CMPLX * (phi + omega)
|
|
352
|
-
const Qrack::complex expM = exp(Qrack::I_CMPLX * (phi - omega)
|
|
349
|
+
const Qrack::complex expP = exp(Qrack::I_CMPLX * (phi + omega) * HALF_R1);
|
|
350
|
+
const Qrack::complex expM = exp(Qrack::I_CMPLX * (phi - omega) * HALF_R1);
|
|
353
351
|
const Qrack::complex mtrx[4U]{
|
|
354
352
|
cos0 / expP, -sin0 * expM,
|
|
355
353
|
sin0 / expM, cos0 * expP
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/pennylane_qrack.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{pennylane_qrack-0.10.10 → pennylane_qrack-0.10.12}/pennylane_qrack.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|