Comments (4)
Seconded!
from pennylane.
I'm in two minds about this. On the one hand, qm.Gate(p1, p2) | [wire1, wire2]
is easier to parse/read, and is close to the style of Strawberry Fields and ProjectQ.
However, in the 'spirit'(?) of OpenQML, I would personally prefer to keep the syntax as 'pythonic' as we could, without overloading operators with a more commonly known use - a beginner or someone with a
a computer science/software engineering background would be more familiar with the 'bitwise or' behaviour of |
, and would likely not recognise the pseudo-braket notation. By keeping everything as a function call and avoiding custom operator definitions, it is similar in style to NumPy np.func(..., axis=[1,2])
, SciPy, TensorFlow, and OpenFermion (of.Hubbard(operators=...)
).
(Avoiding the |
syntax in OpenQML also helps keep the library quantum assembly language agnostic when working with other industry partners with their own quantum assembly language, otherwise it might appear we are co-opting Blackbird.)
An alternative third approach would be to use an operator that currently does not have any explicit action on standard Python objects. Since we are targeting only Python 3.5+ with OpenQML, we could use the @
operator, which invokes the __matmul__()
method:
def circuit(weights):
qm.Gate(weights) @ [wire1, wire2]
Another thing to be considered - assuming we choose to overload an operator, do we make explicit wire
objects, analogous to the RegRef
of Strawberry Fields? Or simply act the gate on a list of integers? I'm inclined to suggest just a list/tuple of integers in version 0.1, to avoid additional code complexity.
from pennylane.
I would use a list of ints to refer to subsystems/wires for simplicity, since there's no need for the extra functionality provided by the RegRefs.
I think I'd prefer |
over the @
operator just because it avoids syntax proliferation (|
is used not only in Blackbird but also in ProjectQ, so we cannot really be accused of pushing our own conventions, we joined an existing "standard"). I don't think operator overloading is a problem in itself, it's relatively common and easy to explain it in the docs. In Python __or__
is only defined for ints, so there shouldn't be much room for error.
Lastly and least importantly, since @
is matrix multiplication, semantically it may be a bit misleading since [w1, w2] does not represent a ket vector but a subsystem reference?
from pennylane.
As @josh146 mentioned, the design philosophy of openqml is to be as close to numpy/tensorflow/scipy etc as possible, with the goal of making things more accessible for ML-only people to give it a shot.
We will stick with the standard pythonic way of calling ops, without overloading any operators
from pennylane.
Related Issues (20)
- [BUG] Loading the MQT Bench dataset does not work as expected. HOT 1
- [BUG] Array indexing error when sampling after mid-circuit measurements are performed on other wires HOT 3
- NotImplementedError: VJP of eigvals wrt argnums (0,) not defined[BUG] HOT 2
- Implement `Hermitian.decomposition`
- [BUG] `qml.center` does not work for all linear combinations of Paulis
- [BUG] JAX JIT errors-out when using a tracer-based PRNG key HOT 4
- [BUG] WireError when computing quantum fisher info of mixed state HOT 2
- `qml.lie_closure` often raises `LinAlgError: Singular matrix` HOT 6
- [BUG] Class method hyperlinks don't work in PL docs
- [BUG] imaginary part of expectation values of observables with complex coefficients is silently discarded HOT 5
- [BUG] TorchLayer doesn't work with diff_method='parameter-shift'
- [Regression] Restore good performance when requesting many individual shots HOT 1
- Add `is_leaf`optional keyword argument to `qml.pytrees.flatten` HOT 4
- specify dtype for "default.qubit" [BUG] HOT 10
- [BUG] qml.shadows.shadow_expval raises an exception HOT 2
- [BUG] `pattern_matching_optimization` eliminates all measurements HOT 2
- [BUG] Incorrect documentation in `mitigate_with_zne`
- Distributive property is not correctly applied without `simplify`
- [BUG] Probabilities not summing to 1 on `default.qubit`
- [BUG] `qml.qsvt` throws `UnboundLocalError` with `convention = Wx` 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.