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

Issue when using batched data on StronglyEntanglingLayers template.[BUG] #5695

Closed
1 task done
BenYyyyyy opened this issue May 16, 2024 · 3 comments · Fixed by #5716
Closed
1 task done

Issue when using batched data on StronglyEntanglingLayers template.[BUG] #5695

BenYyyyyy opened this issue May 16, 2024 · 3 comments · Fixed by #5716
Assignees
Labels
bug 🐛 Something isn't working

Comments

@BenYyyyyy
Copy link

Expected behavior

I want to use the StronglyEntanglingLayers template to process batched data. the shape of the data is like [batch_size, layers, wires, 3].

Actual behavior

Some errors happened:

.../pennylane/templates/layers/strongly_entangling.py", line 209, in compute_decomposition
    weights[..., l, i, 0],
IndexError: index 10 is out of bounds for dimension 1 with size 10

Additional information

I check the strongly_entangling.py and find this bug may comes from this code:

201 line:  n_layers = qml.math.shape(weights)[0]

the correct code may be

201 line:  n_layers = qml.math.shape(weights)[-3]

Source code

No response

Tracebacks

No response

System information

I run pennylane on the server, and the bug I think is not related to the system.

Existing GitHub issues

  • I have searched existing GitHub issues to make sure the issue does not already exist.
@BenYyyyyy BenYyyyyy added the bug 🐛 Something isn't working label May 16, 2024
@trbromley
Copy link
Contributor

Thanks @BenYyyyyy for posting! This does sound like a bug, we'll take a look and get back to you.

Would you be able to share the output of qml.about() or at least qml.version() to help us troubleshoot?

@BenYyyyyy
Copy link
Author

Thanks @BenYyyyyy for posting! This does sound like a bug, we'll take a look and get back to you.

Would you be able to share the output of qml.about() or at least qml.version() to help us troubleshoot?

Platform info: Linux-5.14.21-150400.24.81_12.0.75-cray_shasta_c-x86_64-with-glibc2.31
Python version: 3.9.16
Numpy version: 1.23.5
Scipy version: 1.12.0
Installed devices:

  • default.gaussian (PennyLane-0.30.0)
  • default.mixed (PennyLane-0.30.0)
  • default.qubit (PennyLane-0.30.0)
  • default.qubit.autograd (PennyLane-0.30.0)
  • default.qubit.jax (PennyLane-0.30.0)
  • default.qubit.tf (PennyLane-0.30.0)
  • default.qubit.torch (PennyLane-0.30.0)
  • default.qutrit (PennyLane-0.30.0)
  • null.qubit (PennyLane-0.30.0)
  • lightning.qubit (PennyLane-Lightning-0.31.0)

@CatalinaAlbornoz
Copy link
Contributor

Thanks for sharing this info @BenYyyyyy . I see that you're not using the latest version of PennyLane. Are you able to update it to v0.36 which is our current version? My colleague David is working on a fix for your bug but you'll need to update PennyLane in order to be able to use it.

You can run pip install pennylane --upgrade

dwierichs added a commit that referenced this issue May 24, 2024
)

**Context:**
The decomposition of `StronglyEntanglingLayers` "almost" takes
broadcasting into account: The indexing into the `weights` tensor is
fine, but the number of layers is not determined correctly, leading to
flawed indexing, and in particular to #5695.

**Description of the Change:**
Fix the `n_layers` determined from `weights` in `compute_decomposition`.

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**
Fixes #5695 

[sc-63457]
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.

4 participants