Comments (5)
Status on this? Why was it closed? Has it already been implemented?
from pennylane.
Ah, it was closed by accident. I was attempting to delete it because I messed up the title, and didn't want anyone seeing my mistake 😬
I have been playing around with having operator_map
and observable_map
as class attributes, and here are my thoughts:
-
For the ProjectQ and SF plugins, having an
operator_map
is really natural, as there is a 1-to-1 mapping between OpenQML operations and plugin operations. -
On the other hand, an expectation map is not as natural; for example, in SF, the expectation operations map into SF state methods. One solution would be to create functions within the plugin to allow for this:
def Homodyne(par):
return lambda state, wires: state.quad_expectation(wires, *par)
or something to that effect. These can then be used directly in observable_map
.
Other plugins may have the same issue with operator_map
, resulting in potential spaghetti code. On the other hand, enforcing the use of operator_map
and observable_map
makes the plugin API cleaner - the plugin developer no longer needs to worry about raising DeviceError
if an operation/expectation is not supported, as OpenQML will know by querying the map attributes.
from pennylane.
Looks ok to me.
We won't be able to make too many assumptions about the form of the backends if we want to support as many as possible. It's the job of the plugins to map openqml operators/observables to the relevant backend commands. Sometimes this will use a simple dictionary to map between the two, but in other cases, there might be a few more lines of code (as you illustrated in the lambda
example). This is ok
from pennylane.
Okay, I'll finish this change for the SF and default plugins, and merge tonight.
from pennylane.
from pennylane.
Related Issues (20)
- [BUG] CNOT decomposes to CNOT
- [BUG] Some decompositions/transforms do not preserve derivatives HOT 1
- [BUG] `defer_measurements` does not work with `qml.cond` applied to controlled gates HOT 3
- Define `BasisStateProjector.compute_sparse_matrix` HOT 2
- [BUG] `KerasLayer` has unintended side effects on its QNode HOT 1
- [BUG] Documentation generated does not show the parameters for subclasses of Operation. HOT 1
- Add support for Quantum ESPRESSO HOT 2
- [BUG] `QuantumScript.map_to_standard_wires` sometimes returns original tape HOT 2
- [CHORE] Update `docs/requirements.txt` to reduce package bloat
- [BUG] Differentiation does not work with `dynamic_one_shot`
- [BUG] Different ground states when batching with vmap or calling the function directly HOT 5
- Add `PrepSelPrep` block encoding template HOT 4
- Support variable number of trotter steps in the UCCSD ansatz HOT 12
- [BUG] No warnings or errors are being raised when `shots` argument is passed arbitrarily to `@qnode` with no applicable gradient method HOT 5
- [BUG] `qml.simplify` removes information regarding `num_steps` from `Exp`
- [BUG] QAOA layers incorrectly forbid `Sum` observables
- Add function to convert PennyLane objects to OpenFermion objects HOT 2
- [BUG] Adjoint method does not respect global wires return types
- [BUG] TorchLayer does not work correctly with broadcasting and `tuple` returns HOT 1
- Propagate the gradient to part of an array only HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pennylane.