PennyLaneAI / pennylane-lightning

The PennyLane-Lightning plugin provides a fast state-vector simulator written in C++ for use with PennyLane
https://docs.pennylane.ai/projects/lightning
Apache License 2.0
83 stars 35 forks source link

Memory segfaults with initializing 'lightning.kokkos' after 'lightning.qubit' on macOS (x86_64) #552

Open maliasadi opened 10 months ago

maliasadi commented 10 months ago

Running the following script on macOS x86_64 using PL-Lightning and PL-Lightning-Kokkos version 0.33.1 (installed via pip) will lead to memory segfaults. These segfaults are related to the initialization of the "lightning.kokkos" state vector.

import pennylane as qml
import pytest

def workflow1():
    @qml.qnode(qml.device("lightning.qubit", wires=1))
    def f(x):
        qml.RX(x, wires=0)
        return qml.expval(qml.PauliZ(wires=0))

    f(0.2)

def workflow2():
    @qml.qnode(qml.device("lightning.kokkos", wires=1))
    def g(x):
        qml.RX(x, wires=0)
        return qml.expval(qml.PauliZ(wires=0))

    g(0.2)

if __name__ == "__main__":
    pytest.main(["-x", __file__])

A few notes:

I could reproduce this by building lightning.qubit and lightning.kokkos on the machine from src, and with using lldb, it seems that the issue is propagated from Kokkos vector kernels. I didn't dig more to see if this is related to the Lightning implementation or Kokkos kernels.

dime10 commented 2 months ago

Does anyone know if this is still an issue?

erick-xanadu commented 1 month ago

I noticed that our wheels do not use the same kokkos version than the one used in check-catalyst, I'll keep a note of this and maybe we can investigate after StatePrep is merged. See here: https://github.com/PennyLaneAI/catalyst/pull/955/commits/507302c42d96a2f6f1eac774096f6cfa54ebc639