Skip to content

Commit ca5b142

Browse files
authored
Merge branch 'main' into 0.14_python_notebooks_fix
2 parents c9d748e + 7df57da commit ca5b142

File tree

29 files changed

+840
-150
lines changed

29 files changed

+840
-150
lines changed

.github/pre-commit/spelling_allowlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ OpenSUSE
9090
Ou
9191
POSIX
9292
PSIRT
93+
PTSBE
9394
Pasqal
9495
Pauli
9596
Paulis

docs/CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# LAUNCH_COMMAND <COMMAND>: the command to launch the test (e.g., mpirun)
1818
function(add_nvqpp_test TEST_NAME SOURCE_LOCATION)
1919
cmake_parse_arguments(PARSED_ARGS "" "TARGET;LABELS;SOURCE_DIR;LAUNCH_COMMAND;APPLICATION_ARGS;TARGET_OPTION" "" ${ARGN})
20-
set(NVQPP_COMPILE_ARGS "--library-mode ")
20+
set(NVQPP_COMPILE_ARGS "--library-mode -I${CMAKE_SOURCE_DIR}/runtime/include")
2121
if(PARSED_ARGS_TARGET)
2222
set(NVQPP_COMPILE_ARGS "${NVQPP_COMPILE_ARGS} --target ${PARSED_ARGS_TARGET}")
2323
if (PARSED_ARGS_TARGET_OPTION)
@@ -65,6 +65,13 @@ add_nvqpp_test(QuickStart_default quick_start.cpp SOURCE_DIR ${CMAKE_CURRENT_SOU
6565
add_nvqpp_test(FirstObserve using/first_observe.cpp SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp)
6666
add_nvqpp_test(FirstSample using/first_sample.cpp SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp)
6767
add_nvqpp_test(Timing using/time.cpp SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp APPLICATION_ARGS "10")
68+
69+
set(PTSBE_CPP_SNIPPET_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp/using/examples/ptsbe)
70+
add_nvqpp_test(PTSBE_BellDepol bell_circuit_under_depol_noise.cpp SOURCE_DIR ${PTSBE_CPP_SNIPPET_DIR})
71+
add_nvqpp_test(PTSBE_InspectData inspect_execution_data.cpp SOURCE_DIR ${PTSBE_CPP_SNIPPET_DIR})
72+
add_nvqpp_test(PTSBE_SamplingStrategies sampling_strategies.cpp SOURCE_DIR ${PTSBE_CPP_SNIPPET_DIR})
73+
add_nvqpp_test(PTSBE_ShotAllocation shot_allocation.cpp SOURCE_DIR ${PTSBE_CPP_SNIPPET_DIR})
74+
6875
if (CUDENSITYMAT_ROOT AND CUDA_FOUND)
6976
add_nvqpp_test(Dynamics_Snippets using/backends/dynamics.cpp SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp/ TARGET dynamics LABELS gpu_required)
7077
add_nvqpp_test(Dynamics_State_Batching_Snippets using/backends/dynamics_state_batching.cpp SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/cpp/ TARGET dynamics LABELS gpu_required)
@@ -135,6 +142,13 @@ if (CUDAQ_ENABLE_PYTHON)
135142
endfunction()
136143

137144
add_pycudaq_test(Intro intro.py)
145+
146+
set(PTSBE_PY_SNIPPET_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/python/using/examples/ptsbe)
147+
add_pycudaq_test(PTSBE_BellDepol bell_circuit_under_depol_noise.py SOURCE_DIR ${PTSBE_PY_SNIPPET_DIR})
148+
add_pycudaq_test(PTSBE_InspectData inspect_execution_data.py SOURCE_DIR ${PTSBE_PY_SNIPPET_DIR})
149+
add_pycudaq_test(PTSBE_SamplingStrategies sampling_strategies.py SOURCE_DIR ${PTSBE_PY_SNIPPET_DIR})
150+
add_pycudaq_test(PTSBE_ShotAllocation shot_allocation.py SOURCE_DIR ${PTSBE_PY_SNIPPET_DIR})
151+
138152
if (CUDA_FOUND)
139153
add_pycudaq_test(EvolveDynamics using/backends/dynamics.py LABELS gpu_required SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/python)
140154
add_pycudaq_test(EvolveDynamicsStateBatching using/backends/dynamics_state_batching.py LABELS gpu_required SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sphinx/snippets/python)

docs/sphinx/api/api.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Code documentation
22
******************
3-
3+
.. |:spellcheck-disable:| replace:: \
44
.. toctree::
55
:caption: CUDA-Q API
66
:maxdepth: 1
77

88
C++ API <languages/cpp_api.rst>
99
Python API <languages/python_api.rst>
10-
Quantum Operations <default_ops.rst>
10+
Quantum Operations <default_ops.rst>
11+
.. |:spellcheck-enable:| replace:: \

docs/sphinx/api/languages/cpp_api.rst

Lines changed: 101 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ Common
120120
.. doxygenclass:: cudaq::sample_result
121121
:members:
122122

123-
.. _classcudaq_1_1ptsbe_1_1sample__result:
124-
125-
**cudaq::`ptsbe`::sample_result** — Result type returned by ``ptsbe::sample()``, extending `cudaq::sample_result` with optional execution data (trace and per-trajectory info). See ``PTSBESampleResult.h`` and ``PTSBEExecutionData.h``.
126-
127123
.. doxygenstruct:: cudaq::sample_options
128124
:members:
129125

@@ -190,12 +186,12 @@ Noise Modeling
190186
it is automatically (and silently) stripped from any programs submitted to
191187
hardware targets.
192188

193-
:tparam Channel: A subtype of :cpp:class:`cudaq::kraus_channel` that
189+
:`tparam` Channel: A subtype of :cpp:class:`cudaq::kraus_channel` that
194190
implements/defines the desired noise mechanisms as Kraus channels (e.g.
195191
:cpp:class:`cudaq::depolarization2`). If you want to use a custom
196192
:cpp:class:`cudaq::kraus_channel` (i.e. not built-in to CUDA-Q), it must
197193
first be registered *outside the kernel* with
198-
:cpp:func:`cudaq::noise_model::register_channel`, like this:
194+
`:cpp:func:cudaq::noise_model::register_channel`, like this:
199195

200196
.. code-block:: cpp
201197
@@ -218,7 +214,7 @@ Noise Modeling
218214
cudaq::noise_model noise;
219215
noise.register_channel<my_custom_kraus_channel_subtype>();
220216
221-
:param args: The precise argument pack depend on the concrete `Channel` being
217+
:`param` `args`: The precise argument pack depend on the concrete `Channel` being
222218
used. The arguments are a concatenated list of parameters and targets.
223219
For example, to apply a 2-qubit depolarization channel, which has
224220
`num_parameters = 1` and `num_targets = 2`, one would write the call
@@ -414,3 +410,101 @@ Namespaces
414410
.. doxygenfunction:: cudaq::orca::sample(std::vector<std::size_t> &input_state, std::vector<std::size_t> &loop_lengths, std::vector<double> &bs_angles, std::vector<double> &ps_angles, int n_samples = 10000, std::size_t qpu_id = 0)
415411
.. doxygenfunction:: cudaq::orca::sample_async(std::vector<std::size_t> &input_state, std::vector<std::size_t> &loop_lengths, std::vector<double> &bs_angles, int n_samples = 10000, std::size_t qpu_id = 0)
416412
.. doxygenfunction:: cudaq::orca::sample_async(std::vector<std::size_t> &input_state, std::vector<std::size_t> &loop_lengths, std::vector<double> &bs_angles, std::vector<double> &ps_angles, int n_samples = 10000, std::size_t qpu_id = 0)
413+
414+
PTSBE
415+
=====
416+
417+
The ``cudaq::ptsbe`` namespace implements Pre-Trajectory Sampling with Batch
418+
Execution (PTSBE). For a conceptual overview and usage tutorial see
419+
:doc:`../../using/examples/ptsbe`.
420+
421+
.. doxygennamespace:: cudaq::ptsbe
422+
:desc-only:
423+
424+
Sampling Functions
425+
-------------------
426+
427+
.. doxygenfunction:: cudaq::ptsbe::sample(const cudaq::noise_model &noise, std::size_t shots, QuantumKernel &&kernel, Args &&...args)
428+
.. doxygenfunction:: cudaq::ptsbe::sample(const sample_options &options, QuantumKernel &&kernel, Args &&...args)
429+
.. doxygenfunction:: cudaq::ptsbe::sample_async(const cudaq::noise_model &noise, std::size_t shots, QuantumKernel &&kernel, Args &&...args)
430+
.. doxygenfunction:: cudaq::ptsbe::sample_async(const sample_options &options, QuantumKernel &&kernel, Args &&...args)
431+
432+
----
433+
434+
Options
435+
--------
436+
437+
.. doxygenstruct:: cudaq::ptsbe::sample_options
438+
:members:
439+
440+
.. doxygenstruct:: cudaq::ptsbe::PTSBEOptions
441+
:members:
442+
443+
----
444+
445+
Result Type
446+
------------
447+
448+
.. doxygenclass:: cudaq::ptsbe::sample_result
449+
:members:
450+
451+
----
452+
453+
Trajectory Sampling Strategies
454+
--------------------------------
455+
456+
.. doxygenstruct:: cudaq::ptsbe::detail::NoisePoint
457+
:members:
458+
459+
.. doxygenclass:: cudaq::ptsbe::PTSSamplingStrategy
460+
:members:
461+
462+
.. doxygenclass:: cudaq::ptsbe::ProbabilisticSamplingStrategy
463+
:members:
464+
465+
.. doxygenclass:: cudaq::ptsbe::OrderedSamplingStrategy
466+
:members:
467+
468+
.. doxygenclass:: cudaq::ptsbe::ExhaustiveSamplingStrategy
469+
:members:
470+
471+
.. doxygentypedef:: cudaq::ptsbe::TrajectoryPredicate
472+
473+
.. doxygenclass:: cudaq::ptsbe::ConditionalSamplingStrategy
474+
:members:
475+
476+
----
477+
478+
Shot Allocation Strategy
479+
-------------------------
480+
481+
See :ref:`ptsbe-shot-allocation` for full API details.
482+
483+
----
484+
485+
Execution Data
486+
---------------
487+
488+
.. doxygentypedef:: cudaq::ptsbe::PTSBETrace
489+
490+
.. doxygenstruct:: cudaq::ptsbe::PTSBEExecutionData
491+
:members:
492+
493+
.. doxygenstruct:: cudaq::ptsbe::TraceInstruction
494+
:members:
495+
496+
.. doxygenenum:: cudaq::ptsbe::TraceInstructionType
497+
498+
----
499+
500+
Trajectory and Selection Types
501+
--------------------------------
502+
503+
.. doxygenclass:: cudaq::KrausTrajectoryBuilder
504+
:members:
505+
506+
.. doxygenstruct:: cudaq::KrausTrajectory
507+
:members:
508+
509+
.. doxygenstruct:: cudaq::KrausSelection
510+
:members:

docs/sphinx/api/languages/python_api.rst

Lines changed: 83 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Backend Configuration
9595
it is automatically (and silently) stripped from any programs submitted to
9696
hardware targets.
9797

98-
:param error_type: A subtype of :class:`cudaq.KrausChannel` that
98+
:`param` error_type: A subtype of :class:`cudaq.KrausChannel` that
9999
implements/defines the desired noise mechanisms as Kraus channels (e.g.
100100
:class:`cudaq.Depolarization2`). If you want to use a custom
101101
:class:`cudaq.KrausChannel` (i.e. not built-in to CUDA-Q), it must
@@ -126,7 +126,7 @@ Backend Configuration
126126
noise = cudaq.NoiseModel()
127127
noise.register_channel(CustomNoiseChannel)
128128
129-
:param parameters: The precise argument pack depend on the concrete
129+
:`param` parameters: The precise argument pack depend on the concrete
130130
:class:`cudaq.KrausChannel` being used. The arguments are a concatenated
131131
list of parameters and targets. For example, to apply a 2-qubit
132132
depolarization channel, which has `num_parameters = 1` and `num_targets =
@@ -137,7 +137,7 @@ Backend Configuration
137137
q, r = cudaq.qubit(), cudaq.qubit()
138138
cudaq.apply_noise(cudaq.Depolarization2, 0.1, q, r)
139139
140-
:param targets: The target qubits on which to apply the noise
140+
:`param` targets: The target qubits on which to apply the noise
141141

142142

143143
.. automethod:: cudaq::initialize_cudaq
@@ -299,8 +299,8 @@ Optimizers
299299

300300
Run the optimization procedure.
301301

302-
:param dimensions: The number of parameters to optimize
303-
:param function: The objective function to minimize
302+
:`param` dimensions: The number of parameters to optimize
303+
:`param` function: The objective function to minimize
304304
:returns: tuple of (optimal_value, optimal_parameters)
305305

306306
.. py:method:: requires_gradients() -> bool
@@ -417,3 +417,81 @@ ORCA Submodule
417417
=============================
418418

419419
.. automethod:: cudaq.orca::sample
420+
421+
PTSBE Submodule
422+
=============================
423+
424+
.. _ptsbe_api:
425+
426+
The ``cudaq.ptsbe`` submodule implements Pre-Trajectory Sampling with Batch
427+
Execution (PTSBE). For a conceptual overview and usage tutorial see
428+
:doc:`../../using/examples/ptsbe`.
429+
430+
Sampling Functions
431+
-------------------
432+
433+
.. autofunction:: cudaq.ptsbe.sample
434+
435+
.. autofunction:: cudaq.ptsbe.sample_async
436+
437+
----
438+
439+
Result Type
440+
------------
441+
442+
.. autoclass:: cudaq.ptsbe.PTSBESampleResult
443+
:members:
444+
445+
----
446+
447+
Trajectory Sampling Strategies
448+
--------------------------------
449+
450+
.. autoclass:: cudaq.ptsbe.PTSSamplingStrategy
451+
:members:
452+
453+
.. autoclass:: cudaq.ptsbe.ProbabilisticSamplingStrategy
454+
:members:
455+
456+
.. autoclass:: cudaq.ptsbe.OrderedSamplingStrategy
457+
:members:
458+
459+
.. autoclass:: cudaq.ptsbe.ExhaustiveSamplingStrategy
460+
:members:
461+
462+
----
463+
464+
Shot Allocation Strategy
465+
-------------------------
466+
467+
.. autoclass:: cudaq.ptsbe.ShotAllocationStrategy
468+
:members:
469+
470+
.. autoclass:: cudaq.ptsbe.ShotAllocationType
471+
:members:
472+
473+
----
474+
475+
Execution Data
476+
---------------
477+
478+
.. autoclass:: cudaq.ptsbe.PTSBEExecutionData
479+
:members:
480+
481+
.. autoclass:: cudaq.ptsbe.TraceInstruction
482+
:members:
483+
484+
.. autoclass:: cudaq.ptsbe.TraceInstructionType
485+
:members:
486+
487+
----
488+
489+
Trajectory and Selection Types
490+
--------------------------------
491+
492+
.. autoclass:: cudaq.ptsbe.KrausTrajectory
493+
:members:
494+
495+
.. autoclass:: cudaq.ptsbe.KrausSelection
496+
:members:
497+

0 commit comments

Comments
 (0)