Giter Club home page Giter Club logo

Comments (5)

antalszava avatar antalszava commented on June 5, 2024 1

Hi @mlxd, thanks for the explanation for taking a look! :) The example came up during a discussion, rather than as something that the plugin should support. It was surprising to see the error, as the snippet seems to execute well with the latest master version (not with the released version though). There might be perhaps some new updates that allow this to work. All in all, I think this would not be something that lightning should definitely support at the moment.

from pennylane-lightning.

mlxd avatar mlxd commented on June 5, 2024 1

Can this be closed?

from pennylane-lightning.

trbromley avatar trbromley commented on June 5, 2024

Hey @ankit27kh and thanks for sharing!

Looking through the code you shared, the error may be linked to defining the custom MyRX gate. Please could you confirm whether the following successfully provides the gradient:

import pennylane as qml
from pennylane import numpy as np

dev = qml.device('lightning.qubit', wires=1)

@qml.qnode(dev)
def circuit(x):
    qml.RX(x, wires=0)
    return qml.expval(qml.PauliZ(0))

par = np.array(0.3)
qml.grad(circuit)(par)

Regarding the use of the custom MyRX gate, I'm curious what the use case is? It might be useful to check out the available operations in PennyLane. If you have an arbitrary unitary, you may want to consider using qml.QubitUnitary.

Hope this helps!

from pennylane-lightning.

antalszava avatar antalszava commented on June 5, 2024

Hi @trbromley, this code was created to show a particular example for when we specify diff_method='best' and use finite differences to estimate the gradient. MyRX was created as an example of an operation that doesn't support analytic gradients. See the original comment here.

from pennylane-lightning.

mlxd avatar mlxd commented on June 5, 2024

Hi @antalszava. Lightning's current design will not support the use of custom gates in this way, as we intended to allow use of the supported gate-set and anything else to require use of the explicit matrix for custom gates. This is due to the gate-set being built as const at compile time.

Is the above example something we should be supporting?

from pennylane-lightning.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.