Comments (5)
I might be wrong, as I don't have the time to look into the code carefully, but I think we can get rid of the pre_execute_queued() and post_execute_queued() methods altogether, and just keep the pre/post apply/expectation methods.
I would however suggest to keep all four of the pre/post apply/expectation methods, for symmetry and also because for a plugin developer it can be more logical to put some code in post apply() and some in pre_expectation().
from pennylane.
That's true, I can't really think of anything off the top of my head in SF that needs to be executed outside the context.
So how about this proposal for plugin API simplification? Will this work for the projectQ plugin?
with execution_context():
pre_apply()
for operation in queue:
apply(operation)
post_apply()
pre_expectations()
for observable in observe:
expectation(observable)
post_expectations()
from pennylane.
from pennylane.
Generally I'm on board with clarifying the names as suggested. However, will it be clear what the difference is between pre_execute
and pre_apply
?
from pennylane.
The user has to define the apply
method for how operations are applied to the device during execution, so perhaps that makes it clearer?
Here is the current execution order, using the suggested new nomenclature:
pre_execute()
with execution_context():
pre_apply()
for operation in queue:
apply(operation)
post_apply()
for observable in observe:
expectation(observable)
post_expectations()
post_execute()
Actually, on reading that back, I agree it's a bit confusing.
The key issue here is the context manager, which is only really used by Strawberry Fields and ProjectQ. Without the context manager (i.e. if execution_context
is not overloaded), pre_apply
is the same as pre_execute
, and post_expectations
is the same as post_execute
.
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 3
- [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` HOT 1
- [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.