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

Documentation for NVQC #1412

Merged
merged 160 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 157 commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
45cd1da
Embed CUDA Quantum language in Python via runtime library integration
amccaskey Sep 11, 2023
2138efd
format
amccaskey Sep 13, 2023
5a5413b
spell check fixes
amccaskey Sep 13, 2023
d961ead
sort the file
amccaskey Sep 13, 2023
762a3ff
formatting
amccaskey Sep 13, 2023
72a98d6
python spell check
amccaskey Sep 13, 2023
d3d023b
rename the test
amccaskey Sep 13, 2023
ac12be0
attempt to fix wheel test
amccaskey Sep 14, 2023
f98f532
format
amccaskey Sep 14, 2023
9154b78
remove async work, will come in another patch
amccaskey Sep 16, 2023
c13b6ff
address simpler pr comments
amccaskey Sep 19, 2023
7f7ea19
address more complex if stmts
amccaskey Sep 19, 2023
31d2b75
add np random seed
amccaskey Sep 19, 2023
0f644b1
address pr comments
amccaskey Sep 25, 2023
a2bc58a
clean up and refactor
amccaskey Sep 25, 2023
73666bd
spell / format
amccaskey Sep 25, 2023
c4f757b
rename package
amccaskey Sep 26, 2023
9b785c1
Merge branch 'amccaskey/pyLibraryMode' into experimental/python
bettinaheim Nov 8, 2023
0155b08
additional changes worth keeping unrelated to enabling library mode
bettinaheim Nov 8, 2023
1991e5b
fixing issues introduced during merge|
bettinaheim Nov 8, 2023
404d1d9
Merge branch 'main' into experimental/python
bettinaheim Nov 9, 2023
b366340
Merge branch 'experimental/python' of https://github.com/NVIDIA/cuda-…
bettinaheim Nov 9, 2023
508cced
Merge branch 'main' into experimental/python
bettinaheim Nov 9, 2023
449b19f
updating to include compilation mode
bettinaheim Nov 9, 2023
179aa21
Merge branch 'main' into experimental/python
bettinaheim Nov 24, 2023
7884e9e
Merge branch 'main' into experimental/python
bettinaheim Nov 28, 2023
b65303e
Merge pull request #944 from bettinaheim/experimental/python
bettinaheim Nov 28, 2023
da383a7
Merge branch 'main' into experimental/python
bettinaheim Dec 1, 2023
c8060db
Merge pull request #992 from bettinaheim/experimental/python
bettinaheim Dec 1, 2023
90ac062
Getting experimental/python into a working state (#972)
bettinaheim Dec 1, 2023
b7beff2
Merge branch 'main' into experimental/python
khalatepradnya Dec 5, 2023
cbfa9aa
Merge pull request #1007 from khalatepradnya/align-exp-python-with-ma…
bettinaheim Dec 6, 2023
d2ecf85
Merge branch 'main' into experimental/python
khalatepradnya Dec 12, 2023
7bad04d
Update CUDAQuantumExtension.cpp
khalatepradnya Dec 12, 2023
1b88553
Merge pull request #1032 from khalatepradnya/align-with-main
bettinaheim Dec 13, 2023
8eed135
Merge branch 'main' into align-with-mainline
khalatepradnya Dec 27, 2023
792f463
* Fix merge conflict in 'lib/Optimizer/Transforms/GenKernelExecution.…
khalatepradnya Dec 28, 2023
97ce2b1
Merge branch 'main' into align-with-mainline
khalatepradnya Dec 28, 2023
14fcb61
Merge pull request #1058 from khalatepradnya/align-with-mainline
khalatepradnya Dec 28, 2023
d10ac84
Stabilizing the build and enabling tests (#1001)
khalatepradnya Dec 29, 2023
6bcfdd7
* Merge 'main' into 'experimental/python' feature branch
khalatepradnya Jan 17, 2024
ca5ee1a
Merge branch 'main' into align-with-main
khalatepradnya Jan 17, 2024
bb7c89e
Merge branch 'main' into align-with-main
khalatepradnya Jan 18, 2024
bf1a349
Merge pull request #1100 from khalatepradnya/align-with-main
khalatepradnya Jan 18, 2024
e3efc00
Merge branch 'main' into experimental/python
khalatepradnya Jan 25, 2024
1bee22b
Merge branch 'main' into pkhalate/experimental/python
khalatepradnya Jan 25, 2024
954499e
Merge pull request #1135 from khalatepradnya/pkhalate/experimental/py…
khalatepradnya Jan 25, 2024
0103b8a
Merge branch 'main' into align-with-main
khalatepradnya Feb 3, 2024
189e07d
Merge pull request #1166 from khalatepradnya/align-with-main
khalatepradnya Feb 4, 2024
c5862a2
Unify python stack (#1077)
khalatepradnya Feb 5, 2024
58e4fd6
* Partial fix for 'remote' backend
khalatepradnya Feb 2, 2024
0cc2473
* Enable remote qpu sans multi-qpu
khalatepradnya Feb 5, 2024
9c86d19
Merge pull request #1172 from khalatepradnya/remote-qpu
khalatepradnya Feb 6, 2024
21de0fd
Merge branch 'main' into merge-main
khalatepradnya Feb 6, 2024
3ece616
* Missing header file that got deleted while resolving merge conflict.
khalatepradnya Feb 6, 2024
affec9b
Merge pull request #1181 from khalatepradnya/merge-main
khalatepradnya Feb 6, 2024
e9d41e7
Improve handling of quantum library calls in kernel function bodies (…
amccaskey Feb 8, 2024
8c4a6a0
[experimental/python] Fixes from main for intermittent CI failures (#…
khalatepradnya Feb 8, 2024
0ce08bd
[experimental/python] Build kernel call graph and add all dependent k…
amccaskey Feb 8, 2024
ce9e0fc
[experimental/python] Support remote multi qpu target (#1187)
khalatepradnya Feb 9, 2024
7fff86e
* Re-enabled 'testMPI()' (#1199)
khalatepradnya Feb 9, 2024
6ec9182
Fix register_name being ignored in MLIR mode (#1198)
amccaskey Feb 9, 2024
c0e21c9
update vqe functions to support eager and mlir mode kernels (#1202)
amccaskey Feb 9, 2024
8f2fcbe
Moving the generated MLIR python bindings into the cudaq module (#1200)
bettinaheim Feb 9, 2024
6b2da77
Fix bug whereby kernel decorator was seen as kernel dependency and va…
amccaskey Feb 9, 2024
baa8f2c
[experimental/python] Enhance Python backend tests (#1186)
khalatepradnya Feb 9, 2024
a7961d4
Fix issue where kernels passed as input to other kernels could not be…
amccaskey Feb 10, 2024
6e514ca
Merge branch 'main' into align-with-main
khalatepradnya Feb 10, 2024
f8fef72
Merge branch 'experimental/python' into align-with-main
khalatepradnya Feb 10, 2024
4048036
:art: Apply code formatting
khalatepradnya Feb 10, 2024
c8c52c0
Merge branch 'align-with-main' of https://github.com/khalatepradnya/c…
khalatepradnya Feb 10, 2024
a75f1f6
Merge pull request #1207 from khalatepradnya/align-with-main
khalatepradnya Feb 10, 2024
078d000
re-enable state, get_state, and get_state_async (#1212)
amccaskey Feb 13, 2024
95b4e5e
Python JIT cache optimizations (#1209)
bmhowe23 Feb 13, 2024
497afc6
[experimental/python] Fixes and re-enables the python wheel tests on …
schweitzpgi Feb 13, 2024
1102c23
[experimental/python] Clean-up (#1222)
khalatepradnya Feb 14, 2024
ff44953
Merge branch 'main' into my-exp-python
khalatepradnya Feb 14, 2024
3736c3c
Merge pull request #1230 from khalatepradnya/my-exp-python
khalatepradnya Feb 14, 2024
c3bead3
* 'numpy' version supported on Python 3.8 (#1232)
khalatepradnya Feb 15, 2024
eda62b6
Fix bug in logic for decrementing range (#1228)
amccaskey Feb 15, 2024
3465044
[experimental/python] Enable JIT by default in Python (#1244)
khalatepradnya Feb 16, 2024
0171b72
Merge branch 'main' into experimental/python
khalatepradnya Feb 20, 2024
a3c3ef6
Merge pull request #1255 from khalatepradnya/merge-main
khalatepradnya Feb 20, 2024
c399ad9
[experimental/python] Fixes to support Python v3.8 (#1252)
khalatepradnya Feb 20, 2024
f14630b
Added 'remote' tests for 'mlir' / 'ast' mode in Python (#1182)
khalatepradnya Feb 20, 2024
84bfe3e
Implement list construction from list comprehension and simple kernel…
amccaskey Feb 21, 2024
091d79d
[experimental/python] Fixes to support Python v3.8 - part#2 (#1262)
khalatepradnya Feb 22, 2024
4c94c77
Python Error Diagnostics. Bug fix for incrementing range generation (…
amccaskey Feb 23, 2024
901b6c9
Merge branch 'main' into align-with-main
khalatepradnya Feb 23, 2024
620d562
[experimental/python] Support for legacy control operations in MLIR m…
khalatepradnya Feb 23, 2024
9f558a6
Merge branch 'experimental/python' into align-with-main
khalatepradnya Feb 23, 2024
e6bb6b4
Merge branch 'main' into align-with-main
khalatepradnya Feb 23, 2024
f4b5fec
[experimental/python] Remove library mode from Python workflow (#1256)
khalatepradnya Feb 23, 2024
d8ce0be
Merge branch 'experimental/python' into align-with-main
khalatepradnya Feb 23, 2024
c9ba90d
Merge pull request #1284 from khalatepradnya/align-with-main
khalatepradnya Feb 24, 2024
3a51afe
Properly implement visit_Bool with short-circuiting semantics (#1287)
amccaskey Feb 24, 2024
b3f760c
Count unique quake value extractions when possible, use for argument …
amccaskey Feb 26, 2024
0553caa
Optimize LLVM JIT for large circuits: apply #1261 to experimental/pyt…
bmhowe23 Feb 26, 2024
6eb7933
Enforce observe spec adherence (#1277)
amccaskey Feb 26, 2024
4189262
first pass of updating examples
anthony-santana Feb 26, 2024
d845fea
fixes
anthony-santana Feb 26, 2024
fe9169d
Move AST-to-MLIR compilation to the call operator. (#1282)
amccaskey Feb 26, 2024
e562997
a lot more updates
anthony-santana Feb 26, 2024
6228f0c
new error
anthony-santana Feb 26, 2024
75f274a
formatting and little fixes
anthony-santana Feb 26, 2024
8e88843
Fix bug where args were not validated and processed for sample_async …
amccaskey Feb 26, 2024
6011145
merge
anthony-santana Feb 26, 2024
1df913e
Cleaning up docs preview for PR #4.
cuda-quantum-bot Feb 26, 2024
3a56634
oqc example
anthony-santana Feb 26, 2024
0adf8be
Merge branch 'python_docs' of ssh://github.com/anthony-santana/cuda-q…
anthony-santana Feb 26, 2024
c1ab6e4
adapt rest of notebooks
anthony-santana Feb 27, 2024
709af7f
format new snippets
anthony-santana Feb 27, 2024
2465849
Better error checking for erroneous broadcast arguments (#1296)
amccaskey Feb 27, 2024
cc02838
Merge branch 'experimental/python' into python_docs
anthony-santana Feb 27, 2024
1a9e5d6
Update bernstein_vazirani.py
khalatepradnya Feb 27, 2024
9a1a08a
Fix SymbolTable error with print statements (#1286)
amccaskey Feb 27, 2024
44227aa
Merge branch 'experimental/python' into python_docs
khalatepradnya Feb 27, 2024
bfb1d61
Update advanced_vqe.py
khalatepradnya Feb 27, 2024
d62a8d9
Implement improved error diagnostics for kernel_decorator and kernel_…
amccaskey Feb 27, 2024
d66daab
Merge branch 'experimental/python' into python_docs
khalatepradnya Feb 27, 2024
03cf5d6
pr comments
anthony-santana Feb 27, 2024
6b6358e
merge
anthony-santana Mar 4, 2024
334e62a
post merge cleanup
anthony-santana Mar 4, 2024
a50e2ce
more cleanup
anthony-santana Mar 4, 2024
95ee242
Merge branch 'main' into python_docs
anthony-santana Mar 5, 2024
a5fe3d2
draw bv circuit
anthony-santana Mar 5, 2024
ac03f8c
Initial Documentation Refactor (#1225)
anthony-santana Mar 13, 2024
9676341
merge
anthony-santana Mar 14, 2024
b19182f
big round of pr comments and updates to new files
anthony-santana Mar 15, 2024
643e34b
missed one
anthony-santana Mar 15, 2024
4398956
Merge upstream main (#1407)
anthony-santana Mar 15, 2024
3aeeb56
Merge branch 'features/docs_refactor' into main
anthony-santana Mar 15, 2024
22e66ab
Merge pull request #1408 from anthony-santana/main
anthony-santana Mar 15, 2024
67ed37a
merge upstream
anthony-santana Mar 15, 2024
27a21d9
Merge branch 'features/docs_refactor' into main
anthony-santana Mar 15, 2024
db6b243
formatter
anthony-santana Mar 15, 2024
53dbd33
final pr comments
anthony-santana Mar 15, 2024
e1e9e85
final pr comments
anthony-santana Mar 15, 2024
2502832
MLIR updates for python examples
anthony-santana Mar 15, 2024
676d3d3
Merge branch 'features/docs_refactor' into main
anthony-santana Mar 15, 2024
5837327
Merge pull request #1409 from anthony-santana/main
anthony-santana Mar 15, 2024
c63f4fa
Quick Start updates (#1401)
bettinaheim Mar 17, 2024
e959856
Update data_center_install.rst
bettinaheim Mar 17, 2024
a7aa766
NVQC documentation
1tnguyen Mar 18, 2024
422a9a1
Spelling and code format fixes
1tnguyen Mar 18, 2024
76f6842
Don't run nvqc snippets in CI since there is no API key
1tnguyen Mar 18, 2024
169809c
Merge branch 'features/docs_refactor' into main_copy
anthony-santana Mar 18, 2024
96952cd
Merge pull request #1413 from anthony-santana/main_copy
anthony-santana Mar 18, 2024
716d128
Merge branch 'features/docs_refactor' into main_copy
anthony-santana Mar 18, 2024
2edf4c9
Merge pull request #1414 from anthony-santana/main_copy
anthony-santana Mar 18, 2024
a122fa5
setting up redirects
Mar 18, 2024
62e9ce5
Merge branch 'features/docs_refactor' of https://github.com/NVIDIA/cu…
Mar 18, 2024
63f1cca
no license header check for html
Mar 18, 2024
79e24a1
Merge branch 'main' into features/docs_refactor
bettinaheim Mar 18, 2024
1dc700c
Merge branch 'features/docs_refactor' into tnguyen/nvqc-docs
1tnguyen Mar 18, 2024
dddf663
Merge branch 'main' into tnguyen/nvqc-docs
bettinaheim Mar 18, 2024
3f9d92d
Update backends.rst
bettinaheim Mar 18, 2024
f51b4fe
Update md_link_check_config.json
bettinaheim Mar 18, 2024
54425d5
Merge branch 'main' into tnguyen/nvqc-docs
bettinaheim Mar 18, 2024
91b5f7e
Update releases.rst
bettinaheim Mar 18, 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
1 change: 1 addition & 0 deletions .github/workflows/config/spelling_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ reStructuredText
runtime
rvalue
scalability
scalable
sexualized
struct
structs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ jobs:
docker run --rm -dit --name wheel-validation-snippets wheel_validation:local
status_sum=0

for ex in `find docs/sphinx/snippets/python -name '*.py' -not -path '*/platform/*'`; do
for ex in `find docs/sphinx/snippets/python -name '*.py' -not -path '*/platform/*' -not -path '*/nvqc/*'`; do
file="${ex#docs/sphinx/snippets/python/}"
echo "__Snippet ${file}:__" >> /tmp/validation.out
(docker exec wheel-validation-snippets bash -c "python${{ inputs.python_version }} /tmp/snippets/$file" >> /tmp/validation.out) && success=true || success=false
Expand Down
29 changes: 29 additions & 0 deletions docs/sphinx/snippets/cpp/using/cudaq/nvqc/nvqc_intro.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*******************************************************************************
* Copyright (c) 2022 - 2024 NVIDIA Corporation & Affiliates. *
* All rights reserved. *
* *
* This source code and the accompanying materials are made available under *
* the terms of the Apache License 2.0 which accompanies this distribution. *
******************************************************************************/

// [Begin Documentation]
#include <cudaq.h>

// Define a simple quantum kernel to execute on NVQC.
struct ghz {
// Maximally entangled state between 25 qubits.
auto operator()() __qpu__ {
constexpr int NUM_QUBITS = 25;
cudaq::qvector q(NUM_QUBITS);
h(q[0]);
for (int i = 0; i < NUM_QUBITS - 1; i++) {
x<cudaq::ctrl>(q[i], q[i + 1]);
}
auto result = mz(q);
}
};

int main() {
auto counts = cudaq::sample(ghz{});
counts.dump();
}
51 changes: 51 additions & 0 deletions docs/sphinx/snippets/cpp/using/cudaq/nvqc/nvqc_mqpu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*******************************************************************************
* Copyright (c) 2022 - 2024 NVIDIA Corporation & Affiliates. *
* All rights reserved. *
* *
* This source code and the accompanying materials are made available under *
* the terms of the Apache License 2.0 which accompanies this distribution. *
******************************************************************************/

// [Begin Documentation]
#include <cudaq.h>
#include <cudaq/algorithm.h>
#include <cudaq/gradients.h>
#include <cudaq/optimizers.h>
#include <iostream>

int main() {
using namespace cudaq::spin;
cudaq::spin_op h = 5.907 - 2.1433 * x(0) * x(1) - 2.1433 * y(0) * y(1) +
.21829 * z(0) - 6.125 * z(1);

auto [ansatz, theta] = cudaq::make_kernel<double>();
auto q = ansatz.qalloc();
auto r = ansatz.qalloc();
ansatz.x(q);
ansatz.ry(theta, r);
ansatz.x<cudaq::ctrl>(r, q);

// Run VQE with a gradient-based optimizer.
// Delegate cost function and gradient computation across different NVQC-based
// QPUs.
// Note: this needs to be compiled with `--nvqc-nqpus 3` create 3 virtual
// QPUs.
cudaq::optimizers::lbfgs optimizer;
auto [opt_val, opt_params] = optimizer.optimize(
/*dim=*/1, /*opt_function*/ [&](const std::vector<double> &params,
std::vector<double> &grads) {
// Queue asynchronous jobs to do energy evaluations across multiple QPUs
auto energy_future =
cudaq::observe_async(/*qpu_id=*/0, ansatz, h, params[0]);
const double paramShift = M_PI_2;
auto plus_future = cudaq::observe_async(/*qpu_id=*/1, ansatz, h,
params[0] + paramShift);
auto minus_future = cudaq::observe_async(/*qpu_id=*/2, ansatz, h,
params[0] - paramShift);
grads[0] = (plus_future.get().expectation() -
minus_future.get().expectation()) /
2.0;
return energy_future.get().expectation();
});
std::cout << "Minimum energy = " << opt_val << " (expected -1.74886).\n";
}
23 changes: 23 additions & 0 deletions docs/sphinx/snippets/python/using/cudaq/nvqc/nvqc_intro.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# ============================================================================ #
# Copyright (c) 2022 - 2024 NVIDIA Corporation & Affiliates. #
# All rights reserved. #
# #
# This source code and the accompanying materials are made available under #
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #
# [Begin Documentation]
import cudaq

cudaq.set_target("nvqc")
num_qubits = 25
# Define a simple quantum kernel to execute on NVQC.
kernel = cudaq.make_kernel()
qubits = kernel.qalloc(num_qubits)
# Maximally entangled state between 25 qubits.
kernel.h(qubits[0])
for i in range(num_qubits - 1):
kernel.cx(qubits[i], qubits[i + 1])
kernel.mz(qubits)

counts = cudaq.sample(kernel)
print(counts)
54 changes: 54 additions & 0 deletions docs/sphinx/snippets/python/using/cudaq/nvqc/nvqc_mqpu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# ============================================================================ #
# Copyright (c) 2022 - 2024 NVIDIA Corporation & Affiliates. #
# All rights reserved. #
# #
# This source code and the accompanying materials are made available under #
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #
# [Begin Documentation]
import cudaq
from cudaq import spin
import math

# Use NVQC with 3 virtual QPUs
cudaq.set_target("nvqc", nqpus=3)

print("Number of QPUs:", cudaq.get_target().num_qpus())
# Create the parameterized ansatz
kernel, theta = cudaq.make_kernel(float)
qreg = kernel.qalloc(2)
kernel.x(qreg[0])
kernel.ry(theta, qreg[1])
kernel.cx(qreg[1], qreg[0])

# Define its spin Hamiltonian.
hamiltonian = (5.907 - 2.1433 * spin.x(0) * spin.x(1) -
2.1433 * spin.y(0) * spin.y(1) + 0.21829 * spin.z(0) -
6.125 * spin.z(1))


def opt_gradient(parameter_vector):
# Evaluate energy and gradient on different remote QPUs
# (i.e., concurrent job submissions to NVQC)
energy_future = cudaq.observe_async(kernel,
hamiltonian,
parameter_vector[0],
qpu_id=0)
plus_future = cudaq.observe_async(kernel,
hamiltonian,
parameter_vector[0] + 0.5 * math.pi,
qpu_id=1)
minus_future = cudaq.observe_async(kernel,
hamiltonian,
parameter_vector[0] - 0.5 * math.pi,
qpu_id=2)
return (energy_future.get().expectation(), [
(plus_future.get().expectation() - minus_future.get().expectation()) /
2.0
])


optimizer = cudaq.optimizers.LBFGS()
optimal_value, optimal_parameters = optimizer.optimize(1, opt_gradient)
print("Ground state energy =", optimal_value)
print("Optimal parameters =", optimal_parameters)
2 changes: 2 additions & 0 deletions docs/sphinx/using/backends/backends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CUDA Quantum Backends

Simulation <simulators.rst>
Quantum Hardware <hardware.rst>
NVIDIA Quantum Cloud <nvqc.rst>
Multi-Processor Platforms <platform.rst>

**The following is a comprehensive list of the available targets in CUDA Quantum:**
Expand All @@ -18,6 +19,7 @@ CUDA Quantum Backends
* :ref:`nvidia-fp64 <nvidia-fp64-backend>`
* :ref:`nvidia-mqpu <nvidia-mgpu-backend>`
* :ref:`nvidia-mqpu-fp64 <nvidia-mgpu-backend>`
* :doc:`nvqc <nvqc>`
* :ref:`oqc <oqc-backend>`
* :ref:`qpp-cpu <qpp-cpu-backend>`
* :ref:`quantinuum <quantinuum-backend>`
Expand Down
Loading
Loading