Giter Site home page Giter Site logo

Comments (5)

co9olguy avatar co9olguy commented on July 20, 2024

Status on this? Why was it closed? Has it already been implemented?

from pennylane.

josh146 avatar josh146 commented on July 20, 2024

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:

  1. 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.

  2. 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.

co9olguy avatar co9olguy commented on July 20, 2024

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.

josh146 avatar josh146 commented on July 20, 2024

Okay, I'll finish this change for the SF and default plugins, and merge tonight.

from pennylane.

josh146 avatar josh146 commented on July 20, 2024

Done in #48 and #49

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.