Support Stim DEM strings in get_decoder#571
Conversation
e034551 to
b3aa44a
Compare
b3aa44a to
bccd851
Compare
5b57205 to
6603369
Compare
71c1666 to
1b2c61c
Compare
Signed-off-by: vedika-saravanan <vsaravanan@nvidia.com>
Signed-off-by: vedika-saravanan <vsaravanan@nvidia.com>
Signed-off-by: vedika-saravanan <vsaravanan@nvidia.com>
Signed-off-by: vedika-saravanan <vsaravanan@nvidia.com>
Signed-off-by: vedika-saravanan <vsaravanan@nvidia.com>
Signed-off-by: vedika-saravanan <vsaravanan@nvidia.com>
268ba9a to
85e9d2b
Compare
Signed-off-by: vedika-saravanan <vsaravanan@nvidia.com>
Signed-off-by: vedika-saravanan <vsaravanan@nvidia.com>
00a9838 to
fb6dcfc
Compare
Signed-off-by: vedika-saravanan <vsaravanan@nvidia.com>
d6be6ce to
f428c85
Compare
…vailable Signed-off-by: vedika-saravanan <vsaravanan@nvidia.com>
f428c85 to
1253540
Compare
Signed-off-by: vedika-saravanan <vsaravanan@nvidia.com>
ccb933f to
05b5d5a
Compare
Signed-off-by: vedika-saravanan <vsaravanan@nvidia.com>
bmhowe23
left a comment
There was a problem hiding this comment.
This is looking good...thanks, @vedika-saravanan. Just a few follow-up questions below.
| target_link_libraries(${LIBRARY_NAME} PRIVATE libstim) | ||
| target_link_options(${LIBRARY_NAME} PRIVATE | ||
| $<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>>:-Wl,--exclude-libs,libstim.a> | ||
| ) | ||
|
|
There was a problem hiding this comment.
I downloaded this PR and built locally (using 92d3dc9), and I see the following, which could be problematic:
$ nm -D lib/libcudaq-qec.so | grep stim | c++filt
00000000000907d0 W stim::DetectorErrorModel::~DetectorErrorModel()
00000000000907d0 W stim::DetectorErrorModel::~DetectorErrorModel()The above two items are the only problematic items, so it's possible that your solution here covers most of the issue, but I don't think we should be leaking those symbol out.
In order to prevent something like NVIDIA/cuda-quantum#3045, I think something like NVIDIA/cuda-quantum#3076 is required.
| EXPECT_EQ(decoder2->get_syndrome_size(), new_syndrome_size); | ||
| } | ||
|
|
||
| TEST(DecoderRegistryTest, SingleParameterRegistryDirect) { |
There was a problem hiding this comment.
Just checking - does constructing a decoder w/o heterogenous map no longer supported? I don't think this is very common, so it's probably ok if we deprecate it; I just wanted to double check because if it still works then I'd want to keep this test.
Description
Adds unified decoder initialization from either a parity-check matrix or raw Stim detector error model text.
This supports both existing PCM-based decoders and DEM-native decoders needed by #546. PCM-based decoders can parse DEM text into
H,O, anderror_rate_vecdefaults, while DEM-native decoders can consume the raw DEM text without going through a lossy matrix conversion.API (
cudaq/qec/decoder.h)decoder_init = std::variant<sparse_binary_matrix, std::string>as the decoder registry construction input.get_decoder(name, H, options)decoder::get(name, H, options)get_decoder(name, dem_text, options)decoder::get(name, dem_text, options)dem_from_stim_text(dem_text)to parse Stim DEM text intodetector_error_model.Oanderror_rate_vecare supplied as defaults when not explicitly provided by the user.The DEM-to-detector_error_model parser is lossy: it extracts detector flips, observable flips, and per-error probabilities, but drops detector coordinates and separator-encoded correlation structure. DEM-native decoders should consume the raw string alternative in decoder_init.
Python:
cudaq_qec.get_decoder(...)now accepts Stim DEM strings. Python-registered decoders currently receive parsedHplus DEM-derivedO/error_rate_vecdefaults, not raw DEM text.Dependency / build
QEC now provides its own Stim dependency via
FetchContentwhenlibstimis not already available, so standalone QEC builds do not depend on parent CUDA-Q interim build artifacts.Tests
C++ gtests and Python tests cover:
get_decoder(...)stim::DemTargetcategory assumptionsOut of scope / follow-ups
Chromobius plugin integration itself; detector-coordinate storage on
detector_error_model; optional PyMatching-specific improvements; user-facing Sphinx/RST docs.Runtime / performance impact
N/A
Self-review checklist
Please confirm each item before requesting review. Check
[x]or strikethrough and explain.
Before requesting review
Scope and size
(if so, an issue has been raised).
Tests
just when it is missing.
EXPECT_*/assertchecks areinsufficient for algorithmic correctness.
Documentation
tracked.
release (the docs site publishes immediately on merge to the default
branch, so feature docs must not land before the feature ships).
Code style
snake_casevscamelCase) forthe area being modified.
Dependencies
OSRB tickets filed.