[iqm] Don't reject user-named measurement registers - #4985
Conversation
PR #4818 added a numerical sort of the IQM `measurement_keys` to reorder result bitstrings into physical-qubit order, guarded by a check that every key ends in a digit. That assumption only holds for the auto-generated `r00000`, `r00001`, ... register names. A kernel that names its measurement register explicitly (e.g. `auto result = mz(q)`) produces a key such as `result`, which tripped the guard and threw "Malformed measurement key received: result", aborting the job. The unit tests exercised only digit-suffixed keys via the mock server, so this passed CI at merge time but broke the nightly IQM integration test (targettests/iqm/callable_kernel_arg.cpp) every night since. Non-numeric keys carry no positional information, so there is nothing to sort by. Skip the reordering in that case and leave the bitstrings in the order the measurements were emitted -- the behavior prior to #4818 -- rather than rejecting the response. Numeric keys keep the #4818 reordering. Adds a regression test covering a non-numeric measurement key. Signed-off-by: mdzurick <mitch_dz@hotmail.com>
schweitzpgi
left a comment
There was a problem hiding this comment.
Seems like a good change. Should this look for the "rXXXX" format to be a small step safer? Also, a malicious user could easily use "r00000" as a name to mess that up. What fun.
|
Adding @iqm-bhoffmann for viz. |
CI Summary (
|
| Job | Result |
|---|---|
binaries |
⏩ skipped |
build_and_test |
✅ success |
config_devdeps |
✅ success |
config_source_build |
⏩ skipped |
config_wheeldeps |
✅ success |
devdeps |
✅ success |
docker_image |
⏩ skipped |
gen_code_coverage |
⏩ skipped |
metadata |
✅ success |
python_metapackages |
⏩ skipped |
python_wheels |
⏩ skipped |
source_build |
⏩ skipped |
wheeldeps |
✅ success |
⏩ Skipped jobs (7) — intentionally skipped on PR builds; run on merge_group / workflow_dispatch
| Job |
|---|
binaries |
config_source_build |
docker_image |
gen_code_coverage |
python_metapackages |
python_wheels |
source_build |
All sub-jobs (42) — every matrix leg, with links
| Job | Status | Link |
|---|---|---|
| Build and test (amd64, gcc12, openmpi) / Dev environment (Debug) | ✅ success | view |
| Build and test (amd64, gcc12, openmpi) / Dev environment (Python) | ✅ success | view |
| Build and test (amd64, llvm, openmpi) / Dev environment (Debug) | ✅ success | view |
| Build and test (amd64, llvm, openmpi) / Dev environment (Python) | ✅ success | view |
| Build and test (arm64, llvm, openmpi) / Dev environment (Debug) | ✅ success | view |
| Build and test (arm64, llvm, openmpi) / Dev environment (Python) | ✅ success | view |
| CI Summary | ❔ in_progress | view |
| Configure build (devdeps) | ✅ success | view |
| Configure build (source_build) | ⏩ skipped | view |
| Configure build (wheeldeps) | ✅ success | view |
| Create CUDA Quantum installer | ⏩ skipped | view |
| Create Docker images | ⏩ skipped | view |
| Create Python metapackages | ⏩ skipped | view |
| Create Python wheels | ⏩ skipped | view |
| Gen code coverage | ⏩ skipped | view |
| Load dependencies (amd64, gcc12) / Caching | ✅ success | view |
| Load dependencies (amd64, gcc12) / Finalize | ✅ success | view |
| Load dependencies (amd64, gcc12) / Metadata | ✅ success | view |
| Load dependencies (amd64, llvm) / Caching | ✅ success | view |
| Load dependencies (amd64, llvm) / Finalize | ✅ success | view |
| Load dependencies (amd64, llvm) / Metadata | ✅ success | view |
| Load dependencies (arm64, gcc12) / Caching | ✅ success | view |
| Load dependencies (arm64, gcc12) / Finalize | ✅ success | view |
| Load dependencies (arm64, gcc12) / Metadata | ✅ success | view |
| Load dependencies (arm64, llvm) / Caching | ✅ success | view |
| Load dependencies (arm64, llvm) / Finalize | ✅ success | view |
| Load dependencies (arm64, llvm) / Metadata | ✅ success | view |
| Load source build cache | ⏩ skipped | view |
| Load wheel dependencies (amd64, 12.6) / Caching | ✅ success | view |
| Load wheel dependencies (amd64, 12.6) / Finalize | ✅ success | view |
| Load wheel dependencies (amd64, 12.6) / Metadata | ✅ success | view |
| Load wheel dependencies (amd64, 13.0) / Caching | ✅ success | view |
| Load wheel dependencies (amd64, 13.0) / Finalize | ✅ success | view |
| Load wheel dependencies (amd64, 13.0) / Metadata | ✅ success | view |
| Load wheel dependencies (arm64, 12.6) / Caching | ✅ success | view |
| Load wheel dependencies (arm64, 12.6) / Finalize | ✅ success | view |
| Load wheel dependencies (arm64, 12.6) / Metadata | ✅ success | view |
| Load wheel dependencies (arm64, 13.0) / Caching | ✅ success | view |
| Load wheel dependencies (arm64, 13.0) / Finalize | ✅ success | view |
| Load wheel dependencies (arm64, 13.0) / Metadata | ✅ success | view |
| Prepare cache clean-up | ❔ in_progress | view |
| Retrieve PR info | ✅ success | view |
✅ Required checks (6/6) — declared in .github/required-checks.yml for push
| Required check | Status | Link |
|---|---|---|
| Build and test (amd64, llvm, openmpi) / Dev environment (Debug) | ✅ success | view |
| Build and test (amd64, llvm, openmpi) / Dev environment (Python) | ✅ success | view |
| Build and test (arm64, llvm, openmpi) / Dev environment (Debug) | ✅ success | view |
| Build and test (arm64, llvm, openmpi) / Dev environment (Python) | ✅ success | view |
| Build and test (amd64, gcc12, openmpi) / Dev environment (Debug) | ✅ success | view |
| Build and test (amd64, gcc12, openmpi) / Dev environment (Python) | ✅ success | view |
|
@sacpis thank you for adding me to the conversation. The proposed change will suppress the exception for the presented testcase but will most likely make #4621 re-appear with kernels which name the measurements. If I can confirm this I will re-open #4621 to do a more sophisticated solution than just sorting the keys. In the meantime the change can be merged but could have the described side effect. |
|
Opened PR #5074 with my proposal to fix the problem. This solves also my concern from my last comment that multiple named measurements would still fail. |
PR #4818 added a numerical sort of the IQM
measurement_keysto reorder result bitstrings into physical-qubit order, guarded by a check that every key ends in a digit. That assumption only holds for the auto-generatedr00000,r00001, ... register names. A kernel that names its measurement register explicitly (e.g.auto result = mz(q)) produces a key such asresult, which tripped the guard and threw "Malformed measurement key received: result", aborting the job.The unit tests exercised only digit-suffixed keys via the mock server, so this passed CI at merge time but broke the nightly IQM integration test (targettests/iqm/callable_kernel_arg.cpp) every night since.
Non-numeric keys carry no positional information, so there is nothing to sort by. Skip the reordering in that case and leave the bitstrings in the order the measurements were emitted -- the behavior prior to #4818 -- rather than rejecting the response. Numeric keys keep the #4818 reordering.
Adds a regression test covering a non-numeric measurement key.