Giter VIP home page Giter VIP logo

Comments (3)

albi3ro avatar albi3ro commented on June 25, 2024 1

@josh146 Yes it does.

Minimal non-working example:

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

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

jax.vmap(circuit)(jax.numpy.array([0.5, 0.6, 0.7]))

from pennylane.

albi3ro avatar albi3ro commented on June 25, 2024

Thanks for opening this issue @lauracappelli . We'll try and get a fix in for the next release coming out on March 5th.

The problematic line of code is this:

out = jax.pure_callback(pure_callback_wrapper, shape_dtype_structs, params, vectorized=True)

This works for default.qubit because it does actually support native broadcasting. Most device don't, and use qml.transforms.broadcast_expand during the preprocessing step (Device.preprocess or Device.batch_transform). The problem is that jax is trying to add a batch dimension after we already handled any native broadcasting.

In the short-term, we just update the above line to be:

    out = jax.pure_callback(pure_callback_wrapper, shape_dtype_structs, params, vectorized=device.name == "default.qubit")

Though in the longer term, we should rethink jax.vmap and where we handle parameter broadcasting in pennylane.

from pennylane.

josh146 avatar josh146 commented on June 25, 2024

@albi3ro would this bug also impact lightning.qubit?

from pennylane.

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.