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-backends
This page is read only. You can view the source, but not change it.
# Backends and execution **Backends** are the execution targets: simulators (CPU, GPU) or real quantum hardware. CUDA-Q abstracts backends—same kernel code runs on any target. ```cpp #include "cudaq.h" #include <string> struct SimpleKernel { void operator()() __qpu__ { cudaq::qvector q(2); h(q[0]); cx(q[0], q[1]); mz(q); } }; int main() { // List available backends auto backends = cudaq::available_backends(); for (const auto& backend : backends) { printf("Available: %s\n", backend.c_str()); } // Set backend at runtime cudaq::set_target("nvidia"); // GPU simulator (cuQuantum) auto gpu_result = cudaq::sample<SimpleKernel>(1000); printf("GPU result:\n"); for (auto& [bits, count] : gpu_result) { printf(" %s: %lu\n", bits.c_str(), count); } // Switch to CPU simulator cudaq::set_target("qpp"); auto cpu_result = cudaq::sample<SimpleKernel>(1000); printf("CPU result:\n"); for (auto& [bits, count] : cpu_result) { printf(" %s: %lu\n", bits.c_str(), count); } // Connect to real hardware (if available) cudaq::set_target("iqm"); // IQM backend // auto hw_result = cudaq::sample<SimpleKernel>(1000); return 0; } ``` ## Backend types **GPU Simulators** (nvidia, cuQuantum): fast for 20–30 qubits, perfect fidelity **CPU Simulators** (qpp, stim): universal but slower **Hardware Providers** (IQM, IonQ, etc.): real quantum processors
Page Tools
Show pagesource
Backlinks
Back to top