Skip to content

Commit

Permalink
Noise parameter and new Qrack
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed Oct 5, 2024
1 parent 90d256e commit bdb723c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 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 4e42ae5d0780ad70e86669f01bf0b134f2c8da06; cd ..
git clone https://github.com/unitaryfund/qrack.git; cd qrack; git checkout 61a9f1e4694eab612b5032e884e6f1696842e47d; cd ..
endif
mkdir -p qrack/build
ifeq ($(UNAME_S),Linux)
Expand Down
4 changes: 2 additions & 2 deletions pennylane_qrack/QrackDeviceConfig.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,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"
# Noise parameter. (Default is "0"; depolarizing noise intensity can also be controlled by "QRACK_GATE_DEPOLARIZATION" environment variable)
noise = "noise"

# 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.9.8"
__version__ = "0.10.0"
9 changes: 7 additions & 2 deletions pennylane_qrack/qrack_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,10 @@ struct QrackDevice final : public Catalyst::Runtime::QuantumDevice {
keyMap["'is_qbdd'"] = 5;
keyMap["'is_gpu'"] = 6;
keyMap["'is_host_pointer'"] =7;
keyMap["'is_noisy'"] = 8;
keyMap["'noise'"] = 8;

size_t pos;
real1_f noiseParam = 0;
while ((pos = kwargs.find(":")) != std::string::npos) {
std::string key = trim(kwargs.substr(0, pos));
kwargs.erase(0, pos + 1U);
Expand Down Expand Up @@ -439,14 +440,18 @@ struct QrackDevice final : public Catalyst::Runtime::QuantumDevice {
hp = val;
break;
case 8:
nw = val;
noiseParam = std::stof(value)
nw = noiseParam > ZERO_R1;
break;
default:
break;
}
}

qsim = QSIM_CONFIG(0U);
if (noiseParam > ZERO_R1) {
qsim->SetNoiseParameter(noiseParam);
}
}

QrackDevice &operator=(const QuantumDevice &) = delete;
Expand Down
10 changes: 5 additions & 5 deletions pennylane_qrack/qrack_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ class QrackDevice(QubitDevice):
isOpenCL = True
# 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)
isHostPointer = False
# Use noisy simulation? (Default is "false"; depolarizing noise intensity can be controlled by "QRACK_GATE_DEPOLARIZATION" environment variable)
isNoisy = False
# Noise parameter. (Default is "0"; depolarizing noise intensity can also be controlled by "QRACK_GATE_DEPOLARIZATION" environment variable)
noise = 0

@staticmethod
def get_c_interface():
Expand Down Expand Up @@ -187,8 +187,8 @@ def __init__(self, wires=0, shots=None, **kwargs):
self.isOpenCL = options['isOpenCL']
if 'isHostPointer' in options:
self.isHostPointer = options['isHostPointer']
if 'isNoisy' in options:
self.isNoisy = options['isNoisy']
if 'noise' in options:
self.noise = options['noise']
super().__init__(wires=wires, shots=shots)
self._state = QrackSimulator(
self.num_wires,
Expand All @@ -198,7 +198,7 @@ def __init__(self, wires=0, shots=None, **kwargs):
isBinaryDecisionTree=self.isBinaryDecisionTree,
isOpenCL=self.isOpenCL,
isHostPointer=self.isHostPointer,
isNoisy=self.isNoisy
noise = self.noise
)

def _reverse_state(self):
Expand Down

0 comments on commit bdb723c

Please sign in to comment.