Hi, I wanted to use qml.meaure() with postselect argument to make the measure affect the system. However, I need to use default.mixed device since I need to import my input state by qml.QubitDensityMatrix(), which is a mixed state. But it seems the I cannot perform postselection with the device.mixed. Any suggestions? The Peenylane version is 0.37.0
My code is this
import pennylane as qml
import numpy as np
dev = qml.device("default.qubit", wires=2)
#inputs is a 1-qubit mixed state density matrix
inputs = np.loadtxt('state.txt', dtype = complex)
@qml.qnode(dev2)
def iin(inputs):
qml.QubitDensityMatrix(inputs, wires=[0])
m_0 = qml.measure(1,postselect = 1)
return qml.density_matrix([0])
iin(inputs)
The error message is:
Traceback (most recent call last):
File “/home/max/qc/test/test2.py”, line 51, in
print(iin(aa))
File “/root/miniconda3/envs/tc/lib/python3.9/site-packages/pennylane/workflow/qnode.py”, line 1164, in call
return self._impl_call(*args, **kwargs)
File “/root/miniconda3/envs/tc/lib/python3.9/site-packages/pennylane/workflow/qnode.py”, line 1150, in _impl_call
res = self._execution_component(args, kwargs, override_shots=override_shots)
File “/root/miniconda3/envs/tc/lib/python3.9/site-packages/pennylane/workflow/qnode.py”, line 1103, in _execution_component
res = qml.execute(
File “/root/miniconda3/envs/tc/lib/python3.9/site-packages/pennylane/workflow/execution.py”, line 666, in execute
results = inner_execute(tapes)
File “/root/miniconda3/envs/tc/lib/python3.9/site-packages/pennylane/workflow/execution.py”, line 309, in inner_execute
transformed_tapes, transform_post_processing = transform_program(tapes)
File “/root/miniconda3/envs/tc/lib/python3.9/site-packages/pennylane/transforms/core/transform_program.py”, line 515, in call
new_tapes, fn = transform(tape, *targs, **tkwargs)
File “/root/miniconda3/envs/tc/lib/python3.9/site-packages/pennylane/transforms/defer_measurements.py”, line 290, in defer_measurements
raise ValueError(f"Postselection is not supported on the {device} device.")
ValueError: Postselection is not supported on the Default mixed-state qubit PennyLane plugin
Short name: default.mixed
Package: pennylane
Plugin version: 0.37.0
Author: Xanadu Inc.
Wires: 2
Shots: None device.