skip to content
Ivan's wiki
Site Tools
Search
Tools
Show pagesource
Backlinks
Recent Changes
Media Manager
Sitemap
>
Recent Changes
Media Manager
Sitemap
cuda-q-hybrid-computing
This page is read only. You can view the source, but not change it.
# Hybrid quantum-classical Computing **Hybrid quantum-classical computing** interleaves quantum operations with classical computation. Classical code drives quantum kernels, processes results, and makes decisions—all in the same program. This is essential for variational algorithms, error mitigation, and real-time feedback. CUDA-Q's native C++ support makes hybrid programming natural: quantum kernels are C++ functions, results flow back to classical code seamlessly. ```cpp #include "cudaq.h" #include <vector> #include <cmath> // Quantum kernel: measure qubit state struct MeasureState { void operator()(double angle) __qpu__ { cudaq::qvector q(1); ry(angle, q[0]); mz(q[0]); } }; // Classical optimization loop int main() { std::vector<double> angles; double best_cost = 1e9; // Classical loop driving quantum kernel for (double angle = 0.0; angle < M_PI; angle += 0.1) { // Execute quantum kernel with parameter auto result = cudaq::sample<MeasureState>(1000, angle); // Process classical result double cost = result.probability("1"); // P(|1⟩) if (cost < best_cost) { best_cost = cost; angles.push_back(angle); } } printf("Best angle: %.3f, Best cost: %.6f\n", angles.back(), best_cost); return 0; } ``` Hybrid computing enables [VQE](/cuda-q-vqe), [QAOA](/cuda-q-qaoa), and quantum machine learning. The classical-quantum split is where quantum advantage emerges: quantum for superposition/entanglement, classical for control and optimization.
Page Tools
Show pagesource
Backlinks
Back to top