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

Test QPP state allocation #1143

Conversation

anthony-santana
Copy link
Collaborator

Description

schweitzpgi and others added 7 commits January 22, 2024 19:29
* Add a reference to the Quick Start Guide. (NVIDIA#1109)

Co-authored-by: Bettina Heim <heimb@outlook.com>

* UCCSD Bug Fixes NVIDIA#952 (NVIDIA#1099)

* Fix uccsd issue NVIDIA#952

---------

Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>

* REST Server-Client platform   (NVIDIA#1012)

* [WIP] prototyping a server-client platform

* minor code edits

* [WIP] prototype remote execution

* [WIP] Work on remote server

* [WIP] REST remote server-client implementation

- Server [sim]: ability to run MPI; set simulator dynamically, start on
  a specific port

- Client: make is multi-qpu.

- Target config: pass urls and remote simulator.

* some code clean-up

* more code tidy-up

* Better code structure

* EOF missing

* unused var

* properly handle observe

* Make passes configurable

* code format

* Fix CI

* Clang build fixes

* Fix issue when switching simulators

* Don't build server app for wheels

* Fix build after merge

* [WIP] work on library mode support

* More work for library mode support

- Handle kernel name lookup with manged name.

- Fix issues with curl for large POST requests. Use bitcode to save
  bandwidth.

* [WIP] More experimenation to support library mode

* Prevent local execution when using remote platform in library mode

* Rejit the library mode support

- Workaround a bug in 'symbol responsibility' assertion when using
  mlir::Execution engine for pure llvm bitcode. Use LLJIT directly.

- Basic support for argument passing.

- Don't use the entry/exit marker functions. Rather add a redirection
  similar to std::invoke for clarity.

* code format

* Fixed cmake script

* Add auto launch feature

* Another code format

* Fix clang build

* Add JSON schema version check

* Add wait to auto-launch

* Add some basic tests

* Add observe/observe_async tests

Fixed an oversight of not passing the full sample_result back from the
server

Fix const correctness in MeasureCounts to enable Json conversions.

* add kernel_builder tests for remote REST platform

* Add Python tests

* Fix for build tree vs. install tree

* Add tests and fixes for free function kernels

* Add tests for get_state/get_state_async with remote platform

* Attempt to fix CI test failures on ARM

* some cleanup and docs

* some more code docs

* Fixed Doxygen parser bugs

* Add docs

* Fixed spelling

* Update docs/sphinx/using/cudaq/platform.rst

Co-authored-by: Pradnya Khalate <148914294+khalatepradnya@users.noreply.github.com>

* Address code review comments: code readability

* Address code review comments: update code comments

* Fix a typo in doc

* Add OpenAPI spec for the Json pauloads

* Bypass license header check for the OpenAPI spec yml and conform the payload data to the spec

* BypaAddress code review: escape code in docstring

* Some docs changes

* Update docs/sphinx/using/cudaq/platform.rst

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

* Update docs/sphinx/using/cudaq/platform.rst

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

* Update docs/sphinx/using/cudaq/platform.rst

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

* Address code review

- Add thread_id getter to base QuantumExecutionQueue

- Rename RemoteSimulatorQPU.cpp

- Remove outdated comment about .qplt file.

* Code review: simplify if/else return value and code format

* Add comments to OpenAPI REST spec YAML

* Remove dead code: unused  class

* Core review: REST server to report errors back as HTTP status 500

* Minor tweak for kernel_builder

Use the canonical pattern of calling jitCode().

* Walkthrough followup: First pass of code refactor

Main goal is to add abstraction to make the code extensible:

- Adding interfaces to abstract server and client.

- Using LLVM registry to inject the REST-specific impl.

Next steps: high-level integration: unifying with the mqpu platform and
moving the rest server to tools/

* Walkthrough follow-up #2: Code restructure

(1)  Merging remote platform (client-side) into the existing `mqpu` platform:

- Abstract the QPU (GPU-emulated or remote) via plugin.

- Isolate CUDA-dependency to build `mqpu` platform with/without CUDA.

(2) Move the server app to tools/, add proper CLI args parsing, rename
it to `cudaq-qpud`.

* Fix CMake fallout from my refactor

Find CUDA was not properly relocated to the GPU-only subdirectory (now
mqpu doesn't require CUDA).

Fix a typo in target name.

* Fix another CMake refactor fallout: missing fmt linking, didn't catch locally

* Address code review: make sure that no custom host compiler was used

* Code review: Enhance cudaq-qpud autolaunch helper

Better error handling and reporting.

Add a polling loop to guarantee connection rather than wait for fixed
amount of time.

* Change target config key to be compatible with Python

* Fixes some minor issues found

- Handle the case whereby the kernel is wrapped in `cudaq::gradient`
  before passing to `cudaq::observe`.

- Fix a fallout from code refactor: set_seed on the server side needs to
  be after the simulator lib loading since it'll try to access the
simulator.

* Missing a field in the ExecutionContext Json serialization

* Update JSON  schema

Nest response execution context as a sub-field with a proper key so that
it's in the same path as the request.

Update the openAPI yaml accordingly.

* Minor tweaks to get the examples working for the remote platform

Don't pass kernels as arguments to entry-point invocation.

Make sure that a simple compilation with `--target remote-sim` just works.

* Fix spell check

* Fixed an issue for lambda kernels in library mode and add a test to cover that

* Minor updates to the docs

* Debug container validation CI

* Revert "Debug container validation CI"

This reverts commit 0ddf6b7.

* Fix CI: the app needs to be able to work without MPI support

* Code review: remove SYNTAX_CHECK in tests

* Update docs/sphinx/using/cudaq/platform.rst

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

* Update docs/sphinx/using/cudaq/platform.rst

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

* Update docs/sphinx/using/cudaq/platform.rst

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

* Update runtime/common/KernelWrapper.h

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

* Update runtime/common/KernelWrapper.h

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

* Code review: Update docs

* Code review: Add code comment

* Code review: enum -> enum class

* Update runtime/cudaq/cudaq.cpp

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

* Code review: remore a stray comment

* Code review: code format change

* Code review: fix log messages

* Code review: use make_unique

* Code review: make args parsing more robust

* Update runtime/cudaq/platform/mqpu/MultiQPUPlatform.cpp

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

* Code review: use C++20 starts_with

* Code review: thread_safety for static default context and code comment

* Adding code comments about a skipped test and rest server request handling

* Fixed white spaces

* Fixed RST underline too short error in docs build

* Reduce CI time

* Attempt to fix race conditions when multiple apps with auto-launch starting concurrently

* Debug container validation logs

* Revert changes to examples

* Debug CI container validation

* Exclude tests with callable args

* Handle base64 encoded option

* Better handling no-MPI case: don't repeatedly query MPI plugin registry. Only need to check once

* Add error logging for kernel callable as args and tests

* Revert debug codes

* Code review: simplify the code

* Add new deps to the NOTICE file

* Fixes after merge

- Adjust CMake for installer build and add missing headers for OSX

- Fixed installer validation for remote-sim

The validate_container.sh is shared b/w docker and installer validation.
The installer validation requires an additional step
install_sshclient.sh to run examples that use cudaq::mpi API
(remote-sim).

Add a separate remote sim test for the installer

- Update docs

* Update docs/sphinx/using/cudaq/platform.rst

Co-authored-by: Bettina Heim <heimb@outlook.com>

* Update docs/sphinx/using/cudaq/platform.rst

Co-authored-by: Bettina Heim <heimb@outlook.com>

* Update docs/sphinx/using/cudaq/platform.rst

Co-authored-by: Bettina Heim <heimb@outlook.com>

* Update docs/sphinx/using/cudaq/platform.rst

Co-authored-by: Bettina Heim <heimb@outlook.com>

* Update platform name and docs

- Rename remote-sim -> remote-mqpu.

- Update docs:

+ Adding back some intro about auto-launch.

+ Add examples.

* Fix Cmake for added docs snippet tests

* Fix a ref in docs

* Fix lit test RUN lines after merge

* Revert "Fix lit test RUN lines after merge"

This reverts commit 047baa8.

* Try another fix

* Add reference to Github issue for disabled tests

* Update docs/sphinx/using/cudaq/platform.rst

Co-authored-by: Bettina Heim <heimb@outlook.com>

* Update docs according to review comments

* Update platform.rst

* Update sample_async_remote.py

* Guard the example test that requires cutensornet

---------

Co-authored-by: Pradnya Khalate <148914294+khalatepradnya@users.noreply.github.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Ben Howe <141149032+bmhowe23@users.noreply.github.com>
Co-authored-by: Bettina Heim <heimb@outlook.com>

* MPI plugin docs (NVIDIA#1095)

* Fix deployment validation post merge (NVIDIA#1116)

* Including uninstall script when installed via installer (NVIDIA#1112)

* Fixing wheelname in python_wheels.yml

* Fix an oversight in MultiGPU refactor (NVIDIA#1119)

---------

Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Co-authored-by: Bettina Heim <heimb@outlook.com>
Co-authored-by: Alex McCaskey <amccaskey@nvidia.com>
Co-authored-by: Thien Nguyen <58006629+1tnguyen@users.noreply.github.com>
Co-authored-by: Pradnya Khalate <148914294+khalatepradnya@users.noreply.github.com>
Co-authored-by: Ben Howe <141149032+bmhowe23@users.noreply.github.com>
…ion (NVIDIA#1115)

Initial library mode implementation

---------

Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Co-authored-by: A.M. Santana <39563805+anthony-santana@users.noreply.github.com>
…VIDIA#1141)

* Add support for the new qvector constructor with an initialization list
to the bridge.

* Update add-dealloc to account for InitializeStateOp being present.

Add test.
Signed-off-by: A.M. Santana <anthonys@nvidia.com>
Copy link

copy-pr-bot bot commented Jan 26, 2024

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.

Signed-off-by: A.M. Santana <anthonys@nvidia.com>
@anthony-santana anthony-santana marked this pull request as ready for review January 26, 2024 21:30
qpp::ket initState =
qpp::ket::Map(const_cast<std::complex<double> *>(stateData), count);
qpp::ket initState = qpp::ket::Map(
const_cast<std::complex<double> *>(stateData), (1UL << count));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might want to note in the doxygen comment that count is the power-of-2 exponent.

unittests/backends/QPPDMTester.cpp Outdated Show resolved Hide resolved
@schweitzpgi schweitzpgi force-pushed the features/qalloc branch 2 times, most recently from dec7672 to c6239f6 Compare March 21, 2024 17:22
amccaskey and others added 8 commits April 2, 2024 15:20
…ion (NVIDIA#1115)

Initial library mode implementation

---------

Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Co-authored-by: A.M. Santana <39563805+anthony-santana@users.noreply.github.com>
…VIDIA#1141)

* Add support for the new qvector constructor with an initialization list
to the bridge.

* Update add-dealloc to account for InitializeStateOp being present.

Add test.
* Fixes for the lower to QIR pass.

  - Splits subgraph matching from the conversion pass. The conversion
    rewriter doesn't really let one do both at the same time given the
    way it traversing the IR.
  - Add a new codegen dialect. Only used in codegen. Part of the
    previous bullet. The dialect will be the logical point to add any
    future combination ops.
  - Removes the extra canonicalizer pass

* clang-format
These changes adjust the placement of quake.dealloc ops to account for
the presence of state initializers in local scopes.
* [Core] Add complex types and values.

Fix traversals of casts. Cast expressions sometimes didn't actually
traverse the information required.

Update the test.

Get the test case working end-to-end.

* clang-format

* Update test for run variations.

* Reformat the comments.
schweitzpgi and others added 6 commits April 3, 2024 12:14
* Add qudit initializer to bridge.

* Add a hack to work around visiting allocators, etc. Need to eventually
handle "NOP" types and arguments in a better way than skipping over them
when it is convenient.
…er (NVIDIA#1474)

at runtime

According to MLIR: "The process of loading a Dialect in the context is
not thread-safe, which forces all involved Dialects to be loaded before
the multi-threaded pass manager starts the execution."

This PR makes sure that we load all the dialects when MLIR is needed at
runtime, hence may be used in a multi-threading environment (async.
execution).

In particular, add a method to register the internal CodeGenDialect,
which is only used by passes (not the frontend).

Make sure that we load all Dialects in C++ (CUDAQ MLIRRuntime) and Python (builder/decorator).

Tested by: running python/tests/remote/test_remote_platform.py with
these changes on the features/qalloc branch.
Signed-off-by: A.M. Santana <anthonys@nvidia.com>
Signed-off-by: A.M. Santana <anthonys@nvidia.com>
…ion (NVIDIA#1115)

Initial library mode implementation

---------

Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Co-authored-by: A.M. Santana <39563805+anthony-santana@users.noreply.github.com>
schweitzpgi and others added 8 commits April 8, 2024 09:19
…VIDIA#1141)

* Add support for the new qvector constructor with an initialization list
to the bridge.

* Update add-dealloc to account for InitializeStateOp being present.

Add test.
* Fixes for the lower to QIR pass.

  - Splits subgraph matching from the conversion pass. The conversion
    rewriter doesn't really let one do both at the same time given the
    way it traversing the IR.
  - Add a new codegen dialect. Only used in codegen. Part of the
    previous bullet. The dialect will be the logical point to add any
    future combination ops.
  - Removes the extra canonicalizer pass

* clang-format
These changes adjust the placement of quake.dealloc ops to account for
the presence of state initializers in local scopes.
* [Core] Add complex types and values.

Fix traversals of casts. Cast expressions sometimes didn't actually
traverse the information required.

Update the test.

Get the test case working end-to-end.

* clang-format

* Update test for run variations.

* Reformat the comments.
* Add qudit initializer to bridge.

* Add a hack to work around visiting allocators, etc. Need to eventually
handle "NOP" types and arguments in a better way than skipping over them
when it is convenient.
…er (NVIDIA#1474)

at runtime

According to MLIR: "The process of loading a Dialect in the context is
not thread-safe, which forces all involved Dialects to be loaded before
the multi-threaded pass manager starts the execution."

This PR makes sure that we load all the dialects when MLIR is needed at
runtime, hence may be used in a multi-threading environment (async.
execution).

In particular, add a method to register the internal CodeGenDialect,
which is only used by passes (not the frontend).

Make sure that we load all Dialects in C++ (CUDAQ MLIRRuntime) and Python (builder/decorator).

Tested by: running python/tests/remote/test_remote_platform.py with
these changes on the features/qalloc branch.
* Compute the correct number of qubits.

The initializer length must be 2**q where q is the number of qubits.

* Make the log calls consistent. Fix up the QIR checks.
schweitzpgi and others added 8 commits April 8, 2024 12:27
* [featues/qalloc] Use cc dialect.

Port the intrinsics to cc dialect, which should have everything
required.
Add external/private linkage control.

* Review comment: replace the inline MLIR string with direct builder
calls.

* Replace expanded complex types.

* Remove more LLVMIR code.
…eVecSimulator kron prod (NVIDIA#1482)

* Update builder to support vector state input. Implement Cusv kronprod

Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: A.M. Santana <anthonys@nvidia.com>
Signed-off-by: A.M. Santana <anthonys@nvidia.com>
Signed-off-by: A.M. Santana <anthonys@nvidia.com>
Signed-off-by: A.M. Santana <anthonys@nvidia.com>
@anthony-santana anthony-santana changed the base branch from features/qalloc to experimental/stateHandling April 26, 2024 16:50
Signed-off-by: A.M. Santana <anthonys@nvidia.com>
CMakeLists.txt Outdated
@@ -129,6 +129,7 @@ option(CUDAQ_TEST_MOCK_SERVERS "Enable Remote QPU Tests via Mock Servers." OFF)
option(CUDAQ_DISABLE_RUNTIME "Build without the CUDA Quantum runtime, just the compiler toolchain." OFF)
option(CUDAQ_SKIP_MPI "Do not build with MPI, even when it is available." OFF)
option(CUDAQ_DISABLE_CPP_FRONTEND "Build without the CUDA Quantum C++ Clang-based Frontend." OFF)
option(CUDAQ_ENABLE_CC "Enable CUDA Quantum code coverage generation." OFF)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use something other than CC for code coverage?

(CC is already overloaded with it being an environment variable, a dialect, and a C compiler.)

Copy link
Collaborator

@schweitzpgi schweitzpgi left a comment

Choose a reason for hiding this comment

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

I think I am reviewing a merge ... heh

docs/sphinx/examples/cpp/other/builder/builder.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot locked and limited conversation to collaborators May 22, 2024
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

4 participants