Add chromobius decoder to the decoder plugins#546
Conversation
Add a QEC decoder plugin wrapping Chromobius through the existing decoder factory API. The wrapper accepts a Stim DEM via params, packs detector syndromes for Chromobius, and returns predicted observable flips. Also add Chromobius plugin build wiring and focused unit tests covering construction, decoding, DEM path loading, and validation failures. Fix a PyMatching pointer member access that broke the plugin build. Signed-off-by: Scott Thornton <wsttiger@gmail.com>
- Register the Chromobius decoder with the CUDA-QX extension-point macro - Add small upstream-derived DEM/reference shot data for observable predictions - Add C++ and Python tests that validate single-shot and batched Chromobius decode results - Keep the GCC 12 GTest workaround private so it does not leak into CUDA test builds - Apply minor formatting cleanups in touched tests/headers Signed-off-by: Scott Thornton <wsttiger@gmail.com>
Signed-off-by: Scott Thornton <wsttiger@gmail.com>
fc04644 to
5587a30
Compare
Signed-off-by: Scott Thornton <wsttiger@gmail.com>
| std::string get_dem_text(const cudaqx::heterogeneous_map ¶ms) { | ||
| if (params.contains("dem")) | ||
| return params.get<std::string>("dem"); | ||
| if (params.contains("dem_str")) |
There was a problem hiding this comment.
dem_str is a functional duplicate of dem — same getstd::string lookup, same return, no transformation, and dem wins if both are passed.
Grepping the repo turns up zero callers of dem_stras a parameter key: neither test_chromobius.cpp nor test_chromobius.py exercises it, and there are no examples or docs that pass it.
Suggest dropping dem_str from get_dem_text and keeping just dem / dem_path
| } | ||
|
|
||
| TEST(ChromobiusDecoder, checkDemPath) { | ||
| const std::string dem_path = "/tmp/cudaq_qec_chromobius_test.dem"; |
There was a problem hiding this comment.
I'm generally wary of hardcoded path
| @@ -0,0 +1,8 @@ | |||
| # Reference case from quantumlib/chromobius: | |||
There was a problem hiding this comment.
Does this mean that this file and the .tsv are both straight from the quantumlib/chromobius repo? If so, I think we need to add a readme or a license file/header. @bmhowe23 What's the general rule of thumb on this?
| std::fill(packed_detection_events.begin(), packed_detection_events.end(), | ||
| uint8_t{0}); | ||
| for (std::size_t i = 0; i < syndrome.size(); ++i) { | ||
| if (syndrome[i] >= 0.5) |
There was a problem hiding this comment.
Here we are doing the comparison directly. I think in the base class header decoder.h, we have helpers that does this. (call cudaq::qec::convert_vec_soft_to_hard(syndrome, hard_buf)). Using the helper will prevent future drift and match the pattern that both the sliding_window and the nv-qldpc decoder use.
I'm aware that there are other instances in our repo currently that still do this manual comparison. I'll make a new issue to track those.
Signed-off-by: Scott Thornton <wsttiger@gmail.com>
| chromobius(const cudaqx::tensor<uint8_t> &H, | ||
| const cudaqx::heterogeneous_map ¶ms) | ||
| : decoder(H), dem(get_dem_text(params)) { | ||
| auto H_shape = H.shape(); |
There was a problem hiding this comment.
Is H actually used anywhere?
| FetchContent_Declare( | ||
| chromobius | ||
| GIT_REPOSITORY https://github.com/quantumlib/chromobius.git | ||
| GIT_TAG efae0325e4a8fc13be981434d38e499aa06b989f # v1.1.1 |
There was a problem hiding this comment.
Please make sure to file the OSRB paperwork for this.
Summary
Adds a CUDA-QX QEC decoder plugin for Chromobius and wires it into the existing decoder factory/plugin flow.
The wrapper accepts a Stim detector error model through decoder params, compiles a Chromobius decoder from that DEM, packs detector syndromes into Chromobius’ expected bit-packed format, and returns predicted observable flips directly.
Changes
chromobiusdecoder plugin underlibs/qec/lib/decoders/plugins/chromobiusdem,dem_str, ordem_pathCUDAQ_EXT_PT_REGISTER_TYPETesting
ninja -j16ninja installninja test_chromobius_correctnessctest -R Chromobius --output-on-failurectest -R ChromobiusCorrectness --output-on-failurePYTHONPATH=/usr/local/cudaq:/scratch/cudaqx-realtime/build/python pytest -q ../libs/qec/python/tests/test_chromobius.py