10. Quantum Programming Patterns¶
Within quantum kernels, the CUDA Quantum programming model provides simplified syntax for common quantum programming patterns. The collection of patterns in this section will grow over time, but we start with two basic features providing simplified syntax and semantics for common quantum programming tasks. These tasks may also enable the expressivity of programmer intent that directly influences compile-time circuit optimizations.
10.1. Compute-Action-Uncompute¶
We require syntax and semantics to support the compute-action-uncompute
pattern,
// Will invoke U V U^dag
cudaq::compute_action (
[&](){
/*U_code*/
},
[&]() {
/*V_code*/
}
);
Compiler implementations must add the uncompute segment and optimize on any controlled versions of this block of code.