Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noise channels do not validate parameter values, leading to errors #1337

Closed
nahumsa opened this issue May 19, 2021 · 3 comments · Fixed by #1357
Closed

Noise channels do not validate parameter values, leading to errors #1337

nahumsa opened this issue May 19, 2021 · 3 comments · Fixed by #1357
Assignees
Labels
bug 🐛 Something isn't working

Comments

@nahumsa
Copy link
Contributor

nahumsa commented May 19, 2021

Issue description

Description of the issue - include code snippets and screenshots here
if relevant. You may use the following template below

  • Expected behavior: Raise an error showing that the probability (or sum of probabilities) are not compatible with the expected channel behaviour.

  • Actual behavior: Raises a RuntimeWarning for an invalid value encountered in sqrt.

  • Reproduces how often: 100%

  • System information:

  • Name: PennyLane
    Version: 0.16.0.dev0
    Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
    Home-page: https://github.com/XanaduAI/pennylane
    Author: None
    Author-email: None
    License: Apache License 2.0
    Location: /home/nahum/Documents/pennylane-training/pen-env/lib/python3.6/site-packages
    Requires: scipy, toml, appdirs, autoray, semantic-version, networkx, autograd, numpy
    Required-by: PennyLane-qiskit
    Platform info: Linux-5.4.0-73-generic-x86_64-with-debian-buster-sid
    Python version: 3.6.8
    Numpy version: 1.19.5
    Scipy version: 1.5.4
    Installed devices:

  • default.gaussian (PennyLane-0.16.0.dev0)
  • default.mixed (PennyLane-0.16.0.dev0)
  • default.qubit (PennyLane-0.16.0.dev0)
  • default.qubit.autograd (PennyLane-0.16.0.dev0)
  • default.qubit.jax (PennyLane-0.16.0.dev0)
  • default.qubit.tf (PennyLane-0.16.0.dev0)
  • default.tensor (PennyLane-0.16.0.dev0)
  • default.tensor.tf (PennyLane-0.16.0.dev0)
  • qiskit.aer (PennyLane-qiskit-0.15.0)
  • qiskit.basicaer (PennyLane-qiskit-0.15.0)
  • qiskit.ibmq (PennyLane-qiskit-0.15.0)

Source code and tracebacks

from pennylane.ops.channel import AmplitudeDamping

print(AmplitudeDamping(2, wires=0).kraus_matrices)
pennylane/ops/channel.py:61: RuntimeWarning: invalid value encountered in sqrt
  K0 = np.diag([1, np.sqrt(1 - gamma)])
[array([[ 1.,  0.],
       [ 0., nan]]), array([[0.        , 1.41421356],
       [0.        , 0.        ]])]
@josh146
Copy link
Member

josh146 commented May 19, 2021

Thanks for reporting this @nahumsa!

Could you post the code that created this error? It will help us track down the noisy channel that is causing this bug.

(and if you already have a solution, feel free to make a PR!)

@josh146 josh146 added the bug 🐛 Something isn't working label May 19, 2021
@josh146 josh146 changed the title Noise channels accepting probabilities > 0 Noise channels do not validate parameter values, leading to errors May 19, 2021
@nahumsa
Copy link
Contributor Author

nahumsa commented May 19, 2021

Hi @josh146. Actually, all noise channels have this error, thus maybe the solution can be on the Channel base class. I have added the code sample to reproduce the error.

I plan on making a PR for this issue later this week. 😄

@josh146
Copy link
Member

josh146 commented May 19, 2021

I plan on making a PR for this issue later this week. 😄

Nice, great to hear 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants