You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## 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`, and
`error_rate_vec` defaults, while DEM-native decoders can consume the raw
DEM text without going through a lossy matrix conversion.
### API (`cudaq/qec/decoder.h`)
- Adds `decoder_init = std::variant<sparse_binary_matrix, std::string>`
as the decoder registry construction input.
- Keeps existing PCM construction paths:
- `get_decoder(name, H, options)`
- `decoder::get(name, H, options)`
- Adds DEM string construction through the same entry points:
- `get_decoder(name, dem_text, options)`
- `decoder::get(name, dem_text, options)`
- Adds `dem_from_stim_text(dem_text)` to parse Stim DEM text into
`detector_error_model`.
- Adds helper routing for PCM-based decoders so DEM-derived `O` and
`error_rate_vec` are 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 parsed `H` plus DEM-derived
`O` / `error_rate_vec` defaults, not raw DEM text.
### Dependency / build
QEC now provides its own Stim dependency via `FetchContent` when
`libstim` is not already available, so standalone QEC builds do not
depend on parent CUDA-Q interim build artifacts.
### Tests
C++ gtests and Python tests cover:
- DEM string construction through `get_decoder(...)`
- PCM construction still working
- user-provided options overriding DEM-derived defaults
- DEM parse edge cases
- DEMs without observables
- `stim::DemTarget` category assumptions
### Out 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 strike
through and explain.
### Before requesting review
- [x] I reviewed my own full diff in GitHub or my editor.
- [x] PR is in Draft if it is not yet ready for review.
- [x] Temporary / debugging changes have been removed.
- [x] Local test logs reviewed; no unexplained warnings or errors.
- [x] CI logs reviewed; no unexplained warnings or errors.
- [x] Full CI has been run.
### Scope and size
- [x] PR is under ~1000 lines, or an exception is justified in the
description.
- [x] Refactoring-only changes are isolated in their own PR(s).
- [x] No existing tests were disabled or modified just to make this PR
pass
(if so, an issue has been raised).
### Tests
- [x] New functionality has new tests.
- [x] Tests fail if the new functionality is broken (including crashes),
not
just when it is missing.
- [x] Negative tests added where exceptions are expected.
- [x] Truth data added where simple `EXPECT_*` / `assert` checks are
insufficient for algorithmic correctness.
- [x] CI runtime impact considered; team notified if significant.
### Documentation
- [x] Public-facing APIs have Doxygen docs.
- [x] User-visible behavior changes have public docs, or a follow-up is
tracked.
- [x] User-facing docs for new features are in a **separate PR** held
until
release (the docs site publishes immediately on merge to the default
branch, so feature docs must not land before the feature ships).
### Code style
- [x] Naming follows the existing convention (`snake_case` vs
`camelCase`) for
the area being modified.
### Dependencies
- [x] No new third-party dependencies, **or** the team has been notified
and
OSRB tickets filed.
---------
Signed-off-by: vedika-saravanan <vsaravanan@nvidia.com>
0 commit comments