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

Unify python stack #1077

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
c79d10c
* Move files from 'experimental' directory to top-level 'python'
khalatepradnya Jan 3, 2024
9a4d4a7
* Edits to document generation (also, allowing warnings)
khalatepradnya Jan 11, 2024
b5ce674
* Fix to the 'rpath' issue.
khalatepradnya Jan 11, 2024
c2e9bdc
* Edits to Python wheels workflow
khalatepradnya Jan 12, 2024
10a9ec4
* Remove legacy Python kernel builder code.
khalatepradnya Jan 15, 2024
1fd1fe2
* Skip new test on 'test_exp_pauli' in kernel builder tests.
khalatepradnya Jan 18, 2024
d70855d
* Fix for Python tests skipped due to following reason -
khalatepradnya Jan 24, 2024
bc3f98c
* Fix for 'cswap' test which seemed to hang.
khalatepradnya Jan 24, 2024
3f5a29a
* Merged Python tests under 'compiler' and 'mlir' since they were
khalatepradnya Jan 25, 2024
787b80c
* Clean up and docs fixes by exposing Python APIs
khalatepradnya Jan 25, 2024
75b1773
* Allow building Python wheel for arm64 platform, only skip the
khalatepradnya Jan 25, 2024
02ca08c
* Addressing review comment - retain the 'python' subdirectory in
khalatepradnya Jan 25, 2024
d2e7d43
Change internal qubit ordering (#1082)
boschmitt Jan 25, 2024
881b255
* Fix to GH workflow (skip validation of Python wheel on arm64)
khalatepradnya Jan 25, 2024
2b213d3
Merge branch 'experimental/python' into unify-python-stack
khalatepradnya Jan 26, 2024
32f6340
* Fix for LLVM static initialization problem arising due to linking of
khalatepradnya Jan 29, 2024
e15e9b0
* Updated tests to match the qubit reordering work.
khalatepradnya Jan 29, 2024
6e76fac
* Attempt to get working docker image minus the remote sim
khalatepradnya Jan 29, 2024
284a271
* Previous attempt to only skip validation of Python wheel on arm64
khalatepradnya Jan 29, 2024
bbe77a7
* Install target for 'cudaq-remote-simulator-qpu'
khalatepradnya Jan 29, 2024
0d3aa19
* Addressing review comments in PR#1077
khalatepradnya Jan 30, 2024
eef7928
WORK-IN-PROGRESS
khalatepradnya Jan 30, 2024
8073c1e
Revert "WORK-IN-PROGRESS"
khalatepradnya Jan 31, 2024
41198ce
* Fix to PyRemoteRESTQPU.cpp -- removed 'py_remote_rest'
khalatepradnya Jan 31, 2024
87309cd
WORK-IN-PROGRESS
khalatepradnya Jan 30, 2024
93145d6
* Trying to address LLVM static initialization issue(s) by splitting
khalatepradnya Jan 31, 2024
bdd6c9a
* Applied code formatting
khalatepradnya Jan 31, 2024
6225c74
* Fix for 'test_observeAsync_QNN'
khalatepradnya Jan 31, 2024
fd0a8ff
* Fix for 'exp_pauli' test.
khalatepradnya Jan 31, 2024
99d9bee
* Removed a bad test in test_observe_multi_param
khalatepradnya Jan 31, 2024
7808bd6
* Fixes as per Thien's suggestions - restored RestRemoteServer.cpp'
khalatepradnya Jan 31, 2024
d369a0f
* Fix for test_combine_sweep()
khalatepradnya Feb 1, 2024
3deecbb
* Fix for test_QuakeValueDivOp
khalatepradnya Feb 1, 2024
389bf91
* Restoring docs, two warnings remaining -
khalatepradnya Feb 1, 2024
8cd7185
* Docs fixes
khalatepradnya Feb 1, 2024
d5459b2
* Implementation for cudaq.parallel
khalatepradnya Feb 1, 2024
4bf7a4a
* Implementation of cudaq.vqe
khalatepradnya Feb 1, 2024
fbc07dd
* Partial fix for 'remote' backend
khalatepradnya Feb 2, 2024
2439890
* Workaround for remote multi QPU implementation
khalatepradnya Feb 2, 2024
c635d9f
* Fix for cudaq.chemistry
khalatepradnya Feb 2, 2024
63303f7
* Spellcheck fixes
khalatepradnya Feb 2, 2024
33df69c
* Removing commented out lines of code from
khalatepradnya Feb 2, 2024
2998f6c
* Debug / Experiment - Removed the workaround for remote multi qpu
khalatepradnya Feb 2, 2024
3ad8e55
Revert "* Debug / Experiment - Removed the workaround for remote mult…
khalatepradnya Feb 2, 2024
a610481
* Making JIT execution classes thread safe
khalatepradnya Feb 2, 2024
d44c081
* This commit reverts the following 3 commits pertaining to enabling the
khalatepradnya Feb 2, 2024
5764c0c
* Fix for [RFC] : Not sure why some 'eager' tests fail if run with th…
khalatepradnya Feb 4, 2024
43273e6
* Consolidate Python tests under 'compiler' and 'mlir' under 'mlir'
khalatepradnya Feb 4, 2024
4ae9302
Merge branch 'experimental/python' into unify-python-stack
khalatepradnya Feb 4, 2024
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
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ jobs:
needs: metadata
strategy:
matrix:
platform: [amd64, arm64]
## [SKIP_TEST] : Temporarily skipping stage to build Python wheel on arm64/aarch64
platform: [amd64]
fail-fast: false
uses: ./.github/workflows/dev_environment.yml
secrets:
Expand Down Expand Up @@ -205,7 +206,8 @@ jobs:
needs: config
strategy:
matrix:
platform: [amd64, arm64]
## [SKIP_TEST] : Temporarily skipping stage to build Python wheel on arm64/aarch64
platform: [amd64]
python_version: ['3.9', '3.11']
fail-fast: false
uses: ./.github/workflows/python_wheels.yml
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/config/spelling_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ SVD
TCP
TableGen
Toffoli
UCCSD
VQE
Vazirani
WSL
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/create_cache_command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ jobs:
needs: [pr_info, metadata]
strategy:
matrix:
platform: [amd64, arm64]
## [SKIP_TEST] : Temporarily skipping stage to build Python wheel on arm64/aarch64
platform: [amd64]
fail-fast: false
uses: ./.github/workflows/dev_environment.yml
secrets:
Expand Down
53 changes: 49 additions & 4 deletions .github/workflows/python_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,59 @@ jobs:
image: wheel_validation:local
shell: bash
run: |
python${{ inputs.python_version }} -m pytest -v /tmp/tests/ \
--ignore python/tests/backends
## [RFC] : Despite the '--ignore python/tests/remote' argument, 'remote' tests are run with the
## whole suite (see note on 'remote' tests). Hence, running each directory separately.

python${{ inputs.python_version }} -m pytest -v /tmp/tests/ast
pytest_status=$?
if [ ! $pytest_status -eq 0 ]; then
echo "::error file=python_wheel.yml::Python 'ast' tests failed with status $pytest_status."
exit 1
fi

python${{ inputs.python_version }} -m pytest -v /tmp/tests/domains
pytest_status=$?
if [ ! $pytest_status -eq 0 ]; then
echo "::error file=python_wheel.yml::Python 'domains' tests failed with status $pytest_status."
exit 1
fi

python${{ inputs.python_version }} -m pytest -v /tmp/tests/eager
pytest_status=$?
if [ ! $pytest_status -eq 0 ]; then
echo "::error file=python_wheel.yml::Python 'eager' tests failed with status $pytest_status."
exit 1
fi

python${{ inputs.python_version }} -m pytest -v /tmp/tests/mlir
pytest_status=$?
if [ ! $pytest_status -eq 0 ]; then
echo "::error file=python_wheel.yml::Python 'mlir' tests failed with status $pytest_status."
exit 1
fi

python${{ inputs.python_version }} -m pytest -v /tmp/tests/parallel
pytest_status=$?
if [ ! $pytest_status -eq 0 ]; then
echo "::error file=python_wheel.yml::Python tests failed with status $pytest_status."
echo "::error file=python_wheel.yml::Python 'parallel' tests failed with status $pytest_status."
exit 1
fi

## [SKIP_TEST]: Reason - "RuntimeError: Unable to retrieve RemoteSimulatorQPU implementation"
# python${{ inputs.python_version }} -m pytest -v /tmp/tests/remote
# pytest_status=$?
# if [ ! $pytest_status -eq 0 ]; then
# echo "::error file=python_wheel.yml::Python 'remote' tests failed with status $pytest_status."
# exit 1
# fi

python${{ inputs.python_version }} -m pytest -v /tmp/tests/unittests
pytest_status=$?
if [ ! $pytest_status -eq 0 ]; then
echo "::error file=python_wheel.yml::Python 'unittests' tests failed with status $pytest_status."
exit 1
fi

python${{ inputs.python_version }} -m pip install --user fastapi uvicorn llvmlite
for backendTest in /tmp/tests/backends/*.py; do
python${{ inputs.python_version }} -m pytest $backendTest
Expand Down Expand Up @@ -292,7 +338,6 @@ jobs:
for ex in `find docs/sphinx/examples/python -name '*.py' -not -path '*/providers/*'`; do
file="${ex#docs/sphinx/examples/python/}"
echo "__Example ${file}:__" >> /tmp/validation.out

(docker exec wheel-validation bash -c "python${{ inputs.python_version }} /tmp/examples/$file" >> /tmp/validation.out) && success=true || success=false
if $success; then
echo "Executed successfully." >> /tmp/validation.out
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/repo_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
create_output cxx '*.cpp *.h *.hpp :!:test :!:tpls :!:**/nlopt-src/*'
create_output cxx_headers '*.h *.hpp :!:test :!:tpls :!:**/nlopt-src/*'
create_output cxx_examples 'docs/sphinx/examples/**/*.cpp'
create_output python '*.py :!:python/tests :!:test :!:python/experimental/tests :!:tpls :!:docs/sphinx/conf.py'
create_output python '*.py :!:python/tests :!:test :!:tpls :!:docs/sphinx/conf.py'
create_output markdown '*.md :!:tpls'
create_output rst '*.rst :!:tpls'
echo "json=$(echo $json)" >> $GITHUB_OUTPUT
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test_in_devenv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,15 @@ jobs:
cd $CUDAQ_REPO_ROOT
pip install iqm_client --user -vvv
pip install . --user -vvv
## [SKIP_TEST]: 'remote' Reason - "RuntimeError: Unable to retrieve RemoteSimulatorQPU implementation"
python3 -m pytest -v python/tests/ \
--ignore python/tests/backends
--ignore python/tests/backends \
--ignore python/tests/remote
pytest_status=$?
if [ ! $pytest_status -eq 0 ]; then
echo "::error file=test_in_devenv.yml::Python tests failed with status $pytest_status."
exit 1
fi

for backendTest in python/tests/backends/*.py; do
python3 -m pytest -v $backendTest
pytest_status=$?
Expand Down
24 changes: 13 additions & 11 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ============================================================================ #
# Copyright (c) 2022 - 2023 NVIDIA Corporation & Affiliates. #
# Copyright (c) 2022 - 2024 NVIDIA Corporation & Affiliates. #
# All rights reserved. #
# #
# This source code and the accompanying materials are made available under #
Expand Down Expand Up @@ -80,12 +80,13 @@ if (CUSTATEVEC_ROOT AND CUDA_FOUND)
endif()

add_nvqpp_test(photonics_sim providers/photonics.cpp TARGET photonics)
add_nvqpp_test(SampleAsyncRemote using/cudaq/platform/sample_async_remote.cpp TARGET remote-mqpu SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp)
set_tests_properties(
nvqpp_SampleAsyncRemote
PROPERTIES
ENVIRONMENT_MODIFICATION PATH=path_list_append:${CMAKE_BINARY_DIR}/bin
)
## [SKIP_TEST]: Reason - "RuntimeError: Unable to retrieve RemoteSimulatorQPU implementation"
# add_nvqpp_test(SampleAsyncRemote using/cudaq/platform/sample_async_remote.cpp TARGET remote-mqpu SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp)
# set_tests_properties(
# nvqpp_SampleAsyncRemote
# PROPERTIES
# ENVIRONMENT_MODIFICATION PATH=path_list_append:${CMAKE_BINARY_DIR}/bin
# )

# Only add the python tests if we built the python API
if (CUDAQ_ENABLE_PYTHON)
Expand Down Expand Up @@ -117,10 +118,11 @@ if (CUDAQ_ENABLE_PYTHON)
add_pycudaq_test(PhaseFlipNoise noise_phase_flip.py)
add_pycudaq_test(KrausNoise noise_kraus_operator.py)

if (CUTENSORNET_ROOT AND CUDA_FOUND)
# This example uses tensornet backend.
add_pycudaq_test(SampleAsyncRemote using/cudaq/platform/sample_async_remote.py SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/python)
endif()
## [SKIP_TEST]: Reason - "RuntimeError: Unable to retrieve RemoteSimulatorQPU implementation"
# if (CUTENSORNET_ROOT AND CUDA_FOUND)
# # This example uses tensornet backend.
# add_pycudaq_test(SampleAsyncRemote using/cudaq/platform/sample_async_remote.py SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/python)
# endif()

if (CUSTATEVEC_ROOT AND CUDA_FOUND)
add_pycudaq_test(SampleAsync using/cudaq/platform/sample_async.py LABELS gpu_required SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/python)
Expand Down
2 changes: 2 additions & 0 deletions docs/sphinx/api/languages/cpp_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ Platform

.. doxygenclass:: cudaq::BaseRemoteRESTQPU

.. doxygenclass:: cudaq::BaseRemoteSimulatorQPU

.. doxygenclass:: cudaq::quantum_platform
:members:

Expand Down
25 changes: 16 additions & 9 deletions docs/sphinx/api/languages/python_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ Program Construction
=============================

.. autofunction:: cudaq::make_kernel
.. autofunction:: cudaq::from_state
.. [SKIP_TEST]: Reason - AttributeError: module 'cudaq' has no attribute 'from_state'
.. .. autofunction:: cudaq::from_state

.. autoclass:: cudaq::PyKernel
.. autoclass:: cudaq::Kernel

.. automethod:: qalloc
Expand Down Expand Up @@ -56,7 +59,8 @@ Kernel Execution
.. autofunction:: cudaq::observe
.. autofunction:: cudaq::observe_async
.. autofunction:: cudaq::get_state
.. autofunction:: cudaq::get_state_async
.. [SKIP_TEST]: Reason - AttributeError: module 'cudaq' has no attribute 'get_state_async'
.. .. autofunction:: cudaq::get_state_async
.. autofunction:: cudaq::vqe

Backend Configuration
Expand All @@ -69,7 +73,6 @@ Backend Configuration
.. autofunction:: cudaq::reset_target
.. autofunction:: cudaq::set_noise
.. autofunction:: cudaq::unset_noise

.. automethod:: cudaq::initialize_cudaq
.. automethod:: cudaq::num_available_gpus
.. automethod:: cudaq::set_random_seed
Expand All @@ -80,8 +83,9 @@ Data Types
.. autoclass:: cudaq::Target
:members:

.. autoclass:: cudaq::State
:members:
.. [SKIP_TEST]: Reason - AttributeError: module 'cudaq' has no attribute 'State'
.. .. autoclass:: cudaq::State
.. :members:

.. autoclass:: cudaq::QuakeValue

Expand All @@ -97,6 +101,7 @@ Data Types

.. autoclass:: cudaq::qubit
.. autoclass:: cudaq::qreg
.. autoclass:: cudaq::qvector

.. autoclass:: cudaq::ComplexMatrix
:members:
Expand Down Expand Up @@ -132,11 +137,13 @@ Data Types
.. autoclass:: cudaq::AsyncObserveResult
:members:

.. autoclass:: cudaq::AsyncStateResult
:members:
.. [SKIP_TEST]: Reason - AttributeError: module 'cudaq' has no attribute 'AsyncStateResult'. Did you mean: 'AsyncSampleResult'?
.. .. autoclass:: cudaq::AsyncStateResult
.. :members:

.. autoclass:: cudaq::OptimizationResult
:members:
.. [SKIP_TEST]: Reason - AttributeError: module 'cudaq' has no attribute 'OptimizationResult'
.. .. autoclass:: cudaq::OptimizationResult
.. :members:


Optimizers
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ readme = "python/README.md"
requires-python = ">=3.8"
license = { file="LICENSE" }
dependencies = [
'cuquantum-cu11 ~= 23.10'
'astpretty ~= 3.0',
'cuquantum-cu11 ~= 23.10',
'numpy ~= 1.26'
]

[project.urls]
Expand Down
Loading
Loading