Skip to content

Commit

Permalink
Optional noisy simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed Jul 12, 2024
1 parent 77b5690 commit a25da8d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ help:
build-deps:
ifneq ($(OS),Windows_NT)
ifeq ($(QRACK_PRESENT),)
git clone https://github.com/unitaryfund/qrack.git; cd qrack; git checkout 5e3f038c2c14dc393e70498f9cdb1f07d7a81f57; cd ..
git clone https://github.com/unitaryfund/qrack.git; cd qrack; git checkout f9a5941e9b05eab3d7829ba29cc1a3161b9fcde9; cd ..
endif
mkdir -p qrack/build
ifeq ($(UNAME_S),Linux)
Expand Down
5 changes: 4 additions & 1 deletion doc/devices/simulator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ This is a complete list of boolean options and their meanings:
| | | |
+---------------------------+-------------+------------------------------------------------------------------------------------+
| `isHostPointer` | False | Allocate GPU buffer from general host heap? |
| | | (Might improve performance or reliability, like when accelerating on an Intel HD.) |
| | | (Might improve performance or reliability, like when accelerating on an Intel HD) |
+---------------------------+-------------+------------------------------------------------------------------------------------+
| `isNoisy` | False | Use noisy simulation? |
| | | (Noise intensity controlled by "QRACK_GATE_DEPOLARIZATION" environment variable) |
+---------------------------+-------------+------------------------------------------------------------------------------------+


Expand Down
2 changes: 2 additions & 0 deletions pennylane_qrack/QrackDeviceConfig.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ is_qbdd = "isBinaryDecisionTree"
is_gpu = "isOpenCL"
# Allocate GPU buffer from general host heap? (Default is "false"; "true" might improve performance or reliability in certain cases, like if using an Intel HD as accelerator)
is_host_pointer = "isHostPointer"
# Use noisy simulation? (Default is "false"; depolarizing noise intensity can be controlled by "QRACK_GATE_DEPOLARIZATION" environment variable)
is_noisy = "isNoisy"

# In the above example, a dictionary will be constructed at run time.
# The dictionary will contain the string key "option_key" and its value
Expand Down
2 changes: 1 addition & 1 deletion pennylane_qrack/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.6.16"
__version__ = "0.7.0"
8 changes: 7 additions & 1 deletion pennylane_qrack/qrack_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define CL_HPP_TARGET_OPENCL_VERSION 300
#include "qrack/qfactory.hpp"

#define QSIM_CONFIG(numQubits) Qrack::CreateArrangedLayers(md, sd, sh, bdt, true, tn, true, oc, numQubits, Qrack::ZERO_BCI, nullptr, Qrack::CMPLX_DEFAULT_ARG, false, true, hp)
#define QSIM_CONFIG(numQubits) Qrack::CreateArrangedLayersFull(nw, md, sd, sh, bdt, true, tn, true, oc, numQubits, Qrack::ZERO_BCI, nullptr, Qrack::CMPLX_DEFAULT_ARG, false, true, hp)

std::string trim(std::string s)
{
Expand Down Expand Up @@ -39,6 +39,7 @@ struct QrackDevice final : public Catalyst::Runtime::QuantumDevice {
bool bdt;
bool oc;
bool hp;
bool nw;
bitLenInt allocated_qubits;
bitLenInt mapped_qubits;
size_t shots;
Expand Down Expand Up @@ -389,6 +390,7 @@ struct QrackDevice final : public Catalyst::Runtime::QuantumDevice {
, bdt(false)
, oc(true)
, hp(false)
, nw(false)
, allocated_qubits(0U)
, mapped_qubits(0U)
, shots(1U)
Expand All @@ -410,6 +412,7 @@ struct QrackDevice final : public Catalyst::Runtime::QuantumDevice {
keyMap["'is_qbdd'"] = 7;
keyMap["'is_gpu'"] = 8;
keyMap["'is_host_pointer'"] = 9;
keyMap["'is_noisy'"] = 10;

size_t pos;
while ((pos = kwargs.find(":")) != std::string::npos) {
Expand Down Expand Up @@ -491,6 +494,9 @@ struct QrackDevice final : public Catalyst::Runtime::QuantumDevice {
case 9:
hp = val;
break;
case 10:
nw = val;
break;
default:
break;
}
Expand Down

0 comments on commit a25da8d

Please sign in to comment.