@@ -30,21 +30,10 @@ using float_t = CUDAQX_QEC_FLOAT_TYPE;
3030using float_t = double ;
3131#endif
3232
33- // / @brief Construction input for a decoder: either an explicit parity-check
34- // / matrix (`cudaq::qec::sparse_binary_matrix`) or a Stim detector error model
35- // / string (`std::string`).
36- // /
37- // / Parity-check-matrix-based decoders (LUT, sliding_window, TRT, PyMatching,
38- // / nv-qldpc, ...) accept either alternative: a DEM string is parsed into a
39- // / parity-check matrix via `dem_from_stim_text`. Decoders that require the raw
40- // / DEM (e.g. Chromobius, which needs detector color/basis annotations) require
41- // / the string alternative and reject a bare matrix.
42- // /
43- // / @note The factory input owns the DEM text. Public overloads accept
44- // / `std::string`, `const char *`, and `std::string_view` and copy into this
45- // / variant before dispatching to decoder plugins.
46- using decoder_init =
47- std::variant<cudaq::qec::sparse_binary_matrix, std::string>;
33+ // / Decoder construction input: either a parity-check matrix or raw Stim DEM
34+ // / text. PCM-based decoders can accept both; DEM-native decoders can require
35+ // / the string alternative via `require_dem_text`.
36+ using decoder_init = std::variant<sparse_binary_matrix, std::string>;
4837
4938// / @brief Validates that all keys in a heterogeneous map are found in a list of
5039// / acceptable types
@@ -195,10 +184,7 @@ class decoder
195184
196185 // / @brief Construct a registered decoder by name.
197186 // / @param name The registered decoder name.
198- // / @param init Either a parity-check matrix or a Stim DEM string (see
199- // / `decoder_init`). The variant is forwarded to the decoder's creator, so
200- // / parity-check-matrix-based decoders and DEM-native decoders (Chromobius)
201- // / share a single entry point.
187+ // / @param init A parity-check matrix or raw Stim DEM string.
202188 // / @param param_map Optional decoder-specific parameters.
203189 static std::unique_ptr<decoder>
204190 get (const std::string &name, const decoder_init &init,
@@ -530,39 +516,22 @@ get_decoder(const std::string &name, std::string_view stim_dem_text,
530516 return get_decoder (name, decoder_init{std::string{stim_dem_text}}, options);
531517}
532518
533- // / @brief DEM-derived defaults; pointers alias into the source `dem`.
519+ // / DEM-derived defaults; pointers alias into the source `dem`.
534520struct dem_default_values {
535521 const cudaqx::tensor<uint8_t > *O = nullptr ;
536522 const std::vector<double > *error_rate_vec = nullptr ;
537523};
538524
539- // / @brief Return DEM defaults for any key not already supplied by the user.
540- // / Shared by `make_pcm_decoder` and the Python binding.
525+ // / Return DEM defaults for keys not already supplied by the user.
541526dem_default_values dem_defaults_for_missing_keys (
542527 const std::function<bool (const std::string &)> &contains_user_key,
543528 const detector_error_model &dem);
544529
545- // / @brief Extract the Stim DEM text from a `decoder_init`, throwing if it
546- // / holds a parity-check matrix instead. Use this in the create() function of
547- // / decoders that require a raw DEM (e.g. Chromobius), which cannot be
548- // / reconstructed from a bare parity-check matrix.
530+ // / Extract raw Stim DEM text for DEM-native decoders.
549531std::string_view require_dem_text (const decoder_init &init);
550532
551- // / @brief Build a parity-check-matrix-based decoder from a `decoder_init`.
552- // /
553- // / If `init` holds a sparse matrix, it is used directly as the parity-check
554- // / matrix. If it holds a Stim DEM string, it is parsed via
555- // / `dem_from_stim_text` and the derived observables (`"O"`) and per-error
556- // / rates (`"error_rate_vec"`) are injected into `params` unless the user
557- // / already supplied them (user values win). This is the shared implementation
558- // / behind the create() function of every parity-check-matrix-based decoder,
559- // / giving them DEM-string support for free.
560- // /
561- // / @note The DEM parse is lossy: detector annotations, decomposition
562- // / separators, and `error_ids` are dropped. Sufficient for matching-style /
563- // / parity-check-matrix decoders (LUT, NV, sliding_window, TRT, PyMatching).
564- // / Decoders that need full DEM metadata (e.g. Chromobius detector color/basis)
565- // / must consume the string directly via `require_dem_text`.
533+ // / Build a PCM-based decoder. If `init` holds DEM text, it is parsed into a PCM
534+ // / and DEM-derived `"O"` / `"error_rate_vec"` defaults are added when absent.
566535template <typename DecoderT>
567536std::unique_ptr<decoder>
568537make_pcm_decoder (const decoder_init &init,
@@ -582,10 +551,8 @@ make_pcm_decoder(const decoder_init &init,
582551 cudaq::qec::sparse_binary_matrix (dem.detector_error_matrix ), merged);
583552}
584553
585- // / @brief Construct a decoder by name from a Stim detector error model string.
586- // /
587554// / @deprecated Prefer `get_decoder`, which now accepts a Stim DEM string
588- // / directly via `decoder_init`. Retained as a thin convenience alias .
555+ // / directly.
589556std::unique_ptr<decoder>
590557get_decoder_from_stim_dem (const std::string &name,
591558 const std::string &stim_dem_text,
0 commit comments