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

Segmentation fault with lightning kokkos and 0 qubits. #751

Closed
erick-xanadu opened this issue Jun 5, 2024 · 1 comment · Fixed by #757
Closed

Segmentation fault with lightning kokkos and 0 qubits. #751

erick-xanadu opened this issue Jun 5, 2024 · 1 comment · Fixed by #757

Comments

@erick-xanadu
Copy link
Contributor

With lightning.qubit and default.qubit:

>>> dev = qml.device("lightning.qubit", 0)
>>> qml.qnode(dev)(lambda : qml.state())()
tensor([1.+0.j], requires_grad=True)

With kokkos

>>> dev = qml.device("lightning.kokkos", 0)
Kokkos::OpenMP::initialize WARNING: OMP_PROC_BIND environment variable not set
  In general, for best performance with OpenMP 4.0 or better set OMP_PROC_BIND=spread and OMP_PLACES=threads
  For best performance with OpenMP 3.1 set OMP_PROC_BIND=true
  For unit testing set OMP_PROC_BIND=false

>>> qml.qnode(dev)(lambda : qml.state())()
Segmentation fault (core dumped)
@maliasadi
Copy link
Member

Thanks @erick-xanadu! The following patch will fix the issue,

--- a/pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp
+++ b/pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp
@@ -111,10 +111,9 @@ class StateVectorKokkos final
                 Kokkos::initialize(kokkos_args);
             }
         }
-        if (num_qubits > 0) {
-            data_ = std::make_unique<KokkosVector>("data_", exp2(num_qubits));
-            setBasisState(0U);
-        }
+
+        data_ = std::make_unique<KokkosVector>("data_", exp2(num_qubits));
+        setBasisState(0U);
     };

maliasadi added a commit that referenced this issue Jun 7, 2024
… of control_wires in ctrl_decomp_zyz (#757)

### Before submitting

Please complete the following checklist when submitting a PR:

- [x] All new features must include a unit test.
If you've fixed a bug or added code that should be tested, add a test to
the
      [`tests`](../tests) directory!

- [x] All new functions and code must be clearly commented and
documented.
If you do make documentation changes, make sure that the docs build and
      render correctly by running `make docs`.

- [ ] Ensure that the test suite passes, by running `make test`.

- [x] Add a new entry to the `.github/CHANGELOG.md` file, summarizing
the
      change, and including a link back to the PR.

- [x] Ensure that code is properly formatted by running `make format`. 

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


------------------------------------------------------------------------------------------------------------

**Context:**
- [X] Fix the issue with initializing `lightning.kokkos` with zero-qubit
and
- [X] Invalid number of control_wires in ctrl_decomp_zyz (PR
PennyLaneAI/pennylane#5735)
- [x] Add test for `device('lightning.kokkos', wires=0)`

**Description of the Change:**

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**
Fixes #751

---------

Co-authored-by: ringo-but-quantum <github-ringo-but-quantum@xanadu.ai>
multiphaseCFD pushed a commit that referenced this issue Jun 7, 2024
… of control_wires in ctrl_decomp_zyz (#757)

Please complete the following checklist when submitting a PR:

- [x] All new features must include a unit test.
If you've fixed a bug or added code that should be tested, add a test to
the
      [`tests`](../tests) directory!

- [x] All new functions and code must be clearly commented and
documented.
If you do make documentation changes, make sure that the docs build and
      render correctly by running `make docs`.

- [ ] Ensure that the test suite passes, by running `make test`.

- [x] Add a new entry to the `.github/CHANGELOG.md` file, summarizing
the
      change, and including a link back to the PR.

- [x] Ensure that code is properly formatted by running `make format`.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.

------------------------------------------------------------------------------------------------------------

**Context:**
- [X] Fix the issue with initializing `lightning.kokkos` with zero-qubit
and
- [X] Invalid number of control_wires in ctrl_decomp_zyz (PR
PennyLaneAI/pennylane#5735)
- [x] Add test for `device('lightning.kokkos', wires=0)`

**Description of the Change:**

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**
Fixes #751

---------

Co-authored-by: ringo-but-quantum <github-ringo-but-quantum@xanadu.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants