Update py-pennylane + Lightning plugins + few deps (#43706)

* Update PennyLane packages to v0.32.
* Reformat.
* Couple small fixes.
* Fix Lightning cmake_args.
* Couple dep fixes in py-pennylane + plugins.
* Fix scipy condition.
* Add comment on conflicting requirement.
* Update py-pl versions
* Update lightning versions.
* Fix copyright.
* Fix license.
* Update pl-kokkos versions
* run black
* Fix L-Kokkos build and update autoray.
* build step only required for older versions. update autograd
* Fix LK@0.31 kokkos compat issue. Introduce url_for_version.
* Fix few more version bounds.
This commit is contained in:
Vincent Michaud-Rioux 2024-04-19 14:05:09 -04:00 committed by GitHub
parent 78b5e4cdfa
commit f68ea49e54
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 89 additions and 36 deletions

View file

@ -21,11 +21,17 @@ class PyAutograd(PythonPackage):
examples directory."""
homepage = "https://github.com/HIPS/autograd"
pypi = "autograd/autograd-1.3.tar.gz"
pypi = "autograd/autograd-1.6.2.tar.gz"
license("MIT")
version("1.6.2", sha256="8731e08a0c4e389d8695a40072ada4512641c113b6cace8f4cfbe8eb7e9aedeb")
version("1.6.1", sha256="dd0068f3f78fd76cf28cee94358737c3b5e8a1d2acac0b850e14d14e1bca84ac")
version("1.6", sha256="b10ad7598bab69251a496210370f7802a21da0ae6a7710197eaae99c3a59b30a")
version("1.5", sha256="d80bd225154d1db13cb4eaccf7a18c358be72092641b68717f96fcf1d16acd0b")
version("1.4", sha256="383de0f537ef2e38b85ff9692593b0cfae8958c9b3bd451b52c255fd9171ffce")
version("1.3", sha256="a15d147577e10de037de3740ca93bfa3b5a7cdfbc34cfb9105429c3580a33ec4")
version("1.2", sha256="a08bfa6d539b7a56e7c9f4d0881044afbef5e75f324a394c2494de963ea4a47d")
depends_on("py-setuptools", type="build")
depends_on("py-future@0.15.2:", type=("build", "run"))

View file

@ -15,6 +15,15 @@ class PyAutoray(PythonPackage):
license("Apache-2.0")
version("0.6.9", sha256="9f41759f6a286bc280c4f6aece436da1c87ce75eb00efe7dc7319860c43654fa")
version("0.6.8", sha256="8e31832597cb2075e5f9f65894fafff9d726d9287718415d3c8b008e592f0197")
version("0.6.7", sha256="8945cfdf3aa8a35f9fe1abc03d84925db61f58bbd386623206dd8e9ba1d9e377")
version("0.6.6", sha256="a31cd03f983a6e80b58f40618a652b7979fa09c762050f5dc4b7e6b6a0a3b62d")
version("0.6.5", sha256="093f151539769b03374f67bd2296cf76d359ac190ab6fd8ebe26984a2dc88a4c")
version("0.6.4", sha256="b8e38ff87e2ea1dd8bd17ddd1174f02c41dc4cfec933a3aac9f0516288548e81")
version("0.6.3", sha256="6729f49c8787778fd8bc2a3b57a625c8c21577c6e92628cad4b13aefd7531355")
version("0.6.1", sha256="857cbd4d60d47511ab9956f8765d5fd3c68a538d317cda7d829b00982c599140")
version("0.6.0", sha256="ba3f30812549209bbba9d4976528f3f84bf84c22374699fd2e6aa84bf496d295")
version("0.5.3", sha256="ecbecbc1ab65dd704234b3307fa7c7a511a36f6b9339a0ffcdaa4e5a7aab826b")
depends_on("python@3.6:", type=("build", "run"))

View file

@ -2,8 +2,6 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.package import *
@ -13,21 +11,26 @@ class PyPennylaneLightningKokkos(CMakePackage, PythonExtension, CudaPackage, ROC
homepage = "https://docs.pennylane.ai/projects/lightning-kokkos"
git = "https://github.com/PennyLaneAI/pennylane-lightning-kokkos.git"
url = "https://github.com/PennyLaneAI/pennylane-lightning-kokkos/archive/refs/tags/v0.32.0.tar.gz"
maintainers("AmintorDusko", "vincentmr")
license("Apache-2.0")
version("main", branch="main")
version("master", branch="master")
version("0.35.1", sha256="d39a2749d08ef2ba336ed2d6f77b3bd5f6d1b25292263a41b97943ae7538b7da")
version("0.35.0", sha256="1a16fd3dbf03788e4f8dd510bbb668e7a7073ca62be4d9414e2c32e0166e8bda")
version("0.34.0", sha256="398c3a1d4450a9f3e146204c22329da9adc3f83a1685ae69187f3b25f47824c0")
version("0.33.1", sha256="878f63cd1afadd52386b1aca9c0e3fb0a097b64ce8e347b325ebc7cac722e5e0")
version("0.33.0", sha256="c4cab4a8a1a53edc0990a2a429805dca1c6a46a7ffcc6f77c985b88cd6ff6247")
version("0.32.0", sha256="06f19dfb1073387ef9ee30c38ea44884844a771373256b694a0e1ceb87195bb2")
version("0.31.0", sha256="fe10322fee0fa7df45cd3a81d6c229a79c7dfa7f20ff7d67c65c9a28f494dc89")
version("0.30.0", sha256="7c8f0e0431f8052993cd8033a316f53590c7bf5419445d0725e214b93cbc661b")
version("0.29.1", sha256="f51ba7718defc7bb5064f690f381e04b2ec58cb09f22a171ae5f410860716e30")
depends_on("kokkos@:3.7.2", when="@:0.30", type=("run", "build"))
depends_on("kokkos@4:", when="@0.31:", type=("run", "build"))
depends_on("kokkos@4:4.1", when="@0.31", type=("run", "build"))
depends_on("kokkos@4:4.2", when="@0.32:", type=("run", "build"))
# kokkos backends
backends = {
@ -70,16 +73,20 @@ class PyPennylaneLightningKokkos(CMakePackage, PythonExtension, CudaPackage, ROC
depends_on("cmake@3.20:", type="build")
depends_on("ninja", type="build")
depends_on("python@3.8:", type=("build", "run"))
depends_on("python@3.9:", type=("build", "run"), when="@0.32:")
depends_on("py-setuptools", type="build")
depends_on("py-pybind11", type="link")
depends_on("py-pip", type="build")
depends_on("py-wheel", type="build")
depends_on("py-pennylane@0.28:", type=("build", "run"), when="@:0.30")
depends_on("py-pennylane@0.30:", type=("build", "run"), when="@0.31:")
depends_on("py-pennylane@0.28:0.30", type=("build", "run"), when="@:0.30")
depends_on("py-pennylane@0.30:", type=("build", "run"), when="@0.31")
# This requirement differs from `pennylane>=0.30` in `setup.py`,
# but the introduction of `StatePrep` demands `pennylane>=0.32`
depends_on("py-pennylane@0.32:", type=("build", "run"), when="@0.32:")
depends_on("py-pennylane@0.32:", type=("build", "run"), when="@0.32")
depends_on("py-pennylane-lightning~kokkos", type=("build", "run"), when="@:0.31")
for v in range(33, 36):
depends_on(f"py-pennylane@0.{v}:", type="run", when=f"@0.{v}")
depends_on(f"py-pennylane-lightning@0.{v}", type=("build", "run"), when=f"@0.{v}")
# variant defined dependencies
depends_on("llvm-openmp", when="+openmp %apple-clang")
@ -89,16 +96,27 @@ class PyPennylaneLightningKokkos(CMakePackage, PythonExtension, CudaPackage, ROC
depends_on("py-pytest-mock", type="test")
depends_on("py-flaky", type="test")
def url_for_version(self, version):
extra = "-kokkos" if version <= Version("0.32.0") else ""
return f"https://github.com/PennyLaneAI/pennylane-lightning{extra}/archive/refs/tags/v{version}.tar.gz"
class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
build_directory = "build"
def setup_build_environment(self, env):
env.set("PL_BACKEND", "lightning_kokkos")
cm_args = " ".join([s[2:] for s in self.cmake_args()])
env.set("CMAKE_ARGS", f"{cm_args}")
def cmake_args(self):
"""
Here we specify all variant options that can be dynamically specified at build time
"""
args_prefix = "PLKOKKOS_" if self.spec.version < Version("0.33") else ""
args = [
self.define_from_variant("PLKOKKOS_BUILD_TESTS", "cpptests"),
self.define_from_variant(f"{args_prefix}BUILD_TESTS", "cpptests"),
self.define_from_variant("PLKOKKOS_ENABLE_NATIVE", "native"),
self.define_from_variant("PLKOKKOS_ENABLE_SANITIZER", "sanitize"),
]
@ -108,9 +126,12 @@ def cmake_args(self):
args.append(
"-DPLKOKKOS_ENABLE_WARNINGS=OFF"
) # otherwise build might fail due to Kokkos::InitArguments deprecated
if self.spec.version >= Version("0.33"):
args.append("-DPL_BACKEND=lightning_kokkos")
return args
def build(self, pkg, spec, prefix):
if self.spec.version < Version("0.32"):
super().build(pkg, spec, prefix)
cm_args = ";".join([s[2:] for s in self.cmake_args()])
args = ["-i", f"--define={cm_args}"]

View file

@ -12,13 +12,18 @@ class PyPennylaneLightning(CMakePackage, PythonExtension):
homepage = "https://docs.pennylane.ai/projects/lightning"
git = "https://github.com/PennyLaneAI/pennylane-lightning.git"
url = "https://github.com/PennyLaneAI/pennylane-lightning/archive/refs/tags/v0.32.0.tar.gz"
url = "https://github.com/PennyLaneAI/pennylane-lightning/archive/refs/tags/v0.35.1.tar.gz"
maintainers("mlxd", "AmintorDusko")
maintainers("mlxd", "AmintorDusko", "vincentmr")
license("Apache-2.0")
version("master", branch="master")
version("0.35.1", sha256="d39a2749d08ef2ba336ed2d6f77b3bd5f6d1b25292263a41b97943ae7538b7da")
version("0.35.0", sha256="1a16fd3dbf03788e4f8dd510bbb668e7a7073ca62be4d9414e2c32e0166e8bda")
version("0.34.0", sha256="398c3a1d4450a9f3e146204c22329da9adc3f83a1685ae69187f3b25f47824c0")
version("0.33.1", sha256="878f63cd1afadd52386b1aca9c0e3fb0a097b64ce8e347b325ebc7cac722e5e0")
version("0.33.0", sha256="c4cab4a8a1a53edc0990a2a429805dca1c6a46a7ffcc6f77c985b88cd6ff6247")
version("0.32.0", sha256="124edae1828c7e72e7b3bfbb0e75e98a07a490d7f1eab19eebb3311bfa8a23d4")
version("0.31.0", sha256="b177243625b6fdac0699d163bbc330c92ca87fb9f427643785069273d2a255f6")
version("0.30.0", sha256="0f4032409d20d00991b5d14fe0b2b928baca4a13c5a1b16eab91f61f9273e58d")
@ -64,6 +69,11 @@ class PyPennylaneLightning(CMakePackage, PythonExtension):
class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
build_directory = "build"
def setup_build_environment(self, env):
env.set("PL_BACKEND", "lightning_qubit")
cm_args = " ".join([s[2:] for s in self.cmake_args()])
env.set("CMAKE_ARGS", f"{cm_args}")
def cmake_args(self):
"""
Here we specify all variant options that can be dynamicaly specified at build time
@ -74,9 +84,10 @@ def cmake_args(self):
self.define_from_variant("ENABLE_BLAS", "blas"),
self.define_from_variant("CMAKE_VERBOSE_MAKEFILE:BOOL", "verbose"),
self.define_from_variant("BUILD_TESTS", "cpptests"),
self.define_from_variant("BUILD_BENCHMARKS", "cppbenchmarks"),
self.define_from_variant("ENABLE_GATE_DISPATCHER", "dispatcher"),
]
if self.spec.version < Version("0.32"):
args.append(self.define_from_variant("BUILD_BENCHMARKS", "cppbenchmarks"))
if "+kokkos" in self.spec:
args += [
@ -90,14 +101,10 @@ def cmake_args(self):
return args
def build(self, pkg, spec, prefix):
if self.spec.version < Version("0.32"):
super().build(pkg, spec, prefix)
cm_args = ";".join(
[
s[2:]
for s in self.cmake_args()
if s[2:] not in ["BUILD_TESTS:BOOL=ON", "BUILD_BENCHMARKS:BOOL=ON"]
]
)
skipped_args = ["BUILD_TESTS:BOOL=ON", "BUILD_BENCHMARKS:BOOL=ON"]
cm_args = ";".join([s[2:] for s in self.cmake_args() if s[2:] not in skipped_args])
args = ["-i", f"--define={cm_args}"]
python("setup.py", "build_ext", *args)

View file

@ -12,13 +12,18 @@ class PyPennylane(PythonPackage):
homepage = "https://docs.pennylane.ai/"
git = "https://github.com/PennyLaneAI/pennylane.git"
url = "https://github.com/PennyLaneAI/pennylane/archive/refs/tags/v0.32.0.tar.gz"
url = "https://github.com/PennyLaneAI/pennylane/archive/refs/tags/v0.35.1.tar.gz"
maintainers("mlxd", "AmintorDusko", "marcodelapierre")
maintainers("mlxd", "AmintorDusko", "marcodelapierre", "vincentmr")
license("Apache-2.0")
version("master", branch="master")
version("0.35.1", sha256="5a234d0605012f3d0201fdcfd2bfe84205a09c8ac42801fe7123eddddec71366")
version("0.35.0", sha256="3b99185661e8a0d0f7bc2dcc9cfa51dde20e99708c3c7d858c4732f0eb774716")
version("0.34.0", sha256="f76f544212c028a8f882ce7f66639e7f7c4c9213277bde0454c7f3a7d9d46538")
version("0.33.1", sha256="89d02bfe3a37abd13dcdb2f34f00a38e9e60a13af66a97911c8558f77ff4e32e")
version("0.33.0", sha256="b41c843a432c5869fc63dc35c9e9d53bec64d296ca0e0eeb1c9b83d95a68c3f1")
version("0.32.0", sha256="8a2206268d7cae0a59f9067b6075175eec93f4843519b371f02716c49a22e750")
version("0.31.0", sha256="f3b68700825c120e44434ed2b2ab71d0be9d3111f3043077ec0598661ec33477")
version("0.30.0", sha256="7fe4821fbc733e3e40d7011e054bd2e31edde3151fd9539025c827a5a3579d6b")
@ -28,10 +33,12 @@ class PyPennylane(PythonPackage):
depends_on("python@3.9:", type=("build", "run"), when="@0.32.0:")
depends_on("py-pip", type=("build", "run")) # Runtime req for pennylane.about()
depends_on("py-setuptools", type="build")
depends_on("py-setuptools", type=("build", "run"), when="@0.33")
depends_on("py-numpy@:1.23", type=("build", "run"))
depends_on("py-numpy", type=("build", "run"))
depends_on("py-numpy@:1.23", type=("build", "run"), when="@:0.32.0")
depends_on("py-scipy", type=("build", "run"))
depends_on("py-scipy@:1.10", type=("build", "run"), when="@:0.31.0")
depends_on("py-scipy@:1.10.0", type=("build", "run"), when="@:0.31")
depends_on("py-networkx", type=("build", "run"))
depends_on("py-rustworkx", type=("build", "run"), when="@0.30.0:")
depends_on("py-retworkx", type=("build", "run"), when="@0.28.0:0.29.1")
@ -39,21 +46,24 @@ class PyPennylane(PythonPackage):
depends_on("py-toml", type=("build", "run"))
depends_on("py-appdirs", type=("build", "run"))
depends_on("py-semantic-version@2.7:", type=("build", "run"))
depends_on("py-autoray@0.3.1:", type=("build", "run"))
depends_on("py-autoray@0.3.1:", type=("build", "run"), when="@:0.32.0")
depends_on("py-autoray@0.6.1:", type=("build", "run"), when="@0.33.0:")
depends_on("py-cachetools", type=("build", "run"))
for v in range(30, 33):
depends_on(f"py-pennylane-lightning@0.{v}.0:", type=("build", "run"), when=f"@0.{v}.0:")
depends_on(
"py-pennylane-lightning@0.28.0:0.29.0", type=("build", "run"), when="@0.28.0:0.29.1"
)
for v in range(30, 36):
depends_on(f"py-pennylane-lightning@0.{v}:", type=("build", "run"), when=f"@0.{v}:")
depends_on("py-requests", type=("build", "run"))
depends_on("py-typing-extensions", type=("build", "run"), when="@0.32.0:")
# Test deps
# The following packages are required by the `pl-device-test binary`
depends_on("py-pytest", type="test")
depends_on("py-pytest-xdist@3.2:", type="test")
depends_on("py-pytest-mock", type="test")
depends_on("py-flaky", type="test")
depends_on("py-pytest-benchmark", type="test", when="@0.34.0:")
# Additional test deps
depends_on("py-pytest-xdist@3.2:", type="test")
@run_after("install")
@on_package_attributes(run_tests=True)