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

Add pennylane-lightning-kokkos recipe. #22360

Merged
merged 23 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions recipes/pennylane-lightning-kokkos/0001-setup.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/setup.py b/setup.py
index 7429a8e..9a1e2ae 100644
--- a/setup.py
+++ b/setup.py
@@ -108,9 +108,13 @@ if not os.getenv("READTHEDOCS"):
"-DCMAKE_SYSTEM_PROCESSOR=ARM64",
]
else: # X64 arch
- llvmpath = (
- subprocess.check_output(["brew", "--prefix", "llvm"]).decode().strip()
- )
+ if shutil.which("brew"):
+ llvmpath = (
+ subprocess.check_output(["brew", "--prefix", "llvm"]).decode().strip()
+ )
+ else:
+ llvmpath = shutil.which("clang++")
+ llvmpath = Path(llvmpath).parent.parent
configure_args += [
f"-DCMAKE_CXX_COMPILER={llvmpath}/bin/clang++",
f"-DCMAKE_LINKER={llvmpath}/bin/lld",
66 changes: 66 additions & 0 deletions recipes/pennylane-lightning-kokkos/0002-setup.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
diff --git a/setup.py b/setup.py
index 9a1e2ae..a2f77f6 100644
--- a/setup.py
+++ b/setup.py
@@ -65,11 +65,9 @@ if not os.getenv("READTHEDOCS"):
cfg = "Debug" if debug else "Release"
ninja_path = str(shutil.which("ninja"))

- # Set Python_EXECUTABLE instead if you use PYBIND11_FINDPYTHON
configure_args = [
"-DCMAKE_CXX_FLAGS=-fno-lto",
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}",
- f"-DPYTHON_EXECUTABLE={sys.executable}",
f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm
*(self.cmake_defines),
]
@@ -100,27 +98,7 @@ if not os.getenv("READTHEDOCS"):

# Add more platform dependent options
if platform.system() == "Darwin":
- # To support ARM64
- if os.getenv("ARCHS") == "arm64":
- configure_args += [
- "-DCMAKE_CXX_COMPILER_TARGET=arm64-apple-macos11",
- "-DCMAKE_SYSTEM_NAME=Darwin",
- "-DCMAKE_SYSTEM_PROCESSOR=ARM64",
- ]
- else: # X64 arch
- if shutil.which("brew"):
- llvmpath = (
- subprocess.check_output(["brew", "--prefix", "llvm"]).decode().strip()
- )
- else:
- llvmpath = shutil.which("clang++")
- llvmpath = Path(llvmpath).parent.parent
- configure_args += [
- f"-DCMAKE_CXX_COMPILER={llvmpath}/bin/clang++",
- f"-DCMAKE_LINKER={llvmpath}/bin/lld",
- ] # Use clang instead of appleclang
- # Disable OpenMP in M1 Macs
- configure_args += ["-DKokkos_ENABLE_OPENMP=OFF"]
+ pass
elif platform.system() == "Windows":
configure_args += [
"-DKokkos_ENABLE_OPENMP=OFF"
@@ -135,9 +113,18 @@ if not os.getenv("READTHEDOCS"):
os.makedirs(self.build_temp)

subprocess.check_call(
- ["cmake", str(ext.sourcedir)] + configure_args, cwd=self.build_temp
+ ["cmake"]
+ + os.environ["CMAKE_ARGS"].split(" ")
+ + [str(ext.sourcedir)]
+ + configure_args,
+ cwd=self.build_temp,
+ env=os.environ,
+ )
+ subprocess.check_call(
+ ["cmake", "--build", ".", "--verbose"] + build_args,
+ cwd=self.build_temp,
+ env=os.environ,
)
- subprocess.check_call(["cmake", "--build", "."] + build_args, cwd=self.build_temp)


with open("pennylane_lightning_kokkos/_version.py") as f:
66 changes: 66 additions & 0 deletions recipes/pennylane-lightning-kokkos/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{% set name = "pennylane-lightning-kokkos" %}
{% set version = "0.29.1" %}


package:
name: {{ name }}
version: {{ version }}

source:
url: https://github.com/PennyLaneAI/{{ name }}/archive/refs/tags/v{{ version }}.tar.gz
sha256: f51ba7718defc7bb5064f690f381e04b2ec58cb09f22a171ae5f410860716e30
patches:
- 0001-setup.patch
- 0002-setup.patch # [osx]

build:
number: 0
skip: true # [win]
script: |
{{ PYTHON }} setup.py build_ext --define="PLKOKKOS_ENABLE_WARNINGS=OFF"
{{ PYTHON }} setup.py bdist_wheel
{{ PYTHON }} -m pip install . --no-deps -vv
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package installs some unused CMake files into site-packages. Open a patch upstream to remove them for the next release, please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that. The goal is to ship the header templated library along with the binaries. I'll patch the glob expression to fix this, if that alright.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're asking if modifying MANIFEST.in is the correct way to exclude that file. I think it is.


requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- cmake
- ninja
host:
- libgomp # [linux]
- llvm-openmp # [osx]
- kokkos =3.7
- pip
- pybind11
- python
run:
- pennylane >=0.28
- python
test:
imports:
- pennylane_lightning_kokkos
commands:
- python -c "import pennylane as qml; qml.about()"
- pl-device-test --device lightning.kokkos --shots None --skip-ops
- pl-device-test --device lightning.kokkos --shots 10000 --skip-ops
- pip check
requires:
- setuptools
- flaky
- pip
- pytest
- pytest-mock
about:
home: https://docs.pennylane.ai/projects/lightning-kokkos
summary: The PennyLane-Lightning-Kokkos plugin extends the Pennylane-Lightning state-vector simulator written in C++, and offloads to the Kokkos library for accelerated circuit simulation.
license: Apache-2.0
# MIT is pennylane/grouping/graph_colouring.py
license_file: LICENSE
doc_url: https://docs.pennylane.ai/projects/lightning-kokkos/en/latest/devices.html
dev_url: https://github.com/PennyLaneAI/pennylane-lightning-kokkos

extra:
recipe-maintainers:
- vincentmr
feedstock-name: {{ name }}