-
Notifications
You must be signed in to change notification settings - Fork 590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin extra operations #65
Conversation
…ions disabled AllPauliZ Expectation fixed generation of DeviceError
fixed calculation of expectation values in the simulator
…but which makes no sense commented out Identity gate in default plugin which seems useless
added check of whether the required wires fit on the device
…itional operations small improvements in docstring of qfunc.py moved QuantumFunctionError from device to qnode
moved code to add/remove the extra operations to __enter__() and __exit__()
@@ -110,6 +110,7 @@ class ProjectQDevice(Device): | |||
plugin_version = __version__ | |||
author = 'Christian Gogolin' | |||
_capabilities = {'backend': list(["Simulator", "ClassicalSimulator", "IBMBackend"])} | |||
_extra_operations = {'S': S, 'T': T, 'SqrtX': SqrtX, 'SqrtSwap': SqrtSwap, 'AllPauliZ': AllPauliZ} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is _extra_operations
a optional class attribute, that maps openqml.ops.key
(attribute loaded dynamically) to openqml_pq.ops.value
?
I'll resolve this if it is explained further down, just commenting here while it is fresh in my mind :)
@@ -21,7 +21,8 @@ | |||
|
|||
|
|||
from .configuration import Configuration | |||
from .device import Device, DeviceError, QuantumFunctionError | |||
from .device import Device, DeviceError | |||
from .qnode import QuantumFunctionError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strangely, I think I had to originally put QuantumFunctionError
in device.py
because of a dependency loop...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is no longer used in device.py, so I think now it makes more sense to have it in qnode.py
It looks good in the case of the def quantum_function():
qm.RX()
qm.custom_op()
qnode = QNode(quantum_function, dev1) will not work without an explicit One solution would be to move the |
One are the classes missing in ProjectQ, the other are the classes for additional operations in OpenQML. But, no, nothing apart from that.
…On 5 October 2018 19:19:02 CEST, Josh Izaac ***@***.***> wrote:
josh146 commented on this pull request.
> @@ -57,7 +57,7 @@
from projectq.ops import (HGate, XGate, YGate, ZGate, SGate, TGate,
SqrtXGate, SwapGate, SqrtSwapGate, Rx, Ry, Rz, R, Ph, StatePreparation,
HGate, SGate, TGate, SqrtXGate, SqrtSwapGate
)
from .ops import (CNOT, CZ, Toffoli, AllZGate, Rot, QubitUnitary)
-
+from .ops import (S, T, SqrtX, SqrtSwap, AllPauliZ)
any reason in particular why these are on a different line?
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#65 (review)
--
Christian Gogolin
http://www.cgogolin.de
|
Yes, exactly.
--
Christian Gogolin
http://www.cgogolin.de
|
Will do.
--
Christian Gogolin
http://www.cgogolin.de
|
Than that would be the preferred option. Can you make that change, please?
--
Christian Gogolin
http://www.cgogolin.de
|
…and __exit__() call reset() manually during init removed already commented Identity operation from default plugin
Replying via email to your comments aparently just put all my replies into this thread instead of treating them as replies to your questions... With the latest commits I have:
|
I just finished the classical simulator (I know that this will be of limited use, but it is still nice to support and wasn't much work). With this I think this PR is ready for merging. |
I'm going to close this PR at this point. We have not come to an agreement on the best way to handle plugins importing their own ops. For initial release, we will go with a simple exposure via the plugin's namespace. We can revisit this question for future releases. |
Allows plugins to supply additional
Operations
andExpectations
, which are then automatically accessible along the standard OpenQML Operations form theopenqml.
andopenqml.expectation.
contexts.The device keeps track of which operations it adds and removes them again when the qfunc ends.
This PR in particular solves #44.
The changes are slightly more extensive than I would have wanted, but nothing dramatic. You will see that if you first merge #64:
Adding an removing operations is done in
device.__enter__()
anddevice.__exit__()
, which are now called again because I have reintroduced awith device:
into the qfunc decorator. (@josh146, please comment on whether this will break other things)I had to move
QuantumFunctionError
toqnode
, where it anyway belongs more naturally, to resolve a dependency loop.