CUDA-Q QEC C++ API ****************************** Code ============= .. doxygenclass:: cudaq::qec::code :members: .. doxygenstruct:: cudaq::qec::patch :members: .. doxygenclass:: cudaq::qec::repetition::repetition :members: .. doxygenclass:: cudaq::qec::steane::steane :members: .. _qec_stabilizer_grid_cpp: .. doxygenenum:: cudaq::qec::surface_code::surface_role .. doxygenenum:: cudaq::qec::surface_code::sc_orientation .. doxygenstruct:: cudaq::qec::surface_code::vec2d :members: .. doxygenclass:: cudaq::qec::surface_code::stabilizer_grid :members: .. doxygenclass:: cudaq::qec::surface_code::surface_code :members: Detector Error Model ==================== .. doxygenstruct:: cudaq::qec::detector_error_model :members: .. doxygenstruct:: cudaq::qec::decoder_context :members: .. doxygenfunction:: cudaq::qec::dem_from_memory_circuit(const code &, operation, std::size_t, cudaq::noise_model &, bool) .. doxygenfunction:: cudaq::qec::x_dem_from_memory_circuit(const code &, operation, std::size_t, cudaq::noise_model &, bool) .. doxygenfunction:: cudaq::qec::z_dem_from_memory_circuit(const code &, operation, std::size_t, cudaq::noise_model &, bool) .. doxygenfunction:: cudaq::qec::decoder_context_from_memory_circuit(const code &, operation, std::size_t, cudaq::noise_model &, bool) .. doxygenfunction:: cudaq::qec::dem_from_stim_text(const std::string &, bool) .. _dyn_dem_cpp_api: Dynamic DEM =========== Types for constructing a dynamic detector error model (DEM). See the :doc:`Dynamic Detector Error Models ` and the :doc:`Decoding with a Dynamic DEM example `. .. doxygenstruct:: cudaq::qec::dem_chunks_spec :members: .. doxygenstruct:: cudaq::qec::phase_spec_entry :members: .. doxygenstruct:: cudaq::qec::phase_connection :members: .. doxygenstruct:: cudaq::qec::seam_connection :members: .. doxygenstruct:: cudaq::qec::dem_chunk_spec :members: .. doxygenstruct:: cudaq::qec::seam_spec_entry :members: .. doxygenstruct:: cudaq::qec::dem_seam_spec :members: .. doxygenstruct:: cudaq::qec::seam_id :members: .. doxygentypedef:: cudaq::qec::phase_id .. doxygennamespace:: cudaq::qec::seam_name :members: .. doxygennamespace:: cudaq::qec::phase_name :members: .. doxygenfunction:: cudaq::qec::memory_dem_chunks_from_decoder_inputs .. _dem_sampling_cpp_api: Detector Error Model (DEM) Sampling =================================== CPU sampling (host tensors): .. doxygenfunction:: cudaq::qec::dem_sampler::cpu::sample_dem(const cudaqx::tensor &, std::size_t, const std::vector &) .. doxygenfunction:: cudaq::qec::dem_sampler::cpu::sample_dem(const cudaqx::tensor &, std::size_t, const std::vector &, unsigned) GPU sampling (device pointers, requires cuStabilizer): .. doxygenfunction:: cudaq::qec::dem_sampler::gpu::sample_dem Legacy convenience wrappers (delegate to ``cpu::sample_dem``; prefer the ``dem_sampler::cpu::sample_dem`` overloads above): .. doxygenfunction:: cudaq::qec::dem_sampling(const cudaqx::tensor &, std::size_t, const std::vector &) .. doxygenfunction:: cudaq::qec::dem_sampling(const cudaqx::tensor &, std::size_t, const std::vector &, unsigned) Decoder Interfaces ================== .. doxygenenum:: cudaq::qec::decode_result_type .. doxygenenum:: cudaq::qec::decoder_auxiliary_result_type .. doxygenstruct:: cudaq::qec::decoder_output_request :members: .. doxygenenum:: cudaq::qec::decoder_model_source .. doxygenstruct:: cudaq::qec::decoder_inputs :members: .. doxygenclass:: cudaq::qec::decoder_init :members: .. doxygenfunction:: cudaq::qec::register_decoder_native_model_source .. doxygenfunction:: cudaq::qec::decoder_needs_model_matrices .. doxygenfunction:: cudaq::qec::d_sparse(const cudaq::M2DSparseMatrix &) .. doxygenenum:: cudaq::qec::round_type .. doxygenenum:: cudaq::qec::cancellation_level .. doxygenclass:: cudaq::qec::cancellation_token :members: .. doxygenclass:: cudaq::qec::cancellation_source :members: .. doxygenclass:: cudaq::qec::decoder :members: :protected-members: .. doxygenstruct:: cudaq::qec::decoder_result :members: .. _decoding_task_graph_cpp_api: Decoding Task Graph =================== A ``decoding_task_graph`` is a decoder pipeline of nodes wired by edges. Build one with ``from_spec`` (one decoder in a window), ``combine`` (two decoders whose corrections are XORed) or ``from_topology`` (any nodes and edges). Run it on complete shots with ``run`` and ``run_batch``, or stream rounds with ``enqueue_syndrome``. See the :doc:`Decoding Task Graphs `, its :ref:`Reference section `, and the :doc:`Getting Started with a Decoding Task Graph `. I/O types --------- .. doxygenstruct:: cudaq::qec::measurement_results :members: .. doxygenstruct:: cudaq::qec::detection_events :members: .. doxygenstruct:: cudaq::qec::logical_outcome :members: .. doxygenstruct:: cudaq::qec::error_pattern :members: .. doxygenfunction:: cudaq::qec::apply_d_sparse .. doxygenfunction:: cudaq::qec::apply_o_sparse .. doxygenfunction:: cudaq::qec::xor_logical Graph ----- .. doxygenstruct:: cudaq::qec::task_graph_edge :members: .. doxygenstruct:: cudaq::qec::task_graph_node_config :members: .. doxygenstruct:: cudaq::qec::task_graph_ensemble_spec :members: .. doxygenstruct:: cudaq::qec::candidate :members: .. doxygenclass:: cudaq::qec::candidate_sink :members: :undoc-members: .. doxygenclass:: cudaq::qec::selection_strategy :members: :undoc-members: .. doxygentypedef:: cudaq::qec::selection_strategy_factory .. doxygenclass:: cudaq::qec::selection_strategy_registration .. doxygenfunction:: cudaq::qec::register_selection_strategy .. doxygenfunction:: cudaq::qec::registered_selection_strategies .. doxygenvariable:: cudaq::qec::default_task_graph_node_kind .. doxygenfunction:: cudaq::qec::registered_task_graph_node_kinds .. doxygenclass:: cudaq::qec::edge_value_type :members: .. doxygenfunction:: cudaq::qec::registered_edge_value_types .. doxygenenum:: cudaq::qec::task_graph_streaming_status .. doxygenenum:: cudaq::qec::task_graph_closure .. doxygenstruct:: cudaq::qec::task_graph_output_progress :members: .. doxygenstruct:: cudaq::qec::task_graph_streaming_result :members: .. doxygenstruct:: cudaq::qec::task_graph_options :members: .. doxygenclass:: cudaq::qec::decoding_task_graph :members: Built-in Decoders ================= .. _nv_qldpc_decoder_api_cpp: NVIDIA QLDPC Decoder -------------------- .. include:: nv_qldpc_decoder_api.rst .. _nv_fusion_decoder_api_cpp: NVIDIA Fusion Decoder --------------------- .. include:: nv_fusion_decoder_api.rst .. _sliding_window_decoder_api_cpp: Sliding Window Decoder ---------------------- .. include:: sliding_window_api.rst .. _trt_decoder_api_cpp: TensorRT Decoder ---------------- .. include:: trt_decoder_api.rst .. _pymatching_decoder_api_cpp: PyMatching Decoder ------------------ .. include:: pymatching_api.rst .. _chromobius_decoder_api_cpp: Chromobius Decoder ------------------ .. include:: chromobius_api.rst .. _cpp_realtime_decoding_api: Realtime Decoding ================= .. include:: cpp_realtime_decoding_api.rst .. include:: realtime_pipeline_api.rst .. _parity_check_matrix_utilities: Parity Check Matrix Utilities ============================= The utilities below create, convert, inspect, and transform parity-check matrices (PCMs). CUDA-Q QEC supports dense matrices as ``cudaqx::tensor`` and sparse matrices as ``sparse_binary_matrix``. Decoder entry points accept either representation and store the PCM internally as a sparse matrix. ``sparse_binary_matrix`` stores a binary matrix in compressed sparse column (CSC) or compressed sparse row (CSR) layout without storing values for its nonzero entries. Input indices are preserved as supplied. Use :cpp:func:`cudaq::qec::sparse_binary_matrix::canonicalize` when duplicate indices should be combined over GF(2) and each compressed row or column should be sorted. Canonicalization preserves the matrix layout. The matrix uses ``std::uint32_t`` indices, so each dimension and the number of stored entries must fit in that type. Sparse utility overloads operate without materializing the full input as a dense tensor. Use :cpp:func:`cudaq::qec::generate_random_pcm_sparse` when a generated PCM would be impractical to allocate densely. The dense generator remains available and rejects dimensions whose products overflow ``std::size_t``. .. doxygenenum:: cudaq::qec::sparse_binary_matrix_layout .. doxygenclass:: cudaq::qec::sparse_binary_matrix :members: .. doxygenfunction:: cudaq::qec::to_parity_matrix(const std::vector &, stabilizer_type) .. doxygenfunction:: cudaq::qec::to_parity_matrix(const std::vector &, stabilizer_type) .. doxygenfunction:: cudaq::qec::dense_to_sparse(const cudaqx::tensor &) .. doxygenfunction:: cudaq::qec::generate_random_pcm(std::size_t, std::size_t, std::size_t, int, std::mt19937_64 &&); .. doxygenfunction:: cudaq::qec::generate_random_pcm_sparse(std::size_t, std::size_t, std::size_t, int, std::mt19937_64 &&); .. doxygenfunction:: cudaq::qec::generate_timelike_sparse_detector_matrix(std::uint32_t num_syndromes_per_round, std::uint32_t num_rounds, bool include_first_round = false) .. doxygenfunction:: cudaq::qec::generate_timelike_sparse_detector_matrix(std::uint32_t num_syndromes_per_round, std::uint32_t num_rounds, std::vector first_round_matrix) .. doxygenfunction:: cudaq::qec::get_pcm_for_rounds(const cudaqx::tensor &, std::uint32_t, std::uint32_t, std::uint32_t, bool, bool, std::uint32_t); .. doxygenfunction:: cudaq::qec::get_pcm_for_rounds(const sparse_binary_matrix &, std::uint32_t, std::uint32_t, std::uint32_t, bool, bool, bool, std::uint32_t); .. doxygenfunction:: cudaq::qec::get_sorted_pcm_column_indices(const std::vector> &, std::uint32_t); .. doxygenfunction:: cudaq::qec::get_sorted_pcm_column_indices(const std::vector> &, std::uint32_t, std::uint32_t); .. doxygenfunction:: cudaq::qec::get_sorted_pcm_column_indices(const cudaqx::tensor &, std::uint32_t); .. doxygenfunction:: cudaq::qec::pcm_extend_to_n_rounds(const cudaqx::tensor &, std::size_t, std::uint32_t); .. doxygenfunction:: cudaq::qec::pcm_from_sparse_string(const std::string &, std::size_t, std::size_t) .. doxygenfunction:: cudaq::qec::pcm_from_sparse_vec(const std::vector& sparse_vec, std::size_t num_rows, std::size_t num_cols) .. doxygenfunction:: cudaq::qec::pcm_is_sorted(const cudaqx::tensor &, std::uint32_t); .. doxygenfunction:: cudaq::qec::pcm_is_sorted(const std::vector> &, std::uint32_t, std::uint32_t); .. doxygenfunction:: cudaq::qec::pcm_to_sparse_string(const cudaqx::tensor &) .. doxygenfunction:: cudaq::qec::pcm_to_sparse_string(const sparse_binary_matrix &) .. doxygenfunction:: cudaq::qec::pcm_to_sparse_vec(const cudaqx::tensor& pcm) .. doxygenfunction:: cudaq::qec::pcm_to_sparse_vec(const sparse_binary_matrix &) .. doxygenfunction:: cudaq::qec::reorder_pcm_columns(const cudaqx::tensor &, const std::vector &, uint32_t, uint32_t); .. doxygenfunction:: cudaq::qec::reorder_pcm_columns(const sparse_binary_matrix &, const std::vector &, uint32_t, uint32_t); .. doxygenfunction:: cudaq::qec::shuffle_pcm_columns(const cudaqx::tensor &, std::mt19937_64 &&); .. doxygenfunction:: cudaq::qec::shuffle_pcm_columns(const sparse_binary_matrix &, std::mt19937_64 &&); .. doxygenfunction:: cudaq::qec::simplify_pcm(const cudaqx::tensor &, const std::vector &, std::uint32_t); .. doxygenfunction:: cudaq::qec::sort_pcm_columns(const cudaqx::tensor &, std::uint32_t); Logger ============= The QEC logger API currently lives in ``cudaq::qec::detail`` and is used by the ``CUDA_QEC_*`` macros exposed in ``cudaq/qec/logger.h``. .. doxygenenum:: cudaq::qec::detail::log_level .. doxygenenum:: cudaq::qec::detail::forward_drop_policy .. doxygenstruct:: cudaq::qec::detail::forwarded_log_record :members: .. doxygenvariable:: cudaq::qec::detail::realtime_forwarder_default_message_capacity .. doxygenstruct:: cudaq::qec::detail::forwarder_config :members: .. doxygenstruct:: cudaq::qec::detail::forwarder_stats :members: .. doxygenfunction:: cudaq::qec::detail::should_log .. doxygenfunction:: cudaq::qec::detail::set_forwarder(forwarder_config) .. doxygenfunction:: cudaq::qec::detail::set_forwarder() .. doxygenfunction:: cudaq::qec::detail::clear_forwarder() .. doxygenfunction:: cudaq::qec::detail::is_forwarder_enabled() .. doxygenfunction:: cudaq::qec::detail::get_forwarder_message_capacity() .. doxygenfunction:: cudaq::qec::detail::get_forwarder_stats() .. doxygenfunction:: cudaq::qec::detail::set_log_level .. doxygenfunction:: cudaq::qec::detail::get_log_level .. doxygenfunction:: cudaq::qec::detail::flush_logs() .. doxygenfunction:: cudaq::qec::detail::trace .. doxygenfunction:: cudaq::qec::detail::info .. doxygenfunction:: cudaq::qec::detail::debug .. doxygenfunction:: cudaq::qec::detail::warn .. doxygenfunction:: cudaq::qec::detail::error .. doxygenfunction:: cudaq::qec::detail::path_to_file_name .. _memory_experiments_cpp_api: Common ============= .. doxygentypedef:: cudaq::qec::float_t .. doxygenenum:: cudaq::qec::operation .. doxygenenum:: cudaq::qec::stabilizer_type .. doxygenfunction:: cudaq::qec::sample_code_capacity(const cudaqx::tensor &, std::size_t, double) .. doxygenfunction:: cudaq::qec::sample_code_capacity(const cudaqx::tensor &, std::size_t, double, unsigned) .. doxygenfunction:: cudaq::qec::sample_code_capacity(const code &, std::size_t, double) .. doxygenfunction:: cudaq::qec::sample_code_capacity(const code &, std::size_t, double, unsigned) .. doxygenfunction:: cudaq::qec::sample_memory_circuit(const code &, std::size_t, std::size_t) .. doxygenfunction:: cudaq::qec::sample_memory_circuit(const code &, std::size_t, std::size_t, cudaq::noise_model &) .. doxygenfunction:: cudaq::qec::sample_memory_circuit(const code &, operation, std::size_t, std::size_t) .. doxygenfunction:: cudaq::qec::sample_memory_circuit(const code &, operation, std::size_t, std::size_t, cudaq::noise_model &) .. doxygenfunction:: cudaq::qec::x_sample_memory_circuit .. doxygenfunction:: cudaq::qec::z_sample_memory_circuit