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

First pass of support for C++ operators #2511

Open
wants to merge 392 commits into
base: experimental/operators
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
392 commits
Select commit Hold shift + click to select a range
a4c104a
Fixing the matrix in the unittest and other code in compute_lindblad …
sacpis Jan 23, 2025
11c7b65
Adding cudm_state with unittests
sacpis Jan 25, 2025
40e52d9
Addign few more unit tests for cudm_state
sacpis Jan 25, 2025
4ea6415
Adding an enum with initial quantum state and initilize_state based o…
sacpis Jan 25, 2025
31709a4
Fixing spelling
sacpis Jan 26, 2025
dafc31a
* Renaming cudm_mat_state -> cudm_state
sacpis Jan 28, 2025
e51696a
Exposing state's rawData to be used in the stepper
sacpis Jan 28, 2025
8a0bd3a
Adding cudm_time_stepper with unittests
sacpis Jan 28, 2025
d2e0441
Refactoring time_stepper compute method to align with cuquantum workflow
sacpis Jan 30, 2025
67d658b
Exposing handle and adding operator overloading for + and *
sacpis Jan 31, 2025
5d74f17
Removing redundant constructor and updating tests for cudm_state
sacpis Jan 31, 2025
ef1d09d
Implementing compute function in cudm_time_stepper
sacpis Jan 31, 2025
6544bee
Adding test_mocks for unittests
sacpis Jan 31, 2025
847c383
Adding check for step_size=0 condition and few more unittests
sacpis Jan 31, 2025
a51a70c
Adding #pragma once so that header files are included only once durin…
sacpis Jan 31, 2025
ef24742
* Adding partial implementation of runge-kutta integrator
sacpis Jan 31, 2025
04b9d77
* Implementing move constructor and move assignment
sacpis Feb 1, 2025
6cb5db2
temp
sacpis Feb 2, 2025
aea580f
Using cudensitymatStateComputeAccumulation and cudensitymatStateCompu…
sacpis Feb 3, 2025
6cbdd28
Allocating k1, k2, k3, k4 inside the scope blocks
sacpis Feb 3, 2025
c35225b
Adding operator+= to do an accumulation instead of moving the state
sacpis Feb 3, 2025
24ea1a0
just some test renaming to make it easier to find
bettinaheim Jan 13, 2025
0d69aab
a bunch of templates to draft how dragging type information through t…
bettinaheim Jan 13, 2025
265e3b3
wip to use elementary_operator as matrix handler
bettinaheim Jan 14, 2025
46fe387
wip to use elementary_operator as matrix handler
bettinaheim Jan 14, 2025
9912357
kinded of more cleaned up but left-hand arithmethics need more thought
bettinaheim Jan 14, 2025
02fc125
constrain the templates
bettinaheim Jan 14, 2025
071b115
making the left hand arithmetics friends
bettinaheim Jan 14, 2025
c12d4c9
cleaned up assignments
bettinaheim Jan 15, 2025
6d3e4bf
fixing a some types
bettinaheim Jan 16, 2025
ccc5cc2
this builds, but needs to be cleaned up
bettinaheim Jan 16, 2025
1a909db
scalar ops tests
bettinaheim Jan 17, 2025
314d61f
to be deleted again - just some notes
bettinaheim Jan 23, 2025
b3e2edd
more memory experiments
bettinaheim Jan 24, 2025
86e1337
revised the data structures - all tests now pass again
bettinaheim Jan 24, 2025
6908d91
store one coefficient per product only
bettinaheim Jan 27, 2025
69a3412
getting rid of all elementary operator overloads
bettinaheim Jan 27, 2025
ced3e6a
clean up for scalars
bettinaheim Jan 28, 2025
b50ae07
some clean up of op sum
bettinaheim Jan 28, 2025
d8c1689
some clean up for products
bettinaheim Jan 28, 2025
5c932b1
no type constraints for HandlerTy
bettinaheim Jan 29, 2025
9f102e9
left hand arithmetics cleanup
bettinaheim Jan 29, 2025
326b607
more clean up
bettinaheim Jan 29, 2025
42908b0
more clean up
bettinaheim Jan 29, 2025
666734d
more clean up
bettinaheim Jan 29, 2025
53eed45
finished cleanup of arithmetics
bettinaheim Jan 29, 2025
97198fc
picking up Anthony's changes
bettinaheim Jan 30, 2025
759ac0b
just a quick renaming
bettinaheim Jan 30, 2025
d0b0d26
minor thing
bettinaheim Jan 30, 2025
144ed26
minor thing
bettinaheim Jan 30, 2025
aa98969
minor things
bettinaheim Jan 31, 2025
9591195
enabling a whole bunch of additional tests
bettinaheim Jan 31, 2025
28b748f
some more product op fixes
bettinaheim Feb 3, 2025
b118f81
just some test fixes
bettinaheim Feb 3, 2025
b350295
fixing matrix reordering issues
bettinaheim Feb 3, 2025
8d844c1
enabling the rest of the tests
bettinaheim Feb 3, 2025
a4504ad
Adding template parameter HandlerTy for operator_sum and formatting
sacpis Feb 4, 2025
299cb28
Fixing Rydberg with template HandlerTy
sacpis Feb 4, 2025
4edcc73
Fixing with template typename
sacpis Feb 4, 2025
d3decea
Fixing HandlerTy tenplate by setting it to a value
sacpis Feb 4, 2025
cf37744
Fixing unittests
sacpis Feb 4, 2025
7d3a8ff
Adding missing functions in helpers and updating initialize_operator_…
sacpis Feb 4, 2025
a95d141
fixing helpers.h path
sacpis Feb 5, 2025
a4f94fb
Adding equality comparision operation for matrix_2
sacpis Feb 5, 2025
27dd340
Fixing the helpers.h path
sacpis Feb 5, 2025
4eca1b0
Adding HandlerTy
sacpis Feb 5, 2025
e0709e2
Disabling unneeded (for now) variables
sacpis Feb 5, 2025
2150ed2
Adding cudaq::matrix_operator as a handler
sacpis Feb 6, 2025
d6ef90b
Disabling template method
sacpis Feb 6, 2025
f244d9d
Fixing template definition in the header and instatiating it in teh c…
sacpis Feb 6, 2025
6c09737
Enabling tests
sacpis Feb 6, 2025
1881519
Fixing Rydberg and renaming fixture in test_cudm_helpers
sacpis Feb 6, 2025
d42e173
* Enabling dynamic_cast for scalar operator
sacpis Feb 6, 2025
7da22de
Minor cmake restructure
1tnguyen Feb 6, 2025
0a0b435
Adding cudm_op_conversion interface
sacpis Feb 6, 2025
281079c
Fixing the return type of _wrap_callback_tensor
sacpis Feb 6, 2025
700fc35
Updating cudm_op_conversion interface to accommodate wrap callback an…
sacpis Feb 6, 2025
fc7d038
Adding cudm_op_conversion implementation, exposing get_generator for …
sacpis Feb 7, 2025
86292c7
Fix segfault and add an end-to-end stepper check
1tnguyen Feb 7, 2025
2833124
Fix RK 1st order and add a test
1tnguyen Feb 7, 2025
4f33f64
Adding unittests for cudm_op_conversion
sacpis Feb 7, 2025
ea79f4c
Adding operator* method
sacpis Feb 7, 2025
dfbf83f
Removing norm method from state
sacpis Feb 7, 2025
f2ec850
Fixing midpoint integration
sacpis Feb 7, 2025
bb0baff
Setting the accumulation for 4 states
sacpis Feb 7, 2025
1c798e1
Disabling RK4 for now
sacpis Feb 8, 2025
9911353
* Adding mode_action_duality
sacpis Feb 8, 2025
eb48e97
Fixing AddComplexScalars unittest
sacpis Feb 9, 2025
4a70b23
Fixing AddScalarAndOperator unittest
sacpis Feb 9, 2025
0c2a4b5
* Changing return type from double to std::complex<double>
sacpis Feb 9, 2025
a67cec9
Fixing RK4
sacpis Feb 9, 2025
c67d19c
Using cudensitymatStateComputeScaling for multiplication of state wit…
sacpis Feb 10, 2025
573952b
Add expectation
1tnguyen Feb 10, 2025
b857150
Merge branch 'dynamics_cpp_operators' of https://github.com/sacpis/cu…
sacpis Feb 11, 2025
7c64f06
Moving wrapper callbacks into cudm_helpers.cpp and disabling cudm_op_…
sacpis Feb 11, 2025
c503e7f
Adding tests for callback functions
sacpis Feb 11, 2025
0c8607b
[WIP] evolve single impl
1tnguyen Feb 11, 2025
16b69c1
* WIP fix for compute lindblad
sacpis Feb 11, 2025
f3bbf4b
Fix issue with append_elementary_operator_to_term
1tnguyen Feb 11, 2025
4839077
* Moving the tensor callbck wrapper in create_elementary_operator
sacpis Feb 11, 2025
7a2c7e7
replacing tensor callback parameter
sacpis Feb 11, 2025
2c74fa2
End-end evolve test
1tnguyen Feb 12, 2025
3e81144
Fixing lindblad operator
sacpis Feb 12, 2025
47bfb80
reverting accidental change to the logic handling already existing ma…
sacpis Feb 12, 2025
1e1b44e
Add composite system test and fix an issue with create a product term…
1tnguyen Feb 12, 2025
c134c57
Updating compute_lindblad_op with the updated append_elementary_opera…
sacpis Feb 12, 2025
1e693dc
Code restructure: separate cudm-dependency into nvqir target; no oper…
1tnguyen Feb 13, 2025
3b46cc8
Fix RK unit test
1tnguyen Feb 13, 2025
9cf261b
Adding TimeSteppingWithLindblad unitest to test compute_lindblad_oper…
sacpis Feb 13, 2025
9538ec2
Merge branch 'dynamics_cpp_operators' of https://github.com/sacpis/cu…
sacpis Feb 13, 2025
ed5da79
completing tests, including for custom matrices
bettinaheim Feb 4, 2025
f145e3c
minor clean up
bettinaheim Feb 4, 2025
d308886
general clean up
bettinaheim Feb 4, 2025
138b2e9
clean up (moving some files)
bettinaheim Feb 5, 2025
2669d95
prep for adding different handlers
bettinaheim Feb 5, 2025
5a85e9f
trivial spin ops to set up tests before digging into perf optimizations
bettinaheim Feb 5, 2025
59386f3
some more tests, and making dimensions not required for evaluation if…
bettinaheim Feb 5, 2025
7a1aefe
more spin ops tests
bettinaheim Feb 6, 2025
c277d11
commit before removing inheritance
bettinaheim Feb 7, 2025
aa86a87
removing the inheritance from operator sum
bettinaheim Feb 7, 2025
8767426
some more clean up
bettinaheim Feb 7, 2025
3aa6283
implementing remaining conversions
bettinaheim Feb 10, 2025
1377a2f
finished conversion tests
bettinaheim Feb 10, 2025
261f744
gathering some perf numbers before optimization
bettinaheim Feb 10, 2025
705a650
always link the operator lib
bettinaheim Feb 10, 2025
b422030
undoing accidentally committed change
bettinaheim Feb 10, 2025
e411cb7
product optimizations
bettinaheim Feb 10, 2025
de49502
first version with perf improvements
bettinaheim Feb 13, 2025
a70b22c
perf version 2 with map
bettinaheim Feb 13, 2025
fcdb4c8
Fix linblad test and fix leak
1tnguyen Feb 14, 2025
44341e0
Merge branch 'dynamics_cpp_operators' of https://github.com/sacpis/cu…
sacpis Feb 14, 2025
5d6e73e
Add full density matrix evolve and reduce test time
1tnguyen Feb 14, 2025
6769eb6
Merge branch 'dynamics_cpp_operators' of https://github.com/sacpis/cu…
sacpis Feb 14, 2025
0d31c8b
Support static collapse op and add a test
1tnguyen Feb 14, 2025
2178b0e
Merge branch 'dynamics_cpp_operators' of https://github.com/sacpis/cu…
sacpis Feb 14, 2025
eb5688b
* Adding conversion mechanism (to operator_sum<product_operator>) after
sacpis Feb 14, 2025
f2ba966
changes to the test script
bettinaheim Feb 13, 2025
b5ada26
checking in v2 perf numbers for comparison
bettinaheim Feb 14, 2025
79a9b15
Bringing in more commits from Bettina's branch
bettinaheim Feb 14, 2025
ae4ae7c
Hook public API
1tnguyen Feb 15, 2025
4bd04be
Port cudm_state under cudaq::SimulationState type
1tnguyen Feb 17, 2025
69118b5
More cleanup: only use cudaq::state at the API surface
1tnguyen Feb 17, 2025
9fdf186
More cleanup: remove the type alias
1tnguyen Feb 17, 2025
6f03515
Add handle to sim class
1tnguyen Feb 17, 2025
d1ddf76
Some fixes for _wrap_callback and add TODO
1tnguyen Feb 17, 2025
737c667
commit before switching branches
bettinaheim Feb 14, 2025
b682430
third and final version with a decent performance across the board
bettinaheim Feb 17, 2025
a3ad658
adding missing rvalue overloads
bettinaheim Feb 17, 2025
8ee54f2
Fixing Scalar callback using Python callback from cudensitymat and fo…
sacpis Feb 18, 2025
aa8d3f0
Removing mutex
sacpis Feb 18, 2025
272f436
Passing param names to scalar callback
1tnguyen Feb 19, 2025
0521183
integrator + schedule in the loop to resolve parameter values
1tnguyen Feb 19, 2025
1a652bf
Adding tensor callback with the unittest
sacpis Feb 19, 2025
0784b45
Support state vec -> density matrix conversion if collapse ops are pr…
1tnguyen Feb 19, 2025
1b2eecc
Removing batch_size from tensor_callback and formatting
sacpis Feb 19, 2025
d684a15
Fixing unittest and string formatting
sacpis Feb 19, 2025
fb0e146
Fixing checkScalarTd
sacpis Feb 19, 2025
c1a3b2c
Fixing CheckScalarCallback by enabling memcpy to copy the flattened m…
sacpis Feb 19, 2025
7efb20c
Adding cavity_qed example for C++ dynamics
sacpis Feb 20, 2025
d612030
Adding cross_resonance example for C++ dynamics
sacpis Feb 20, 2025
677f460
Hook callback support to Linblad conversion
1tnguyen Feb 20, 2025
0c9a219
[Code Cleanup] Create a global context to track the handle + scratch …
1tnguyen Feb 20, 2025
44ea577
Merge remote-tracking branch 'origin/dynamics_cpp_operators' into dyn…
sacpis Feb 20, 2025
9a4cc40
getting updates from main
bettinaheim Feb 18, 2025
4b47201
removing some files that should not be part of this PR
bettinaheim Feb 18, 2025
3695e7b
forgot one file
bettinaheim Feb 18, 2025
309b8dd
forgot one file
bettinaheim Feb 18, 2025
940cdc4
[Cleanup] Tidy up the code
1tnguyen Feb 20, 2025
788ab73
Merge branch 'dynamics_cpp_operators' of github.com:sacpis/cuda-quant…
1tnguyen Feb 20, 2025
3909ef2
just some clean up
bettinaheim Feb 18, 2025
4307a89
just some clean up
bettinaheim Feb 18, 2025
b0f60ce
full in-place multiplication for bosons
bettinaheim Feb 19, 2025
c582721
additional boson tests and clean up
bettinaheim Feb 19, 2025
b52b3f4
Merging Bettina's changes and formatting
sacpis Feb 20, 2025
97f229b
Fix the order of elemetary op application in a product term: we write…
1tnguyen Feb 20, 2025
41dee84
Dynamics target uses library mode
1tnguyen Feb 21, 2025
83f96c8
Optimization for skipping tensor callback generation for known ops
1tnguyen Feb 21, 2025
5d6fe4d
Adding initial version of cavity_qed example
sacpis Feb 21, 2025
7dd9769
Merge remote-tracking branch 'origin/dynamics_cpp_operators' into dyn…
sacpis Feb 21, 2025
db25bf8
Saving simulation result to csv files, adding a utility helper to cre…
sacpis Feb 21, 2025
30b4aab
Add async API and tests
1tnguyen Feb 21, 2025
ea66c29
Merge branch 'dynamics_cpp_operators' of github.com:sacpis/cuda-quant…
1tnguyen Feb 21, 2025
2a58c55
Make dynamics mqpu capable
1tnguyen Feb 21, 2025
3d99f9b
Adding qubit_dynamics, formatting
sacpis Feb 21, 2025
df14a1e
Merge remote-tracking branch 'origin/dynamics_cpp_operators' into dyn…
sacpis Feb 21, 2025
d08087d
Adding qubit_control example
sacpis Feb 21, 2025
2decf75
Edit C++ dynamics examples
1tnguyen Feb 21, 2025
36f908d
[wip] preparing to add fermion operators
bettinaheim Feb 20, 2025
b05ccdb
[wip] - commit before deciding to change the representation
bettinaheim Feb 21, 2025
ab44af1
fermion on a single degree - tests may need to be updated once we mak…
bettinaheim Feb 21, 2025
9c9d8d7
do not reorder terms for fermions - should take care of antisymmetry,…
bettinaheim Feb 21, 2025
8300465
Fixing build issue with header file and formatting
sacpis Feb 21, 2025
ab7dbdb
Adding heisenberg_model example
sacpis Feb 21, 2025
7ff9be4
Adding cross_resonance example
sacpis Feb 21, 2025
5e74fb8
Creating state and schedule for each g value
sacpis Feb 22, 2025
fc2a6ac
Workaround issue with cudm scale and accum API (to be investigated)
1tnguyen Feb 22, 2025
dc08d56
Merge branch 'dynamics_cpp_operators' of github.com:sacpis/cuda-quant…
1tnguyen Feb 22, 2025
aa565a9
Output text change with the correct file names
sacpis Feb 22, 2025
30c0510
Temporary disabling MPI tests
sacpis Feb 22, 2025
3563ad0
Fix cross resonance examples
1tnguyen Feb 22, 2025
d68f40d
use cudaq::linspace
1tnguyen Feb 22, 2025
09e7270
Constructing value as a complex double as the implict conversion from…
sacpis Feb 22, 2025
8a54e43
Merge remote-tracking branch 'origin/dynamics_cpp_operators' into dyn…
sacpis Feb 22, 2025
02d471b
Constructing complex<double> to fix implicit conversion error
sacpis Feb 23, 2025
fbadb03
Removing default argument in TYPE_CONVERSION_CONSTRAINT as it is alre…
sacpis Feb 23, 2025
235da3f
Removing default argument as it is already defined
sacpis Feb 23, 2025
25fe003
Added comments mostly Physics concepts
sacpis Feb 25, 2025
3ccd0af
Adding comments, for the dynamics examples, related to Physics
sacpis Feb 25, 2025
d6f7e05
Revert "Removing default argument as it is already defined"
sacpis Feb 25, 2025
eb30c64
Revert "Removing default argument in TYPE_CONVERSION_CONSTRAINT as it…
sacpis Feb 25, 2025
13f30dc
Revert "Constructing complex<double> to fix implicit conversion error"
sacpis Feb 25, 2025
b58fb8f
Revert "Constructing value as a complex double as the implict convers…
sacpis Feb 25, 2025
aa86ea4
commit before moving the operator arithmetics into the header...
bettinaheim Feb 24, 2025
791a582
first draft for spin ops to matrix opt - needs clean up
bettinaheim Feb 24, 2025
c643d4e
minor things
bettinaheim Feb 24, 2025
3ef23a3
some clean up and more tests
bettinaheim Feb 25, 2025
91ddebe
some clean up
bettinaheim Feb 25, 2025
122cfdd
making internal (canonical) ordering and user facing ordering constan…
bettinaheim Feb 25, 2025
cc2dd11
clean up and a test
bettinaheim Feb 25, 2025
5981afc
less copying during evaluation
bettinaheim Feb 25, 2025
184127d
Bringing in Bettina's changes and formatting
sacpis Feb 25, 2025
0bbb1eb
* Separating evolve API for Python and C++
sacpis Feb 26, 2025
1e50360
Cleaning up unwanted cudm_op_conversion
sacpis Feb 26, 2025
c168b32
Adding libcudensitymat as the public link lib
sacpis Feb 26, 2025
ba31a9e
Using PascalCase for classes, camel for methods, and snake_case for p…
sacpis Feb 26, 2025
00a991e
trivial implementation of anti-commutation relations (needs clean up)
bettinaheim Feb 26, 2025
79871e6
simplifying fermion operator handler since we don't use negative op c…
bettinaheim Feb 26, 2025
207cae5
test boson commutation relation
bettinaheim Feb 26, 2025
88841c2
introducing a more general notion of 'commutation sets'
bettinaheim Feb 26, 2025
1c012a7
template specialization to avoid unnecessary overhead and some explan…
bettinaheim Feb 26, 2025
85795d3
properly allowing to customize commutation behavior - should allow fo…
bettinaheim Feb 27, 2025
3cc7d83
review comments
bettinaheim Feb 27, 2025
098bb2f
formatting
bettinaheim Feb 27, 2025
25939d9
adding a quick check that fermion commutation relation with number op…
bettinaheim Feb 27, 2025
5ad29f9
formatting
bettinaheim Feb 27, 2025
09b9253
spelling
bettinaheim Feb 27, 2025
8a340b0
one more formatting fix
bettinaheim Feb 27, 2025
d6c268b
Cleaning up and adding missing code in schedule
sacpis Feb 27, 2025
2861144
Adding comments
sacpis Feb 27, 2025
ff0e6bb
Making comments consistent with othe rclasses
sacpis Feb 27, 2025
794e0d1
Add a missing evolve_async overload
1tnguyen Feb 28, 2025
92f9939
Adding default copy assignment operator
sacpis Feb 28, 2025
97b55cb
Merge remote-tracking branch 'origin/dynamics_cpp_operators' into dyn…
sacpis Feb 28, 2025
cedbb48
Adding begin and end which returns an iterator to iterate schedule in…
sacpis Feb 28, 2025
b8da9d9
Adding explicit copy operator, added return type for begin and end it…
sacpis Feb 28, 2025
6433ed4
Adding default constructor to ensure m_schedule is properly initialized
sacpis Feb 28, 2025
5fd3eb0
Adding comments, renaming, formatting
sacpis Feb 28, 2025
2939d64
Few more comments
sacpis Mar 1, 2025
d2bbf9c
Renaming unittests
sacpis Mar 1, 2025
28566d5
Tidy up evolve.h: make type conversion helpers
1tnguyen Mar 3, 2025
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
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@
"C_Cpp.inlayHints.referenceOperator.enabled": false,
"C_Cpp.doxygen.generateOnType": false,
"C_Cpp.default.cStandard": "c17",
"C_Cpp.default.cppStandard": "c++20",
"C_Cpp.default.cppStandard": "c++17",
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json",
"C_Cpp.default.compileCommands": "${workspaceFolder}/build/debug/compile_commands.json",
"C_Cpp.default.includePath": [
"${workspaceFolder}/**",
"${CUDAQ_INSTALL_PREFIX}/**",
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/config/spelling_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ discoverable
discretization
discretize
discretized
eigenbasis
eigensolver
eigensolvers
eigenstate
Expand All @@ -201,6 +202,7 @@ eigenvalues
eigenvector
eigenvectors
endian
endianness
enqueue
enqueues
enqueuing
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publishing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ jobs:
fi; \
done`

rm -rf examples applications targets && mv github-repo/docs/sphinx/examples examples && mv github-repo/docs/sphinx/applications applications && mv github-repo/docs/sphinx/targets targets
rm -rf examples applications targets snippets && mv github-repo/docs/sphinx/examples examples && mv github-repo/docs/sphinx/applications applications && mv github-repo/docs/sphinx/targets targets && mv github-repo/docs/sphinx/snippets/python snippets
mv github-repo/docs/notebook_validation.py .
GITHUB_STEP_SUMMARY=$GITHUB_STEP_SUMMARY \
bash github-repo/scripts/validate_container.sh $backends_to_test | tee /tmp/validation.out
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/python_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ jobs:
done

- name: Run Python MPI tests
if: matrix.os_image == 'redhat/ubi9:9.2'
# Temporary disabling this test for the bug bash
# matrix.os_image == 'redhat/ubi9:9.2'
if: false
uses: ./.github/actions/run-in-docker
with:
image: wheel_validation:local
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ endif()
if(NOT CUTENSORNET_ROOT)
SET(CUTENSORNET_ROOT "$ENV{CUQUANTUM_INSTALL_PREFIX}")
endif()
if(NOT CUDENSITYMAT_ROOT)
SET(CUDENSITYMAT_ROOT "$ENV{CUQUANTUM_INSTALL_PREFIX}")
endif()
if(NOT CUTENSOR_ROOT)
SET(CUTENSOR_ROOT "$ENV{CUTENSOR_INSTALL_PREFIX}")
endif()
Expand Down
1 change: 1 addition & 0 deletions cmake/Modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set(CONFIG_FILES
CUDAQEmDefaultConfig.cmake
CUDAQNloptConfig.cmake
CUDAQSpinConfig.cmake
CUDAQOperatorConfig.cmake
CUDAQConfig.cmake
CUDAQEnsmallenConfig.cmake
CUDAQPlatformDefaultConfig.cmake
Expand Down
3 changes: 3 additions & 0 deletions cmake/Modules/CUDAQConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ list(APPEND CMAKE_MODULE_PATH "${CUDAQ_CMAKE_DIR}")
set (CUDAQSpin_DIR "${CUDAQ_CMAKE_DIR}")
find_dependency(CUDAQSpin REQUIRED)

set (CUDAQOperator_DIR "${CUDAQ_CMAKE_DIR}")
find_dependency(CUDAQOperator REQUIRED)

set (CUDAQCommon_DIR "${CUDAQ_CMAKE_DIR}")
find_dependency(CUDAQCommon REQUIRED)

Expand Down
3 changes: 3 additions & 0 deletions cmake/Modules/CUDAQEmDefaultConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ get_filename_component(CUDAQ_EM_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set (CUDAQSpin_DIR "${CUDAQ_EM_CMAKE_DIR}")
find_dependency(CUDAQSpin REQUIRED)

set (CUDAQOperator_DIR "${CUDAQ_EM_CMAKE_DIR}")
find_dependency(CUDAQOperator REQUIRED)

set (CUDAQCommon_DIR "${CUDAQ_EM_CMAKE_DIR}")
find_dependency(CUDAQCommon REQUIRED)

Expand Down
13 changes: 13 additions & 0 deletions cmake/Modules/CUDAQOperatorConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ============================================================================ #
# Copyright (c) 2022 - 2025 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. #
# ============================================================================ #

get_filename_component(CUDAQ_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)

if(NOT TARGET cudaq::cudaq-operator)
include("${CUDAQ_CMAKE_DIR}/CUDAQOperatorTargets.cmake")
endif()
3 changes: 3 additions & 0 deletions cmake/Modules/CUDAQPlatformDefaultConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ get_filename_component(CUDAQ_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set (CUDAQEmDefault_DIR "${CUDAQ_CMAKE_DIR}")
find_dependency(CUDAQEmDefault REQUIRED)

set (CUDAQOperator_DIR "${CUDAQ_CMAKE_DIR}")
find_dependency(CUDAQOperator REQUIRED)

set (CUDAQSpin_DIR "${CUDAQ_CMAKE_DIR}")
find_dependency(CUDAQSpin REQUIRED)

Expand Down
1 change: 1 addition & 0 deletions cmake/Modules/NVQIRConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ include(CMakeFindDependencyMacro)
get_filename_component(PARENT_DIRECTORY ${NVQIR_CMAKE_DIR} DIRECTORY)

find_dependency(CUDAQSpin REQUIRED HINTS "${PARENT_DIRECTORY}/cudaq")
find_dependency(CUDAQOperator REQUIRED HINTS "${PARENT_DIRECTORY}/cudaq")
find_dependency(CUDAQCommon REQUIRED HINTS "${PARENT_DIRECTORY}/cudaq")
find_package(fmt QUIET)
if (NOT fmt_FOUND)
Expand Down
4 changes: 0 additions & 4 deletions docker/build/devdeps.ext.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,3 @@ ENV CUTENSOR_INSTALL_PREFIX="$CUTENSOR_INSTALL_PREFIX"
ENV CUTENSOR_ROOT="$CUTENSOR_INSTALL_PREFIX"
ENV LD_LIBRARY_PATH="$CUTENSOR_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH"
ENV CPATH="$CUTENSOR_INSTALL_PREFIX/include:$CPATH"

# Active MPI support for the cuTensorNet library
RUN cd "$CUQUANTUM_INSTALL_PREFIX/distributed_interfaces/" && source activate_mpi_cutn.sh
ENV CUTENSORNET_COMM_LIB="$CUQUANTUM_INSTALL_PREFIX/distributed_interfaces/libcutensornet_distributed_interface_mpi.so"
144 changes: 144 additions & 0 deletions docs/sphinx/examples/cpp/dynamics/cavity_qed.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/*******************************************************************************
* Copyright (c) 2022 - 2025 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. *
******************************************************************************/

// Compile and run with:
// ```
// nvq++ --target dynamics cavity_qed.cpp -o a.out && ./a.out
// ```

#include "cudaq/algorithms/evolve.h"
#include "cudaq/dynamics_integrators.h"
#include "cudaq/operators.h"
#include "export_csv_helper.h"
#include <cudaq.h>

int main() {

// Dimension of our composite quantum system:
// subsystem 0 (atom) has 2 levels (ground and excited states).
// subsystem 1 (cavity) has 10 levels (Fock states, representing photon number
// states).
std::map<int, int> dimensions{{0, 2}, {1, 10}};

// For the cavity subsystem 1
// We create the annihilation (a) and creation (a+) operators.
// These operators lower and raise the photon number, respectively.
auto a = cudaq::boson_operator::annihilate(1);
auto a_dag = cudaq::boson_operator::create(1);

// For the atom subsystem 0
// We create the annihilation (sm) and creation (sm_dag) operators.
// These operators lower and raise the excitation number, respectively.
auto sm = cudaq::boson_operator::annihilate(0);
auto sm_dag = cudaq::boson_operator::create(0);

// Number operators
// These operators count the number of excitations.
// For the atom (subsytem 0) and the cavity (subsystem 1) they give the
// population in each subsystem.
auto atom_occ_op = cudaq::matrix_operator::number(0);
auto cavity_occ_op = cudaq::matrix_operator::number(1);

// Hamiltonian
// The hamiltonian models the dynamics of the atom-cavity (cavity QED) system
// It has 3 parts:
// 1. Caity energy: 2 * pi * photon_number_operator -> energy proportional to
// the number of photons.
// 2. Atomic energy: 2 * pi * atom_number_operator -> energy proportional to
// the atomic excitation.
// 3. Atomic-cavity interaction: 2 * pi * 0.25 * (sm * a_dag + sm_dag * a) ->
// represents the exchange of energy between the atom and the cavity. It is
// analogous to the Jaynes-Cummings model in cavity QED.
auto hamiltonian = (2 * M_PI * cavity_occ_op) + (2 * M_PI * atom_occ_op) +
(2 * M_PI * 0.25 * (sm * a_dag + sm_dag * a));

// Build the initial state
// Atom (sub-system 0) in ground state.
// Cavity (sub-system 1) has 5 photons (Fock space).
// The overall Hilbert space is 2 * 10 = 20.
const int num_photons = 5;
std::vector<std::complex<double>> initial_state_vec(20, 0.0);
// The index is chosen such that the atom is in the ground state while the
// cavity is in the Fock state with 5 photons.
initial_state_vec[dimensions[0] * num_photons] = 1;

// Define a time evolution schedule
// We define a time grid from 0 to 10 (in arbitray time units) with 201 time
// steps This schedule is used by the integrator to simulate the dynamics.
const int num_steps = 201;
auto steps = cudaq::linspace(0.0, 10.0, num_steps);
cudaq::Schedule schedule(steps);

// Create a CUDA quantum state
// The initial state is converted into a quantum state object for evolution.
auto rho0 = cudaq::state::from_data(initial_state_vec);

// Numerical integrator
// Here we choose a Runge-Kutta method for time evolution.
// dt defines the time step for the numerical integration, and order 4
// indicates a 4th order method.
std::shared_ptr<cudaq::RungeKuttaIntegrator> integrator =
std::make_shared<cudaq::RungeKuttaIntegrator>();
integrator->dt = 0.01;
integrator->order = 4;

// Evolve without collapse operators
// This evolution is ideal (closed system) dynamics governed solely by the
// Hamiltonian. The expectation values of the observables (cavity photon
// number and atom excitation probability) are recorded.
cudaq::evolve_result evolve_result =
cudaq::evolve(hamiltonian, dimensions, schedule, rho0, integrator, {},
{cavity_occ_op, atom_occ_op}, true);

// Adding dissipation
// To simulate a realistic scenario, we introduce decay (dissipation).
// Here, the collapse operator represents photon loss from the cavity.
constexpr double decay_rate = 0.1;
auto collapse_operator = std::sqrt(decay_rate) * a;
// Evolve with the collapse operator to incorporate the effect of decay.
cudaq::evolve_result evolve_result_decay =
cudaq::evolve(hamiltonian, dimensions, schedule, rho0, integrator,
{collapse_operator}, {cavity_occ_op, atom_occ_op}, true);

// Lambda to extract expectation values for a given observable index
// Here, index 0 corresponds to the cavity photon number and index 1
// corresponds to the atom excitation probability.
auto get_expectation = [](int idx,
const auto &result) -> std::vector<double> {
std::vector<double> expectations;

auto all_exps = result.get_expectation_values().value();
for (auto exp_vals : all_exps) {
expectations.push_back((double)exp_vals[idx]);
}
return expectations;
};

// Retrieve expectation values from both the ideal and decaying evolutions.
auto ideal_result0 = get_expectation(0, evolve_result);
auto ideal_result1 = get_expectation(1, evolve_result);
auto decay_result0 = get_expectation(0, evolve_result_decay);
auto decay_result1 = get_expectation(1, evolve_result_decay);

// Export the results to CSV files
// "cavity_qed_ideal_result.csv" contains the ideal evolution results.
// "cavity_qed_decay_result.csv" contains the evolution results with cavity
// decay.
export_csv("cavity_qed_ideal_result.csv", "time", steps,
"cavity_photon_number", ideal_result0,
"atom_excitation_probability", ideal_result1);
export_csv("cavity_qed_decay_result.csv", "time", steps,
"cavity_photon_number", decay_result0,
"atom_excitation_probability", decay_result1);

std::cout << "Simulation complete. The results are saved in "
"cavity_qed_ideal_result.csv "
"and cavity_qed_decay_result.csv files."
<< std::endl;
return 0;
}
Loading
Loading