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
Added bundled decoder_context struct for measurement extraction (#671)
<!--
Thanks for contributing to CUDA-Q Libraries!
Please read the full Pull Request Guidelines in Contributing.md:
https://github.com/NVIDIA/cudaqx/blob/main/Contributing.md#pull-request-guidelines
-->
## Description
In order to process enqueued syndromes, the decoder needs access to a
measurement map so it knows how to form detectors. Right now, this comes
from `generate_timelike_sparse_detector_matrix`, which does not include
boundary detectors.
Rather than refactor this function (which would require it to be aware
of the stabilizer structure of the code), I include the `m2d` map
calculated by `dem_from_kernel`, and bundle it into a new struct
`decoder_context`, and provide a new helper function
`decoder_context_from_memory_circuit` with a similar signature to
`dem_from_memory_circuit`, which it essentially supersedes. This new
function returns the DEM as well as the measurement map needed by the
decoder. The `decoder_context` struct also provides helper methods for
extracting the X/Z components, alleviating the need for helper functions
(in the style of `*_dem_from_memory_circuit`) as well as allowing a
single circuit analysis to provide both the X and Z decoder contexts.
The PR also applies some changes to the `real_time_complete`
documentation examples to use this function.
New tests:
`test_dem.py::test_decoder_context_from_memory_circuit_requires_noise_model`
- asserts a throw on the `decoder_context_from_memory_circuit` if no
noise model is provided
`test_dem.py::test_decoder_context_and_components` - asserts that
`decoder_context_from_memory_circuit` matches output of superceded
`*_dem_from_memory_circuit`
`test_dem.py::test_decoder_context_d_sparse_layout()` - asserts that
`.d_sparse()` on `decoder_context` flattens m2d map into correct
-1-terminated sparse vector
`test_dem.py::test_decoder_context_single_type_code_empty_component` -
check that empty component (i.e. x-component of a repetition code) is
consistent
`test_qec_stim.cpp::checkTealtimeDecodeFromMemoryCircuit` - end-to-end
check of realtime API using decoder_context
`test_qec_stim.cpp::checkDecoderContextAndComponents` - Verify DEM
output by `decoder_context_from_memory_circuit` matches superseded
`*_dem_from_memory_circuit`, and that extracting `x/z` components is
idempotent and consistent.
## 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.
### 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: Eliot Heinrich <eheinrich@nvidia.com>
Signed-off-by: Eliot Heinrich <38039898+eliotheinrich@users.noreply.github.com>
0 commit comments