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

Updating experimental/python with updates from main #944

Merged

Conversation

bettinaheim
Copy link
Collaborator

@bettinaheim bettinaheim commented Nov 17, 2023

There are changes necessary to restore the build and tests for the experimental/python branch.
However, I'll put them into their own PR.

1tnguyen and others added 30 commits November 10, 2023 10:57
* Add cutensornet-based simulator backends

* Fix code format

* Missing Python cuquantum dependency version bump

* Update code comments

* Update runtime/nvqir/cutensornet/tensornet_state.cpp

Co-authored-by: Ben Howe <141149032+bmhowe23@users.noreply.github.com>

* Address code review comments

* Address code review comments

* Address PR comments: cmake and comments for external plugin interface

* updates to tensornet mpi

* Update runtime/nvqir/cutensornet/tensornet_state.cpp

Co-authored-by: Ben Howe <141149032+bmhowe23@users.noreply.github.com>

* Refactor MPI support code in tensornet backend

* update a code comment for clarity

* Update unittests/integration/ghz_nisq_tester.cpp

* Fix a couple of compiler warnings on Clang

Thanks @bmhowe23 for spotting them.

- Dead `default` switch case. Clang doesn't like it.

- Missing a default virtual destructor and one inconsistent declaration.

- Update the example to be generic with/without cutensornet MPI support.

* escape code comments from spell checking

---------

Co-authored-by: Ben Howe <141149032+bmhowe23@users.noreply.github.com>
Co-authored-by: Bettina Heim <heimb@outlook.com>
…ckends (NVIDIA#901)

* Missing GPU_REQUIREMENTS field in the config file

An oversight of not having this field caused problems in the validation.
Previously, tensornet backend was pulled in after deployment hence no problem.

* Skipped some tests in publishing validation step (GPU backends) for MPS
…#877)

* * Allow the environment variable to override the default target
-- Added an environment variable - CUDAQ_DEFAULT_SIMULATOR
-- Check value against valid simulators
-- Added basic tests

* Update tools/nvqpp/nvq++.in
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>

* * Check environment variable and GPU availability in the   LinkedLibraryHolder constructor.

* * Clean up code from Python cudaq module (moved to LinkedLibraryHolder)

* Update python/utils/LinkedLibraryHolder.cpp
Co-authored-by: Ben Howe <141149032+bmhowe23@users.noreply.github.com>

* * Addressing review comments - enhanced tests
* * Explicitly set simulator along with target

* * Addressing review comments - Python tests modified for clarity
* Initializing current target to default in Python

* Update python/utils/LinkedLibraryHolder.cpp
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>

* Update python/utils/LinkedLibraryHolder.h
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>

* Update python/utils/LinkedLibraryHolder.h
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>

* * Removing 'NULL' check

---------

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Ben Howe <141149032+bmhowe23@users.noreply.github.com>
This PR
- Revises the install guide, and thereby fixes NVIDIA#849, NVIDIA#748, NVIDIA#513, and NVIDIA#353, as well as covers the two items with a checkmark in NVIDIA#845
- Removes the section about logging in to NGC, and (validating this) updates integration tests to use the NGC image
- Fixes various typos in the tutorials
…IA#902)

* Missing #ifdef escapes for new controlled rotation unit tests

* Fixed an issue in the updated Basic validation script: need to use bash rather than sh
* QuantinuumTester: allow a little bit more tolerance
* Change OQC port to unique number to allow it to run in parallel with
  other tests
* Update py_testing_utils.cpp to use the correct simulator, which is now
  required because the default is no longer purely qpp
* Sleep for 3 seconds instead of 1 during tests to allow test
  initialization to complete. (It's longer for GPU backend than CPU
  backend.)
* Reduce test time, especially for tensornet backends

(1) Some VQE tests/examples need L-BFGS

e.g., H2 example: 36 params => ~ 72 evals needed per iteration

We don't expose L-BFGS's maxLineSearchTrials (inner loop of the search); hence were not able to limit the number of runs
(knowing that it has converged).

Add this params and set them accordingly.

(2) The gate_library_tester.cpp did lots of simulation (small circuits) to verify the unitary matrices of these kernels.
Reduced the load on tensornet backends (not very efficient for these super small circuits).

(3) Lower the number of shots in case where we are expecting certain bitstrings, i.e., no need to get a large number of shots.

* fix clang compiler warnings: unused variables

* Fix a bad merge conflict

* Update docs/sphinx/examples/cpp/basics/cuquantum_backends.cpp

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>

* Address CR: simplify type casting in bernstein_vazirani.cpp example

---------

Co-authored-by: Bettina Heim <heimb@outlook.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
…e to override it (NVIDIA#899)

* * 📝 Adding documentation about default target and the environment variable to override it.

* Update docs/sphinx/using/simulators.rst
Co-authored-by: Bettina Heim <heimb@outlook.com>

* Update docs/sphinx/using/simulators.rst
Co-authored-by: Bettina Heim <heimb@outlook.com>

* * Applied clang formatting on the modified source file.
* * Added a clarifying statement about Python API (from PR#877).
* * Added explicit targets to reference specific simulators.

---------

Co-authored-by: Bettina Heim <heimb@outlook.com>
* [NFC] Move a transformation pass.

Moves the transformation pass, ref to veq, from the CodeGen directory to
the Transforms directory. This puts it the same place as related passes
like factor quantum alloc and combine quantum alloc.

* clang-format
Minor code maintenance to update factory functions and uses of same.
These changes do not change behavior, but make uses more uniform.
This pass converts the "value semantics" form of the quake dialect from
the "pruned control relations" form to the "linear control relations"
form. The pruned form is the less constrained IR representation while
the latter is overly constrained. The following examples illustrate the
distinction.

This is a sequence of ctrl-x ops in pruned form:

    %10 = quake.to_ctrl %0 : (!quake.wire) -> !quake.control
    %11 = quake.x [%10] %1 : (!quake.control, !quake.wire) -> !quake.wire
    %12 = quake.x [%10] %2 : (!quake.control, !quake.wire) -> !quake.wire
    %13 = quake.x [%10] %3 : (!quake.control, !quake.wire) -> !quake.wire
    %14 = quake.x [%10] %4 : (!quake.control, !quake.wire) -> !quake.wire
    %15 = quake.x [%10] %5 : (!quake.control, !quake.wire) -> !quake.wire
    %16 = quake.x [%10] %6 : (!quake.control, !quake.wire) -> !quake.wire
    %17 = quake.x [%10] %7 : (!quake.control, !quake.wire) -> !quake.wire
    %18 = quake.x [%10] %8 : (!quake.control, !quake.wire) -> !quake.wire
    %19 = quake.x [%10] %9 : (!quake.control, !quake.wire) -> !quake.wire
    %20 = quake.from_ctrl %10 : (!quake.control) -> !quake.wire

This is the same sequence in linear form:

    %10:2 = quake.x [%0] %1 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
    %11:2 = quake.x [%10#0] %2 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
    %12:2 = quake.x [%11#0] %3 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
    %13:2 = quake.x [%12#0] %4 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
    %14:2 = quake.x [%13#0] %5 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
    %15:2 = quake.x [%14#0] %6 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
    %16:2 = quake.x [%15#0] %7 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
    %17:2 = quake.x [%16#0] %8 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)
    %18:2 = quake.x [%17#0] %9 : (!quake.wire, !quake.wire) -> (!quake.wire, !quake.wire)

Notice that the pruned form makes it apparent that any permutation for
scheduling these operations is legal and should give the same result.
The linear form does not.

Reorganize the passes in the tablegen file, putting them back in
alphabetical order.

Add test.

Review comments.
…NVIDIA#889)

* Remove negative control handling from LowerToQIR to a standalone pass

---------

Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Closes NVIDIA#845
Partially addresses NVIDIA#704 (does not add chemistry/hardware efficient ansatz docs)
Adding/updating docs for tensor network backends.

Related to: NVIDIA#863

Resolved: NVIDIA#753
* Code block updated to use tabs for C++ and Python for sake of consistency with the rest of documentation.
* Fixed the link from 'Next Steps' section to 'Default Simulator'.
Fixing links in docs such that the link always point to the same version of the docs that someone is currently browsing
Fixing a minor typo in the workflow when launching deployment manually
Installing the iqm client for testing such that iqm server helper tests are not skipped.
Adds a new type for the result of a measurement operation. A value of
type `!quake.measurement` must be post-processed by the new operation
`quake.discriminate` to convert that value to a classical integer value.
`quake.discriminate`, like the previous measurement ops, can produce
either a single integer (bit) or a `std::vector` of integers (bits).

This splits the measurement operation into two steps:
  - acquiring the measurement on a qubit(s)
  - converting the measurement results to a classical value(s).

Fix all the tests and passes to accept the new representation.

Add verifier for DiscriminateOp.

Update the python tests.
This fixes a bug in the newly added linear-ctrl-form pass. The index of
the operand to be replaced was being miscomputed which was producing
incorrect results. Corrects the test.
* Lower the ctrl-swap operations to QIR.

Extend and generalize the invoke* code.

Closes NVIDIA#806

* Add tests.

Update signature if two target qubits.

* Fix test.
…#909)

* Try reproduce CI error to find a way to move applyExpPauli to base class

* Fix a info log
... and test tolerances
Signed-off-by: A.M. Santana <anthonys@nvidia.com>

With (PR NVIDIA#876), we are now enforcing the use of cudaq::ctrl when a programmer intends to run a control gate. This behavior must be matched in the kernel builder to remain specification compliant.

As is, this deprecates the old functions with a stern warning, and replaces them with new templated versions. Depending on when this PR is merged, the deprecated functions should be removed for the following release cycle.

Note: this has no impact on the Python API, only the C++ kernel builder.

Old behavior that will now show a deprecation notice:

auto [kernel, value] = cudaq::make_kernel<float>();
std::vector<cudaq::QuakeValue> ctrls{kernel.qalloc(), kernel.qalloc()};
auto target = kernel.qalloc();

// Now deprecated:
kernel.x(ctrls, target);
kernel.x(value, ctrls, target);
kernel.rx(3.14, ctrls, target);
The preferred method moving forward is

kernel.x<cudaq::ctrl>(ctrls, target);
kernel.x<cudaq::ctrl>(value, ctrls, target);
kernel.rx<cudaq::ctrl>(3.14, ctrls, target);
@bettinaheim bettinaheim changed the title [WIP] Dev environment to build the experimental python version Updating experimental/python with updates from main Nov 24, 2023
@NVIDIA NVIDIA deleted a comment from copy-pr-bot bot Nov 27, 2023
@NVIDIA NVIDIA deleted a comment from copy-pr-bot bot Nov 27, 2023
Copy link

copy-pr-bot bot commented Nov 27, 2023

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@bettinaheim
Copy link
Collaborator Author

bettinaheim commented Nov 27, 2023

/ok to test

Command Bot: Processing...

@bettinaheim
Copy link
Collaborator Author

bettinaheim commented Nov 28, 2023

/ok to test

Command Bot: Processing...

@bettinaheim bettinaheim changed the base branch from experimental/python to main November 28, 2023 12:23
@bettinaheim bettinaheim changed the base branch from main to experimental/python November 28, 2023 12:24
@bettinaheim bettinaheim changed the base branch from experimental/python to main November 28, 2023 12:27
@bettinaheim bettinaheim changed the base branch from main to experimental/python November 28, 2023 12:27
@bettinaheim bettinaheim marked this pull request as ready for review November 28, 2023 12:27
@bettinaheim bettinaheim merged commit b65303e into NVIDIA:experimental/python Nov 28, 2023
5 of 6 checks passed
@bettinaheim bettinaheim deleted the experimental/python branch November 28, 2023 12:29
@github-actions github-actions bot locked and limited conversation to collaborators Nov 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants