1313#include " cuda-qx/core/tensor.h"
1414#include " sparse_binary_matrix.h"
1515#include " cudaq/qec/detector_error_model.h"
16+ #include < algorithm>
1617#include < functional>
1718#include < future>
1819#include < memory>
1920#include < optional>
2021#include < string>
2122#include < string_view>
23+ #include < tuple>
2224#include < variant>
2325#include < vector>
2426
@@ -31,8 +33,7 @@ using float_t = double;
3133#endif
3234
3335// / 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+ // / text.
3637using decoder_init = std::variant<sparse_binary_matrix, std::string>;
3738
3839// / @brief Validates that all keys in a heterogeneous map are found in a list of
@@ -516,6 +517,7 @@ get_decoder(const std::string &name, std::string_view stim_dem_text,
516517 return get_decoder (name, decoder_init{std::string{stim_dem_text}}, options);
517518}
518519
520+ namespace details {
519521// / DEM-derived defaults; pointers alias into the source `dem`.
520522struct dem_default_values {
521523 const cudaqx::tensor<uint8_t > *O = nullptr ;
@@ -526,9 +528,7 @@ struct dem_default_values {
526528dem_default_values dem_defaults_for_missing_keys (
527529 const std::function<bool (const std::string &)> &contains_user_key,
528530 const detector_error_model &dem);
529-
530- // / Extract raw Stim DEM text for DEM-native decoders.
531- std::string_view require_dem_text (const decoder_init &init);
531+ } // namespace details
532532
533533// / Build a PCM-based decoder. If `init` holds DEM text, it is parsed into a PCM
534534// / and DEM-derived `"O"` / `"error_rate_vec"` defaults are added when absent.
@@ -541,7 +541,7 @@ make_pcm_decoder(const decoder_init &init,
541541
542542 const auto dem = dem_from_stim_text (std::get<std::string>(init));
543543 cudaqx::heterogeneous_map merged = params;
544- const auto defaults = dem_defaults_for_missing_keys (
544+ const auto defaults = details:: dem_defaults_for_missing_keys (
545545 [&](const std::string &key) { return merged.contains (key); }, dem);
546546 if (defaults.O )
547547 merged.insert (" O" , *defaults.O );
0 commit comments