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

Revert openblas linking changes from #451 #1386

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 7 additions & 3 deletions .github/workflows/build-wheel-macos-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
- name: Checkout Catalyst repo
uses: actions/checkout@v4

# Python 3.10 was dropped from the GH images on macOS arm
- name: Install Python 3.10
uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -235,8 +236,10 @@ jobs:
- name: Checkout Catalyst repo
uses: actions/checkout@v4

# Python 3.10 was dropped from the GH images on macOS arm
- name: Install Python 3.10
uses: actions/setup-python@v5
if: ${{ matrix.python_version }} == '3.10'
with:
python-version: '3.10'

Expand Down Expand Up @@ -418,10 +421,12 @@ jobs:
- name: Checkout Catalyst repo
uses: actions/checkout@v4

- name: Install Python ${{ matrix.python_version }}
# Python 3.10 was dropped from the GH images on macOS arm
- name: Install Python 3.10
uses: actions/setup-python@v5
if: ${{ matrix.python_version }} == '3.10'
with:
python-version: ${{ matrix.python_version }}
python-version: '3.10'

- name: Download Wheel Artifact
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -453,7 +458,6 @@ jobs:
python${{ matrix.python_version }} -m pip install PennyLane-Lightning-Kokkos
python${{ matrix.python_version }} -m pip install 'amazon-braket-pennylane-plugin>1.27.1'


- name: Install OQC client
run: |
python${{ matrix.python_version }} -m pip install oqc-qcaas-client
Expand Down
37 changes: 17 additions & 20 deletions frontend/catalyst/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,25 +121,24 @@ def get_default_flags(options):
path_within_package = "lib"
file_extension = ".so" if platform.system() == "Linux" else ".dylib" # pragma: no branch

package_spec = importlib.util.find_spec(package_name)
package_directory = path.dirname(package_spec.origin)
lapack_lib_path = path.join(package_directory, path_within_package)

search_pattern = path.join(lapack_lib_path, f"lib*{lib_name}*{file_extension}")
search_result = glob.glob(search_pattern)
if not search_result: # pragma: nocover
raise CompileError(
f'Unable to find OpenBLAS library at "{search_pattern}". '
"Please ensure that scipy is installed and available via pip."
)

lib_path_flags += [f"-Wl,-rpath,{lapack_lib_path}", f"-L{lapack_lib_path}"]
lapack_lib_name = path.basename(search_result[0])[3 : -len(file_extension)]

lapack_libs = [lapack_lib_name]
if platform.system() == "Darwin" and platform.machine() == "arm64": # pragma: nocover
# use our own build of LAPACKe to interface with Accelerate
lapack_libs += ["lapacke.3"]
lapack_lib_name = "lapacke.3"
else:
package_spec = importlib.util.find_spec(package_name)
package_directory = path.dirname(package_spec.origin)
lapack_lib_path = path.join(package_directory, path_within_package)

search_pattern = path.join(lapack_lib_path, f"lib*{lib_name}*{file_extension}")
search_result = glob.glob(search_pattern)
if not search_result: # pragma: nocover
raise CompileError(
f'Unable to find OpenBLAS library at "{search_pattern}". '
"Please ensure that scipy is installed and available via pip."
)

lib_path_flags += [f"-Wl,-rpath,{lapack_lib_path}", f"-L{lapack_lib_path}"]
lapack_lib_name = path.basename(search_result[0])[3 : -len(file_extension)]

system_flags = []
if platform.system() == "Linux":
Expand All @@ -159,8 +158,6 @@ def get_default_flags(options):
elif options.async_qnodes and platform.system() == "Darwin": # pragma: nocover
system_flags += ["-lc++"]

lapack_libs = [f"-l{name}" for name in lapack_libs]

default_flags = [
"-shared",
"-rdynamic",
Expand All @@ -169,7 +166,7 @@ def get_default_flags(options):
"-lrt_capi",
"-lpthread",
"-lmlir_c_runner_utils", # required for memref.copy
*lapack_libs,
f"-l{lapack_lib_name}", # required for custom_calls lib
"-lcustom_calls",
"-lmlir_async_runtime",
]
Expand Down
Loading