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

Install Qrack from source on build #3

Merged
merged 9 commits into from
May 29, 2024
Merged

Conversation

WrathfulSpatula
Copy link
Collaborator

In theory, Qrack has a perfectly "sane and rational" set of various supported methods by which users can install it; in practice, this a large cognitive load on users who just want the Python package from PyPi. Hence, this PR adds an automatic Qrack source checkout and build for the Catalyst device, such that no manual installation of Qrack by the user is necessary to install the Catalyst Qrack device package from PyPi.

@cosenal
Copy link
Contributor

cosenal commented May 29, 2024

I tried running pip install -e . on this branch and I got the following error:

-- Found OpenCL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks/OpenCL.framework (found version "1.2")
    -- Configuring done (2.6s)
    -- Generating done (0.0s)
    -- Build files have been written to: /Users/cosenal/Coding/unitaryfund/pennylane-qrack/_skbuild/macosx-14.0-arm64-3.11/cmake-build
    [ 50%] Building CXX object CMakeFiles/qrack_device.dir/pennylane_qrack/qrack_device.cpp.o
    /Users/cosenal/Coding/unitaryfund/pennylane-qrack/pennylane_qrack/qrack_device.cpp:4:10: fatal error: 'QuantumDevice.hpp' file not found
    #include <QuantumDevice.hpp>
             ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    make[2]: *** [CMakeFiles/qrack_device.dir/pennylane_qrack/qrack_device.cpp.o] Error 1
    make[1]: *** [CMakeFiles/qrack_device.dir/all] Error 2
    make: *** [all] Error 2
    Traceback (most recent call last):
      File "/opt/miniconda3/envs/pennylane-qrack/lib/python3.11/site-packages/skbuild/setuptools_wrap.py", line 674, in setup
        cmkr.make(make_args, install_target=cmake_install_target, env=env)
      File "/opt/miniconda3/envs/pennylane-qrack/lib/python3.11/site-packages/skbuild/cmaker.py", line 697, in make
        self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
      File "/opt/miniconda3/envs/pennylane-qrack/lib/python3.11/site-packages/skbuild/cmaker.py", line 742, in make_impl
        raise SKBuildError(msg)

    An error occurred while building with CMake.
      Command:
        /usr/local/bin/cmake --build . --target install --config Release --
      Install target:
        install
      Source directory:
        /Users/cosenal/Coding/unitaryfund/pennylane-qrack
      Working directory:
        /Users/cosenal/Coding/unitaryfund/pennylane-qrack/_skbuild/macosx-14.0-arm64-3.11/cmake-build
    Please check the install target is valid and see CMake's output for more information.

    [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

@WrathfulSpatula
Copy link
Collaborator Author

I tried running pip install -e . on this branch and I got the following error:...

Likely, the issue is that, before packaging, you need to run these two commands, first, to pull in Qrack and Catalyst:

git submodule init
git submodule update

When the source package builds, the necessary files will end up copied over directly into the source package, so PyPi install doesn't need the submodules. Just a "packaging environment" does.

@WrathfulSpatula
Copy link
Collaborator Author

Sorry for the "noise" in the diff from running black, but it shouldn't happen when we run it again.

@cosenal
Copy link
Contributor

cosenal commented May 29, 2024

I tried running pip install -e . on this branch and I got the following error:...

Likely, the issue is that, before packaging, you need to run these two commands, first, to pull in Qrack and Catalyst:

git submodule init
git submodule update

When the source package builds, the necessary files will end up copied over directly into the source package, so PyPi install doesn't need the submodules. Just a "packaging environment" does.

For that, don't we need to add qrack url in https://github.com/unitaryfund/pennylane-qrack/blob/qrack_source_install/.gitmodules ?

Explicitly add Qrack to .gitmodules
@WrathfulSpatula
Copy link
Collaborator Author

...For that, don't we need to add qrack url in https://github.com/unitaryfund/pennylane-qrack/blob/qrack_source_install/.gitmodules ?

I think the answer is actually, "It's optional," because the command line tools didn't do it automatically in this case, while the submodule was successfully added, but I just made it explicit in .gitmodules.

Copy link
Contributor

@vprusso vprusso left a comment

Choose a reason for hiding this comment

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

(minor changes, but aside from the LGTM!)

setup.py Outdated Show resolved Hide resolved
pennylane_qrack/qrack_device.py Outdated Show resolved Hide resolved
pennylane_qrack/qrack_device.py Show resolved Hide resolved
@WrathfulSpatula
Copy link
Collaborator Author

@cosenal To the point of your comment elsewhere, you asked about examples we could run to show the package works, and I actually ran into an issue with even static linkage of the Qrack library when I attempted to run the tutorial_qft.py file in the PennyLaneAI/qml repository. I've now spent about a full working day trying to include Qrack as a submodule: it's not easy to do this at all, with scikit-build and setuptools. Hence, most of the point of this PR is moot, although it's good to review formatting.

Everyone be aware, you will have to install Qrack separately, currently. On the bright side, the Python package installation will complain that the qrack library can't be found to link, which should be understood by users with basic computer science savvy. However, let me add explicit instructions to the README! I really wish I could eliminate every point of friction for users, but this is becoming a disproportionate level-of-effort to work around a build process that is theoretically already standardized and working.

@WrathfulSpatula WrathfulSpatula merged commit 3149766 into master May 29, 2024
4 checks passed
@WrathfulSpatula WrathfulSpatula deleted the qrack_source_install branch May 29, 2024 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants