Giter Site home page Giter Site logo

Comments (12)

co9olguy avatar co9olguy commented on August 20, 2024

I believe this is caused by plugins having a larger set of implemented gates than openqml core. Safe to ignore for now.

At some point we intend to allow plugins to put their own gates in openqml, but I doubt this will make it into the initial release.

from pennylane.

josh146 avatar josh146 commented on August 20, 2024

It could also be typos, I'll double check. Things like Squeeze instead of Squeezing.

from pennylane.

cgogolin avatar cgogolin commented on August 20, 2024

I just had a look a the code and it looks like it should be rather easy to modify the OperationFactory and ExpectationFactory to also load operations/expectations from the plugin scope, such as openqml.plugins.[plugin].ops. Both the ProjectQ and the SF plugin already have custom operations, so that would actually add value. Shall I give that a shot next week or do you want to wait until after 0.1?

from pennylane.

co9olguy avatar co9olguy commented on August 20, 2024

@josh146 this is your area of expertise; what do you think?

from pennylane.

josh146 avatar josh146 commented on August 20, 2024

I think this makes sense - it avoids the user having to import from both openqml and the plugin. There are only two pain points I can think of:

  1. As this is not standard Python packaging behaviour, we'll have to make it very clear how this works in the plugin documentation.

  2. If the user is working in an interactive environment, such as Jupyter, IPython or PyCharm, autocomplete likely won't work on the dynamically generated attributes.

from pennylane.

cgogolin avatar cgogolin commented on August 20, 2024

from pennylane.

josh146 avatar josh146 commented on August 20, 2024

Yep. The user should automatically be able to import it from the plugin if they wanted to, right? In fact, I can't see any obvious issues with them importing one of the current projectq plugin operations, it should just work.

I quite like this approach - I feel like, either way, the user will definitely be able to find the operations

from pennylane.

cgogolin avatar cgogolin commented on August 20, 2024

I looked into this. Some research reveals that __getattr__() does not work on modules below python 3.7. :-( The there are some proposed hacks (see the link), but I am not sure how hacky we want to go here....

from pennylane.

cgogolin avatar cgogolin commented on August 20, 2024

Another option is to use setattr(openqml, 'foo', 'bar'). I didn't expect it, but this can even already be used from __init__() of openqml! I think we can use that to add operations to the openqml context during the initialization of a device, or, maybe even better during in the qfunc decorator. The special operations would then only be accessible via openqml.XXX(...) during a qufunc with a device that actually supports them. I will look into that later today...

from pennylane.

josh146 avatar josh146 commented on August 20, 2024

@cgogolin let me know if you can get that working! My other concern would be what happens if two plugins are loaded with two operations with the same name? Having them accessible only within a particular QNode/device that actually supports them would solve that issue.

Another thing: I've been thinking about test_installed_plugins, and I'm not sure it belongs in OpenQML base. The tests provided with OpenQML should be testing the code provided with OpenQML, such as the operations, gradients, devices, QNodes, and default plugins.

External plugins should be responsible for their own tests, including: making sure that the plugin device works as expected, and that all supported/unsupported operations work. The plugins themselves should not need to test gradients, as that should be covered by the base OpenQML test suite.

Having test_installed_plugins in OpenQML base is problematic, as it can cause the OpenQML test suite to fail depending on external Python packages the user has installed. Alternatively, we should provide a test suite template that plugin developers can use for their own testing purposes, perhaps based on test_default_plugin or the SF/ProjectQ tests.

from pennylane.

cgogolin avatar cgogolin commented on August 20, 2024

Yes, that was my concern as well and this approach would solve this nicely.

I agree that test_installed_plugins should be moved out of the core openqml test suite before release, Please leave it there a little longer, because for the moment it is tremendously useful for me...

from pennylane.

cgogolin avatar cgogolin commented on August 20, 2024

This is fixed in #65. If you like that PR, we can close this issue.

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.