qBraid / community

Where qBraid users discuss, report bugs and submit feature requests.
MIT License
4 stars 0 forks source link

[BUG] PennyLane-Qiskit isn't installing #28

Open CatalinaAlbornoz opened 10 months ago

CatalinaAlbornoz commented 10 months ago

Describe the bug When I run !pip install pennylane-qiskit in a new notebook it says the plugin is successfully installed. However when I run "qml.about()" none of the qiskit devices are installed and when I try to run anything requiring the plugin it shows the following error: DeviceError("Device does not exist. Make sure the required plugin is installed.")

To Reproduce Steps to reproduce the behavior:

  1. Create a new notebook in the qBraid lab
  2. Run !pip install pennylane-qiskit
  3. Run:
    
    import pennylane as qml
    qml.about()

dev = qml.device('qiskit.aer', wires=2) @qml.qnode(dev) def circuit(): qml.Hadamard(wires=0) qml.CNOT(wires=[0,1]) return qml.state()

result = circuit() result

4. See error:

Name: PennyLane Version: 0.31.1 Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc. Home-page: https://github.com/PennyLaneAI/pennylane Author: Author-email: License: Apache License 2.0 Location: /opt/.qbraid/environments/qbraid_000000/pyenv/lib/python3.9/site-packages Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions Required-by: amazon-braket-pennylane-plugin, PennyLane-Lightning

Platform info: Linux-5.15.0-1036-gke-x86_64-with-glibc2.31 Python version: 3.9.12 Numpy version: 1.23.5 Scipy version: 1.11.1 Installed devices:

File /opt/.qbraid/environments/qbraid_000000/pyenv/lib/python3.9/site-packages/pennylane/init.py:350, in device(name, *args, **kwargs) 346 dev.custom_expand(custom_decomp_expand_fn) 348 return dev --> 350 raise DeviceError("Device does not exist. Make sure the required plugin is installed.")

DeviceError: Device does not exist. Make sure the required plugin is installed.

5. If I additionally try to install qiskit-aer using `!pip install qiskit-aer` I get a version conflict when running the same code as before.

ContextualVersionConflict Traceback (most recent call last) Cell In[1], line 4 1 import pennylane as qml 2 qml.about() ----> 4 dev = qml.device('qiskit.aer', wires=2) 5 @qml.qnode(dev) 6 def circuit(): 7 qml.Hadamard(wires=0)

File /opt/.qbraid/environments/qbraid_000000/pyenv/lib/python3.9/site-packages/pennylane/init.py:329, in device(name, *args, **kwargs) 326 options.update(kwargs) 328 # loads the device class --> 329 plugin_device_class = plugin_devices[name].load() 331 if Version(version()) not in SimpleSpec(plugin_device_class.pennylane_requires): 332 raise DeviceError( 333 f"The {name} plugin requires PennyLane versions {plugin_device_class.pennylane_requires}, " 334 f"however PennyLane version {version} is installed." 335 )

File /opt/.qbraid/environments/qbraid_000000/pyenv/lib/python3.9/site-packages/pkg_resources/init.py:2449, in EntryPoint.load(self, require, *args, *kwargs) 2442 warnings.warn( 2443 "Parameters to load are deprecated. Call .resolve and " 2444 ".require separately.", 2445 PkgResourcesDeprecationWarning, 2446 stacklevel=2, 2447 ) 2448 if require: -> 2449 self.require(args, **kwargs) 2450 return self.resolve()

File /opt/.qbraid/environments/qbraid_000000/pyenv/lib/python3.9/site-packages/pkg_resources/init.py:2472, in EntryPoint.require(self, env, installer) 2466 # Get the requirements for this entry point with all its extras and 2467 # then resolve them. We have to pass extras along when resolving so 2468 # that the working set knows what extras we want. Otherwise, for 2469 # dist-info distributions, the working set will assume that the 2470 # requirements for that extra are purely optional and skip over them. 2471 reqs = self.dist.requires(self.extras) -> 2472 items = working_set.resolve(reqs, env, installer, extras=self.extras) 2473 list(map(working_set.add, items))

File /opt/.qbraid/environments/qbraid_000000/pyenv/lib/python3.9/site-packages/pkg_resources/init.py:777, in WorkingSet.resolve(self, requirements, env, installer, replace_conflicting, extras) 774 if dist not in req: 775 # Oops, the "best" so far conflicts with a dependency 776 dependent_req = required_by[req] --> 777 raise VersionConflict(dist, req).with_context(dependent_req) 779 # push the new requirements onto the stack 780 new_requirements = dist.requires(req.extras)[::-1]

ContextualVersionConflict: (qiskit-terra 0.25.0 (/opt/.qbraid/environments/qbraid_000000/pyenv/lib/python3.9/site-packages), Requirement.parse('qiskit-terra==0.25.1'), {'qiskit'})


**Expected behavior**
Getting a statevector when I run the code.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
 - Browser: chrome

**Additional context**
It's not just the qiskit-aer device. Using `qml.from_qasm()` also doesn't work.
rryoung98 commented 4 months ago

Thanks! @ryanhill1 did we resolve this?

kanavsetia commented 3 months ago

@CatalinaAlbornoz Thank you for bringing this to our notice!

I would suggest using the pennylane environment in the environment manager in which pennylane-qiskit package should already be present along with pennylane. If not you can use:

%pip install pennylane-qiskit instead of !pip install pennylane-qiskit

I tested out the code you put in and I am able to see the following output:

Version: 0.35.0
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page: https://github.com/PennyLaneAI/pennylane
Author: 
Author-email: 
License: Apache License 2.0
Location: /home/jovyan/.qbraid/environments/xanadu_fil4xi/pyenv/lib/python3.9/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions
Required-by: amazon-braket-pennylane-plugin, PennyLane-qiskit, PennyLane_Lightning

Platform info:           Linux-5.15.146+-x86_64-with-glibc2.35
Python version:          3.9.18
Numpy version:           1.23.0
Scipy version:           1.8.0
Installed devices:
- default.clifford (PennyLane-0.35.0)
- default.gaussian (PennyLane-0.35.0)
- default.mixed (PennyLane-0.35.0)
- default.qubit (PennyLane-0.35.0)
- default.qubit.autograd (PennyLane-0.35.0)
- default.qubit.jax (PennyLane-0.35.0)
- default.qubit.legacy (PennyLane-0.35.0)
- default.qubit.tf (PennyLane-0.35.0)
- default.qubit.torch (PennyLane-0.35.0)
- default.qutrit (PennyLane-0.35.0)
- null.qubit (PennyLane-0.35.0)
- qiskit.aer (PennyLane-qiskit-0.23.0)
- qiskit.basicaer (PennyLane-qiskit-0.23.0)
- qiskit.ibmq (PennyLane-qiskit-0.23.0)
- qiskit.ibmq.circuit_runner (PennyLane-qiskit-0.23.0)
- qiskit.ibmq.sampler (PennyLane-qiskit-0.23.0)
- lightning.qubit (PennyLane-Lightning-0.35.0)
- braket.aws.qubit (amazon-braket-pennylane-plugin-1.6.6)
- braket.local.qubit (amazon-braket-pennylane-plugin-1.6.6)

Let me know if this solves your problem and we can close this issue! Thanks!